Class PoolNetwork

    • Field Detail

      • magic

        private static final byte[] magic
        Magic number to identify peer.
      • sessions

        PoolNetwork.NetSession[] sessions
        Components handling communication with other servers. There is a NetSession component for each server in the domain, some are 'active' (i.e connected).
      • compressedFlows

        boolean compressedFlows
        Defines if the streams between servers are compressed or not.

        Default value is false, be careful in a domain all servers must use the same definition.

        This value can be adjusted for all network components by setting PoolNetwork.compressedFlows global property or for a particular network by setting <DomainName>.compressedFlows specific property.

        Theses properties can be fixed either from java launching command, or in a3servers.xml configuration file.

      • nbMaxCnx

        int nbMaxCnx
        Defines the maximum number of concurrent connected sessions.

        By default this property is set to -1 to dynamically adjust to the number of servers of the domain (excepting the current server). Setting this value needs precautions to avoid unexpected connection loss.

        This value can be adjusted for all network components by setting PoolNetwork.nbMaxCnx global property or for a particular network by setting <DomainName>.nbMaxCnx specific property.

        Theses properties can be fixed either from java launching command, or in a3servers.xml configuration file.

      • IdleTimeout

        long IdleTimeout
        Defines in milliseconds the maximum idle period permitted before reseting the connection.

        The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout. Default value is 60000 (1 minute), value less than 1000 are unauthorized.

        This value can be adjusted for all network components by setting PoolNetwork.IdleTimeout global property or for a particular network by setting <DomainName>.IdleTimeout specific property.

        Theses properties can be fixed either from java launching command, or in a3servers.xml configuration file.

      • defaultMaxMessageInFlow

        int defaultMaxMessageInFlow
        Defines the default value for maximum number of message sent and non acknowledged on a connection.

        By default this value is set to -1 and there is no flow control.

        This value can be adjusted for all network components by setting the PoolNetwork.maxMessageInFlow global property or for a particular network by setting <DomainName>.maxMessageInFlow specific property.

        For a particular network the value can be defined finely for a the connection with a particular remote server by setting PoolNetwork.maxMessageInFlow_N or <DomainName>.maxMessageInFlow_N.

        Theses properties can be fixed either from java launching command, or in a3servers.xml configuration file.

    • Constructor Detail

      • PoolNetwork

        public PoolNetwork()
                    throws Exception
        Creates a new network component.
        Throws:
        Exception - an error occurs.
    • Method Detail

      • getCompressedFlows

        public boolean getCompressedFlows()
        Returns if the stream between servers are compressed or not.
        Specified by:
        getCompressedFlows in interface PoolNetworkMBean
        Returns:
        true if the streams between servers are compressed, false otherwise.
      • getNbMaxActiveSession

        public int getNbMaxActiveSession()
        Returns the maximum number of concurrent connected sessions.
        Specified by:
        getNbMaxActiveSession in interface PoolNetworkMBean
        Returns:
        the number of concurrent connected sessions.
      • getNbActiveSession

        public int getNbActiveSession()
        Returns the number of currently connected sessions.
        Specified by:
        getNbActiveSession in interface PoolNetworkMBean
        Returns:
        the number of currently connected sessions.
      • getIdleTimeout

        public long getIdleTimeout()
        Returns the maximum idle period permitted before reseting the connection.
        Specified by:
        getIdleTimeout in interface PoolNetworkMBean
        Returns:
        the maximum idle period permitted before reseting the connection.
      • setIdleTimeout

        public void setIdleTimeout​(long idleTimeout)
        Sets the maximum idle period permitted before reseting the connection.
        Specified by:
        setIdleTimeout in interface PoolNetworkMBean
        Parameters:
        idleTimeout - the maximum idle period permitted before reseting the connection.
      • init

        public void init​(String name,
                         int port,
                         short[] servers)
                  throws Exception
        Initializes a new network component. This method is used in order to easily creates and configure a Network component from a class name. So we can use the Class.newInstance() method for create (without any parameter) the component, then we can initialize it with this method.
        This method initializes the logical clock for the domain.
        Overrides:
        init in class StreamNetwork
        Parameters:
        name - The domain name.
        port - The listen port.
        servers - The list of servers directly accessible from this network interface.
        Throws:
        Exception - an error occurs.
        See Also:
        Network
      • setProperties

        public void setProperties()
                           throws Exception
        Set the properties of the network. Inherited from Network class, can be extended by subclasses.
        Overrides:
        setProperties in class StreamNetwork
        Throws:
        Exception - an error occurs.
      • addServer

        public void addServer​(short id)
                       throws Exception
        Adds the server sid in the network configuration.
        Overrides:
        addServer in class Network
        Parameters:
        id - the unique server id.
        Throws:
        Exception - an error occurs.
      • delServer

        public void delServer​(short id)
                       throws Exception
        Removes the server sid in the network configuration.
        Overrides:
        delServer in class Network
        Parameters:
        id - the unique server id.
        Throws:
        Exception - an error occurs.
      • getMBeanName

        private String getMBeanName​(short sid)
      • wakeup

        public void wakeup()
        Wakes up the watch-dog thread.
      • isRunning

        public boolean isRunning()
        Tests if the network component is alive.
        Specified by:
        isRunning in interface MessageConsumer
        Specified by:
        isRunning in interface NetworkMBean
        Returns:
        true if this MessageConsumer is alive; false otherwise.
      • getSession

        final PoolNetwork.NetSession getSession​(short sid)
                                         throws UnknownServerException
        Returns the NetSession component handling the communication with the remote server that id is passed in parameter.
        Parameters:
        sid - the server id of remote server.
        Returns:
        the NetSession component handling the communication with the remote server.
        Throws:
        UnknownServerException - the server is not defined.
      • isSessionRunning

        final boolean isSessionRunning​(short sid)
        Tests if the session is connected.
        Parameters:
        sid - the server id of remote server.
        Returns:
        true if this session is connected; false otherwise.
      • getMaxMessageInFlow

        final int getMaxMessageInFlow​(short sid)
        Gets the maximum number of message sent and non acknowledged.
        Parameters:
        sid - the server id of remote server.
        Returns:
        the maximum number of message sent and non acknowledged.
      • setMaxMessageInFlow

        void setMaxMessageInFlow​(short sid,
                                 int maxMessageInFlow)
        Sets the maximum number of message sent and non acknowledged.
        Parameters:
        sid - the server id of remote server.
        maxMessageInFlow - the maximum number of message sent and non acknowledged.
      • getSessionNbWaitingMessages

        final int getSessionNbWaitingMessages​(short sid)
        Gets the number of waiting messages to send for this session.
        Parameters:
        sid - the server id of remote server.
        Returns:
        the number of waiting messages.
      • getNbMessageSent

        final int getNbMessageSent​(short sid)
        Returns the number of messages sent since last reboot.
        Parameters:
        sid - the server id of remote server.
        Returns:
        the number of messages sent since last reboot.
      • getNbMessageReceived

        final int getNbMessageReceived​(short sid)
        Returns the number of messages received since last reboot.
        Parameters:
        sid - the server id of remote server.
        Returns:
        the number of messages received since last reboot.
      • getNbAckSent

        final int getNbAckSent​(short sid)
        Returns the number of acknowledge sent since last reboot.
        Parameters:
        sid - the server id of remote server.
        Returns:
        the number of acknowledge sent since last reboot.
      • getLastReceived

        final long getLastReceived​(short sid)
        Returns the time in milliseconds of last message received.
        Parameters:
        sid - the server id of remote server.
        Returns:
        the time in milliseconds of last message received.
      • getNbBufferingMessageToSent

        final int getNbBufferingMessageToSent​(short sid)
        Returns the number of buffering messages to sent since last reboot.
        Parameters:
        sid - the server id of remote server.
        Returns:
        the number of buffering messages to sent since last reboot.
      • toString

        public String toString()
        Returns a string representation of this consumer, including the daemon's name and status.
        Specified by:
        toString in interface NetworkMBean
        Overrides:
        toString in class Network
        Returns:
        A string representation of this consumer.