|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@MXBean public interface IAgent
MXBean interface - serves the purpose only to JMX, you should always derive your agent from at least AbstractAgent, even though it's not enforced right now it may be in the future!
The key component of the agent is EventBus. The agent is propagating system events like
"state of the agent has changed", "agent is starting", "agent is running", "agent name has changed",
etc. See ComponentBus
for information how the system is working - notice that the best
way how to see what events are propagated - attach a listener to "ISystemClass.class" into the event bus
and log all events that are being broadcasted.
Method Summary | |
---|---|
IAgentId |
getComponentId()
Returns agent id - contains also a human-readable name that can be changed |
Folder |
getIntrospection()
Returns folder with introspection information. |
IAgentLogger |
getLogger()
Returns AgentLogger for the instance allowing creating new log categories or adding new handlers to them. |
java.lang.String |
getName()
Returns human-readable agent's name. |
ImmutableFlag<IAgentState> |
getState()
Returns the state of the agent (whether it's running / dead / etc.). |
void |
kill()
Stops the agent (unconditionally), closing whatever connection it may have, this method must be non-blocking + interrupting all the communication, logic or whatever threads the agent may have. |
void |
pause()
This should pause the the agent. |
void |
resume()
This should resume the logic of the agent. |
void |
start()
Attempt to launch the agent. |
void |
startPaused()
Attempt to launch the agent. |
void |
stop()
Attempt to stop the agent, usually meaning dropping all running flags and see whether it will stop automatically. |
Methods inherited from interface cz.cuni.amis.pogamut.base.component.IComponentAware |
---|
getEventBus |
Method Detail |
---|
java.lang.String getName()
Do not use as unique id of the agent:
1) the name might change during the life of agent
2) we do not ensure it's unique
Use getComponentId().getToken() instead!
Use getComponentId().getName().setFlag() to change the name of the agent.
IAgentId getComponentId()
getComponentId
in interface IComponent
IAgentLogger getLogger()
ImmutableFlag<IAgentState> getState()
Note that the type AgentState wraps two things:
Folder getIntrospection()
void start() throws ComponentCantStartException
This method is not suitable for simultaneous start of multiple agents that should start working together in the environment.
(I.e., during tournaments of agents when you need to synchronize their start in the environment.) In such cases
use startPaused()
and then multiple threads+barrier to execute resume()
of all agents at once.
start
in interface IControllable
ComponentCantStartException
void startPaused() throws ComponentCantStartException
In contrast with start()
this method will initialize the agent inside the environment but pauses
it after the start (i.e., its reasoning should not run, the action should not do any decisions).
To fully start the agent, you need to resume()
it.
It is designed to provide safe synchronization of multiple agent simulations when you need to start the reasoning of agents synchronously.
ComponentCantStartException
void pause() throws ComponentCantPauseException
ComponentCantPauseException
void resume() throws ComponentCantResumeException
ComponentCantResumeException
void stop() throws ComponentCantStopException
If the stop can not complete - it must automatically call kill() method.
stop
in interface IControllable
ComponentCantStopException
void kill()
After calling kill() method, the only method that may be called is getState() to examine state of the agent.
This also equals to "exception happened outside the agent" and "IFatalErrorEvent
should be propagated inside
the agent"
kill
in interface IControllable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |