Class Topic
- java.lang.Object
-
- fr.dyade.aaa.agent.Agent
-
- org.objectweb.joram.mom.dest.Destination
-
- org.objectweb.joram.mom.dest.Topic
-
- All Implemented Interfaces:
AgentMBean,Encodable,Serializable,ClusterDestinationMBean,DestinationMBean,TopicMBean
- Direct Known Subclasses:
AcquisitionTopic,AdminTopic,DistributionTopic,ElasticTopic
public class Topic extends Destination implements TopicMBean
TheTopicclass implements the MOM topic behavior, basically distributing the received messages to subscribers.A Topic might be part of a hierarchy; if it is the case, and if the topic is not on top of that hierarchy, it will have a father to forward messages to.
A topic might also be part of a cluster; if it is the case, it will have friends to forward messages to.
A topic can be part of a hierarchy and of a cluster at the same time.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static booleanDEBUGprotected AgentIdfatherIdIdentifier of this topic's father, if any.protected Set<AgentId>friendsSet of cluster elements (including itself), if any.private static Loggerloggerprotected longnbMsgsReceiveSinceCreationprotected Map<AgentId,String>selectorsTable of subscribers' selectors.private static longserialVersionUIDdefine serialVersionUID for interoperabilityprotected List<AgentId>subscribersVector of subscribers' identifiers.-
Fields inherited from class org.objectweb.joram.mom.dest.Destination
clients, dmqId, freeReading, freeWriting, nbMsgsDeliverSinceCreation, nbMsgsSentToDMQSinceCreation, READ, READWRITE, strbuf, strictCounters, task, temporary, WRITE
-
Fields inherited from class fr.dyade.aaa.agent.Agent
agentProfiling, emptyString, fixed, logmon
-
Fields inherited from interface fr.dyade.aaa.common.encoding.Encodable
BOOLEAN_ENCODED_SIZE, BYTE_ENCODED_SIZE, DOUBLE_ENCODED_SIZE, FLOAT_ENCODED_SIZE, INT_ENCODED_SIZE, LONG_ENCODED_SIZE, SHORT_ENCODED_SIZE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidclusterAdd(FwdAdminRequestNot req, String joiningTopic)Reaction to the request of adding a new cluster element.protected voidclusterJoin(ClusterJoinNot not)Method implementing the reaction to aClusterJoinNotnotification, sent by a fellow topic for notifying this topic to join the cluster, doing a transitive closure of clusters, if any.protected voidclusterJoinAck(ClusterJoinAck not)Method implementing the reaction to aClusterJoinAcknotification, doing a transitive closure with the current cluster and the one of the new cluster element.private voidclusterLeave()Ask this topic to leave the cluster.private List<String>clusterList()Returns the cluster list.private voidclusterRemove(AgentId topic)Remove the specified topic from current cluster.protected TopicForwardNotcreateTopicForward(AgentId destId, ClientMessages messages, boolean fromCluster)protected voiddoClientMessages(AgentId from, ClientMessages not, boolean throwsExceptionOnFullDest)Method specifically processing aClientMessagesinstance.private voiddoClientMessages(AgentId from, ClientMessages not, boolean fromCluster, boolean throwsExceptionOnFullDest)protected voiddoDeleteNot(DeleteNot not)Method specifically processing afr.dyade.aaa.agent.DeleteNotinstance.protected voiddoRightRequest(AgentId user, int right)Method specifically processing aSetRightRequestinstance.protected voiddoUnknownAgent(UnknownAgent uA)Method specifically processing anUnknownAgentinstance.protected voidfinalize(boolean last)Finalizes the destination before it is garbaged.protected voidforwardMessages(AgentId from, ClientMessages messages)Actually forwards a list of messages to the father or the cluster fellows, if any.protected voidforwardMessages(AgentId from, ClientMessages messages, boolean fromCluster)String[]getClusterElements()longgetNbMsgsReceiveSinceCreation()Returns the number of messages received since creation time of this destination.intgetNumberOfSubscribers()Returns the number of subscribers.protected PropertiesgetStats()String[]getSubscriberIds()Returns the list of unique identifiers of all subscribers.bytegetType()Returns the type of this destination: Queue or Topic.voidhandleAdminRequestNot(AgentId from, FwdAdminRequestNot not)voidinitialize(boolean firstTime)Initializes the destination.protected voidprocessMessages(AgentId from, ClientMessages not)Actually processes the distribution of the received messages to the valid subscriptions by sending aTopicMsgsReplynotification to the valid subscribers.voidreact(AgentId from, Notification not)Distributes the received notifications to the appropriate reactions.protected voidsendToCluster(Notification not)Sends a notification to all topics in cluster.private voidsetDmq(TopicMsgsReply not)protected voidsubscribeRequest(AgentId from, SubscribeRequest not)Method implementing the reaction to aSubscribeRequestinstance.protected voidtopicForwardNot(AgentId from, TopicForwardNot not)Method implementing the reaction to aTopicForwardNotinstance, carrying messages forwarded by a cluster fellow or a hierarchical son.StringtoString()Returns a string representation of this destination.protected voidunsubscribeRequest(AgentId from)Method implementing the reaction to anUnsubscribeRequestinstance, requesting to remove a subscriber.voidwakeUpNot(WakeUpNot not)-
Methods inherited from class org.objectweb.joram.mom.dest.Destination
agentFinalize, agentInitialize, clientMessages, decode, delete, deleteNot, encode, forward, getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQAgentId, getDMQId, getEncodedSize, getJMXStatistics, getNbMsgsDeliverSinceCreation, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, getRights, handleDeniedMessage, interceptorsAvailable, isAdministrator, isFreeReading, isFreeWriting, isLocal, isReader, isValidJMXAttribute, isWriter, postProcess, preProcess, processAdminCommand, processInterceptors, processPause, processSetRight, processStartHandler, processStopHandler, replyToTopic, requestGroupNot, setAdminId, setFreeReading, setFreeWriting, setPeriod, setProperties, setRight, unknownAgent
-
Methods inherited from class fr.dyade.aaa.agent.Agent
agentSave, delete, delete, deploy, deploy, doAdminSyncNotification, getAgentId, getCommitTime, getEncodableClassId, getId, getLogTopic, getName, getReactNb, getReactTime, hasName, incWorkInProgress, isAgentProfiling, isDeployed, isFixed, isUpdated, load, needToBeCommited, resetCommitTime, resetReactTime, resetTimer, save, sendTo, sendTo, sendTo, setAgentProfiling, setName, setNoSave, setSave
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface fr.dyade.aaa.agent.AgentMBean
getAgentId, getCommitTime, getReactNb, getReactTime, isAgentProfiling, isFixed, resetCommitTime, resetReactTime, resetTimer, setAgentProfiling
-
Methods inherited from interface org.objectweb.joram.mom.dest.DestinationMBean
delete, getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQId, getName, getNbMsgsDeliverSinceCreation, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, isFreeReading, isFreeWriting, setFreeReading, setFreeWriting, setPeriod
-
-
-
-
Field Detail
-
logger
private static final Logger logger
-
DEBUG
private static final boolean DEBUG
-
serialVersionUID
private static final long serialVersionUID
define serialVersionUID for interoperability- See Also:
- Constant Field Values
-
fatherId
protected AgentId fatherId
Identifier of this topic's father, if any.
-
nbMsgsReceiveSinceCreation
protected long nbMsgsReceiveSinceCreation
-
-
Constructor Detail
-
Topic
public Topic()
Creates a Topic agent.
-
Topic
public Topic(String name, boolean fixed, int stamp)
Creates a Topic agent with specific stamp.- Parameters:
name- Name of topic;fixed- If true, topic is fixed in memory.stamp- Specific stamp for resulting agent.
-
-
Method Detail
-
getType
public final byte getType()
Description copied from class:DestinationReturns the type of this destination: Queue or Topic.- Specified by:
getTypein interfaceDestinationMBean- Specified by:
getTypein classDestination- Returns:
- the type of this destination.
- See Also:
DestinationConstants.TOPIC_TYPE,DestinationConstants.QUEUE_TYPE,DestinationConstants.TEMPORARY
-
react
public void react(AgentId from, Notification not) throws Exception
Distributes the received notifications to the appropriate reactions.- Overrides:
reactin classDestination- Parameters:
from- agent sending notificationnot- notification to react to- Throws:
Exception
-
initialize
public void initialize(boolean firstTime)
Initializes the destination.- Specified by:
initializein classDestination- Parameters:
firstTime- true when first called by the factory
-
finalize
protected void finalize(boolean last)
Finalizes the destination before it is garbaged.- Specified by:
finalizein classDestination- Parameters:
last- true if the destination is deleted
-
toString
public String toString()
Returns a string representation of this destination.- Specified by:
toStringin interfaceAgentMBean- Specified by:
toStringin interfaceDestinationMBean- Overrides:
toStringin classAgent- Returns:
- A string representation of this agent.
-
wakeUpNot
public void wakeUpNot(WakeUpNot not)
- Specified by:
wakeUpNotin classDestination
-
clusterAdd
private void clusterAdd(FwdAdminRequestNot req, String joiningTopic)
Reaction to the request of adding a new cluster element.
-
clusterJoin
protected void clusterJoin(ClusterJoinNot not)
Method implementing the reaction to aClusterJoinNotnotification, sent by a fellow topic for notifying this topic to join the cluster, doing a transitive closure of clusters, if any.
-
clusterJoinAck
protected void clusterJoinAck(ClusterJoinAck not)
Method implementing the reaction to aClusterJoinAcknotification, doing a transitive closure with the current cluster and the one of the new cluster element.
-
getClusterElements
public String[] getClusterElements()
- Specified by:
getClusterElementsin interfaceClusterDestinationMBean- Returns:
- an array containing the ids of the cluster elements.
-
clusterLeave
private void clusterLeave()
Ask this topic to leave the cluster.
-
clusterRemove
private void clusterRemove(AgentId topic)
Remove the specified topic from current cluster.- Parameters:
topic- The topic which left the cluster
-
sendToCluster
protected void sendToCluster(Notification not)
Sends a notification to all topics in cluster.- Parameters:
not- The notification to send.
-
subscribeRequest
protected void subscribeRequest(AgentId from, SubscribeRequest not) throws AccessException
Method implementing the reaction to aSubscribeRequestinstance.- Throws:
AccessException- If the sender is not a READER.
-
unsubscribeRequest
protected void unsubscribeRequest(AgentId from)
Method implementing the reaction to anUnsubscribeRequestinstance, requesting to remove a subscriber.
-
topicForwardNot
protected void topicForwardNot(AgentId from, TopicForwardNot not)
Method implementing the reaction to aTopicForwardNotinstance, carrying messages forwarded by a cluster fellow or a hierarchical son.
-
handleAdminRequestNot
public void handleAdminRequestNot(AgentId from, FwdAdminRequestNot not)
-
getNumberOfSubscribers
public final int getNumberOfSubscribers()
Returns the number of subscribers. Each user appears once even if there is multiples subscriptions, the different subscriptions can be enumerate through the proxy MBean.- Specified by:
getNumberOfSubscribersin interfaceTopicMBean- Returns:
- the number of subscribers.
-
getSubscriberIds
public final String[] getSubscriberIds()
Returns the list of unique identifiers of all subscribers. Each user appears once even if there is multiples subscriptions, the different subscriptions can be enumerate through the proxy MBean.- Specified by:
getSubscriberIdsin interfaceTopicMBean- Returns:
- the list of unique identifiers of all subscribers.
-
doRightRequest
protected void doRightRequest(AgentId user, int right)
Method specifically processing aSetRightRequestinstance.When a reader is removed, deleting this reader's subscription if any, and sending an
ExceptionReplynotification to the client.- Specified by:
doRightRequestin classDestination- Parameters:
user- The user about right modification.right- The right modification.
-
doClientMessages
protected void doClientMessages(AgentId from, ClientMessages not, boolean throwsExceptionOnFullDest)
Method specifically processing aClientMessagesinstance.This method may forward the messages to the topic father if any, or to the cluster fellows if any.It may finally send
TopicMsgsReplyinstances to the valid subscribers.- Specified by:
doClientMessagesin classDestination
-
doClientMessages
private void doClientMessages(AgentId from, ClientMessages not, boolean fromCluster, boolean throwsExceptionOnFullDest)
-
doUnknownAgent
protected void doUnknownAgent(UnknownAgent uA)
Method specifically processing anUnknownAgentinstance.This method notifies the administrator of the failing cluster or hierarchy building request, if needed, or removes the subscriptions of the deleted client, if any, or sets the father identifier to null if it comes from a deleted father.
- Specified by:
doUnknownAgentin classDestination
-
doDeleteNot
protected void doDeleteNot(DeleteNot not)
Method specifically processing afr.dyade.aaa.agent.DeleteNotinstance.UnknownAgentnotifications are sent to each subscriber andUnclusterNotnotifications to the cluster fellows.- Specified by:
doDeleteNotin classDestination
-
forwardMessages
protected void forwardMessages(AgentId from, ClientMessages messages)
Actually forwards a list of messages to the father or the cluster fellows, if any.
-
createTopicForward
protected TopicForwardNot createTopicForward(AgentId destId, ClientMessages messages, boolean fromCluster)
-
forwardMessages
protected void forwardMessages(AgentId from, ClientMessages messages, boolean fromCluster)
-
processMessages
protected void processMessages(AgentId from, ClientMessages not)
Actually processes the distribution of the received messages to the valid subscriptions by sending aTopicMsgsReplynotification to the valid subscribers.
-
setDmq
private void setDmq(TopicMsgsReply not)
-
getNbMsgsReceiveSinceCreation
public long getNbMsgsReceiveSinceCreation()
Description copied from class:DestinationReturns the number of messages received since creation time of this destination.- Specified by:
getNbMsgsReceiveSinceCreationin interfaceDestinationMBean- Specified by:
getNbMsgsReceiveSinceCreationin classDestination- Returns:
- the number of messages received since creation time.
-
getStats
protected Properties getStats()
- Specified by:
getStatsin classDestination
-
-