Class Network

    • Field Detail

      • DEBUG

        protected static final boolean DEBUG
      • logger

        protected Logger logger
      • WDActivationPeriod

        long WDActivationPeriod
        Period of time in ms between two activations of watch-dog thread, default value is 1000L (1 second). This value can be adjusted for all network components by setting WDActivationPeriod global property or for a particular network by setting <DomainName>.WDActivationPeriod specific property.

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

      • WDNbRetryLevel1

        int WDNbRetryLevel1
        Number of try at stage 1, default value is 5. This value can be adjusted for all network components by setting WDNbRetryLevel1 global property or for a particular network by setting <DomainName>.WDNbRetryLevel1 specific property.

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

      • WDRetryPeriod1

        long WDRetryPeriod1
        Period of time in ms between two connection try at stage 1, default value is WDActivationPeriod. This value can be adjusted for all network components by setting WDRetryPeriod1 global property or for a particular network by setting <DomainName>.WDRetryPeriod1 specific property.

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

        Be careful, in most Network components setting this value to a value less than WDActivationPeriod is useless. In the same way, the real try period is depending of the connection timeout.

      • WDNbRetryLevel2

        int WDNbRetryLevel2
        Number of try at stage 2, default value is 30. This value can be adjusted for all network components by setting WDNbRetryLevel2 global property or for a particular network by setting <DomainName>.WDNbRetryLevel2 specific property.

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

      • WDRetryPeriod2

        long WDRetryPeriod2
        Period of time in ms between two connection try at stage 2, default value is 10000L (10 seconds). This value can be adjusted for all network components by setting WDRetryPeriod2 global property or for a particular network by setting <DomainName>.WDRetryPeriod2 specific property.

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

        Be careful, in most Network components setting this value to a value less than WDActivationPeriod is useless. In the same way, the real try period is depending of the connection timeout.

      • WDRetryPeriod3

        long WDRetryPeriod3
        Period of time in ms between two connection try at stage 3, default value is 60000L (1 minute). This value can be adjusted for all network components by setting WDRetryPeriod3 global property or for a particular network by setting <DomainName>.WDRetryPeriod3 specific property.

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

        Be careful, in most Network components setting this value to a value less than WDActivationPeriod is useless. In the same way, the real try period is depending of the connection timeout.

      • nbMessageOut

        protected int nbMessageOut
      • nbMessageIn

        protected int nbMessageIn
      • sid

        protected short sid
        Id. of local server.
      • idxLS

        protected int idxLS
        Index of local server in status and matrix arrays.
      • servers

        protected short[] servers
        List of id. for all servers in the domain, this list is sorted and is used as index for internal tables.
      • serversFN

        protected transient String serversFN
        Filename for servers storage.
      • stamp

        private int[] stamp
        Logical timestamp information for messages in domain, stamp[idxLS)] for messages sent, and stamp[index(id] for messages received.
      • stampbuf

        private byte[] stampbuf
        Buffer used to optimize transactions.
      • bootTS

        private int[] bootTS
      • bootTSFN

        protected transient String bootTSFN
        Filename for boot time stamp storage.
      • name

        protected String name
        The component's name as it appears in logging.
      • domain

        protected String domain
        The domain name.
      • port

        protected int port
        The communication port.
      • qout

        protected MessageVector qout
        The MessageVector associated with this network component.
      • DELIVER

        protected static final int DELIVER
        The message can be delivered.
        See Also:
        Constant Field Values
      • ALREADY_DELIVERED

        protected static final int ALREADY_DELIVERED
        The message has already been delivered.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Network

        public Network()
        Creates a new network component. This simple constructor is required in order to use Class.newInstance() method during configuration. The configuration of component is then done by init method.
    • Method Detail

      • getWDActivationPeriod

        public long getWDActivationPeriod()
        Gets the WDActivationPeriod value.
        Specified by:
        getWDActivationPeriod in interface NetworkMBean
        Returns:
        the WDActivationPeriod value
      • setWDActivationPeriod

        public void setWDActivationPeriod​(long WDActivationPeriod)
        Sets the WDActivationPeriod value.
        Specified by:
        setWDActivationPeriod in interface NetworkMBean
        Parameters:
        WDActivationPeriod - the WDActivationPeriod value
      • getWDNbRetryLevel1

        public int getWDNbRetryLevel1()
        Gets the WDNbRetryLevel1 value.
        Specified by:
        getWDNbRetryLevel1 in interface NetworkMBean
        Returns:
        the WDNbRetryLevel1 value
      • setWDNbRetryLevel1

        public void setWDNbRetryLevel1​(int WDNbRetryLevel1)
        Sets the WDNbRetryLevel1 value.
        Specified by:
        setWDNbRetryLevel1 in interface NetworkMBean
        Parameters:
        WDNbRetryLevel1 - the WDNbRetryLevel1 value
      • getWDRetryPeriod1

        public long getWDRetryPeriod1()
        Gets the WDRetryPeriod1 value.
        Specified by:
        getWDRetryPeriod1 in interface NetworkMBean
        Returns:
        the WDRetryPeriod1 value
      • setWDRetryPeriod1

        public void setWDRetryPeriod1​(long WDRetryPeriod1)
        Sets the WDRetryPeriod1 value.
        Specified by:
        setWDRetryPeriod1 in interface NetworkMBean
        Parameters:
        WDRetryPeriod1 - the WDRetryPeriod1 value
      • getWDNbRetryLevel2

        public int getWDNbRetryLevel2()
        Gets the WDNbRetryLevel2 value.
        Specified by:
        getWDNbRetryLevel2 in interface NetworkMBean
        Returns:
        the WDNbRetryLevel2 value
      • setWDNbRetryLevel2

        public void setWDNbRetryLevel2​(int WDNbRetryLevel2)
        Sets the WDNbRetryLevel2 value.
        Specified by:
        setWDNbRetryLevel2 in interface NetworkMBean
        Parameters:
        WDNbRetryLevel2 - the WDNbRetryLevel2 value
      • getWDRetryPeriod2

        public long getWDRetryPeriod2()
        Gets the WDRetryPeriod2 value.
        Specified by:
        getWDRetryPeriod2 in interface NetworkMBean
        Returns:
        the WDRetryPeriod2 value
      • setWDRetryPeriod2

        public void setWDRetryPeriod2​(long WDRetryPeriod2)
        Sets the WDRetryPeriod2 value.
        Specified by:
        setWDRetryPeriod2 in interface NetworkMBean
        Parameters:
        WDRetryPeriod2 - the WDRetryPeriod2 value
      • getWDRetryPeriod3

        public long getWDRetryPeriod3()
        Gets the WDRetryPeriod3 value.
        Specified by:
        getWDRetryPeriod3 in interface NetworkMBean
        Returns:
        the WDRetryPeriod3 value
      • setWDRetryPeriod3

        public void setWDRetryPeriod3​(long WDRetryPeriod3)
        Sets the WDRetryPeriod3 value.
        Specified by:
        setWDRetryPeriod3 in interface NetworkMBean
        Parameters:
        WDRetryPeriod3 - the WDRetryPeriod3 value
      • getNbWaitingMessages

        public int getNbWaitingMessages()
        Gets the number of waiting messages in this engine.
        Specified by:
        getNbWaitingMessages in interface NetworkMBean
        Returns:
        the number of waiting messages.
      • getNbMessageSent

        public int getNbMessageSent()
        Returns the number of messages sent since last reboot.
        Specified by:
        getNbMessageSent in interface NetworkMBean
        Returns:
        the number of messages sent since last reboot.
      • getNbMessageReceived

        public int getNbMessageReceived()
        Returns the number of messages received since last reboot.
        Specified by:
        getNbMessageReceived in interface NetworkMBean
        Returns:
        the number of messages received since last reboot.
      • getDomainName

        public final String getDomainName()
        Returns the corresponding domain's name.
        Specified by:
        getDomainName in interface MessageConsumer
        Returns:
        this domain's name.
      • toString

        public String toString()
        Returns a string representation of this consumer.
        Specified by:
        toString in interface NetworkMBean
        Overrides:
        toString in class Object
        Returns:
        A string representation of this consumer.
      • insert

        public void insert​(Message msg)
        Insert a message in the MessageQueue. This method is used during initialization to restore the component state from persistent storage.
        Specified by:
        insert in interface MessageConsumer
        Parameters:
        msg - the message
      • restore

        public void restore()
                     throws Exception
        Restores component's information from persistent storage. If it is the first load, initializes it.
        Specified by:
        restore in interface MessageConsumer
        Throws:
        Exception - an error occurs.
      • 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.
        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.
      • setProperties

        public void setProperties()
                           throws Exception
        Set the properties of the network. Can be extended by subclasses.
        Throws:
        Exception - an error occurs.
      • addServer

        public void addServer​(short id)
                       throws Exception
        Adds the server sid in the network configuration.
        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.
        Parameters:
        id - the unique server id.
        Throws:
        Exception - an error occurs.
      • resetServer

        void resetServer​(short id,
                         int boot)
                  throws IOException
        Reset all information related to server sid in the network configuration.
        Parameters:
        id - the unique server id.
        boot - ?
        Throws:
        IOException - an error occurs.
      • post

        public void post​(Message msg)
                  throws Exception
        Adds a message in "ready to deliver" list. This method allocates a new time stamp to the message ; be Careful, changing the stamp imply the filename change too.
        Specified by:
        post in interface MessageConsumer
        Parameters:
        msg - the message to transmit.
        Throws:
        Exception - an error occurs.
      • index

        protected final int index​(short id)
        Returns the index in internal table of the specified server. The servers array must be ordered.
        Parameters:
        id - the unique server id.
        Returns:
        the index of server.
      • getStamp

        protected final byte[] getStamp()
      • setStamp

        protected final void setStamp​(byte[] stampbuf)
      • testRecvUpdate

        protected int testRecvUpdate​(short source,
                                     int update)
                              throws IOException
        Test if a received message with the specified clock must be delivered. If the message is ready to be delivered, the method returns DELIVER and the matrix clock is updated. If the message has already been delivered, the method returns ALREADY_DELIVERED, and if other messages are waited before this message the method returns WAIT_TO_DELIVER. In the last two case the matrix clock remains unchanged.
        Parameters:
        source - The identifier of source server.
        update - The message matrix clock (list of update).
        Returns:
        DELIVER, ALREADY_DELIVERED, or WAIT_TO_DELIVER code.
        Throws:
        IOException - an error occurs.
      • getSendUpdate

        private int getSendUpdate​(short to)
                           throws IOException
        Computes the matrix clock of a send message. The server's matrix clock is updated.
        Parameters:
        to - The identification of receiver.
        Returns:
        The message matrix clock (list of update).
        Throws:
        IOException - an error occurs.
      • isPrior

        public boolean isPrior​(Message m1,
                               Message m2)
        Description copied from interface: MessageComparator
        Compares the 2 messages for time ordering. Returns true if the first message is earlier than the second, false otherwise.
        Specified by:
        isPrior in interface MessageComparator
        Parameters:
        m1 - The first message.
        m2 - The second message.
        Returns:
        true if the first message is earlier than the second, false otherwise.
      • getBootTS

        final int getBootTS()
      • deliver

        protected void deliver​(Message msg)
                        throws Exception
        Try to deliver the received message to the right consumer.
        Parameters:
        msg - the message.
        Throws:
        Exception - an error occurs.
      • delete

        public void delete()
                    throws IllegalStateException
        Deletes the component, removes all persistent data. The component may have been previously stopped, and removed from MessageConsumer list. This operation use Transaction calls, you may use commit to validate it.
        Specified by:
        delete in interface MessageConsumer
        Throws:
        IllegalStateException - the server is running.
        See Also:
        Transaction
      • validate

        public void validate()
        Validates all messages pushed in queue during transaction session.
        Specified by:
        validate in interface MessageConsumer
      • getQueue

        public MessageQueue getQueue()
        Description copied from interface: MessageConsumer
        Get this consumer's MessageQueue. Use in administration and debug tasks, should be replaced by a common attribute.
        Specified by:
        getQueue in interface MessageConsumer
        Returns:
        this MessageConsumer's queue.
      • setPort

        public void setPort​(int port)
        Updates the network port.
        Parameters:
        port - the listening port.
      • getPort

        public final int getPort()
      • deleteMessage

        protected void deleteMessage​(Message msg)
      • getMessageSource

        protected short getMessageSource​(Message msg)
      • setMessageSource

        protected void setMessageSource​(Message msg,
                                        short source)
      • getMessageDest

        protected short getMessageDest​(Message msg)
      • checkActive

        protected void checkActive​(ServerDesc desc)
      • validateChannel

        protected void validateChannel()