Class Topic

    • 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.
      • friends

        protected Set<AgentId> friends
        Set of cluster elements (including itself), if any.
      • subscribers

        protected List<AgentId> subscribers
        Vector of subscribers' identifiers.
      • selectors

        protected Map<AgentId,​String> selectors
        Table of subscribers' selectors.
      • 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

      • react

        public void react​(AgentId from,
                          Notification not)
                   throws Exception
        Distributes the received notifications to the appropriate reactions.
        Overrides:
        react in class Destination
        Parameters:
        from - agent sending notification
        not - notification to react to
        Throws:
        Exception
      • initialize

        public void initialize​(boolean firstTime)
        Initializes the destination.
        Specified by:
        initialize in class Destination
        Parameters:
        firstTime - true when first called by the factory
      • finalize

        protected void finalize​(boolean last)
        Finalizes the destination before it is garbaged.
        Specified by:
        finalize in class Destination
        Parameters:
        last - true if the destination is deleted
      • 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 a ClusterJoinNot notification, 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 a ClusterJoinAck notification, doing a transitive closure with the current cluster and the one of the new cluster element.
      • clusterList

        private List<String> clusterList()
        Returns the cluster list.
        Returns:
        the cluster list.
      • 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.
      • unsubscribeRequest

        protected void unsubscribeRequest​(AgentId from)
        Method implementing the reaction to an UnsubscribeRequest instance, requesting to remove a subscriber.
      • topicForwardNot

        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.
      • 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:
        getNumberOfSubscribers in interface TopicMBean
        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:
        getSubscriberIds in interface TopicMBean
        Returns:
        the list of unique identifiers of all subscribers.
      • doRightRequest

        protected void doRightRequest​(AgentId user,
                                      int right)
        Method specifically processing a SetRightRequest instance.

        When a reader is removed, deleting this reader's subscription if any, and sending an ExceptionReply notification to the client.

        Specified by:
        doRightRequest in class Destination
        Parameters:
        user - The user about right modification.
        right - The right modification.
      • doClientMessages

        protected void doClientMessages​(AgentId from,
                                        ClientMessages not,
                                        boolean throwsExceptionOnFullDest)
        Method specifically processing a 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.

        Specified by:
        doClientMessages in class Destination
      • doClientMessages

        private void doClientMessages​(AgentId from,
                                      ClientMessages not,
                                      boolean fromCluster,
                                      boolean throwsExceptionOnFullDest)
      • doUnknownAgent

        protected void doUnknownAgent​(UnknownAgent uA)
        Method specifically processing an 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.

        Specified by:
        doUnknownAgent in class Destination
      • doDeleteNot

        protected void doDeleteNot​(DeleteNot not)
        Method specifically processing a fr.dyade.aaa.agent.DeleteNot instance.

        UnknownAgent notifications are sent to each subscriber and UnclusterNot notifications to the cluster fellows.

        Specified by:
        doDeleteNot in class Destination
      • forwardMessages

        protected void forwardMessages​(AgentId from,
                                       ClientMessages messages)
        Actually forwards a list of messages to the father or the cluster fellows, if any.
      • 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 a TopicMsgsReply notification to the valid subscribers.