public class Topic extends Destination implements TopicMBean
Topic
class 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.
Modifier and Type | Field and Description |
---|---|
protected boolean |
alreadySentLocally
Internal boolean used for tagging local sendings.
|
protected AgentId |
fatherId
Identifier of this topic's father, if any.
|
protected Set |
friends
Set of cluster elements (including itself), if any.
|
static org.objectweb.util.monolog.api.Logger |
logger |
protected long |
nbMsgsReceiveSinceCreation |
protected Map |
selectors
Table of subscribers' selectors.
|
private static long |
serialVersionUID
define serialVersionUID for interoperability
|
protected List |
subscribers
Vector of subscribers' identifiers.
|
_rights, clients, creationDate, dmqId, freeReading, freeWriting, nbMsgsDeliverSinceCreation, nbMsgsSentToDMQSinceCreation, READ, READWRITE, strbuf, task, WAKEUP_PERIOD, WRITE
agentProfiling, emptyString, fixed, logmon
BOOLEAN_ENCODED_SIZE, BYTE_ENCODED_SIZE, DOUBLE_ENCODED_SIZE, FLOAT_ENCODED_SIZE, INT_ENCODED_SIZE, LONG_ENCODED_SIZE, SHORT_ENCODED_SIZE
Constructor and Description |
---|
Topic() |
Topic(String string,
boolean b,
int joramAdminStamp) |
Modifier and Type | Method and Description |
---|---|
private void |
clusterAdd(FwdAdminRequestNot req,
String joiningTopic)
Reaction to the request of adding a new cluster element.
|
protected void |
clusterJoin(ClusterJoinNot not)
Method implementing the reaction to a
ClusterJoinNot notification,
sent by a fellow topic for notifying this topic to join the cluster, doing
a transitive closure of clusters, if any. |
protected void |
clusterJoinAck(ClusterJoinAck not)
Method implementing the reaction to a
ClusterJoinAck notification,
doing a transitive closure with the current cluster and the one of the new
cluster element. |
private void |
clusterLeave()
Ask this topic to leave the cluster.
|
private List |
clusterList()
Returns the cluster list.
|
private void |
clusterRemove(AgentId topic)
Remove the specified topic from current cluster.
|
protected TopicForwardNot |
createTopicForward(AgentId destId,
ClientMessages messages,
boolean fromCluster) |
protected void |
doClientMessages(AgentId from,
ClientMessages not,
boolean throwsExceptionOnFullDest)
Method specifically processing a
ClientMessages instance. |
private void |
doClientMessages(AgentId from,
ClientMessages not,
boolean fromCluster,
boolean throwsExceptionOnFullDest) |
protected void |
doDeleteNot(DeleteNot not)
Method specifically processing a
fr.dyade.aaa.agent.DeleteNot
instance. |
protected void |
doRightRequest(AgentId user,
int right)
Method specifically processing a
SetRightRequest instance. |
protected void |
doUnknownAgent(UnknownAgent uA)
Method specifically processing an
UnknownAgent instance. |
protected void |
finalize(boolean lastTime)
Finalizes the destination before it is garbaged.
|
protected void |
forwardMessages(AgentId from,
ClientMessages messages)
Actually forwards a list of messages to the father or the cluster
fellows, if any.
|
protected void |
forwardMessages(AgentId from,
ClientMessages messages,
boolean fromCluster) |
String[] |
getClusterElements() |
long |
getNbMsgsReceiveSinceCreation()
Returns the number of messages received since creation time of this
destination.
|
int |
getNumberOfSubscribers()
Returns the number of subscribers.
|
protected Properties |
getStats() |
String[] |
getSubscriberIds()
Returns the list of unique identifiers of all subscribers.
|
String |
getTxName(String msgId) |
byte |
getType()
Returns the type of this destination: Queue or Topic.
|
void |
handleAdminRequestNot(AgentId from,
FwdAdminRequestNot not) |
void |
initialize(boolean firstTime)
Initializes the destination.
|
void |
postSubscribe()
Deprecated.
|
void |
postUnsubscribe()
Deprecated.
|
void |
preSubscribe()
Deprecated.
|
void |
preUnsubscribe()
Deprecated.
|
protected void |
processMessages(AgentId from,
ClientMessages not)
Actually processes the distribution of the received messages to the
valid subscriptions by sending a
TopicMsgsReply notification
to the valid subscribers. |
void |
react(AgentId from,
Notification not)
Distributes the received notifications to the appropriate reactions.
|
protected void |
sendToCluster(Notification not)
Sends a notification to all topics in cluster.
|
void |
setAlreadySentLocally(boolean alreadySentLocally) |
private void |
setDmq(TopicMsgsReply not) |
protected void |
subscribeRequest(AgentId from,
SubscribeRequest not)
Method implementing the reaction to a
SubscribeRequest
instance. |
protected void |
topicForwardNot(AgentId from,
TopicForwardNot not)
Method implementing the reaction to a
TopicForwardNot
instance, carrying messages forwarded by a cluster fellow or a
hierarchical son. |
String |
toString()
Returns a string representation of this destination.
|
protected void |
unsubscribeRequest(AgentId from)
Method implementing the reaction to an
UnsubscribeRequest
instance, requesting to remove a subscriber. |
void |
wakeUpNot(WakeUpNot not) |
agentFinalize, agentInitialize, clientMessages, decode, delete, deleteNot, encode, forward, getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQAgentId, getDMQId, getEncodedSize, getJMXStatistics, getMBeanName, getNbMsgsDeliverSinceCreation, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, getRights, handleDeniedMessage, interceptorsAvailable, isAdministrator, isFreeReading, isFreeWriting, isLocal, isReader, isValidJMXAttribute, isWriter, postProcess, preProcess, processAdminCommand, processInterceptors, processSetRight, processStartHandler, processStopHandler, replyToTopic, requestGroupNot, setAdminId, setFreeReading, setFreeWriting, setPeriod, setProperties, setRight, unknownAgent
agentSave, delete, delete, deploy, deploy, getAgentId, getCommitTime, getEncodableClassId, getId, getLogTopic, getName, getReactNb, getReactTime, hasName, isAgentProfiling, isDeployed, isFixed, isUpdated, needToBeCommited, resetCommitTime, resetReactTime, resetTimer, save, sendTo, sendTo, sendTo, setAgentProfiling, setName, setNoSave, setSave
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
delete, getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQId, getName, getNbMsgsDeliverSinceCreation, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, isFreeReading, isFreeWriting, setFreeReading, setFreeWriting, setPeriod
getAgentId, getCommitTime, getReactNb, getReactTime, isAgentProfiling, isFixed, resetCommitTime, resetReactTime, resetTimer, setAgentProfiling
public static org.objectweb.util.monolog.api.Logger logger
private static final long serialVersionUID
protected AgentId fatherId
protected Set friends
protected List subscribers
protected Map selectors
protected transient boolean alreadySentLocally
protected long nbMsgsReceiveSinceCreation
public Topic()
public Topic(String string, boolean b, int joramAdminStamp)
public final byte getType()
Destination
getType
in class Destination
DestinationConstants.TOPIC_TYPE
,
DestinationConstants.QUEUE_TYPE
public void react(AgentId from, Notification not) throws Exception
react
in class Destination
from
- agent sending notificationnot
- notification to react toException
public void initialize(boolean firstTime)
initialize
in class Destination
firstTime
- true when first called by the factoryprotected void finalize(boolean lastTime)
finalize
in class Destination
lastime
- true if the destination is deletedpublic String toString()
toString
in interface AgentMBean
toString
in interface DestinationMBean
toString
in class Agent
public void wakeUpNot(WakeUpNot not)
wakeUpNot
in class Destination
private void clusterAdd(FwdAdminRequestNot req, String joiningTopic)
protected void clusterJoin(ClusterJoinNot not)
ClusterJoinNot
notification,
sent by a fellow topic for notifying this topic to join the cluster, doing
a transitive closure of clusters, if any.protected void clusterJoinAck(ClusterJoinAck not)
ClusterJoinAck
notification,
doing a transitive closure with the current cluster and the one of the new
cluster element.private List clusterList()
public String[] getClusterElements()
getClusterElements
in interface ClusterDestinationMBean
private void clusterLeave()
private void clusterRemove(AgentId topic)
topic
- The topic which left the clusterprotected void sendToCluster(Notification not)
not
- The notification to send.public void preSubscribe()
public void postSubscribe()
protected void subscribeRequest(AgentId from, SubscribeRequest not) throws AccessException
SubscribeRequest
instance.AccessException
- If the sender is not a READER.public void preUnsubscribe()
public void postUnsubscribe()
protected void unsubscribeRequest(AgentId from)
UnsubscribeRequest
instance, requesting to remove a subscriber.protected void topicForwardNot(AgentId from, TopicForwardNot not)
TopicForwardNot
instance, carrying messages forwarded by a cluster fellow or a
hierarchical son.public void handleAdminRequestNot(AgentId from, FwdAdminRequestNot not)
public final int getNumberOfSubscribers()
getNumberOfSubscribers
in interface TopicMBean
public final String[] getSubscriberIds()
getSubscriberIds
in interface TopicMBean
protected void doRightRequest(AgentId user, int right)
SetRightRequest
instance.
When a reader is removed, deleting this reader's subscription if any,
and sending an ExceptionReply
notification to the client.
doRightRequest
in class Destination
user
- The user about right modification.right
- The right modification.protected void doClientMessages(AgentId from, ClientMessages not, boolean throwsExceptionOnFullDest)
ClientMessages
instance.
This method may forward the messages to the topic father if any, or
to the cluster fellows if any.It may finally send
TopicMsgsReply
instances to the valid subscribers.
doClientMessages
in class Destination
private void doClientMessages(AgentId from, ClientMessages not, boolean fromCluster, boolean throwsExceptionOnFullDest)
protected void doUnknownAgent(UnknownAgent uA)
UnknownAgent
instance.
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.
doUnknownAgent
in class Destination
protected void doDeleteNot(DeleteNot not)
fr.dyade.aaa.agent.DeleteNot
instance.
UnknownAgent
notifications are sent to each subscriber and
UnclusterNot
notifications to the cluster fellows.
doDeleteNot
in class Destination
protected void forwardMessages(AgentId from, ClientMessages messages)
protected TopicForwardNot createTopicForward(AgentId destId, ClientMessages messages, boolean fromCluster)
protected void forwardMessages(AgentId from, ClientMessages messages, boolean fromCluster)
protected void processMessages(AgentId from, ClientMessages not)
TopicMsgsReply
notification
to the valid subscribers.private void setDmq(TopicMsgsReply not)
public void setAlreadySentLocally(boolean alreadySentLocally)
public long getNbMsgsReceiveSinceCreation()
Destination
getNbMsgsReceiveSinceCreation
in interface DestinationMBean
getNbMsgsReceiveSinceCreation
in class Destination
protected Properties getStats()
getStats
in class Destination
Copyright © 2015 ScalAgent D.T.. All Rights Reserved.