Package jade.core.messaging
Class MessagingService
- java.lang.Object
-
- jade.core.BaseService
-
- jade.core.messaging.MessagingService
-
- All Implemented Interfaces:
jade.core.messaging.MessageManager.Channel,Service
- Direct Known Subclasses:
MomMessagingService
public class MessagingService extends BaseService implements jade.core.messaging.MessageManager.Channel
The JADE service to manage the message passing subsystem installed on the platform.- Author:
- Giovanni Rimassa - FRAMeTech s.r.l., Nicolas Lhuillier - Motorola Labs, Jerome Picault - Motorola Labs
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMessagingService.UnknownACLEncodingException-
Nested classes/interfaces inherited from interface jade.core.Service
Service.Slice, Service.SliceProxy
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTACH_PLATFORM_INFOstatic StringCACHE_SIZEstatic intCACHE_SIZE_DEFAULTprotected MapcachedSlicesstatic StringDELIVERY_TIME_MEASUREMENT_RATEstatic intDELIVERY_TIME_MEASUREMENT_RATE_DEFAULTstatic StringENABLE_MESSAGE_MANAGER_METRICSstatic StringENABLE_POSTED_MESSAGE_COUNTstatic StringMAX_DELIVERY_RETRY_ATTEMPTSDefines the maximum number of delivery attempts when an agent is found in the GADT, but not in the container it is supposed to be (see deliverUntilOK())static intMAX_DELIVERY_RETRY_ATTEMPTS_DEFAULTprotected intmaxDeliveryRetryAttemptsstatic StringMTP_IDENTIFIERprotected AgentContainermyContainerprotected ProfilemyProfilestatic StringNAMEstatic StringPLATFORM_IDENTIFIER-
Fields inherited from class jade.core.BaseService
ALL_DUMP_KEY, MAIN_SLICE, myFinder, myLogger, THIS_SLICE
-
Fields inherited from interface jade.core.Service
ADOPTED_NODE, DEAD_NODE, DEAD_PLATFORM_MANAGER, DEAD_REPLICA, DEAD_SLICE, NEW_NODE, NEW_REPLICA, NEW_SLICE, REATTACHED, RECONNECTED
-
-
Constructor Summary
Constructors Constructor Description MessagingService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidboot(Profile myProfile)Performs the active initialization step of a kernel-level service: Activates the ACL codecs and MTPs as specified in the givenProfileinstance.protected voidcheckTracing(GenericMessage msg)protected voidclearCachedSlice(String name)voiddeadAlias(AID alias)protected voiddeliverInLocalPlatfrom(GenericMessage msg, AID receiverID)voiddeliverNow(GenericMessage msg, AID receiverID)Stringdump(String key)This method can be redefined to support service internal data inspection by means of the ContainerMonitorAgent included in the misc add-on.protected ContainerIDgetAgentLocation(AID agentID)FiltergetCommandFilter(boolean direction)Access the command filter this service needs to perform its tasks.SinkgetCommandSink(boolean side)Access the command sink this service uses to handle its own vertical commands.protected Service.SlicegetFreshSlice(String name)ServiceHelpergetHelper(Agent a)This should be properly implemented by the services that have helpers.ClassgetHorizontalInterface()Retrieve the interface through which the different service slices will communicate, that is, the service Horizontal Interface.Service.SlicegetLocalSlice()Retrieve the locally installed slice of this service.StringgetMessageManagerGlobalInfo()String[]getMessageManagerQueueStatus()Thread[]getMessageManagerThreadPool()String[]getMessageManagerThreadPoolStatus()StringgetName()Retrieve the name of this service, that can be used to look up its slices in the Service Finder.String[]getOwnedCommands()Access the names of the vertical commands this service wants to handle as their final destination.voidinit(AgentContainer ac, Profile p)Performs the passive initialization step of the service.voidnewAlias(AID alias, AID agent)voidnotifyFailureToSender(GenericMessage msg, AID receiver, InternalError ie)This method is used internally by the platform in order to notify the sender of a message that a failure was reported by the Message Transport Service.voidremoveGlobalAliases(AID agent)voidshutdown()Performs the shutdown step of a kernel-level service.-
Methods inherited from class jade.core.BaseService
addAlias, broadcast, createInvokator, getAllSlices, getAMSBehaviour, getIMTPManager, getLocalNode, getNumberOfSlices, getSlice, isLocal, lookupAlias, stringifySlice, submit
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
CACHE_SIZE
public static final String CACHE_SIZE
- See Also:
- Constant Field Values
-
CACHE_SIZE_DEFAULT
public static final int CACHE_SIZE_DEFAULT
- See Also:
- Constant Field Values
-
ATTACH_PLATFORM_INFO
public static final String ATTACH_PLATFORM_INFO
- See Also:
- Constant Field Values
-
PLATFORM_IDENTIFIER
public static final String PLATFORM_IDENTIFIER
- See Also:
- Constant Field Values
-
MTP_IDENTIFIER
public static final String MTP_IDENTIFIER
- See Also:
- Constant Field Values
-
MAX_DELIVERY_RETRY_ATTEMPTS
public static final String MAX_DELIVERY_RETRY_ATTEMPTS
Defines the maximum number of delivery attempts when an agent is found in the GADT, but not in the container it is supposed to be (see deliverUntilOK())- See Also:
- Constant Field Values
-
MAX_DELIVERY_RETRY_ATTEMPTS_DEFAULT
public static final int MAX_DELIVERY_RETRY_ATTEMPTS_DEFAULT
- See Also:
- Constant Field Values
-
DELIVERY_TIME_MEASUREMENT_RATE
public static final String DELIVERY_TIME_MEASUREMENT_RATE
- See Also:
- Constant Field Values
-
DELIVERY_TIME_MEASUREMENT_RATE_DEFAULT
public static final int DELIVERY_TIME_MEASUREMENT_RATE_DEFAULT
- See Also:
- Constant Field Values
-
ENABLE_POSTED_MESSAGE_COUNT
public static final String ENABLE_POSTED_MESSAGE_COUNT
- See Also:
- Constant Field Values
-
ENABLE_MESSAGE_MANAGER_METRICS
public static final String ENABLE_MESSAGE_MANAGER_METRICS
- See Also:
- Constant Field Values
-
myProfile
protected Profile myProfile
-
myContainer
protected AgentContainer myContainer
-
cachedSlices
protected Map cachedSlices
-
maxDeliveryRetryAttempts
protected int maxDeliveryRetryAttempts
-
-
Method Detail
-
init
public void init(AgentContainer ac, Profile p) throws ProfileException
Performs the passive initialization step of the service. This method is called before activating the service. Its role should be simply the one of a constructor, setting up the internal data as needed. Service implementations should not use the Service Manager and Service Finder facilities from within this method. A distributed initialization protocol, if needed, should be exectuted within theboot()method.- Specified by:
initin interfaceService- Overrides:
initin classBaseService- Parameters:
ac- The agent container this service is activated on.p- The configuration profile for this service.- Throws:
ProfileException- If the given profile is not valid.
-
boot
public void boot(Profile myProfile) throws ServiceException
Performs the active initialization step of a kernel-level service: Activates the ACL codecs and MTPs as specified in the givenProfileinstance.- Specified by:
bootin interfaceService- Overrides:
bootin classBaseService- Parameters:
myProfile- TheProfileinstance containing the list of ACL codecs and MTPs to activate on this node.- Throws:
ServiceException- If a problem occurs during service initialization.
-
shutdown
public void shutdown()
Description copied from interface:ServicePerforms the shutdown step of a kernel-level service. The JADE kernel calls this method just before uninstalling this service- Specified by:
shutdownin interfaceService- Overrides:
shutdownin classBaseService
-
getName
public String getName()
Retrieve the name of this service, that can be used to look up its slices in the Service Finder.- Specified by:
getNamein interfaceService- Returns:
- The name of this service.
- See Also:
ServiceFinder
-
getHorizontalInterface
public Class getHorizontalInterface()
Retrieve the interface through which the different service slices will communicate, that is, the service Horizontal Interface.- Specified by:
getHorizontalInterfacein interfaceService- Overrides:
getHorizontalInterfacein classBaseService- Returns:
- A
Classobject, representing the interface that is implemented by the slices of this service.
-
getHelper
public ServiceHelper getHelper(Agent a) throws ServiceException
Description copied from class:BaseServiceThis should be properly implemented by the services that have helpers.- Specified by:
getHelperin interfaceService- Overrides:
getHelperin classBaseService- Parameters:
a- The agent which the helper is requested for.- Returns:
- The ServiceHelper to be used by the agent.
- Throws:
ServiceException- See Also:
AgentToolkit.getHelper(jade.core.Agent, java.lang.String),Agent.getHelper(java.lang.String)
-
deadAlias
public void deadAlias(AID alias)
-
removeGlobalAliases
public void removeGlobalAliases(AID agent)
-
getLocalSlice
public Service.Slice getLocalSlice()
Retrieve the locally installed slice of this service.- Specified by:
getLocalSlicein interfaceService- Overrides:
getLocalSlicein classBaseService- Returns:
- The slice of this service that resides on the local
platform node, or
nullif no such slice exists.
-
getCommandFilter
public Filter getCommandFilter(boolean direction)
Access the command filter this service needs to perform its tasks. This filter will be installed within the local command processing engine.- Specified by:
getCommandFilterin interfaceService- Overrides:
getCommandFilterin classBaseService- Parameters:
direction- One of the two constantsFilter.INCOMINGandFilter.OUTGOING, distinguishing between the two filter chains managed by the command processor.- Returns:
- A
Filterobject, used by this service to intercept and process kernel-level commands. - See Also:
CommandProcessor
-
getCommandSink
public Sink getCommandSink(boolean side)
Access the command sink this service uses to handle its own vertical commands.- Specified by:
getCommandSinkin interfaceService- Overrides:
getCommandSinkin classBaseService- Parameters:
side- One of the two constantsSink.COMMAND_SOURCEorSink.COMMAND_TARGET, to state whether this sink will handle locally issued commands or commands incoming from remote nodes.- Returns:
- Concrete services must return their own implementation
of the
Sinkinterface, that will be invoked by the kernel in order to consume any incoming vertical command owned by this service. If the service does not wish to install a command sink, it can just returnnull. - See Also:
Service.getOwnedCommands()
-
getOwnedCommands
public String[] getOwnedCommands()
Access the names of the vertical commands this service wants to handle as their final destination. This set must not overlap with the owned commands set of any previously installed service, or an exception will be raised and service activation will fail.- Specified by:
getOwnedCommandsin interfaceService- Overrides:
getOwnedCommandsin classBaseService- Returns:
- An array containing the names of all the vertical
commands this service wants to own. If this service has no such
commands (it acts purely as a command filter), it can return an
empty array, or
nullas well. - See Also:
jade.core.Service#getCommandSink()
-
getAgentLocation
protected ContainerID getAgentLocation(AID agentID) throws IMTPException, NotFoundException
- Throws:
IMTPExceptionNotFoundException
-
deliverNow
public void deliverNow(GenericMessage msg, AID receiverID)
- Specified by:
deliverNowin interfacejade.core.messaging.MessageManager.Channel
-
deliverInLocalPlatfrom
protected void deliverInLocalPlatfrom(GenericMessage msg, AID receiverID) throws IMTPException, ServiceException, NotFoundException, JADESecurityException
-
notifyFailureToSender
public void notifyFailureToSender(GenericMessage msg, AID receiver, InternalError ie)
This method is used internally by the platform in order to notify the sender of a message that a failure was reported by the Message Transport Service.- Specified by:
notifyFailureToSenderin interfacejade.core.messaging.MessageManager.Channel
-
getFreshSlice
protected Service.Slice getFreshSlice(String name) throws ServiceException
- Overrides:
getFreshSlicein classBaseService- Throws:
ServiceException
-
checkTracing
protected void checkTracing(GenericMessage msg)
-
getMessageManagerQueueStatus
public String[] getMessageManagerQueueStatus()
-
getMessageManagerThreadPoolStatus
public String[] getMessageManagerThreadPoolStatus()
-
getMessageManagerGlobalInfo
public String getMessageManagerGlobalInfo()
-
getMessageManagerThreadPool
public Thread[] getMessageManagerThreadPool()
-
clearCachedSlice
protected void clearCachedSlice(String name)
- Overrides:
clearCachedSlicein classBaseService
-
dump
public String dump(String key)
Description copied from class:BaseServiceThis method can be redefined to support service internal data inspection by means of the ContainerMonitorAgent included in the misc add-on. The default implementation just dumps the map of cached slices- Overrides:
dumpin classBaseService- Parameters:
key- A hint indicating which service data should be dumped- Returns:
- A string representation of the service internal data
-
-