All Packages Class Hierarchy This Package Previous Next Index
Class RouterLayer.Router.RouterAction
Abstract.AgentAction
|
+----BaseLayer.BAgentAction
|
+----KQMLLayer.KQMLAgentAction
|
+----RouterLayer.Router.RouterAction
- public class RouterAction
- extends KQMLAgentAction
Router server action class.
Router performs to route messages to the receiver agent and keep the messages to the
file until the receiver agent request to delete the messages.
Router server features
- Route a message to the receiver and keep it to the receiver file
- Applets can send/receive messages using Router
- If the receiver agent is on-line, deliver the message promptly
- If the receiver agent is off-line, try to initiate the connection to the receiver
if the receiver has ServerThread. If initialization is successful, send the message
promptly. If initialization fails, keep it to the receiver file. Afterward, if
the receiver is connected to the Router, the Router sends received messages to the
receiver
- Agent can register to the Router through on-line.
- RouterSecurity will check the password. Therefore, when an agent registers to the
Router, it should send its password.
- The messages can be reserved to be sent later to the specific location in a specific
time
- The agents can request the other agents address(Agent Name Service)
- The agents can request the current on-line agent list.
The Router server will open two ServerSocket, one for accepting the registration and
one for accepting the connection from the registered agents. The Router delegate its
utilities(ANS,list-users,delete-message) to the RouterRecvThread. The Router does not
have centralized MessageBuffer. Each RouterRecvThread has its own MessageBuffer and
work invidually. For each router client, one unique RouterRecvThread will be created
by accepting the conneciton. If a message is received from the connection the RouterRecvThread
will parse the message to find out the receiver. Then, if the receiver is on-line,
the message will be stored to the receiver RouterRecvThread's MessageBuffer after
adding time stamp. While looping, the RouterRecvThread check its MessageBuffer. If the
MessageBuffer is not empty, it will directly send the message through its connection
and save it to its incoming file.(Note that by this approach, we can evade critical
section when save/retrieve the message from the file).
- See Also:
- RouterRecvThread
-
_disconnectTable
-
-
_messageBoxPath
- Incoming message file directory path.
-
_offLineCheckPeriod
-
-
_offLineList
- Hashtable which maintains the off-line agent list.
-
_offLineTrialTimes
-
-
_reserveCheckPeriod
-
-
_reservedBook
- Hashtable which maintains the reserved messages.
-
_reserveTrialTimes
-
-
_sleepPeriod
-
-
RouterAction()
- Default constructor.
-
RouterAction(String, String, String, String, String, int, int, int, int, int, int)
- Constructor
-
Act(Object)
- Router does not implement Act(Object) method.
-
createReceiverThread(String, int)
- Override AgentAction createRecvThread method
Create client receiver thread using name of the agent
Override this method if your connection type is different.
-
createServerThread(String, int)
- Override AgentAction createServerThread method
Create server thread using name of the agent
Override this method if your connection type is different.
-
getAddress()
- Get Router address
-
getOffLineAgentList()
- Get reservation table
-
getReservedBook()
- Get reservation table
-
main(String[])
-
-
processMessage(String, Object)
- Override processMessage of AgentAction.
-
resetReservedTime(long, Reservation)
- If the attempt to send reserved messages to the receiver, the Router will
reset time as one more hour from the original reserved time.
-
run()
- check whether there's a reserved messages.
-
sendOffLineAgentMessages()
- Send off line agent message if time meets
-
sendReservedMessages()
- Send reserved message if time meets
-
setOffLineAgentList(OffLineAgentTable)
- Set the Off line agent list
-
setReservedBook(Hashtable)
- Set the ReservationTable
-
unregisterAgent(Address)
-
_messageBoxPath
protected String _messageBoxPath
- Incoming message file directory path. You should specify this data member for the
Router to save the incoming messages to the receiver file. The incoming file for
each registered agent will be created under the messageBoxPath directory
_reservedBook
protected Hashtable _reservedBook
- Hashtable which maintains the reserved messages. The key field is time stamp and
the field value is Reservation object.
- See Also:
- Reservation
_offLineList
protected OffLineAgentTable _offLineList
- Hashtable which maintains the off-line agent list. An agent will be added to the
off line list, if the receiver thread is time out or the Router can not initiate the
connection to the agent. Note that if an agent send disconnect-agent message to the
Router, the Router will never initiate the connection. Key is time and the field is
a reservation object.
_offLineTrialTimes
protected int _offLineTrialTimes
_offLineCheckPeriod
protected int _offLineCheckPeriod
_reserveTrialTimes
protected int _reserveTrialTimes
_reserveCheckPeriod
protected int _reserveCheckPeriod
_sleepPeriod
protected int _sleepPeriod
_disconnectTable
protected Vector _disconnectTable
RouterAction
public RouterAction()
- Default constructor. You should use setAddressFilePath, setMessageBoxPath, setPasswordFilePath
methods afterwards.
RouterAction
public RouterAction(String id,
String addressFilePath,
String messageBoxPath,
String passwordFilePath,
String registryFilePath,
int durationTime,
int offLineTrialTimes,
int offLineCheckPeriod,
int reserveTrialTimes,
int reserveCheckPeriod,
int sleepPeriod)
- Constructor
- Parameters:
- id - Router name
- addressFilePath - Address file path. Address file contains the addresses of Router and
RouterRegistrar at the minimum. Add on those, you can specify the addresses of other agents
where the Router want to initiate the conneciton
- messageBoxPath - Message incoming file directory path
- passwordFilePath - Password file path
- registryFilePath - Registry file path
- duration - Maximum idle time
- offLineTrialTimes - Maximum trial times to voluntarily reconnect to stand alone agent
- offLineCheckPeriod - Off line agent time check period in minutes
- reserveTrialTimes - Maximum trial times to send reserved message
- reserveCheckPeriod - Reseved message sending time check period in minutes
- sleepPeriod - Sleep period in minutes
setReservedBook
public void setReservedBook(Hashtable reservedBook)
- Set the ReservationTable
- Parameters:
- reservedBook - ReservationTable from the RouterAction
getReservedBook
public Hashtable getReservedBook()
- Get reservation table
- Returns:
- Reserved message table
setOffLineAgentList
public void setOffLineAgentList(OffLineAgentTable offlinelist)
- Set the Off line agent list
- Parameters:
- offlinelist - Off line agent table from the RouterAction
getOffLineAgentList
public OffLineAgentTable getOffLineAgentList()
- Get reservation table
- Returns:
- Reserved message table
createServerThread
public ServerThread createServerThread(String id,
int priority)
- Override AgentAction createServerThread method
Create server thread using name of the agent
Override this method if your connection type is different.
- Parameters:
- id - ServerThread name
- priority - Server thread priority
- Returns:
- ServerThread, generated. Null if fails
- Overrides:
- createServerThread in class KQMLAgentAction
createReceiverThread
public ReceiverThread createReceiverThread(String serverid,
int priority)
- Override AgentAction createRecvThread method
Create client receiver thread using name of the agent
Override this method if your connection type is different.
Before you invoke this method, the Router name(the same as RouterAction thread name)
should be specified.
- Parameters:
- serverid - Server agent name. This name is not my name. The name of the other
agent you want to connect
- priority - Receiver thread priority
- Returns:
- ReceoverThread, generated
- Overrides:
- createReceiverThread in class KQMLAgentAction
getAddress
public Address getAddress()
- Get Router address
- Returns:
- The Router address
processMessage
public void processMessage(String command,
Object obj)
- Override processMessage of AgentAction.
- Parameters:
- command - Command to be executed
- obj - String array arguments
- Overrides:
- processMessage in class BAgentAction
Act
public boolean Act(Object o)
- Router does not implement Act(Object) method. A lot of Router action is delegated
to the RouterRecvThread
- Parameters:
- o - Object to be instantiated and performed
- Overrides:
- Act in class BAgentAction
run
public void run()
- check whether there's a reserved messages. If it's time to send
try to open connection and sent it to the receiver
- Overrides:
- run in class BAgentAction
sendReservedMessages
protected void sendReservedMessages()
- Send reserved message if time meets
resetReservedTime
protected void resetReservedTime(long time,
Reservation res)
- If the attempt to send reserved messages to the receiver, the Router will
reset time as one more hour from the original reserved time. This process will
be performed five times. If the receiver is still unreachable after five attempt,
the reserved messages will be canceled to be sent.
- Parameters:
- time - Current setting time
- res - Reservation object to be delayed
sendOffLineAgentMessages
protected void sendOffLineAgentMessages()
- Send off line agent message if time meets
unregisterAgent
protected void unregisterAgent(Address addr)
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index