agentland.util.scheduler
Class SchedulerAgent
java.lang.Object
|
+--java.rmi.server.RemoteObject
|
+--java.rmi.server.RemoteServer
|
+--java.rmi.server.UnicastRemoteObject
|
+--metaglue.AgentAgent
|
+--agentland.util.scheduler.SchedulerAgent
- All Implemented Interfaces:
- Agent, MetagluePrimitives, Remote, Scheduler, Serializable
- public class SchedulerAgent
- extends AgentAgent
- implements Scheduler
Like crontab but better(more opaque).
- See Also:
- Serialized Form
Inner Class Summary |
protected class |
SchedulerAgent.Timer
This class deals with the timing for our scheduler agent |
Methods inherited from class metaglue.AgentAgent |
addMonitor, alive, buildEHAFor, defrost, defrostAll, defrostBoolean, defrostInt, defrostString, fixAttribute, fixAttribute, freeze, freeze, freeze, freezeAll, freezeVar, getAgentID, getAttribute, getCatalog, getCatalogID, getDesignation, getFrozenVariables, getLogLevel, getMetaglueAgent, getMetaglueAgentID, getOccupation, getOldLogs, getProperties, getProxyHandlerClass, getSociety, installAPH, log, log, log, lookupClass, reliesOn, reliesOn, reliesOn, reliesOnSynch, removeAPHFromCatalog, removeFrozen, setFreezeName, setLogLevel, setLogName, shutdown, startAgent, startAgentOn, startAgentOn, startup, status, tiedTo, tiedTo, tiedTo, tiedTo, tieToDesignation, whereAreYou |
lastID
protected static long lastID
remindersByID
protected Hashtable remindersByID
remindersInOrder
protected Vector remindersInOrder
SchedulerAgent
public SchedulerAgent()
throws RemoteException
addReminder
public long addReminder(ReminderRecord reminder)
throws RemoteException
- Allows you to add a reminder record
- Specified by:
addReminder
in interface Scheduler
- Parameters:
reminder
- a ReminderRecord
value- Returns:
- the id of the reminder, when you do updating or
removing later, you must use this id
removeReminder
public boolean removeReminder(long id)
throws RemoteException
- Removes a reminder from the list
- Specified by:
removeReminder
in interface Scheduler
- Parameters:
id
- the id of the reminder to be removed- Returns:
- true of everything went ok or false otherwise
updateReminder
public boolean updateReminder(long id,
ReminderRecord reminder)
throws RemoteException
- Allows you to modify an existing reminder; if the reminder with
given id does not exist, we add the new reminder with the given
id
- Specified by:
updateReminder
in interface Scheduler
- Parameters:
id
- the id of the reminder to be modifiedreminder
- the new reminder object that should go in its place- Returns:
- true if everything went ok or false if no reminder with
given id could be found
getReminder
public ReminderRecord getReminder(long id)
throws RemoteException
- Returns the reminder with a given id
- Specified by:
getReminder
in interface Scheduler
- Parameters:
id
- id of the reminder to get- Returns:
- the reminder or null if no reminder with given id could
be found
getMyReminders
public Vector getMyReminders(AgentID aid)
throws RemoteException
- Returns all reminders owned by an agent specified by agent id
- Specified by:
getMyReminders
in interface Scheduler
- Parameters:
aid
- agent id whose reminders you want to see- Returns:
- vector of reminders (if anything goes wrong, it returns
an empty vector)
addReminder
protected void addReminder(ReminderRecord reminder,
long id)
storeReminder
protected void storeReminder(ReminderRecord reminder)
unstoreReminder
protected boolean unstoreReminder(long id)
- Removes the reminder and, if necessary, resets the timer
- Parameters:
id
- id of reminder to remove.- Returns:
- true reminder was found and removed, false otherwise.
whatsUp
protected void whatsUp()
- This method gets called by the timer thread; it checks if there
are any ripe reminders and if so, issues them.
getNextReminder
protected ReminderRecord getNextReminder()
- Returns the next unexpired reminder. If it finds any expired
reminders in the queue, it silently removes them
- Returns:
- the next unexpired reminder or null
setTimer
protected void setTimer()
- Looks at the next unexpired reminder and sets the timer
accordingly. Even if the reminder is already past due, this
method is not going to do anything about it. It will just mean
that the timer will fire right away....
callMethod
protected void callMethod(ReminderRecord reminder)
- This method gets called from the MethodCaller thread -- it
calls a method specified in the reminder record. According to
the settings in the reminder record, it will either wake the
dead agents for the call or not
- Parameters:
reminder
- the reminder record from which the call info is
to be taken
toString
public String toString()
- Overrides:
toString
in class AgentAgent