|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjist.runtime.Controller
public final class Controller
Maintains all the data structures of a single simulation thread of execution. The Controller also contains the implementation of static callbacks from the simulation application to the JiST system.
Field Summary | |
---|---|
static Controller |
activeController
Active controller, iff controllerCount==1. |
Event.ContinuationFrame |
callbackState
Incoming callback state for returning (blocking) call event. |
Event.ContinuationFrame |
callState
Outgoing callback state for (blocking) call event. |
Event |
currentCaller
Incoming caller information for returning (blocking) call event. |
BlockingSleep |
entityBlockingSleep
Blocking sleep singleton entity. |
static GuiLog |
guilog
GUI logger. |
static org.apache.log4j.Logger |
log
Controller logger. |
static java.lang.reflect.Method |
method_entityInvocation
Method stub for callback to invoke a method on an entity. |
static java.lang.reflect.Method |
method_entityInvocationCont
Method stub for callback to invoke a method on an entity, with continuation -- a blocking call. |
static java.lang.reflect.Method |
method_getEntityReference
Method stub for callback to get an entity references for an entity. |
static java.lang.reflect.Method |
method_getTHIS
Method stub for callback to return the current active entity. |
static java.lang.reflect.Method |
method_isModeRestore
Method stub for callback to determine whether current event invocation is in restore mode. |
static java.lang.reflect.Method |
method_isModeSave
Method stub for callback to determine whether current event invocation is in save mode. |
static java.lang.reflect.Method |
method_newEntityReference
Method stub for callback to register an new entity, creating an entity reference. |
static java.lang.reflect.Method |
method_popStateInFrame
Return next frame of incoming event continuation state. |
static java.lang.reflect.Method |
method_pushStateOutFrame
Store next frame of outgoing event continuation state. |
Method Summary | |
---|---|
void |
addEvent(Event ev)
Insert event in into event queue. |
void |
addEvent(java.lang.reflect.Method meth,
EntityRef ref,
java.lang.Object[] params)
Insert event in into event queue (performance: avoids need to get controller instance to create event - shaves off around 10%). |
void |
addEvent(java.lang.reflect.Method meth,
EntityRef ref,
java.lang.Object[] params,
long time)
Insert event in into event queue (performance: avoids need to get controller instance to create event - shaves off around 10%). |
void |
advanceSimulationTime(long i)
Advance the current simulation time. |
java.lang.Object |
clearRestoreState()
Clear restore state of current event, and callback result. |
void |
disposeEvent(Event ev)
Dispose event into the event pool, and clear any references in the event object to allow for GC. |
void |
endAt(long time)
End simulation after given time-step. |
static void |
entityInvocation(java.lang.reflect.Method meth,
Entity entity,
java.lang.Object[] params)
Application callback method to perform (intercept) an entity method invocation at the appropriate simulation time. |
static void |
entityInvocation(java.lang.reflect.Method meth,
EntityRef ref,
java.lang.Object[] params)
Application callback method to perform (intercept) an entity method invocation at the appropriate simulation time. |
static void |
entityInvocation(java.lang.reflect.Method meth,
java.lang.Object callee,
java.lang.Object[] params)
Application callback method to perform (intercept) an entity method invocation at the appropriate simulation time. |
static java.lang.Object |
entityInvocationCont(java.lang.reflect.Method meth,
Entity entity,
java.lang.Object[] params)
Application callback method to perform (intercept) a BLOCKING entity method invocation at the appropriate simulation time. |
static java.lang.Object |
entityInvocationCont(java.lang.reflect.Method meth,
EntityRef ref,
java.lang.Object[] params)
Application callback method to perform (intercept) a BLOCKING entity method invocation at the appropriate simulation time. |
static java.lang.Object |
entityInvocationCont(java.lang.reflect.Method meth,
java.lang.Object callee,
java.lang.Object[] params)
Application callback method to perform (intercept) a BLOCKING entity method invocation at the appropriate simulation time. |
static Controller |
getActiveController()
Return active controller instance. |
java.lang.ClassLoader |
getClassLoader()
Return class loader used by this Controller instance. |
Event |
getCurrentEvent()
Return event currently being processed. |
Entity |
getEntity(int index)
Return an entity owned by this Controller. |
java.lang.Class |
getEntityClass(int index)
Return type of specific entity at this Controller. |
static EntityRef |
getEntityReference(java.lang.Object o)
Application callback method to return the entity reference for a given object. |
long |
getSimulationTime()
Get current simulation time. |
java.lang.String |
getSimulationTimeString()
Return time string in simulation time units. |
long |
getStartTime()
Return the simulation starting time. |
EntityRef |
getStaticEntityRef()
Return the entity reference to the "static" entity. |
static EntityRef |
getTHIS()
Return current entity. |
static boolean |
isModeRestore()
Return whether the event invocation is currently in restore mode. |
boolean |
isModeRestoreInst()
Return whether the event invocation is currently in restore mode. |
static boolean |
isModeSave()
Return whether the event invocation is currently in save mode. |
boolean |
isModeSaveInst()
Return whether the event invocation is currently in save mode. |
boolean |
isRunning()
Return whether the simulation controller is running. |
void |
join()
Wait for simulation to finish. |
void |
log(java.lang.String s)
Emit message in JisT log. |
static Controller |
newController(java.lang.ClassLoader loader)
Create and initialize a new Controller instance. |
static EntityRef |
newEntityReference(Entity entity)
Application callback method to register an new entity, creating an entity reference. |
static Event.ContinuationFrame |
popStateInFrame()
Pop a frame from the incoming execution stack. |
static void |
pushStateOutFrame(Event.ContinuationFrame f)
Push a frame onto the outgoing execution stack. |
void |
registerCallEvent(java.lang.reflect.Method method,
EntityRef ref,
java.lang.Object[] args)
Create and register an outgoing call event. |
EntityRef |
registerEntity(Entity entity)
Register an entity with the Controller. |
java.lang.Throwable |
reset()
Create internal event queue and entity list. |
void |
run()
Begin execution of simulation events. |
void |
setClassLoader(java.lang.ClassLoader loader)
Set the Controller class loader (rewriter). |
void |
setLog(java.lang.Class loggerClass)
Set logging implementation. |
void |
setLog(JistAPI.Logger logger)
Set logging implementation. |
void |
setSimUnits(long ticks,
java.lang.String name)
Set the simulation time units. |
void |
start()
Start the Controller processing thread with given rewriter instance. |
java.lang.Thread |
startDisplayThread()
Start thread to display status of simulation every so often. |
Event |
switchCaller(Event caller)
Switch caller (return) event. |
static java.lang.String |
toString(java.lang.Object o)
String of given object or entity. |
java.lang.String |
toStringEntity(int index)
Return string of entity at given index. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.reflect.Method method_getTHIS
public static final java.lang.reflect.Method method_newEntityReference
public static final java.lang.reflect.Method method_getEntityReference
public static final java.lang.reflect.Method method_entityInvocation
public static final java.lang.reflect.Method method_entityInvocationCont
public static final java.lang.reflect.Method method_popStateInFrame
public static final java.lang.reflect.Method method_pushStateOutFrame
public static final java.lang.reflect.Method method_isModeRestore
public static final java.lang.reflect.Method method_isModeSave
public static final Controller activeController
public static final org.apache.log4j.Logger log
public static final GuiLog guilog
public Event.ContinuationFrame callState
public Event.ContinuationFrame callbackState
public Event currentCaller
public BlockingSleep entityBlockingSleep
Method Detail |
---|
public static Controller newController(java.lang.ClassLoader loader) throws java.rmi.RemoteException
loader
- class loader (rewriter) to use
java.rmi.RemoteException
- distributed simulation failureMain.SINGLE_CONTROLLER
public java.lang.Throwable reset()
public boolean isRunning()
public long getStartTime()
public void run()
run
in interface java.lang.Runnable
public java.lang.Thread startDisplayThread()
public void start()
start
in interface ControllerRemote
public void join() throws java.lang.InterruptedException
java.lang.InterruptedException
- interrupted simulation threadpublic Event getCurrentEvent()
public void registerCallEvent(java.lang.reflect.Method method, EntityRef ref, java.lang.Object[] args)
method
- invocation method for eventref
- invocation entity reference for eventargs
- invocation parameters for eventpublic void disposeEvent(Event ev)
ev
- event instance to disposepublic void addEvent(Event ev)
addEvent
in interface ControllerRemote
ev
- event to schedulepublic void addEvent(java.lang.reflect.Method meth, EntityRef ref, java.lang.Object[] params)
addEvent
in interface ControllerRemote
meth
- method of event to scheduleref
- entity reference of event to scheduleparams
- parameters of event to schedulepublic void addEvent(java.lang.reflect.Method meth, EntityRef ref, java.lang.Object[] params, long time)
addEvent
in interface ControllerRemote
meth
- method of event to scheduleref
- entity reference of event to scheduleparams
- parameters of event to scheduletime
- event invocation timepublic long getSimulationTime()
public java.lang.String getSimulationTimeString()
public void advanceSimulationTime(long i)
i
- number of steps to advance simulation timepublic void endAt(long time)
endAt
in interface ControllerRemote
time
- simulation time to endpublic void setSimUnits(long ticks, java.lang.String name)
setSimUnits
in interface ControllerRemote
ticks
- number of simulation quantaname
- unit of time namepublic EntityRef registerEntity(Entity entity)
entity
- entity to register with current controller
public Entity getEntity(int index)
index
- local entity identifier
public java.lang.Class getEntityClass(int index) throws java.rmi.RemoteException
getEntityClass
in interface ControllerRemote
index
- local entity identifier
java.rmi.RemoteException
- rpc failurepublic EntityRef getStaticEntityRef()
public java.lang.String toStringEntity(int index) throws java.rmi.RemoteException
toStringEntity
in interface ControllerRemote
index
- entity id
java.rmi.RemoteException
- distributed simulation failurepublic static java.lang.String toString(java.lang.Object o) throws java.rmi.RemoteException
o
- object or entity to stringify
java.rmi.RemoteException
- distributed simulation failurepublic static Controller getActiveController()
public java.lang.ClassLoader getClassLoader()
public void setClassLoader(java.lang.ClassLoader loader)
loader
- class loader / rewriter for controllerpublic static EntityRef getTHIS()
public static EntityRef newEntityReference(Entity entity)
entity
- newly created entity to be registered
public static EntityRef getEntityReference(java.lang.Object o)
o
- object of either Entity or EntityRef type
public static void entityInvocation(java.lang.reflect.Method meth, EntityRef ref, java.lang.Object[] params)
meth
- method to be invokedref
- reference to entity being invokedparams
- invocation parameterspublic static void entityInvocation(java.lang.reflect.Method meth, Entity entity, java.lang.Object[] params)
meth
- method to be invokedentity
- entity to be invokedparams
- invocation parameterspublic static void entityInvocation(java.lang.reflect.Method meth, java.lang.Object callee, java.lang.Object[] params)
meth
- method to be invokedcallee
- object (either entity or entityreference) to be invokedparams
- invocation parameterspublic static java.lang.Object entityInvocationCont(java.lang.reflect.Method meth, EntityRef ref, java.lang.Object[] params) throws JistAPI.Continuation, java.lang.Throwable
meth
- method to be invokedref
- reference to entity being invokedparams
- invocation parameters
JistAPI.Continuation
- never (marker for rewriter)
java.lang.Throwable
- whatever was thrown by blocking eventpublic static java.lang.Object entityInvocationCont(java.lang.reflect.Method meth, Entity entity, java.lang.Object[] params) throws JistAPI.Continuation, java.lang.Throwable
meth
- method to be invokedentity
- entity to be invokedparams
- invocation parameters
JistAPI.Continuation
- never (marker for rewriter)
java.lang.Throwable
- whatever was thrown by blocking eventpublic static java.lang.Object entityInvocationCont(java.lang.reflect.Method meth, java.lang.Object callee, java.lang.Object[] params) throws JistAPI.Continuation, java.lang.Throwable
meth
- method to be invokedcallee
- object (either entity or entityreference) to be invokedparams
- invocation parameters
JistAPI.Continuation
- never (marker for rewriter)
java.lang.Throwable
- whatever was thrown by blocking eventpublic static boolean isModeRestore()
public boolean isModeRestoreInst()
public static boolean isModeSave()
public boolean isModeSaveInst()
public java.lang.Object clearRestoreState() throws java.lang.Throwable
java.lang.Throwable
- whatever was thrown by the blocking eventpublic static Event.ContinuationFrame popStateInFrame()
public static void pushStateOutFrame(Event.ContinuationFrame f)
f
- next frame of outgoing execution stack.public Event switchCaller(Event caller)
caller
- new caller (return) event
public void setLog(JistAPI.Logger logger)
logger
- logging implementationpublic void setLog(java.lang.Class loggerClass) throws java.lang.InstantiationException, java.lang.IllegalAccessException
loggerClass
- logging class
java.lang.InstantiationException
- invalid logger class
java.lang.IllegalAccessException
- invalid logger classpublic void log(java.lang.String s)
log
in interface ControllerRemote
s
- string to log
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |