Class ReplicationBroker


  • public class ReplicationBroker
    extends Object
    The broker for Multi-master Replication.
    • Constructor Detail

      • ReplicationBroker

        public ReplicationBroker​(ServerContext serverContext,
                                 ReplicationDomain replicationDomain,
                                 ServerState state,
                                 ReplicationDomainCfg config,
                                 ReplSessionSecurity replSessionSecurity)
        Creates a new ReplicationServer Broker for a particular ReplicationDomain.
        Parameters:
        serverContext - The directory server context
        replicationDomain - The replication domain that is creating us.
        state - The ServerState that should be used by this broker when negotiating the session with the replicationServer.
        config - The configuration to use.
        replSessionSecurity - The session security configuration.
    • Method Detail

      • start

        public void start()
        Start the ReplicationBroker.
      • getReplicationServerId

        public ReplicationServerId getReplicationServerId()
        Gets the server id of the RS we are connected to.
        Returns:
        The server id of the RS we are connected to
      • getReplicaId

        public ReplicaId getReplicaId()
        Gets the replica id.
        Returns:
        The replica id
      • setGenerationID

        public void setGenerationID​(GenerationId generationID)
        Set the generation id - for test purpose.
        Parameters:
        generationID - The generation id
      • restart

        public void restart​(boolean infiniteTry)
        Restart the ReplicationBroker.
        Parameters:
        infiniteTry - the socket which failed
      • publish

        public boolean publish​(ReplicationMsg msg)
        Publish a message to the other servers.
        Parameters:
        msg - the message to publish
        Returns:
        whether the message was successfully sent
      • publishRecoveryMsg

        public void publishRecoveryMsg​(ReplicationMsg msg)
        Publish a recovery message to the other servers.
        Parameters:
        msg - the message to publish
      • receive

        public ReplicationMsg receive()
                               throws SocketTimeoutException
        Receive a message. This method is not thread-safe and should either always be called in a single thread or protected by a locking mechanism before being called. This is a wrapper to the method with a boolean version so that we do not have to modify existing tests.
        Returns:
        the received message
        Throws:
        SocketTimeoutException - if the timeout set by setSoTimeout has expired
      • updateWindowAfterReplay

        public void updateWindowAfterReplay()
        This method allows to do the necessary computing for the window management after treatment by the worker threads. This should be called once the replay thread have done their job and the window can be open again.
      • stop

        public void stop()
        Stop the server.
      • setSoTimeout

        public void setSoTimeout​(int timeout)
                          throws SocketException
        Set a timeout value. With this option set to a non-zero value, calls to the receive() method block for only this amount of time after which a java.net.SocketTimeoutException is raised. The Broker is valid and usable even after such an Exception is raised.
        Parameters:
        timeout - the specified timeout, in milliseconds.
        Throws:
        SocketException - if there is an error in the underlying protocol, such as a TCP error.
      • getChangelogEndpoint

        public com.forgerock.opendj.util.HostPort getChangelogEndpoint()
        Get the host and port of the replicationServer to which this broker is currently connected.
        Returns:
        the host and port of the replicationServer to which this domain is currently connected.
      • getCurrentRcvWindow

        public int getCurrentRcvWindow()
        Get the current receive window size.
        Returns:
        The current receive window size.
      • getNumLostConnections

        public int getNumLostConnections()
        Get the number of times the connection was lost.
        Returns:
        The number of times the connection was lost.
      • isConnected

        public boolean isConnected()
        Check if the broker is connected to a ReplicationServer and therefore ready to received and send Replication Messages.
        Returns:
        true if the server is connected, false if not.
      • isSessionEncrypted

        public boolean isSessionEncrypted()
        Determine whether the connection to the replication server is encrypted.
        Returns:
        true if the connection is encrypted, false otherwise.
      • signalStatusChangeToRs

        public void signalStatusChangeToRs​(ServerStatus newStatus)
        Signals the RS we just entered a new status.
        Parameters:
        newStatus - The status the local DS just entered
      • getReplicaInfos

        public List<DSInfo> getReplicaInfos()
        Gets the info for DSs in the topology (except us).
        Returns:
        The info for DSs in the topology (except us)
      • getRsInfos

        public List<RSInfo> getRsInfos()
        Gets the info for RSs in the topology (except the one we are connected to).
        Returns:
        The info for RSs in the topology (except the one we are connected to)
      • setRecoveryRequired

        public void setRecoveryRequired​(boolean recoveryInProgress)
        This flag is used to indicate if a recovery of update messages is necessary after a reconnection to a RS. It is the responsibility of the ReplicationDomain to set it during the sessionInitiated phase.
        Parameters:
        recoveryInProgress - true when recovery is required.