Class AbstractClusterManager

    • Field Detail

      • WAIT_LOCAL_PROCESSING_TIMEOUT_MS

        protected static final long WAIT_LOCAL_PROCESSING_TIMEOUT_MS
        Wait local processing timeout in milliseconds.
        Since:
        12.4.0
        See Also:
        Constant Field Values
      • serverId

        protected java.lang.String serverId
        The identifier for this cluster node.
        Since:
        4.1.0
    • Constructor Detail

      • AbstractClusterManager

        public AbstractClusterManager()
    • Method Detail

      • transmissionReceived

        protected <T extends java.io.Serializable> ITransmissionResult<T> transmissionReceived​(IClusterTransmission transmission)
        Processes a received transmission. Subclasses should call this method whenever a transmission is received. processTransmissionsReceived may be used to disable the processing done by this method.
        Parameters:
        transmission - the transmission received.
        Since:
        4.1.0
      • init

        public void init()
        Description copied from interface: IClusterManager
        Initializes the cluster manager. This method should start the monitoring and connections necessary for the cluster manager to execute its communications.
        Specified by:
        init in interface IClusterManager
      • destroy

        public void destroy()
        Description copied from interface: IClusterManager
        Destroys the cluster manager. This method should close all resources used by the cluster manager.
        Specified by:
        destroy in interface IClusterManager
      • createClusterCommand

        public IClusterCommand<java.io.Serializable> createClusterCommand​(java.lang.Runnable runnable)
        Description copied from interface: IClusterManager
        Creates a cluster command instance and returns it.
        Specified by:
        createClusterCommand in interface IClusterManager
        Parameters:
        runnable - the runnable that contains the command's execution. It must be serializable.
        See Also:
        IClusterCommand
      • createClusterMessage

        public IClusterMessage createClusterMessage​(java.lang.String group,
                                                    java.io.Serializable data)
        Description copied from interface: IClusterManager
        Creates a cluster message instance and returns it.
        Specified by:
        createClusterMessage in interface IClusterManager
        Parameters:
        group - the destination group for the message.
        data - the data sent in the message.
        Returns:
        the cluster message created.
        See Also:
        IClusterMessage
      • callAndWaitResponses

        public <T extends java.io.Serializable> java.util.Map<IClusterMember,​T> callAndWaitResponses​(IClusterCallable<T> command,
                                                                                                           long timeout)
                                                                                                    throws ClusterInvocationException,
                                                                                                           java.util.concurrent.TimeoutException,
                                                                                                           java.lang.InterruptedException,
                                                                                                           java.lang.IllegalArgumentException
        Description copied from interface: IClusterManager
        Calls a cluster command execution and waits all current cluster servers to respond with their result and, then, returns an unmodifiable map having the cluster member as the key and the execution result as the value.

        If some server raises an exception, a ClusterInvocationException will be raised locally on the server that called this method with all exceptions that happened in the servers as suppressed.

        This method has no guarantee it will execute properly if cluster members enter or leave the cluster during its execution.

        If all responses couldn't be retrieved in the given timeout, a TimeoutException will be raised.

        Specified by:
        callAndWaitResponses in interface IClusterManager
        Type Parameters:
        T - the response type. it must be serializable.
        Parameters:
        command - the command to be invoked.
        timeout - the timeout this method will wait the invoke finishes.
        Returns:
        a map with all responses.
        Throws:
        ClusterInvocationException - if some server raises an exception during the invoke.
        java.util.concurrent.TimeoutException - if the timeout has been reached and not all responses were returned.
        java.lang.InterruptedException - if the thread that called this method was interrupted.
        java.lang.IllegalArgumentException - if the given command is null.
      • callAndWaitResponsesInternal

        protected abstract <T extends java.io.Serializable> java.util.Map<IClusterMember,​T> callAndWaitResponsesInternal​(IClusterCallable<T> command,
                                                                                                                               long timeout)
                                                                                                                        throws ClusterInvocationException,
                                                                                                                               java.util.concurrent.TimeoutException,
                                                                                                                               java.lang.InterruptedException
        Throws:
        ClusterInvocationException
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        See Also:
        #callAndWaitResponses(IClusterCommand, long)