|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ls.lars.communication.MessageRouter
This class is managing all messengers of the agents and has methods for the routing of messages
Field Summary | |
protected static String |
SERVICE_PROVIDER_RANGE_DECREASED
Constants specifying that the number of providers for a service has decreased |
protected static String |
SERVICE_PROVIDER_RANGE_INCREASED
Constants specifying that the number of providers for a service has increased |
Method Summary | |
boolean |
addAgentToWatch(String connectedAgent)
Adds an agent to the list of watched agents, i.e. when that agent gets connected the AgentMessageRouter will be notified about that. |
boolean |
addForward(String agentName,
String amrForward)
adds a forward to an agent to the forward list |
boolean |
addMessenger(String agentName,
com.ls.lars.communication.Messenger messenger)
Adds a messenger of an agent to the list of messengers. |
boolean |
addPlatform(String platform,
String ip,
int port)
adds a platform to the list of connected platforms |
void |
allMessengersCloseConnection()
sends a 'close_connection' message to all connected messengers |
void |
controlInboxSize(int delimiter)
Checks the size of the inbox of all known messengers, whether or not the given delimiter is reached. |
static void |
createMessageRouter(String theLocalIpAddress,
String theHomePlatform)
creates the message router of this platform |
void |
deregisterFromServiceStatusChangedNotification(String agent)
Deregisters the given agent from getting notified on the status changing of any service |
Set |
getAllMessageGroupMemberNames()
returns a set of the names of all agents, that are currently subscribed to any message group |
Set |
getAllServiceProviderNames()
returns a set of the names of all agents, that are currently registered as a service provider for any service |
Collection |
getGroupMembers(String groupName)
returns the collection of names of all agents, that are subscribed to the specified message |
static String |
getHomePlatform()
returns the name of the local platform |
static String |
getLocalIpAddress()
returns the IP address of the local platform |
com.ls.lars.communication.Messenger |
getMessenger(String messengerName)
returns the object reference of a messenger given the name of the messenger |
static MessageRouter |
getPlatformMessageRouter()
returns the message router of this platform |
Collection |
getServiceProviderMembers(String serviceName)
returns the names, as a HashSet, of the agents that are regitered for a service specified by the parameter |
boolean |
isAvailable(String agentName)
Checks, if a messenger entry already exists for the passed agent name. |
Set |
listAllProvidedServices()
Returns a list of all services, which are currently provided on this platform. |
Map |
listPlatforms()
returns a list of all platforms to which this platform is connected... |
void |
registerForServiceStatusChangedNotification(String service,
String agent,
String replyId)
Registers the given agent for getting notified when the status of the given service changes (e.g. the service becomes available or unavailable) |
void |
registerService(Object service,
String agentName)
adds an agent to the list(s) of service providers for the specified service(s) |
boolean |
removeAgentToWatch(String connectedAgent)
Removes an agent from the list of watched agents. |
boolean |
removeForward(String agentName)
removes the forward for the passed agent name from the forward list |
void |
removeMessageGroup(String groupName)
Removes a complete message group. |
boolean |
removeMessenger(String agentName)
Removes the messenger entry for the passed agent name from the list of messengers. |
boolean |
removePlatform(String platformName)
removes the platform entry for the passed platform name |
void |
routeMessage(GroupMessage message)
Sends given message to all agents of a message group (the groupname specifies the recipients of the message). |
void |
routeMessage(Message message)
Routes a message from the sender messenger to the receiver messenger. |
void |
routeMessage(MulticastMessage message)
Sends given message to all agents from the list of the receivers. |
void |
routeMessage(ServiceBroadcastMessage message)
Sends given message to all known providers of the requested service (the service is the subject of the message) Failure behaviour: An error with reason QualityOfService.QOS_SERVICE_NOT_REGISTERED is produced, if the service
is known, but no service providers are registered.
|
void |
routeMessage(ServiceSingleMessage message)
Sends given message to all known providers of the requested service (the service is the subject of the message) Failure behaviour: An error with reason QualityOfService.QOS_SERVICE_NOT_REGISTERED is produced, if the service
is known, but no service providers are registered.
|
void |
routeMessage(SingleMessage message)
routes a message from the sender messenger to the receiver messenger |
void |
setEncapsulatingAgentName(String agentName)
sets the name of the agent, which encapsulates this message router (i.e. the agent, which adds agent behavior to the message router) |
void |
subscribeToMessageGroup(String groupName,
Object agentNames,
boolean isTransaction)
adds an agent to a message group |
String |
toString()
returns a string representation of this message router containing if system log level is TRACE5: all registered messengers (take care: includes all messages in the inboxes) if system log level is TRACE5: all known forwards all known platforms all known services |
void |
unregisterAllServices(String agentName)
removes an agent from all service provider lists |
void |
unregisterService(Object service,
String agentName)
removes an agent from the specifed service provider list(s) |
void |
unsubscribeFromAllMessageGroups(String agentName)
Removes an agent from all message groups it is subscribed to. |
void |
unsubscribeFromMessageGroup(String groupName,
Object agentName)
Removes an agent from the specified message group. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final String SERVICE_PROVIDER_RANGE_INCREASED
protected static final String SERVICE_PROVIDER_RANGE_DECREASED
Method Detail |
public boolean isAvailable(String agentName)
agentName
- name of the agentpublic boolean addAgentToWatch(String connectedAgent)
connectedAgent
- name of the agent, which connection is awaitedpublic boolean removeAgentToWatch(String connectedAgent)
connectedAgent
- name of the agent, which shall be removedpublic boolean addMessenger(String agentName, com.ls.lars.communication.Messenger messenger)
agentName
- name of the agent to which the messenger belongmessenger
- Messenger that has to be added.public boolean removeMessenger(String agentName)
agentName
- agent name for which the messenger entry has to be removedpublic void controlInboxSize(int delimiter)
delimiter
is reached. If so, the method logs a warning into the systems log file.delimiter
- the delimiter to check againstpublic void allMessengersCloseConnection()
public boolean addForward(String agentName, String amrForward)
agentName
- name of the agent to which the messenger belongsamrForward
- address of the agent message router where the agent is currently locatedpublic boolean removeForward(String agentName)
agentName
- agent name for which the messenger entry has to be removedpublic boolean addPlatform(String platform, String ip, int port)
platform
- Name of the platform for which a entry should be addedip
- IP address of the platformport
- port number of the platformpublic boolean removePlatform(String platformName)
platformName
- name of the platform which entry has to be removed from the known platformspublic Map listPlatforms()
public void registerService(Object service, String agentName) throws ServiceException
service
- String or List containing the service(s), for that the agent wants to be registered as a
service provideragentName
- name of the service provider agentServiceException
- if service is null
or if service is neither instance of String nor instance of Collectionpublic Collection getServiceProviderMembers(String serviceName)
serviceName
- name of the servicepublic com.ls.lars.communication.Messenger getMessenger(String messengerName)
messengerName
- name of the messengerpublic void unregisterAllServices(String agentName) throws ServiceException
agentName
- Name of the agent that has to be removed from the subscriber listsServiceException
- if agentName is null or emptypublic void unregisterService(Object service, String agentName) throws ServiceException
service
- String or List of Strings specifying the services, for which the agent does not want to
be a provider any moreagentName
- Name of the agent that has to be removed from the subscriber listsServiceException
- if agentName is null or empty
or if service is null
or if service is neither instance of String nor instance of Collectionpublic Set getAllServiceProviderNames()
public void registerForServiceStatusChangedNotification(String service, String agent, String replyId)
service
- the name of the service to watchagent
- the name of the registering agentreplyId
- the id to be used when notifying the agentpublic void deregisterFromServiceStatusChangedNotification(String agent)
agent
- the name of the deregistered agentpublic Set listAllProvidedServices()
public void subscribeToMessageGroup(String groupName, Object agentNames, boolean isTransaction) throws ServiceException
groupName
- name of the group to subscribe toagentNames
- String or Collection containing a single or multiple agent namesisTransaction
- if true, the subscription of a collection of agent names to a message group is a
transaction: all of the agents are added to the group or none of them;
if false, as many agents (contained in agentNames) as possible are addedServiceException
- if groupName is null or if agentName is neither a String nor a Collectionpublic Collection getGroupMembers(String groupName)
groupName
- the name of the grouppublic void unsubscribeFromAllMessageGroups(String agentName) throws ServiceException
agentName
- name of the agent that has to be removed from the message groupServiceException
- if agentName is null or emptypublic void unsubscribeFromMessageGroup(String groupName, Object agentName) throws ServiceException
groupName
- name of the group to subscribe toagentName
- String or collection containing a single or multiple agent namesServiceException
- if groupName is null or no valid group name
or agentName is neither a String nore a Collectionpublic void removeMessageGroup(String groupName) throws ServiceException
groupName
- name of the message group that is removedServiceException
- if groupName is null or emptypublic Set getAllMessageGroupMemberNames()
public static void createMessageRouter(String theLocalIpAddress, String theHomePlatform)
theLocalIpAddress
- IP address of the local platformtheHomePlatform
- name of the local platform#getMessageRouter
public static MessageRouter getPlatformMessageRouter() throws SecurityException
SecurityException
- if the caller of this method is not allowed to get a reference to the platform's
message routerpublic void setEncapsulatingAgentName(String agentName)
agentName
- the name of the encapsulating agentpublic void routeMessage(Message message) throws UnsupportedOperationException
Failure behaviour:
QualityOfService.QOS_LARS_FAILURE
is produced, if the message is of an
unsupported type.
Programming tip: If you know the type of a message object at point of calling routeMessage, always cast the Message object yourself to avoid the determination of the type at runtime.
message
- message to be routedUnsupportedOperationException
- if message type is unsupportedpublic void routeMessage(SingleMessage message)
message
- Message to be routedpublic void routeMessage(ServiceSingleMessage message)
QualityOfService.QOS_SERVICE_NOT_REGISTERED
is produced, if the service
is known, but no service providers are registered.
QualityOfService.QOS_SERVICE_NOT_REGISTERED
is produced, if the service
is unknown.
message
- message that has to be passed to all known service providerspublic void routeMessage(ServiceBroadcastMessage message)
Failure behaviour:
QualityOfService.QOS_SERVICE_NOT_REGISTERED
is produced, if the service
is known, but no service providers are registered.
QualityOfService.QOS_SERVICE_NOT_REGISTERED
is produced, if the service
is unknown.
message
- message that has to be passed to all known service providerspublic void routeMessage(GroupMessage message)
Failure behaviour:
QualityOfService.QOS_GROUP_UNKNOWN
is produced, if the message group is
unknown.
message
- message that has to be passed to all agents of the grouppublic void routeMessage(MulticastMessage message)
message
- message that has to be passed to all agents from he list of receiverspublic static String getLocalIpAddress()
public static String getHomePlatform()
public String toString()
toString
in class Object
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |