All Packages Class Hierarchy This Package Previous Next Index
Class RouterLayer.AgentClient.RouterClientAction
Abstract.AgentAction
|
+----BaseLayer.BAgentAction
|
+----KQMLLayer.KQMLAgentAction
|
+----RouterLayer.AgentClient.RouterClientAction
- public abstract class RouterClientAction
- extends KQMLAgentAction
Template to support RouterClientAction. You should fill in processAction
and Act method.
The RouterClient is a KQML agent which just follow the RouterSecurity
protocol for connection. However 'sendMessage' is different - the messages will be
sent to the Router whoever the receiver is. And the Router will deliver the
message to the actual receiver. To maintain the Router more efficiently, it
would be better to send the delete-message message frequently.(It is just like
the same as using e-mail. If your mail box has a lot of mails, the mail server's
process speed will be very slow).
- See Also:
- RCActionExample
-
_deleteFPT
- Delete message number array for buffering the delete messages
-
_deleteFPTSize
- Current buffered delete message size
-
_mailQueue
- Message repository
-
_maxDeleteSize
- Deleted message numbers will be piled up to the maximum size.
-
_messageNumber
- number of messages you have received from the Router
-
_myAddress
- My address
-
_registrarName
- The registrar name
-
_routerName
- The Router name
-
RouterClientAction()
- Default constructor.
-
RouterClientAction(Address, Address, Address, int)
- Router AgentAction constructor with given my address,rotuer address and router registrar
address.
-
RouterClientAction(Address, Address, Address, int, ThreadGroup)
- Router AgentAction constructor with given my address,rotuer address ,router registrar
address ,maximum idle time, and thread group.
-
RouterClientAction(Address, Address, int)
- Constructor.
-
RouterClientAction(String, String, int)
- Constructor using Address strings.
-
RouterClientAction(String, String, String, int)
- Router AgentAction constructor with given my address,rotuer address and router registrar
address.
-
Act(Object)
- Since message format is different(reading tag and time stamp), this
method should be overriden.
-
addToDeleteBuffer(int)
- If a message is performed, you should request to delete the message
for the Router to maintain the incoming files.
-
addToDeleteBuffer(int[])
- Passing integer array which contains the message number to be deleted.
-
connect()
- Connect to the Router, using current agent name
-
connect(Address)
- Connect to the Router.
-
connect(String)
- Connect to the Router, using the agent name
-
ConvertStringToAddress(String)
- Parse KQML address string and convert to Address object.
-
disconnect()
- Disconnect from the Router.
-
endAction()
- Override endAction() to send buffered delete-messages
-
getMailQueue()
- Get mail queue
-
getMaxDeleteSize()
- Get maximum delete buffer size.
-
getMyAddress()
- Get my address
-
getRouterName()
- Get the Router name
-
initDataMembers()
- Initialize all data members
-
listUsers()
- Router utility to request list the current registered agent to the Router
Message format:
(list-agent :sender xx :receiver Router)
Returned message format from the Router
(registered-agent :sender Router :receiver xx :content (aaa bbb ccc))
-
processMessage(String, Object)
- You should implement this method.
-
register()
- Router utility to register.
-
register(Address, Address)
- Router utility to register.
-
requestAddress(String)
- Router utility for agent name service.
-
requestAddress(String, String)
- Router utility for agent name service.
-
reserveMessage(long, int[], Address)
- Make message reservation content from given time,message number array and reserved
address and send 'reserve-message' message to the Router
-
reserveMessage(long, String, Address)
- Send 'reserve-message' message to the Router
The reserve-message will follow the message format:
(reserve-message :sender xx :receiver Router :content (1 3 5 7) :time 888837363524
:address (receive-address :name xx :host cdr.stanford.edu :port 4352 :message-method
MessageRouter :description (agent-info :password zzz)))
The 'receive-address' name slot represent that the intended receiver may be different
from the 'sender'.
-
sendDeleteMessage()
- Update the message number when the deleted message number is upto _maxDeleteSize.
-
sendKQMLMessage(String)
- Send message to the router.
-
sendMessage(KQMLmessage)
- Send KQMLmessage.
-
sendMessage(String)
- Send message to the router
-
sendMessage(String, String)
-
-
setMyAddress(Address)
- Set my address
-
setMyAddress(String)
- Set my address using address string
-
setRegistrarAddress(Address)
- Set router registrar address
-
setRegistrarAddress(String)
- Set router registrar address using address string
-
setRouterAddress(Address)
- Set router address
-
setRouterAddress(String)
- Set router address using address string
-
unregister()
- Router utility to unregister
-
unregister(Address)
- Router utility to unregister
_routerName
protected String _routerName
- The Router name
_registrarName
protected String _registrarName
- The registrar name
_myAddress
protected Address _myAddress
- My address
_messageNumber
protected int _messageNumber
- number of messages you have received from the Router
_deleteFPT
protected int _deleteFPT[]
- Delete message number array for buffering the delete messages
_deleteFPTSize
protected int _deleteFPTSize
- Current buffered delete message size
_mailQueue
protected Vector _mailQueue
- Message repository
_maxDeleteSize
protected int _maxDeleteSize
- Deleted message numbers will be piled up to the maximum size.
For more delete, actual delete operation will be happen on the
Router and AgentClient also should update the message number
Default is 1.
RouterClientAction
public RouterClientAction()
- Default constructor. All data members will be initialized except
addresses for me, route and registrar. If you use this constructor,
you shoud use setMyAddress(Address),setRouterAddress(Address) and setRegistrarAddress(Address)
to initialize essential addresses.
RouterClientAction
public RouterClientAction(Address routeraddress,
Address registraraddress,
int durationTime)
- Constructor. Note that your address is not specified yet. You should use setMyAddress()
method before invoke connect() method.
- Parameters:
- routeraddress - The Router address to connect
- router - registrar address
- durationTime - Maximum idle time for the connection
RouterClientAction
public RouterClientAction(Address myAddress,
Address routerAddress,
Address registrarAddress,
int durationTime)
- Router AgentAction constructor with given my address,rotuer address and router registrar
address.
- Parameters:
- myAddress - My address
- routerAddress - The Router address
- registrarAddress - The Registrar address
- durationTime - Maximum idle time
RouterClientAction
public RouterClientAction(String routeraddressstr,
String registraraddressstr,
int durationTime)
- Constructor using Address strings. Addresses string is basically a line of string :
The address string should have the format :
(agent-address :name [agent-name] :host [host-inetaddress] :port [port no]
:password [password] :KQML-extensions [kqml extensions] :email [email address]
:description [agent description])
KQML-extensions, email and description is optional.
Example
(agent-address :name agentA :host java.stanford.edu :port 1234 :password xxxxxxxx
:KQML-extensions http://java.stanford.edu/newprotocol :email jhc@cdr.stanford.edu
:description (Network service))
- Parameters:
- routeraddressstr - The Router address string to connect
- registraraddressstr - The Router registrar address string
- durationTime - Maximum idle time for the connection
RouterClientAction
public RouterClientAction(String myAddressstr,
String routerAddressstr,
String registrarAddressstr,
int durationTime)
- Router AgentAction constructor with given my address,rotuer address and router registrar
address.
The address string should have the format :
(agent-address :name [agent-name] :host [host-inetaddress] :port [port no]
:password [password] :KQML-extensions [kqml extensions] :email [email address]
:description [agent description])
KQML-extensions, email and description is optional.
Example
(agent-address :name agentA :host java.stanford.edu :port 1234 :password xxxxxxxx
:KQML-extensions http://java.stanford.edu/newprotocol :email jhc@cdr.stanford.edu
:description (Network service))
- Parameters:
- myAddressstr - My address string
- routerAddressstr - The Router address string
- durationTime - Maximum idle time
RouterClientAction
public RouterClientAction(Address myAddress,
Address routerAddress,
Address registrarAddress,
int durationTime,
ThreadGroup t)
- Router AgentAction constructor with given my address,rotuer address ,router registrar
address ,maximum idle time, and thread group.
- Parameters:
- myAddress - My address
- routerAddress - The Router address
- routerAddress - The Router address
- durationTime - Maximum idle time
- t - Thread group
initDataMembers
protected void initDataMembers()
- Initialize all data members
setMyAddress
public void setMyAddress(Address address)
- Set my address
- Parameters:
- address - My address to be set
setRouterAddress
public void setRouterAddress(Address addr)
- Set router address
- Parameters:
- addr - The Router address
setRegistrarAddress
public void setRegistrarAddress(Address addr)
- Set router registrar address
- Parameters:
- addr - The rotuer registrar address
setMyAddress
public void setMyAddress(String addressstr)
- Set my address using address string
- Parameters:
- addressstr - My address string to be set
setRouterAddress
public void setRouterAddress(String addrstr)
- Set router address using address string
- Parameters:
- addr - The Router address
setRegistrarAddress
public void setRegistrarAddress(String addrstr)
- Set router registrar address using address string
- Parameters:
- addr - The rotuer registrar address
getMyAddress
public Address getMyAddress()
- Get my address
- Returns:
- My address
connect
public synchronized void connect(Address addr) throws ConnectionException
- Connect to the Router. Addrss should be passed. If the connection is already exist,
it first disconnect the connection and try to reconnect.
- Parameters:
- addr - My address to be sent to the Router
- Throws: ConnectionException
- for any error occurs during processing connect. If addr
is null, it will also throws ConnectionException
connect
public synchronized void connect(String id) throws ConnectionException
- Connect to the Router, using the agent name
- Parameters:
- id - My name
connect
public synchronized void connect() throws ConnectionException
- Connect to the Router, using current agent name
disconnect
public void disconnect()
- Disconnect from the Router.
register
public synchronized void register(Address registrar,
Address myaddress) throws ConnectionException
- Router utility to register. Declared to be as a critical section, to finish
registration before connect.
- Parameters:
- registrar - The Router Registrar address
- myaddress - My address to be registered
- Throws: ConnectionException
- for any error occurs during processing this service
register
public synchronized void register() throws ConnectionException
- Router utility to register. Declared to be as a critical section, to finish
registration before connect. Before you invoke this method, my address and the
registrar address should be set(either by constructor or setRegistrarAddress,
setMyAddress methods.
- Throws: ConnectionException
- for any error occurs during processing this service
unregister
public synchronized void unregister(Address myaddress) throws ConnectionException
- Router utility to unregister
- Parameters:
- myaddress - My address to be unregistered
- Throws: ConnectionException
- for any error during processing this service
unregister
public synchronized void unregister() throws ConnectionException
- Router utility to unregister
- Throws: ConnectionException
- for any error during processing this service
requestAddress
public void requestAddress(String name) throws ConnectionException
- Router utility for agent name service. Request the other agent address by passing
its name.
Message format:
(request-address :sender xx :receiver Router :content Xname)
Returned message format from the Router:
(address :sender Router :receiver xx :name Xname :host cdr.stanford.edu :port 1234
:message-method MessageRouter :description (agent-info :service sort-service))
- Parameters:
- name - Agent name you want to get the address information
- Throws: ConnectionException
- for any error during the processing this service
requestAddress
public void requestAddress(String name,
String replyWith) throws ConnectionException
- Router utility for agent name service. Request the other agent address by passing
its name.
Message format:
(request-address :sender xx :receiver Router :content Xname)
Returned message format from the Router:
(address :sender Router :receiver xx :name Xname :host cdr.stanford.edu :port 1234
:message-method MessageRouter :description (agent-info :service sort-service))
- Parameters:
- name - Agent name you want to get the address information
- Throws: ConnectionException
- for any error during the processing this service
listUsers
public void listUsers() throws ConnectionException
- Router utility to request list the current registered agent to the Router
Message format:
(list-agent :sender xx :receiver Router)
Returned message format from the Router
(registered-agent :sender Router :receiver xx :content (aaa bbb ccc))
- Throws: ConnectionException
- for any error during processing the message
reserveMessage
public void reserveMessage(long time,
String mailNoList,
Address address) throws ConnectionException
- Send 'reserve-message' message to the Router
The reserve-message will follow the message format:
(reserve-message :sender xx :receiver Router :content (1 3 5 7) :time 888837363524
:address (receive-address :name xx :host cdr.stanford.edu :port 4352 :message-method
MessageRouter :description (agent-info :password zzz)))
The 'receive-address' name slot represent that the intended receiver may be different
from the 'sender'. You can reserve message for other agent.
The 'address' slot is optional.
- Parameters:
- time - Time stamp
- mailNoList - list of message numbers
- address - Intended receiving address. Null if the receiving location is not different
- Throws: ConnectionException
- if the given information is incomplete
reserveMessage
public void reserveMessage(long time,
int a[],
Address address) throws ConnectionException
- Make message reservation content from given time,message number array and reserved
address and send 'reserve-message' message to the Router
- Parameters:
- time - Time stamp
- a[] - Reserved message numbers
- address - Reserved location if different from the current address
sendMessage
public void sendMessage(String receiver,
String msg) throws ConnectionException
- Parameters:
- receiver - Whoever the receiver is, the message will be sent to the Router
- msg - Message to be sent
- Overrides:
- sendMessage in class BAgentAction
sendMessage
public void sendMessage(String msg) throws ConnectionException, ParseException
- Send message to the router
- Parameters:
- msg - Message to be sent to the Router
sendMessage
public void sendMessage(KQMLmessage kqml) throws ConnectionException
- Send KQMLmessage.
- Parameters:
- kqml - KQMLmessage object
- Overrides:
- sendMessage in class KQMLAgentAction
sendKQMLMessage
public void sendKQMLMessage(String msg) throws ConnectionException, ParseException
- Send message to the router. Message will be parsed and checked before sent to router. If KQML parse error occurs, ParseException will be thrown. This method is safer than sendMessage(String msg).
- Parameters:
- msg - Message to be sent to the Router
- Throws: ConnectionExcaption,
- KQMLLayer.ParseException.
getRouterName
public String getRouterName()
- Get the Router name
- Returns:
- Router name the agent is registered to and communicate witl
getMailQueue
public Vector getMailQueue()
- Get mail queue
- Returns:
- Mail queue
getMaxDeleteSize
public int getMaxDeleteSize()
- Get maximum delete buffer size.
- Returns:
- Maximum delete buffer size
processMessage
public abstract void processMessage(String command,
Object obj)
- You should implement this method.
- Parameters:
- command - Command to be executed
- obj - Reference object
- Overrides:
- processMessage in class BAgentAction
Act
public boolean Act(Object o)
- Since message format is different(reading tag and time stamp), this
method should be overriden. At least, you need to add the received
KQMLmail to the _mailQueue.
- Parameters:
- o - KQMLmail object.
- Overrides:
- Act in class BAgentAction
addToDeleteBuffer
public void addToDeleteBuffer(int mailno)
- If a message is performed, you should request to delete the message
for the Router to maintain the incoming files. Since Router will
update the deleteMessage when the number of deletedMessage Size is
_maxDeleteSize, the message number after delete _maxDeleteSize messages will be updated
- Parameters:
- mailno - Message number to be deleted
sendDeleteMessage
public void sendDeleteMessage()
- Update the message number when the deleted message number is upto _maxDeleteSize.
addToDeleteBuffer
public void addToDeleteBuffer(int a[])
- Passing integer array which contains the message number to be deleted.
Internally, if the deleted message size is over the _maxDeleteSize, the message
numbers will be updated.
- Parameters:
- a[] - Current message numbers to be deleted
endAction
public void endAction()
- Override endAction() to send buffered delete-messages
- Overrides:
- endAction in class BAgentAction
ConvertStringToAddress
public Address ConvertStringToAddress(String kqmladdr)
- Parse KQML address string and convert to Address object.
The address string should have the format :
(agent-address :name [agent-name] :host [host-inetaddress] :port [port no]
:password [password] :KQML-extensions [kqml extensions] :email [email address]
:description [agent description])
KQML-extensions, email and description is optional.
Example
(agent-address :name agentA :host java.stanford.edu :port 1234 :password xxxxxxxx
:KQML-extensions http://java.stanford.edu/newprotocol :email jhc@cdr.stanford.edu
:description (Network service))
- Parameters:
- addrstr - Address string
- Returns:
- Address object. If wrong format, return null
All Packages Class Hierarchy This Package Previous Next Index