fr.dyade.aaa.agent.Driver Class Reference

Inherited by com.scalagent.task.util.ProcessMonitor, com.scalagent.task.util.ThreadTaskDriver, fr.dyade.aaa.agent.AgentDriver, fr.dyade.aaa.agent.DriverConnect, fr.dyade.aaa.agent.DriverIn, and fr.dyade.aaa.agent.DriverOut.

Inheritance diagram for fr.dyade.aaa.agent.Driver:

Inheritance graph
[legend]
List of all members.

Public Member Functions

String getName ()
String toString ()
abstract void run () throws Exception
void start ()
synchronized void stop ()

Public Attributes

volatile boolean isRunning = false
volatile boolean canStop = false

Protected Member Functions

 Driver (int id)
 Driver ()
void end ()
final void sendTo (AgentId to, Notification not) throws IOException

Protected Attributes

Thread thread
int id
Logger logmon = null
String name = null

Static Protected Attributes

static Hashtable drivers = new Hashtable()

Package Functions

synchronized void reset ()

Static Package Functions

static void stopAll ()

Detailed Description

Abstract base class for drivers such as DriverIn used by ProxyAgent.

Multithreading in the agent server is special, as the code executed outside of the main engine thread is no longer part of a transaction. The class Driver has been designed to help programming in a separate thread in the agent server.

A key difference between the main thread and a driver thread is the semantics of sending a notification. When in the main thread of the agent server, a notification is sent as part of an agent reaction. It is then part of a transaction, and is actually sent only when the transaction commits. When in a separate thread, the directSendto function of class Channel is used instead, actually creating a new transaction for the single purpose of sending the notification. When the function returns the notification sending has been committed. The function sendTo in this class encapsulates the call to the special Channel function, and should be used by derived classes.

This class is designed to be derived. Derived classes should define the function run, providing the actual code to be executed in the separate thread, and may define the function end, providing finalizing code executed when the thread terminates. The end function is always called, even when the run function raises an exception.

Definition at line 102 of file Driver.java.


Constructor & Destructor Documentation

fr.dyade.aaa.agent.Driver.Driver ( int  id  )  [protected]

Constructor.

Parameters:
id identifier local to the driver creator

Definition at line 125 of file Driver.java.

References fr.dyade.aaa.agent.Driver.isRunning, fr.dyade.aaa.agent.Driver.logmon, and fr.dyade.aaa.agent.Driver.thread.

fr.dyade.aaa.agent.Driver.Driver (  )  [protected]

Constructor with default id.

Definition at line 142 of file Driver.java.

References fr.dyade.aaa.agent.Driver.isRunning.


Member Function Documentation

String fr.dyade.aaa.agent.Driver.getName (  ) 

Returns name of driver, actually classname and driver id. It should be overloaded in subclass to take in account the proxy name.

Reimplemented in com.scalagent.task.util.ProcessMonitor.

Definition at line 151 of file Driver.java.

References fr.dyade.aaa.agent.Driver.name.

Referenced by fr.dyade.aaa.agent.DriverOut.end(), fr.dyade.aaa.agent.DriverIn.end(), fr.dyade.aaa.agent.AgentDriver.end(), com.scalagent.task.util.ThreadTaskDriver.end(), fr.dyade.aaa.agent.DriverIn.recvFlowControl(), fr.dyade.aaa.agent.DriverOut.run(), fr.dyade.aaa.agent.DriverIn.run(), fr.dyade.aaa.agent.DriverConnect.run(), fr.dyade.aaa.agent.AgentDriver.run(), fr.dyade.aaa.agent.ThreadFinalizer.run(), fr.dyade.aaa.agent.DriverIn.sendFlowControl(), fr.dyade.aaa.agent.Driver.start(), fr.dyade.aaa.agent.Driver.stopAll(), and fr.dyade.aaa.agent.Driver.toString().

String fr.dyade.aaa.agent.Driver.toString (  ) 

Provides a string image for this object.

Returns:
printable image of this object

Reimplemented in com.scalagent.task.util.MoveDriver, com.scalagent.task.util.ThreadTaskDriver, fr.dyade.aaa.agent.AgentDriver, and fr.dyade.aaa.agent.DriverIn.

Definition at line 160 of file Driver.java.

References fr.dyade.aaa.agent.Driver.canStop, fr.dyade.aaa.agent.Driver.getName(), and fr.dyade.aaa.agent.Driver.isRunning.

Here is the call graph for this function:

abstract void fr.dyade.aaa.agent.Driver.run (  )  throws Exception [pure virtual]

Actually executes the driver code. To be defined in derived classes.

Beware: this code is executed in a separate thread, outside from any transaction. Notifications may be sent using function sendTo, and they will actually be sent as soon as the function is called; there is no atomic treatment as there is in an agent reaction.

Exceptions:
Exception unspecialized exception

Implemented in com.scalagent.task.util.MoveDriver, com.scalagent.task.util.ProcessMonitor, com.scalagent.task.util.ThreadTaskDriver, fr.dyade.aaa.agent.AgentDriver, fr.dyade.aaa.agent.DriverConnect, fr.dyade.aaa.agent.DriverIn, and fr.dyade.aaa.agent.DriverOut.

Referenced by fr.dyade.aaa.agent.ThreadFinalizer.run().

void fr.dyade.aaa.agent.Driver.end (  )  [protected]

Finalizes driver; called in finally clause of driver thread. May be overloaded in derived classes.

Reimplemented in com.scalagent.task.util.ThreadTaskDriver, fr.dyade.aaa.agent.AgentDriver, fr.dyade.aaa.agent.DriverIn, and fr.dyade.aaa.agent.DriverOut.

Definition at line 186 of file Driver.java.

Referenced by fr.dyade.aaa.agent.ThreadFinalizer.run().

void fr.dyade.aaa.agent.Driver.start (  ) 

Starts the driver execution.

Reimplemented in fr.dyade.aaa.agent.DriverConnect.

Definition at line 191 of file Driver.java.

References fr.dyade.aaa.agent.Driver.drivers, fr.dyade.aaa.agent.Driver.getName(), and fr.dyade.aaa.agent.Driver.thread.

Referenced by fr.dyade.aaa.agent.ProxyAgent.createDrivers(), and com.scalagent.task.util.ThreadTask.start().

Here is the call graph for this function:

synchronized void fr.dyade.aaa.agent.Driver.reset (  )  [package]

Nullify thread variable. To be used by ThreadFinalizer.

Definition at line 201 of file Driver.java.

References fr.dyade.aaa.agent.Driver.drivers, and fr.dyade.aaa.agent.Driver.thread.

Referenced by fr.dyade.aaa.agent.ThreadFinalizer.run().

synchronized void fr.dyade.aaa.agent.Driver.stop (  ) 

Stops the driver execution.

Definition at line 209 of file Driver.java.

References fr.dyade.aaa.agent.Driver.canStop, fr.dyade.aaa.agent.Driver.isRunning, and fr.dyade.aaa.agent.Driver.thread.

Referenced by com.scalagent.task.util.ThreadTaskDriver.end(), com.scalagent.task.util.MoveDriver.run(), fr.dyade.aaa.agent.ProxyAgent.stop(), fr.dyade.aaa.agent.Driver.stopAll(), and com.scalagent.task.util.ThreadTaskDriver.toString().

final void fr.dyade.aaa.agent.Driver.sendTo ( AgentId  to,
Notification  not 
) throws IOException [protected]

Sends a notification to an agent.

Provides a similar function as the sendTo function in Agent class, except that the notification is sent directly via a directSendTo method.

Parameters:
to target agent
not notification to send

Definition at line 241 of file Driver.java.

Referenced by fr.dyade.aaa.agent.DriverIn.end(), fr.dyade.aaa.agent.AgentDriver.end(), com.scalagent.task.util.ThreadTaskDriver.end(), com.scalagent.task.util.ProcessMonitor.run(), and fr.dyade.aaa.agent.DriverIn.sendFlowControl().


Member Data Documentation

Thread fr.dyade.aaa.agent.Driver.thread [protected]

separate thread running the driver

Definition at line 105 of file Driver.java.

Referenced by fr.dyade.aaa.agent.Driver.Driver(), fr.dyade.aaa.agent.Driver.reset(), fr.dyade.aaa.agent.Driver.start(), and fr.dyade.aaa.agent.Driver.stop().

int fr.dyade.aaa.agent.Driver.id [protected]

identifier local to the driver creator

Definition at line 107 of file Driver.java.

volatile boolean fr.dyade.aaa.agent.Driver.isRunning = false

Boolean variable used to stop the driver properly. If this variable is true then it indicates that the driver is stopping.

Definition at line 112 of file Driver.java.

Referenced by fr.dyade.aaa.agent.ProxyAgent.createDrivers(), fr.dyade.aaa.agent.Driver.Driver(), fr.dyade.aaa.agent.DriverOut.run(), fr.dyade.aaa.agent.DriverIn.run(), fr.dyade.aaa.agent.DriverConnect.run(), fr.dyade.aaa.agent.AgentDriver.run(), com.scalagent.task.util.ProcessMonitor.run(), fr.dyade.aaa.agent.Driver.stop(), fr.dyade.aaa.agent.Driver.stopAll(), and fr.dyade.aaa.agent.Driver.toString().


The documentation for this class was generated from the following file:
Generated on Tue Sep 16 16:16:21 2008 for joram by  doxygen 1.5.0