public class AgentJMXProxy extends Object implements IAgent
| Constructor and Description |
|---|
AgentJMXProxy(String agentJmxAddress) |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
call(String actionName) |
protected Object |
callNoException(String actionName)
All exceptions are wrapped in RuntimeException.
|
protected Object |
callNoException(String actionName,
Object[] params,
String[] sig)
All exceptions are wrapped in RuntimeException.
|
protected Object |
getAttributeNoException(String atr) |
IAgentId |
getComponentId()
Returns agent id - contains also a human-readable name that can be changed
|
IComponentBus |
getEventBus()
IComponentBus that the instance is working with. |
cz.cuni.amis.introspection.Folder |
getIntrospection()
Returns folder with introspection information.
|
Logger |
getLog() |
IAgentLogger |
getLogger()
Returns AgentLogger for the instance allowing creating new log categories
or adding new handlers to them.
|
MBeanServerConnection |
getMBeanServerConnection() |
String |
getName()
Returns human-readable agent's name.
|
ObjectName |
getObjectName() |
cz.cuni.amis.utils.flag.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.
|
public AgentJMXProxy(String agentJmxAddress)
public MBeanServerConnection getMBeanServerConnection()
public ObjectName getObjectName()
public IAgentLogger getLogger()
IAgentpublic Logger getLog()
public cz.cuni.amis.utils.flag.ImmutableFlag<IAgentState> getState()
IAgentNote that the type AgentState wraps two things:
protected Object callNoException(String actionName)
actionName - protected Object callNoException(String actionName, Object[] params, String[] sig)
actionName - protected Object call(String actionName) throws AgentException
AgentExceptionpublic void start()
throws AgentException
IAgent
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 IAgent.startPaused() and then multiple threads+barrier to execute IAgent.resume() of all agents at once.
start in interface IAgentstart in interface IControllableAgentExceptionpublic void startPaused()
throws ComponentCantStartException
IAgent
In contrast with IAgent.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 IAgent.resume() it.
It is designed to provide safe synchronization of multiple agent simulations when you need to start the reasoning of agents synchronously.
startPaused in interface IAgentComponentCantStartExceptionpublic void pause()
throws AgentException
IAgentpause in interface IAgentAgentExceptionpublic void resume()
throws AgentException
IAgentresume in interface IAgentAgentExceptionpublic void stop()
IAgentIf the stop can not complete - it must automatically call kill() method.
stop in interface IAgentstop in interface IControllablepublic void kill()
IAgentAfter 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 IAgentkill in interface IControllablepublic IAgentId getComponentId()
IAgentgetComponentId in interface IAgentgetComponentId in interface IComponentpublic String getName()
IAgentDo 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.
public cz.cuni.amis.introspection.Folder getIntrospection()
IAgentgetIntrospection in interface IAgentpublic IComponentBus getEventBus()
IComponentAwareIComponentBus that the instance is working with.
Note that by design-choice - the IComponentBus is a singleton inside AgentScoped,
therefore you don't have to necessarily obtain the instance through the component, it suffice
to obtain it using injection into your object.
getEventBus in interface IComponentAwareCopyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.