Class ReplicationBroker
java.lang.Object
org.opends.server.replication.service.ReplicationBroker
The broker for Multi-master Replication.
-
Constructor Summary
ConstructorDescriptionReplicationBroker
(ServerContext serverContext, ReplicationDomain replicationDomain, ServerState state, ReplicationDomainCfg config, ReplSessionSecurity replSessionSecurity) Creates a new ReplicationServer Broker for a particular ReplicationDomain. -
Method Summary
Modifier and TypeMethodDescriptioncom.forgerock.opendj.util.HostPort
Get the host and port of the replicationServer to which this broker is currently connected.int
Get the current receive window size.int
Get the number of times the connection was lost.Gets the replica id.Gets the info for DSs in the topology (except us).Gets the server id of the RS we are connected to.Gets the info for RSs in the topology (except the one we are connected to).boolean
Check if the broker is connected to a ReplicationServer and therefore ready to received and send Replication Messages.boolean
Determine whether the connection to the replication server is encrypted.boolean
publish
(ReplicationMsg msg) Publish a message to the other servers.void
Publish a recovery message to the other servers.receive()
Receive a message.void
restart
(boolean infiniteTry) Restart the ReplicationBroker.void
setGenerationID
(GenerationId generationID) Set the generation id - for test purpose.void
setRecoveryRequired
(boolean recoveryInProgress) This flag is used to indicate if a recovery of update messages is necessary after a reconnection to a RS.void
setSoTimeout
(int timeout) Set a timeout value.void
signalStatusChangeToRs
(ServerStatus newStatus) Signals the RS we just entered a new status.void
start()
Start the ReplicationBroker.void
stop()
Stop the server.toString()
void
This method allows to do the necessary computing for the window management after treatment by the worker threads.
-
Constructor Details
-
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 contextreplicationDomain
- 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 Details
-
start
public void start()Start the ReplicationBroker. -
getReplicationServerId
Gets the server id of the RS we are connected to.- Returns:
- The server id of the RS we are connected to
-
getReplicaId
Gets the replica id.- Returns:
- The replica id
-
setGenerationID
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
Publish a message to the other servers.- Parameters:
msg
- the message to publish- Returns:
- whether the message was successfully sent
-
publishRecoveryMsg
Publish a recovery message to the other servers.- Parameters:
msg
- the message to publish
-
receive
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
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
Signals the RS we just entered a new status.- Parameters:
newStatus
- The status the local DS just entered
-
getReplicaInfos
Gets the info for DSs in the topology (except us).- Returns:
- The info for DSs in the topology (except us)
-
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.
-
toString
-