public interface AgentEngine extends MessageConsumer
AgentEngine
provides multiprogramming of agents. It
realizes the program loop which successively gets the notifications from
the message queue and calls the relevant reaction function member of the
target agent. The engine's basic behaviour is:
While (true) { // get next message in channel Message msg = qin.get(); // get the agent to process event Agent agent = load(msg.to); // execute relevant reaction, all notification sent during this // reaction is inserted into persistent queue in order to processed // by the channel. agent.react(msg.from, msg.not); // save changes, then commit. <BEGIN TRANSACTION> qin.pop(); channel.dispatch(); agent.save(); <COMMIT TRANSACTION> }
The AgentEngine
ensures the atomic handling of an agent
reacting to a notification:
Two types of errors may occur: errors of first type are detected in the
source code and signaled by an Exception
; serious errors lead
to an Error
being raised then the engine exits. In the first
case the exception may be handled at any level, even partially. Most of
them are signaled up to the engine loop. Two cases are then distinguished
depending on the recovery policy:
recoveryPolicy
is set to RP_EXC_NOT
(default value) then the agent state and the message queue are restored
(ROLLBACK); an ExceptionNotification
notification is sent
to the sender and the engine may then proceed with next notification;
recoveryPolicy
is set to RP_EXIT
the engine
stops the agent server.
Modifier and Type | Method and Description |
---|---|
void |
createAgent(AgentId id,
Agent agent)
Creates and initializes an agent.
|
void |
deleteAgent(AgentId from)
Deletes an agent.
|
String |
dumpAgent(AgentId id)
Returns a string representation of the specified agent.
|
float |
getAverageLoad1()
Returns the load averages for the last minute.
|
float |
getAverageLoad15()
Returns the load averages for the past 15 minutes.
|
float |
getAverageLoad5()
Returns the load averages for the past 5 minutes.
|
long |
getCommitTime() |
int |
getNbWaitingMessages()
Gets the number of waiting messages in this engine.
|
long |
getReactTime() |
void |
init(AgentEngineContext agentEngineContext)
Initializes the engine.
|
boolean |
isAgentProfiling()
Returns true if the agent profiling is on.
|
boolean |
isEngineThread()
Checks if the current thread calling this method
belongs to the engine.
|
boolean |
isNoTxIfTransient()
Returns the flag to avoid transactions.
|
void |
push(AgentId from,
AgentId to,
Notification not)
Puts a notification in the output queue.
|
void |
push(AgentId to,
Notification not)
Puts a notification in the output queue.
|
void |
resetAverageLoad() |
void |
setAgentProfiling(boolean agentProfiling)
Sets the agent profiling.
|
delete, getDomainName, getName, getQueue, insert, isRunning, post, postAndValidate, restore, save, start, stop, validate
boolean isEngineThread()
void resetAverageLoad()
float getAverageLoad1()
getAverageLoad1
in interface MessageConsumer
float getAverageLoad5()
getAverageLoad5
in interface MessageConsumer
float getAverageLoad15()
getAverageLoad15
in interface MessageConsumer
boolean isAgentProfiling()
EngineMBean.isAgentProfiling()
void setAgentProfiling(boolean agentProfiling)
long getReactTime()
long getCommitTime()
void init(AgentEngineContext agentEngineContext) throws Exception
AgentEngineContext
parameter should be for the unique private use of this
AgentEngine
and should not be shared
with any other components otherwise
the agent server security would be broken.agentEngineContext
- context enabling this
AgentEngine
to invoke operations
that cannot be accessed outside of the
fr.dyade.aaa.agent
package.
The AgentEngineContext
should be for the unique private use of this
AgentEngine
and should not be shared
with any other components otherwise
the agent server security would be broken.Exception
int getNbWaitingMessages()
String dumpAgent(AgentId id) throws IOException, ClassNotFoundException
id
- The agent's unique identification.IOException
ClassNotFoundException
void push(AgentId to, Notification not)
to
- the destinationnot
- the notification to pushvoid push(AgentId from, AgentId to, Notification not)
from
- the sourceto
- the destinationnot
- the notification to pushvoid createAgent(AgentId id, Agent agent) throws Exception
agent
- agent object to createException
- unspecialized exceptionvoid deleteAgent(AgentId from) throws Exception
agent
- agent to deleteException
boolean isNoTxIfTransient()
Copyright © 2013 ScalAgent D.T.. All Rights Reserved.