Class AdminWrapper

  • All Implemented Interfaces:
    AdminItf

    public class AdminWrapper
    extends Object
    implements AdminItf
    The AdminWrapper class allows to set an administrator connection to a given JORAM server, and provides administration and monitoring methods at a server/platform level.
    • Field Detail

      • server

        private Server server
        The description of the server the module is connected to.
      • requestor

        private AdminRequestor requestor
        The requestor for sending the synchronous requests.
      • logger

        public static org.objectweb.util.monolog.api.Logger logger
    • Method Detail

      • setTimeOutToAbortRequest

        public final void setTimeOutToAbortRequest​(long timeOut)
                                            throws ConnectException
        Set the maximum time in ms before aborting request.
        Specified by:
        setTimeOutToAbortRequest in interface AdminItf
        Parameters:
        timeOut - the maximum time in ms before aborting request.
        Throws:
        ConnectException - if the connection is not established.
      • getTimeOutToAbortRequest

        public final long getTimeOutToAbortRequest()
                                            throws ConnectException
        Returns the maximum time in ms before aborting request.
        Specified by:
        getTimeOutToAbortRequest in interface AdminItf
        Returns:
        the maximum time in ms before aborting request.
        Throws:
        ConnectException - if the connection is not established.
      • close

        public void close()
        Closes the underlying requestor.
        Specified by:
        close in interface AdminItf
      • isClosed

        public boolean isClosed()
        Returns true if the underlying requestor is closed.
        Specified by:
        isClosed in interface AdminItf
        Returns:
        true if the underlying requestor is closed.
      • stopServer

        public final void stopServer​(int serverId)
                              throws ConnectException,
                                     AdminException
        Stops a given server of the platform.

        The request fails if the target server does not belong to the platform.

        Specified by:
        stopServer in interface AdminItf
        Parameters:
        serverId - Identifier of the server to stop.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • addServer

        public final void addServer​(int sid,
                                    String host,
                                    String domain,
                                    int port,
                                    String server,
                                    String[] services,
                                    String[] args)
                             throws ConnectException,
                                    AdminException
        Adds a server to the platform.
        Specified by:
        addServer in interface AdminItf
        Parameters:
        sid - Id of the added server
        host - Address of the host where the added server is started
        domain - Name of the domain where the server is added
        port - Listening port of the server in the specified domain
        server - Name of the added server
        services - Names of the service to start within the server
        args - Services' arguments
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • addDomain

        public final void addDomain​(String domain,
                                    int sid,
                                    int port)
                             throws ConnectException,
                                    AdminException
        Adds a domain to the platform.

        The domain will use the default network component "SimpleNetwork".

        Specified by:
        addDomain in interface AdminItf
        Parameters:
        domain - Name of the added domain.
        sid - Id of the router server that gives access to the added domain.
        port - Listening port in the added domain of the router server.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • addDomain

        public final void addDomain​(String domain,
                                    String network,
                                    int sid,
                                    int port)
                             throws ConnectException,
                                    AdminException
        Adds a domain to the platform using a specific network component.
        Specified by:
        addDomain in interface AdminItf
        Parameters:
        domain - Name of the added domain.
        network - Classname of the network component to use.
        sid - Id of the router server that gives access to the added domain.
        port - Listening port in the added domain of the router server.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • getStatistics

        public final Hashtable getStatistics​(int serverId)
                                      throws ConnectException,
                                             AdminException
        Returns statistics for the specified server.

        The request fails if the target server does not belong to the platform.

        Specified by:
        getStatistics in interface AdminItf
        Parameters:
        serverId - Unique identifier of the server.
        Returns:
        the statistics for the the specified server.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • getJMXAttribute

        public final Hashtable getJMXAttribute​(int serverId,
                                               String attname)
                                        throws ConnectException,
                                               AdminException
        Returns JMX attribute value for the specified server.

        The request fails if the target server does not belong to the platform.

        Specified by:
        getJMXAttribute in interface AdminItf
        Parameters:
        serverId - Unique identifier of the server.
        Returns:
        the statistics for the the specified server.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • getDefaultDMQId

        public final String getDefaultDMQId​(int serverId)
                                     throws ConnectException,
                                            AdminException
        Returns the unique identifier of the default dead message queue for a given server, null if not set.

        The request fails if the target server does not belong to the platform.

        Specified by:
        getDefaultDMQId in interface AdminItf
        Parameters:
        serverId - Unique identifier of the server.
        Returns:
        The unique identifier of the default dead message queue for the local server, null if not set.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • setDefaultDMQId

        public final void setDefaultDMQId​(int serverId,
                                          String dmqId)
                                   throws ConnectException,
                                          AdminException
        Sets a given dead message queue as the default DMQ for a given server (null for unsetting previous DMQ).

        The request fails if the target server does not belong to the platform.

        Specified by:
        setDefaultDMQId in interface AdminItf
        Parameters:
        serverId - The identifier of the server.
        dmqId - The dmqId (AgentId) to be set as the default one.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • getDefaultDMQ

        public final Queue getDefaultDMQ​(int serverId)
                                  throws ConnectException,
                                         AdminException
        Returns the default dead message queue for a given server, null if not set.

        The request fails if the target server does not belong to the platform.

        Specified by:
        getDefaultDMQ in interface AdminItf
        Parameters:
        serverId - Unique identifier of the server.
        Returns:
        The default dead message queue for the local server, null if not set.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • setDefaultDMQ

        public final void setDefaultDMQ​(int serverId,
                                        Queue dmq)
                                 throws ConnectException,
                                        AdminException
        Sets a given dead message queue as the default DMQ for a given server (null for unsetting previous DMQ).

        The request fails if the target server does not belong to the platform.

        Specified by:
        setDefaultDMQ in interface AdminItf
        Parameters:
        serverId - The identifier of the server.
        dmq - The dmq to be set as the default one.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • getDefaultThreshold

        public final int getDefaultThreshold​(int serverId)
                                      throws ConnectException,
                                             AdminException
        Returns the default threshold value for a given server, -1 if not set.

        The request fails if the target server does not belong to the platform.

        Specified by:
        getDefaultThreshold in interface AdminItf
        Returns:
        The default threshold value for the local server, -1 if not set.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • setDefaultThreshold

        public final void setDefaultThreshold​(int serverId,
                                              int threshold)
                                       throws ConnectException,
                                              AdminException
        Sets a given value as the default threshold for a given server (-1 for unsetting previous value).

        The request fails if the target server does not belong to the platform.

        Specified by:
        setDefaultThreshold in interface AdminItf
        Parameters:
        serverId - The identifier of the server.
        threshold - The threshold value to be set.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • getServersIds

        public final int[] getServersIds​(String domain)
                                  throws ConnectException,
                                         AdminException
        Returns the list of the servers' identifiers that belong to the specified domain
        Specified by:
        getServersIds in interface AdminItf
        Parameters:
        domain - Name of the domain.
        Returns:
        An array containing the list of server's identifiers of the specified domain.
        Throws:
        ConnectException - If the connection fails.
        AdminException - Never thrown.
      • getDestinations

        public final Destination[] getDestinations​(int serverId)
                                            throws ConnectException,
                                                   AdminException
        Returns the list of all destinations that exist on a given server.

        The request fails if the target server does not belong to the platform.

        Specified by:
        getDestinations in interface AdminItf
        Parameters:
        serverId - Unique identifier of the server.
        Returns:
        An array containing all destinations defined on the given server or null if none exists.
        Throws:
        ConnectException - If the admin connection is closed or broken.
        AdminException - If the request fails.
      • createQueue

        public Destination createQueue​(int serverId,
                                       String name,
                                       String className,
                                       Properties prop)
                                throws ConnectException,
                                       AdminException
        Creates or retrieves a queue destination on a given JORAM server.

        First a destination with the specified name is searched on the given server, if it does not exist it is created.

        The request fails if the target server does not belong to the platform, or if the destination deployment fails server side.

        Specified by:
        createQueue in interface AdminItf
        Parameters:
        serverId - The identifier of the server where deploying the queue.
        name - The name of the queue.
        className - The queue class name.
        prop - The queue properties.
        Throws:
        ConnectException - If the admin connection is closed or broken.
        AdminException - If the request fails.
      • createTopic

        public Destination createTopic​(int serverId,
                                       String name,
                                       String className,
                                       Properties prop)
                                throws ConnectException,
                                       AdminException
        Creates or retrieves a topic destination on a given JORAM server.

        First a destination with the specified name is searched on the given server, if it does not exist it is created.

        The request fails if the target server does not belong to the platform, or if the destination deployment fails server side.

        Specified by:
        createTopic in interface AdminItf
        Parameters:
        serverId - The identifier of the server where deploying the topic.
        name - The name of the topic.
        className - The topic class name.
        prop - The topic properties.
        Throws:
        ConnectException - If the admin connection is closed or broken.
        AdminException - If the request fails.
      • createDeadMQueue

        public Queue createDeadMQueue​(int serverId,
                                      String name)
                               throws ConnectException,
                                      AdminException
        Deprecated.
        No longer needed, any queue can be used as DMQ.
        Creates or retrieves a DeadMessageQueue destination on a given JORAM server.

        First a destination with the specified name is searched on the given server, if it does not exist it is created.

        The request fails if the target server does not belong to the platform, or if the destination deployment fails server side.

        Parameters:
        serverId - The identifier of the server where deploying the topic.
        name - The name of the queue.
        Throws:
        ConnectException - If the admin connection is closed or broken.
        AdminException - If the request fails.
      • getUsers

        public final User[] getUsers​(int serverId)
                              throws ConnectException,
                                     AdminException
        Returns the list of all users that exist on a given server.

        The request fails if the target server does not belong to the platform.

        Specified by:
        getUsers in interface AdminItf
        Parameters:
        serverId - Unique identifier of the given server.
        Returns:
        An array containing all users defined on the local server, or null if none exist.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • createUser

        public User createUser​(String name,
                               String password,
                               int serverId,
                               String identityClassName)
                        throws ConnectException,
                               AdminException
        Admin method creating a user for a given server and instantiating the corresponding User object.

        If the user has already been set on this server, the method simply returns the corresponding User object. Its fails if the target server does not belong to the platform, or if a proxy could not be deployed server side for a new user.

        Specified by:
        createUser in interface AdminItf
        Parameters:
        name - Name of the user.
        password - Password of the user.
        serverId - The identifier of the user's server.
        identityClassName - By default user/password for SimpleIdentity.
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • createUser

        public User createUser​(String name,
                               String password,
                               int serverId,
                               String identityClassName,
                               Properties prop)
                        throws ConnectException,
                               AdminException
        Admin method creating a user for a given server and instantiating the corresponding User object.

        If the user has already been set on this server, the method simply returns the corresponding User object. Its fails if the target server does not belong to the platform, or if a proxy could not be deployed server side for a new user.

        Specified by:
        createUser in interface AdminItf
        Parameters:
        name - Name of the user.
        password - Password of the user.
        serverId - The identifier of the user's server.
        identityClassName - By default user/password for SimpleIdentity.
        prop - properties
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the request fails.
      • createIdentity

        private org.objectweb.joram.shared.security.Identity createIdentity​(String user,
                                                                            String passwd,
                                                                            String identityClassName)
                                                                     throws AdminException
        Create a user Identity.
        Parameters:
        user - Name of the user.
        passwd - Password of the user.
        identityClassName - identity class name (simple, jaas).
        Returns:
        identity user Identity.
        Throws:
        AdminException
      • doRequest

        public org.objectweb.joram.shared.admin.AdminReply doRequest​(org.objectweb.joram.shared.admin.AdminRequest request)
                                                              throws AdminException,
                                                                     ConnectException
        Method actually sending an AdminRequest instance to the platform and getting an AdminReply instance.
        Specified by:
        doRequest in interface AdminItf
        Parameters:
        request - the administration request to send
        Returns:
        the reply message
        Throws:
        ConnectException - If the connection to the platform fails.
        AdminException - If the platform's reply is invalid, or if the request failed.
      • invokeStaticServerMethod

        public String invokeStaticServerMethod​(int serverId,
                                               String className,
                                               String methodName,
                                               Class<?>[] parameterTypes,
                                               Object[] args)
                                        throws ConnectException,
                                               AdminException
        Invokes the specified static method with the specified parameters on the chosen server. The parameters types of the invoked method must be java primitive types, the java objects wrapping them or String type. The method is invoked synchronously by the server and the result is returned.
        Specified by:
        invokeStaticServerMethod in interface AdminItf
        Parameters:
        serverId - the identifier of the server.
        className - the name of the class holding the static method
        methodName - the name of the invoked method
        parameterTypes - the list of parameters
        args - the arguments used for the method call
        Returns:
        the result of the invoked method after applying the toString method
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the invocation can't be done or fails
      • invokeStaticServerMethod

        public String invokeStaticServerMethod​(int serverId,
                                               String className,
                                               String methodName,
                                               Class<?>[] parameterTypes,
                                               Object[] args,
                                               boolean async)
                                        throws ConnectException,
                                               AdminException
        Invokes the specified static method with the specified parameters on the chosen server. The parameters types of the invoked method must be java primitive types, the java objects wrapping them or String type. The method can be invoked either asynchronously or not by the server depending of the parameter async.
        Parameters:
        serverId - the identifier of the server.
        className - the name of the class holding the static method
        methodName - the name of the invoked method
        parameterTypes - the list of parameters
        args - the arguments used for the method call
        async - if true the method is invoked asynchronously by the server and the result is lost.
        Returns:
        the result of the invoked method after applying the toString method
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the invocation can't be done or fails
      • addAMQPBridgeConnection

        public String addAMQPBridgeConnection​(int serverId,
                                              String urls)
                                       throws ConnectException,
                                              AdminException
        Adds an AMQP server and starts a live connection with it, accessible via the url provided. A server is uniquely identified by the given name. Adding an existing server won't do anything.
        Specified by:
        addAMQPBridgeConnection in interface AdminItf
        Parameters:
        serverId - the serverId
        urls - the amqp url list identifying the servers separate by space, for example: "amqp://user:pass@localhost:5672/?name=serv1 amqp://user:pass@localhost:5678/?name=serv2"
        Returns:
        the result of the method
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the invocation can't be done or fails
      • addJMSBridgeConnection

        public String addJMSBridgeConnection​(int serverId,
                                             String urls)
                                      throws ConnectException,
                                             AdminException
        Adds a JMS server and starts a live connection with it, accessible via the url provided. A server is uniquely identified by the given name. Adding an existing server won't do anything.
        Specified by:
        addJMSBridgeConnection in interface AdminItf
        Parameters:
        serverId - the serverId
        urls - the jms url list identifying the servers separate by space, for example: "jndi_url/?name=cnx1&cf=cfName&jndiFactoryClass=com.xxx.yyy&user=user1&pass=pass1&clientID=clientID"
        Returns:
        the result of the method
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the invocation can't be done or fails
      • deleteJMSPBridgeConnection

        public String deleteJMSPBridgeConnection​(int serverId,
                                                 String names)
                                          throws ConnectException,
                                                 AdminException
        Deprecated.
        Use deleteJMSBridgeConnection instead.
        Removes the live connection to the specified JMS server (Use deleteJMSBridgeConnection instead).
        Specified by:
        deleteJMSPBridgeConnection in interface AdminItf
        Parameters:
        serverId - the serverId
        names - the name identifying the server or list of name separate by space
        Returns:
        the result of the method
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the invocation can't be done or fails
      • deleteJMSBridgeConnection

        public String deleteJMSBridgeConnection​(int serverId,
                                                String names,
                                                boolean async)
                                         throws ConnectException,
                                                AdminException
        Removes the live connection to the specified JMS server.
        Specified by:
        deleteJMSBridgeConnection in interface AdminItf
        Parameters:
        serverId - the serverId
        names - the name identifying the server or list of name separate by space
        async - invoke asynchronously
        Returns:
        the result of the method
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the invocation can't be done or fails
      • deleteJMSPBridgeConnection

        public String deleteJMSPBridgeConnection​(int serverId,
                                                 String names,
                                                 boolean async)
                                          throws ConnectException,
                                                 AdminException
        Deprecated.
        Use deleteJMSBridgeConnection instead.
        Removes the live connection to the specified JMS server (Use deleteJMSBridgeConnection instead).
        Specified by:
        deleteJMSPBridgeConnection in interface AdminItf
        Parameters:
        serverId - the serverId
        names - the name identifying the server or list of name separate by space
        async - invoke asynchronously
        Returns:
        the result of the method
        Throws:
        ConnectException - If the connection fails.
        AdminException - If the invocation can't be done or fails