Class AdminTopic

  • All Implemented Interfaces:
    AgentMBean, Encodable, Serializable, AdminTopicMBean, ClusterDestinationMBean, DestinationMBean, TopicMBean

    public final class AdminTopic
    extends Topic
    implements AdminTopicMBean
    The AdminTopic class implements the administration topic behavior, basically processing administration requests.

    It receives administration requests from the client encapsulated in JMS messages:

    • If the request concerns an user or a destination it forwards the request to the target. This target directly replies (*) to the client sending a JMS message to the replyTo destination specified in the original JMS message.
    • If the request can be processed by the administration topic, either the request concerns the local server and it is processed, or it is forwarded to the administration topic of the target server.
    (*) Currently the getRights reply is handled differently as it needs the transformation of the user list. This behavior should disappear with the role based mechanism.
    See Also:
    Serialized Form
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        define serialVersionUID for interoperability
        See Also:
        Constant Field Values
      • logger

        private static final Logger logger
      • DEBUG

        private static final boolean DEBUG
      • ref

        private static AdminTopic ref
        Reference of the server's local AdminTopic instance.
      • serverId

        private int serverId
        Identifier of the server this topic is deployed on.
      • destinationsTable

        private Map<String,​AdminTopic.DestinationDesc> destinationsTable
        Table holding the local server's destinations names. This table is used by more than one thread so it needs to be synchronized.

        Key: destination name
        Object: destination agent identifier

      • usersTable

        private Map<String,​Identity> usersTable
        Table holding the TCP users identifications.

        Key: user name
        Object: user password

      • proxiesTable

        private Map<String,​AgentId> proxiesTable
        Table holding the TCP users proxies identifiers.

        Key: user name
        Object: proxy's identifier

      • requestsTable

        private Map<String,​AgentId> requestsTable
        Table keeping the administrator's requests.

        Key: request's message identifier
        Value: request's message ReplyTo field

      • msgCounter

        private long msgCounter
        Counter of messages produced by this AdminTopic.
    • Method Detail

      • getDefault

        public static AgentId getDefault​(short serverId)
        Gets the identifier of the default administration topic on a given server.
      • getDefault

        public static final AgentId getDefault()
        Gets the identifier of the default administration topic on the current server.
      • isAdminTopicId

        public static final boolean isAdminTopicId​(AgentId id)
        Returns true if the given AgentId is the unique identifier of an AdminTopic agent.
        Parameters:
        id - the AgentId to verify.
        Returns:
        true if the given AgentId is the unique identifier of an AdminTopic agent.
      • react

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

        private AgentId getProxyId​(Identity identity,
                                   String inaddr)
                            throws Exception
        Method used by ConnectionManager proxies to check their clients identification.
        Parameters:
        identity -
        inaddr -
        Returns:
        The agent unique identifier of the authentified user.
        Throws:
        Exception - If the user does not exist, is wrongly identified, or does not have any proxy deployed.
        See Also:
        ConnectionManager
      • handleDeniedMessage

        protected void handleDeniedMessage​(String msgId,
                                           AgentId replyTo)
        Method used to send a response when a message is denied because of a lack of rights.
        Overrides:
        handleDeniedMessage in class Destination
      • handleAdminNotification

        private void handleAdminNotification​(AdminNotification adminNot)
        Method implementing the reaction to a AdminNotification notification notifying of the creation of an administrator proxy.
        Parameters:
        adminNot - the AdminNotification notification.
      • handleAdminReply

        private void handleAdminReply​(AdminReplyNot not)
        Method implementing the reaction to a org.objectweb.joram.mom.notifications.AdminReply notification replying to an administration request.

        A reply is sent back to the connected administrator if needed.

      • handleGetProxyIdNot

        private void handleGetProxyIdNot​(GetProxyIdNot not)
      • handleGetProxyIdListNot

        private void handleGetProxyIdListNot​(GetProxyIdListNot not)
      • doProcess

        private AdminReply doProcess​(GetRightsReplyNot not)
        Processes a Monit_GetUsersRep notification holding a destination's readers' or writers' identifiers.
      • preProcess

        protected ClientMessages preProcess​(AgentId from,
                                            ClientMessages msgs)
        Overrides this Destination method;
        Overrides:
        preProcess in class Destination
        Parameters:
        msgs - ClientMessages notifications hold requests sent by an administrator.
        from - The sender of the message
        Returns:
        The incoming messages after processing.
      • clusterJoinAck

        protected void clusterJoinAck​(ClusterJoinAck ack)
        Overrides this Topic method; a ClusterAck is not expected by an AdminTopic.
        Overrides:
        clusterJoinAck in class Topic
      • clusterJoin

        protected void clusterJoin​(ClusterJoinNot not)
        Overrides this Topic method; if this AdminTopic is on server0, new cluster fellow is notified to other fellows and other fellows are notified to it.
        Overrides:
        clusterJoin in class Topic
      • topicForwardNot

        protected void topicForwardNot​(AgentId from,
                                       TopicForwardNot not)
        Overrides this Topic method; the forwarded messages contain admin requests and will be processed.
        Overrides:
        topicForwardNot in class Topic
      • processAdminRequests

        private void processAdminRequests​(ClientMessages not)
        Method getting the administration requests from messages, and distributing them to the appropriate reactions.
      • processAdminRequests

        private void processAdminRequests​(AgentId replyTo,
                                          String msgId,
                                          AdminRequest request,
                                          AgentId from)
        Method getting the administration requests from messages, and distributing them to the appropriate reactions.
      • doProcess

        private void doProcess​(SetDMQRequest request,
                               AgentId replyTo,
                               String msgId)
                        throws UnknownServerException
        Processes a SetDMQ request requesting a given queue to be set as the DMQ of a given destination or user. If the AgentId of the destination is NullId set the default DMQ. If the AgentId of the DMQ is NullId unset the DMQ.
        Throws:
        UnknownServerException - If the target server does not exist.
      • doProcess

        private void doProcess​(SetThresholdRequest request,
                               AgentId replyTo,
                               String msgId)
                        throws UnknownServerException
        Processes a SetThreshold request requesting a given threshold value to be set as the threshold of a given destination or user. If the AgentId of the destination is NullId set the default threshold. If the threshold value is less than 0 reset the threshold.
        Throws:
        UnknownServerException - If the target server does not exist.
      • doProcess

        private void doProcess​(AgentId replyTo,
                               String msgId)
      • doProcess

        private void doProcess​(GetStatsRequest request,
                               AgentId replyTo,
                               String msgId)
        Processes a Monitor_GetStat request or forwards it to its target destination if needed.
      • doProcess

        private void doProcess​(GetJMXAttsRequest request,
                               AgentId replyTo,
                               String msgId)
        Processes a Monitor_GetJMXAtts request or forwards it to its target destination if needed.
      • doProcess

        private void doProcess​(DestinationAdminRequest request,
                               AgentId replyTo,
                               String msgId)
        Processes a DestinationRequest request by forwarding it to its target destination, if local.
      • doProcess

        private void doProcess​(AddDomainRequest request,
                               AgentId replyTo,
                               String msgId,
                               AgentId from)
        Adds a new domain to the configuration.
        Parameters:
        request - The request describing the domain to create.
        replyTo - The destination to reply.
        msgId - The JMS message id needed to reply.
        from - The AgentId of sender.
      • doProcess

        private void doProcess​(RemoveDomainRequest request,
                               AgentId replyTo,
                               String msgId,
                               AgentId from)
        Removes a domain in the configuration.
        Parameters:
        request - The request describing the domain to remove.
        replyTo - The destination to reply.
        msgId - The JMS message id needed to reply.
        from - The AgentId of sender.
      • doProcess

        private void doProcess​(AddServerRequest request,
                               AgentId replyTo,
                               String msgId,
                               AgentId from)
        Adds a server to the configuration.
        Parameters:
        request - The request describing the server to create.
        replyTo - The destination to reply.
        msgId - The JMS message id needed to reply.
        from - The AgentId of sender.
      • doProcess

        private void doProcess​(RemoveServerRequest request,
                               AgentId replyTo,
                               String msgId,
                               AgentId from)
        Removes a server in the configuration.
        Parameters:
        request - The request describing the server to remove.
        replyTo - The destination to reply.
        msgId - The JMS message id needed to reply.
        from - The AgentId of sender.
      • broadcastRequest

        private void broadcastRequest​(AdminRequest request,
                                      int avoidServerId,
                                      AgentId replyTo,
                                      String msgId)
        Sends the administration request to AdminTopic of all servers except the given one. This method is used to broadcast server/domain creation and deletion.
        Parameters:
        request - The administration request.
        avoidServerId - The id. of the server to avoid.
        replyTo - The destination to reply.
        msgId - The JMS message id needed to reply.
      • doProcess

        private void doProcess​(GetConfigRequest request,
                               AgentId replyTo,
                               String msgId)
        Gets the current configuration.
        Parameters:
        request -
        replyTo -
        msgId -
      • distributeReply

        private void distributeReply​(AgentId to,
                                     String msgId,
                                     AdminReply reply)
        Actually sends an AdminReply object to an identified destination.
        Parameters:
        to - Identifier of a destination to send the reply to.
        msgId - Identifier of the original request.
        reply - The AdminReply instance to send.
      • createMessageId

        private String createMessageId()
      • invokeStaticMethod

        private static Object invokeStaticMethod​(Properties prop)
                                          throws Exception
        Invokes a static method on the server using the specified properties. TODO (AF): Should be factorized in an helper class.
        Parameters:
        prop -
        Throws:
        Exception
      • checkServerId

        private boolean checkServerId​(int serverId)
                               throws UnknownServerException
        Returns true if a given server identification corresponds to the local server's.
        Parameters:
        serverId - Server identifier.
        Throws:
        UnknownServerException - If the server does not exist.
      • createUser

        public void createUser​(String user,
                               String passwd,
                               int serverId)
                        throws Exception
        Creates a new user on the selected server. SimpleIdentity class is used.
        Specified by:
        createUser in interface AdminTopicMBean
        Parameters:
        user - the user name
        passwd - the user password
        serverId - the server where the user will be created
        Throws:
        Exception
      • createUser

        public void createUser​(String user,
                               String passwd,
                               int serverId,
                               String identityClassName)
                        throws Exception
        Creates a new user on the selected server.
        Specified by:
        createUser in interface AdminTopicMBean
        Parameters:
        user - the user name
        passwd - the user password
        serverId - the server where the user will be created
        identityClassName - the identity class name to instantiate
        Throws:
        Exception
      • createQueue

        public void createQueue​(String name)
        Creates a new queue on the local server.
        Specified by:
        createQueue in interface AdminTopicMBean
        Parameters:
        name - the queue name
      • createQueue

        public void createQueue​(String name,
                                int serverId)
        Creates a new queue on the selected server. The queue will be an instance of Queue.
        Specified by:
        createQueue in interface AdminTopicMBean
        Parameters:
        name - the topic name
        serverId - the server where the queue will be deployed
      • createQueue

        public void createQueue​(String name,
                                String queueClassName,
                                int serverId)
        Creates a new queue on the selected server.
        Specified by:
        createQueue in interface AdminTopicMBean
        Parameters:
        name - the topic name
        queueClassName - the queue class to instantiate
        serverId - the server where the queue will be deployed
      • createTopic

        public void createTopic​(String name)
        Creates a new topic on the local server.
        Specified by:
        createTopic in interface AdminTopicMBean
        Parameters:
        name - the topic name
      • createTopic

        public void createTopic​(String name,
                                int serverId)
        Creates a new topic on the selected server. The topic will be an instance of Topic.
        Specified by:
        createTopic in interface AdminTopicMBean
        Parameters:
        name - the topic name
        serverId - the server where the topic will be deployed
      • createTopic

        public void createTopic​(String name,
                                String topicClassName,
                                int serverId)
        Creates a new topic on the selected server.
        Specified by:
        createTopic in interface AdminTopicMBean
        Parameters:
        name - the topic name
        topicClassName - the topic class to instantiate
        serverId - the server where the topic will be deployed
      • deleteUser

        public static void deleteUser​(String userName)
      • lookupDest

        public static AdminTopic.DestinationDesc lookupDest​(String name,
                                                            byte type)
                                                     throws RequestException
        Retrieves an existing destination.
        Parameters:
        name - The name of the destination.
        type - The type of the destination.
        Returns:
        the descriptor of the destination, null if it does not exist.
        Throws:
        RequestException - If the existing destination have a different type.
      • lookupUser

        public static AgentId lookupUser​(String name)
        Retrieves an existing user
        Parameters:
        name - The name of the user
      • registerDest

        public static void registerDest​(AgentId id,
                                        String name,
                                        byte type)
        Registers a newly created destination.
        Parameters:
        id - The unique identifier of the created destination.
        name - The name of the created destination.
        type - The type of the created destination.
      • unregisterDest

        public static void unregisterDest​(String name)
        Removes a registered destination.
        Parameters:
        name - The name of the destination to remove.
      • isDestinationTableContain

        public static boolean isDestinationTableContain​(String destName)
        Deprecated.
        is destinationTable contain destName ? (used by ScalAgent mediation)
        Parameters:
        destName - destination name.
        Returns:
        true if contain.
      • reverseLookupDest

        public static AdminTopic.DestinationDesc reverseLookupDest​(String agentId,
                                                                   byte type)
        Retrieves an existing destination.
        Parameters:
        agentId - The identifier of the destination.
        type - The type of the destination.
        Returns:
        the descriptor of the destination, null if it does not exist.