com.ls.lars.server
Class AgentTimer

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.ls.lars.communication.CommunicationTemplate
              |
              +--com.ls.lars.server.AgentTemplate
                    |
                    +--com.ls.lars.server.AgentTimer
All Implemented Interfaces:
ICommunication, IToLars, Runnable, Serializable

public class AgentTimer
extends AgentTemplate


to Class Specification

Note: AgentTimer logs ERROR and WARNING log information in both the system's log file and it's own log file, alll log messages with a less important log level are logged in AgentTimer's own log file.


 Incoming Messages  AgentTimer offers the following services.
                    Input parameters you have to specify are listed
                    with the messages and must be transmitted using a map.
                    ------------------------------------------------------------
                    notify_agent
                    ------------------------------------------------------------
                    Function:   Inserts a notification request into the timer
                                queue. The request is stored for an agent
                                agent and a set time time. The value for time
                                is an absolute value, not relative to the
                                current time.

                    Parameters: time, agent (Map)

                    Responses:  notified_agent      The notification request
                                                    was added to the timer queue.

                                agent_not_notified  The request was malformed
                                                    (i.e. bad time) and was not
                                                    added to the queue. Use Java's
                                                    System.currentTimeMillis()
                                                    method and add an amount of
                                                    milliseconds to that to
                                                    create a time stamp for
                                                    AgentTimer.

                    Both responses use the reply ID of the incoming message and
                    send back the original parameter map as content. This
                    can be saved, for instance, to be able to cancel a
                    notification later on. The quality of service of either 
                    reply is QualityOfService.QOS_NONE.
                    ------------------------------------------------------------
                    cancel_notify
                    ------------------------------------------------------------
                    Function:   Removes a notification from the timer queue.

                    Parameters: time, agent (Map)

                    Responses:  notify_canceled           The notification
                                                          request was removed
                                                          from the timer queue.

                                notify_not_canceled       The notification
                                                          could not be removed
                                                          because of a
                                                          malformed time
                                                          argument, or because
                                                          the notification
                                                          request does not exist.

                    Both responses use the reply ID of the incoming message and
                    send back the original parameter map as content. The quality
                    of service of either reply is QualityOfService.QOS_NONE.
                    ------------------------------------------------------------
                    sender_rip
                    ------------------------------------------------------------
                    Function:   Removes all notification requests of the sender
                                from the timer queue. This should be sent in
                                the terminateActions() method of all agents,
                                that cooperate with AgentTimer, when those
                                agents are terminating.

                    Parameters: none (content is not needed and ignored)
                    Responses:  Due to the termination of the requesting
                                agent no answer is sent.

                    ------------------------------------------------------------
 Config File        AgentTimer does not need a config file.
 

Version:
$Revision: 1.13 $
Author:
Last modified by $Author: MHeitz $
See Also:
Serialized Form

Field Summary
protected  String revisionInformation
          revision information string, managed by our version control system.
 
Fields inherited from class com.ls.lars.server.AgentTemplate
agentMaxPool, agentMessageRouterName, agentMinPool, defaultServiceAccessPermission, defaultServiceAccessPrivilege, dynamicObjectController, FULL_SERVICE_ACCESS, iXMLHandlerForConfigLoader, localPlatform, maxInvokeStackCounter, NO_SERVICE_ACCESS, RUN_LEVEL_ACTIONS_INITIALIZED, RUN_LEVEL_CONFIG_FILE_INTERPRETED, RUN_LEVEL_CONFIG_FILE_READ, RUN_LEVEL_EMBRYONIC, RUN_LEVEL_INTERPRET_METHODS_REGISTERED, RUN_LEVEL_POOL_INITIALIZED, RUN_LEVEL_RUNNING, RUN_LEVEL_STOPPED, RUN_LEVEL_TERMINATED
 
Fields inherited from class com.ls.lars.communication.CommunicationTemplate
agentName, homePlatform, iPKIHandler, logger, STATUS_CONNECTED, STATUS_NOT_CONNECTED
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface com.ls.lars.communication.ICommunication
AUTHENTICATION_PASSWORD, AUTHENTICATION_USER, COMPRESSION_AUTO_COMPRESSION, COMPRESSION_AUTO_COMPRESSION_START_SIZE, COMPRESSION_LEVEL, COMPRESSION_TYPE, COMPRESSION_ZIP_ENTRY_NAME, CONNECTION_TYPE, HOST_ID, HOST_IP, HOST_PORT, HTTP, J_SECURE_SOCKET, J_SOCKET, JMS, JMS_INITIAL_CONTEXT_FACTORY, JMS_JMSMESSENGER_APPLICATION_LOCATION, JMS_PROVIDER_URL, JMS_RECEIVING_QUEUE_NAME, JMS_SECURITY_CREDENTIALS, JMS_SECURITY_PRINCIPAL, JMS_SENDING_QUEUE_NAME, MAXIMUM_MESSAGE_LENGTH, PROTOCOL, RMI, SOCKET, TIMEOUT, USE_OUTBOX
 
Constructor Summary
AgentTimer(String agentName, String homePlatform, List agentConfigFiles)
          Constructor with the agentName, its homePlatform and a List containing the names of the configuration file(s) of the new agent.
 
Method Summary
protected  String getRevisionInformation()
          gets the revision information of this agent
protected  void initializeAction()
          Initializes the TimerQueue and TimerThread components. This method gets called, before the config file is interpreted!
 void initializeMessages()
          Calls super.initializeMessages() and afterwards registers AgentTimer as a service provider for the service "sender_rip".
protected  boolean interpretCancelNotify(Message currentMessage)
          Cancels the notification of an agent.
protected  boolean interpretNotifyAgent(Message currentMessage)
          registers the sender of the given message to be notified at a specific time
protected  boolean interpretSenderRip(Message currentMessage)
          Cancels all notifications for the sender of the given message, because that agent just died.
 boolean terminateAction()
          Checks, if the corresponding timer thread has any notification requests.
 
Methods inherited from class com.ls.lars.server.AgentTemplate
executeLifeCycle, executeWhileRunning, getAgentRevisionInformation, getIPKIHandler, getOwnPublicKeyCertificate, interpret, interpretAccessDenied, interpretAgentConnected, interpretCheckRegisteredServices, interpretCloseConnection, interpretDefineObject, interpretDeliveryFailed, interpretGetRevisionInformation, interpretInterpretationSuccessful, interpretLoadObject, interpretLogInbox, interpretMonitorLookup, interpretNotifiedAgent, interpretNotifyCanceled, interpretNotifyNotCanceled, interpretNotUnderstood, interpretPing, interpretRegisterService, interpretSendAsConfigured, interpretSetAccessPrivileges, interpretSetForeignPublicKeyCertificate, interpretSetLog, interpretSetOwnPublicKeyCertificate, interpretSetPkiEnvironment, interpretSetPkiMessages, interpretSetPrivateKey, interpretSetRunLevel, interpretSignatureNotValid, interpretStartupConstraint, loadConfigFile, performDefaultBehavior, reconnectAfterMigration, registerInterpretMethods, registerInterpretMethods, registerInterpretMethods, reInitializeAction, setAgentMessageRouterName, setIXMLHandler, setLocalPlatform, setPKIMessage, toString
 
Methods inherited from class com.ls.lars.communication.CommunicationTemplate
addConnectionParameter, checkSendSystemReply, connect, createReplyId, disconnect, disconnectForMigration, finalize, forwardMessage, forwardMessage, getAgentName, getConnectionParameters, getInboxSize, getLarsHost, getNumberOfProcessedMessages, getNumberOfProcessedMessagesPerMinute, getStartTime, isConnected, logInbox, receiveBlockedMessage, receiveBlockedMessage, run, sendMessage, sendSynchronousRequest, sendSynchronousRequest, setConnectionParameters, setLog, setMeantimeBetweenConnectionCheck, waitForConnection, waitForConnection
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ls.lars.communication.IToLars
start
 

Field Detail

revisionInformation

protected String revisionInformation
revision information string, managed by our version control system.
Constructor Detail

AgentTimer

public AgentTimer(String agentName,
                  String homePlatform,
                  List agentConfigFiles)
Constructor with the agentName, its homePlatform and a List containing the names of the configuration file(s) of the new agent.
Parameters:
agentName - name of the agent (example: xyz )
homePlatform - name of the homePlatform where the agent was created (example: 195.52.158.233/lars)
agentConfigFiles - config file(s), which should be read by the agent when it starts up
See Also:
TimerQueue, TimerThread
Method Detail

getRevisionInformation

protected String getRevisionInformation()
gets the revision information of this agent
Overrides:
getRevisionInformation in class AgentTemplate
Returns:
the revision information

initializeAction

protected void initializeAction()
Initializes the TimerQueue and TimerThread components. This method gets called, before the config file is interpreted!
Overrides:
initializeAction in class AgentTemplate

initializeMessages

public void initializeMessages()
Calls super.initializeMessages() and afterwards registers AgentTimer as a service provider for the service "sender_rip". This assures, that AgentTimer gets to know, if any of its clients (agents, that want to be notified) ceases to exist and allows AgentTimer, to remove the (then unused) notification requests.
Overrides:
initializeMessages in class AgentTemplate

terminateAction

public boolean terminateAction()
Checks, if the corresponding timer thread has any notification requests. If not, the timer thread is stopped and super.terminateAction is called.
Overrides:
terminateAction in class AgentTemplate
Returns:
false, if the corresponding timer thread has any more agent notification requests; super.terminateAction() else
See Also:
AgentTemplate.terminateAction()

interpretNotifyAgent

protected boolean interpretNotifyAgent(Message currentMessage)
registers the sender of the given message to be notified at a specific time
Parameters:
currentMessage - current message with a notification request of an agent
Returns:
true, if successful; false else

interpretCancelNotify

protected boolean interpretCancelNotify(Message currentMessage)
Cancels the notification of an agent. This usually happens when the notification is not necessary any more or the agent ends before the notification has to be sent.
Parameters:
currentMessage - current message with a cancel request of an agent
Returns:
true, if the interpretation of the message was successful; false else

interpretSenderRip

protected boolean interpretSenderRip(Message currentMessage)
Cancels all notifications for the sender of the given message, because that agent just died. Due to the termination of the requesting agent no answer is sent.
Parameters:
currentMessage - message with cancel request
Returns:
always true