public abstract class ServerHandler extends MonitorProvider<org.forgerock.opendj.server.config.server.MonitorProviderCfg>
Modifier and Type | Field and Description |
---|---|
protected long |
generationId
Remote generation id.
|
protected byte |
groupId
Group id of this remote server.
|
protected long |
heartbeatInterval
The time in milliseconds between heartbeats from the replication
server.
|
protected long |
localGenerationId
The generation id of the hosting RS.
|
protected int |
maxQueueSize
Specifies the max queue size for this handler.
|
protected int |
maxRcvWindow
The size of the receiving window.
|
protected long |
oldGenerationId
The generation id before processing a new start handshake.
|
protected ReplicationServer |
replicationServer
Local hosting RS.
|
protected ReplicationServerDomain |
replicationServerDomain
Specifies the related replication server domain based on baseDN.
|
protected int |
serverId
The serverId of the remote server.
|
protected String |
serverURL
The serverURL of the remote server.
|
protected Session |
session
The session opened with the remote server.
|
protected boolean |
sslEncryption
The SSL encryption after the negotiation with the peer.
|
protected int |
weight
Weight of this remote server.
|
Constructor and Description |
---|
ServerHandler(Session session,
int queueSize,
ReplicationServer replicationServer,
int rcvWindowSize)
Creates a new server handler instance with the provided socket.
|
Modifier and Type | Method and Description |
---|---|
protected void |
abortStart(LocalizableMessage reason)
Abort a start procedure currently establishing.
|
void |
checkWindow()
Check the protocol window and send WindowMsg if necessary.
|
protected ReplServerStartMsg |
createReplServerStartMsg()
Creates a ReplServerStartMsg for the current ServerHandler.
|
void |
doStop()
Stop this handler.
|
protected void |
finalizeStart()
Finalize the initialization, create reader, writer, heartbeat system
and monitoring system.
|
long |
getApproxFirstMissingDate()
Get the age of the older change that has not yet been replicated
to the server handled by this ServerHandler.
|
int |
getAssuredSdReceivedUpdates()
Get the number of updates received from the server in assured safe data
mode.
|
AtomicInteger |
getAssuredSdReceivedUpdatesTimeout()
Get the number of updates received from the server in assured safe data
mode that timed out.
|
int |
getAssuredSdSentUpdates()
Get the number of updates sent to the server in assured safe data mode.
|
AtomicInteger |
getAssuredSdSentUpdatesTimeout()
Get the number of updates sent to the server in assured safe data mode that
timed out.
|
int |
getAssuredSrReceivedUpdates()
Get the number of updates received from the server in assured safe read
mode.
|
AtomicInteger |
getAssuredSrReceivedUpdatesTimeout()
Get the number of updates received from the server in assured safe read
mode that timed out.
|
int |
getAssuredSrSentUpdates()
Get the number of updates sent to the server in assured safe read mode.
|
AtomicInteger |
getAssuredSrSentUpdatesTimeout()
Get the number of updates sent to the server in assured safe read mode that
timed out.
|
LocalizableMessage |
getBadlyDisconnectedErrorMessage()
Returns a "badly disconnected" error message for this server handler.
|
protected org.forgerock.opendj.ldap.Dn |
getBaseDN()
Get the baseDN for this handler.
|
ReplicationServerDomain |
getDomain()
Returns the Replication Server Domain to which belongs this server handler.
|
long |
getGenerationId()
Returns the value of generationId for that handler.
|
byte |
getGroupId()
Gets the group id of the server represented by this object.
|
long |
getHeartbeatInterval()
Get our heartbeat interval.
|
byte |
getLocalGroupId()
Get the groupId of the hosting RS.
|
MonitorData |
getMonitorData()
Retrieves a set of attributes containing monitor data that should
be returned to the client if the corresponding monitor entry is
requested.
|
abstract String |
getMonitorInstanceName()
Retrieves the name of this monitor provider.
|
protected UpdateMsg |
getNextMessage()
Get the next update that must be sent to the consumer from the message queue or from the database.
|
CSN |
getOlderUpdateCSN()
Get the older CSN for that server.
|
short |
getProtocolVersion()
Gets the protocol version used with this remote server.
|
int |
getRcvMsgQueueSize()
Get the number of message in the receive message queue.
|
long |
getReferenceGenId()
Get the reference generation id (associated with the changes in the db).
|
int |
getReplicationServerId()
Get the serverId of the hosting replication server.
|
String |
getReplicationServerURL()
Get the server URL of the hosting replication server.
|
int |
getServerId()
Get the Server Id.
|
ServerState |
getServerState()
Get the state of this server.
|
String |
getServerURL()
Retrieves the URL for this server handler.
|
protected abstract ServerStatus |
getStatus()
Return the ServerStatus.
|
void |
incrementAssuredSdReceivedUpdates()
Increment the number of updates received from the server in assured safe
data mode.
|
void |
incrementAssuredSdReceivedUpdatesTimeout()
Increment the number of updates received from the server in assured safe
data mode that timed out.
|
void |
incrementAssuredSdSentUpdatesTimeout()
Increment the number of updates sent to the server in assured safe data
mode that timed out.
|
void |
incrementAssuredSrReceivedUpdates()
Increment the number of updates received from the server in assured safe
read mode.
|
void |
incrementAssuredSrReceivedUpdatesTimeout()
Increment the number of updates received from the server in assured safe
read mode that timed out.
|
void |
incrementAssuredSrSentUpdatesTimeout()
Increment the number of updates sent to the server in assured safe read
mode that timed out.
|
void |
initializeMonitorProvider(org.forgerock.opendj.server.config.server.MonitorProviderCfg configuration)
Initializes this monitor provider based on the information in the provided configuration entry.
|
abstract boolean |
isDataServer()
Check if the server associated to this ServerHandler is a data server
in the topology.
|
boolean |
isReplicationServer()
Check if the server associated to this ServerHandler is a replication
server.
|
void |
lockDomainNoTimeout()
Lock the domain without a timeout.
|
void |
lockDomainWithTimeout()
Lock the domain with a timeout.
|
protected void |
logStartHandshakeRCVandSND(StartMsg inStartMsg,
StartMsg outStartMsg)
Log the messages involved in the start handshake.
|
protected void |
logStartHandshakeSNDandRCV(StartMsg outStartMsg,
StartMsg inStartMsg)
Log the messages involved in the start handshake.
|
protected void |
logStartSessionHandshake(StartSessionMsg inStartSessionMsg,
TopologyMsg outTopoMsg)
Log the messages involved in the Topology/StartSession handshake.
|
protected void |
logStopReceived()
Log stop message has been received.
|
protected void |
logTopoHandshakeRCVandSND(TopologyMsg inTopoMsg,
TopologyMsg outTopoMsg)
Log the messages involved in the Topology handshake.
|
protected void |
logTopoHandshakeSNDandRCV(TopologyMsg outTopoMsg,
TopologyMsg inTopoMsg)
Log the messages involved in the Topology handshake.
|
void |
put(UpdateMsg update)
Put a new update message received.
|
protected void |
releaseDomainLock()
Releases the lock on the replication server domain if it was held.
|
void |
replyToWindowProbe()
Process the reception of a WindowProbeMsg message.
|
void |
send(ReplicationMsg msg)
Sends a message.
|
void |
sendTopoInfo(TopologyMsg topoMsg)
Sends the provided TopologyMsg to the peer server.
|
protected void |
setBaseDNAndDomain(org.forgerock.opendj.ldap.Dn baseDN,
boolean isDataServer)
Set the baseDN for this handler.
|
void |
setConsumerActive(boolean active)
Set that the consumer is now becoming inactive and thus getNextMessage
should not return any UpdateMsg any more.
|
void |
setGenerationId(long generationId)
Set a new generation ID.
|
void |
setInitialServerState(ServerState serverState)
Set the initial value of the serverState for this handler.
|
protected void |
setSendWindowSize(int size)
Sets the window size when used when sending to the remote.
|
void |
shutdown()
Shutdown This ServerHandler.
|
UpdateMsg |
take()
Select the next update that must be sent to the server managed by this
ServerHandler.
|
RSInfo |
toRSInfo()
Creates a RSInfo structure representing this remote RS.
|
String |
toString() |
void |
updateWindow(WindowMsg windowMsg)
Update the send window size based on the credit specified in the
given window message.
|
finalizeMonitorProvider, getMonitorObjectClass, isConfigurationAcceptable, scheduleUpdate
protected int serverId
protected final int maxRcvWindow
protected long generationId
protected long localGenerationId
protected long oldGenerationId
protected byte groupId
protected boolean sslEncryption
protected long heartbeatInterval
protected int weight
protected final ReplicationServer replicationServer
protected ReplicationServerDomain replicationServerDomain
protected final int maxQueueSize
public ServerHandler(Session session, int queueSize, ReplicationServer replicationServer, int rcvWindowSize)
session
- The Session used by the ServerHandler to
communicate with the remote entity.queueSize
- The maximum number of update that will be kept
in memory by this ServerHandler.replicationServer
- The hosting replication server.rcvWindowSize
- The window size to receive from the remote server.protected void abortStart(LocalizableMessage reason)
reason
- The provided reason.protected void releaseDomainLock()
public void checkWindow() throws IOException
IOException
- when the session becomes unavailable.protected void finalizeStart() throws DirectoryException
DirectoryException
- When an exception is raised.public void send(ReplicationMsg msg) throws IOException
msg
- The message to be sent.IOException
- When it occurs while sending the message,public long getApproxFirstMissingDate()
public int getAssuredSdReceivedUpdates()
public AtomicInteger getAssuredSdReceivedUpdatesTimeout()
public int getAssuredSdSentUpdates()
public AtomicInteger getAssuredSdSentUpdatesTimeout()
public int getAssuredSrReceivedUpdates()
public AtomicInteger getAssuredSrReceivedUpdatesTimeout()
public int getAssuredSrSentUpdates()
public AtomicInteger getAssuredSrSentUpdatesTimeout()
public ReplicationServerDomain getDomain()
public long getGenerationId()
public byte getGroupId()
public long getHeartbeatInterval()
public MonitorData getMonitorData()
MonitorProvider
public abstract String getMonitorInstanceName()
public short getProtocolVersion()
public int getServerId()
public String getServerURL()
protected abstract ServerStatus getStatus()
public void incrementAssuredSdReceivedUpdates()
public void incrementAssuredSdReceivedUpdatesTimeout()
public void incrementAssuredSdSentUpdatesTimeout()
public void incrementAssuredSrReceivedUpdates()
public void incrementAssuredSrReceivedUpdatesTimeout()
public void incrementAssuredSrSentUpdatesTimeout()
public void initializeMonitorProvider(org.forgerock.opendj.server.config.server.MonitorProviderCfg configuration) throws org.forgerock.opendj.config.server.ConfigException, InitializationException
configuration
- The configuration to use to initialize this monitor provider.org.forgerock.opendj.config.server.ConfigException
- If an unrecoverable problem arises in the process of performing the initialization.InitializationException
- If a problem occurs during initialization that is not related to the server
configuration.public abstract boolean isDataServer()
public boolean isReplicationServer()
public void lockDomainNoTimeout() throws DirectoryException, InterruptedException
If domain already exists, lock it until handshake is finished otherwise it will be created and locked later in the method
DirectoryException
- When an exception occurs.InterruptedException
- If the current thread was interrupted while waiting for the lock.public void lockDomainWithTimeout() throws DirectoryException, InterruptedException
Take the lock on the domain. WARNING: Here we try to acquire the lock with a timeout. This is for preventing a deadlock that may happen if there are cross connection attempts (for same domain) from this replication server and from a peer one.
Here is the scenario:
To prevent threads locking in such situation, the listen threads here will both timeout trying to acquire the lock. The random time for the timeout should allow on connection attempt to be aborted whereas the other one should have time to finish in the same time.
Warning: the minimum time (3s) should be big enough to allow normal situation connections to terminate. The added random time should represent a big enough range so that the chance to have one listen thread timing out a lot before the peer one is great. When the first listen thread times out, the remote connect thread should release the lock and allow the peer listen thread to take the lock it was waiting for and process the connection attempt.
DirectoryException
- When an exception occurs.InterruptedException
- If the current thread was interrupted while waiting for the lock.public void replyToWindowProbe() throws IOException
IOException
- When the session becomes unavailable.public void sendTopoInfo(TopologyMsg topoMsg) throws IOException
topoMsg
- The TopologyMsg message to be sent.IOException
- When it occurs while sending the message,public void setGenerationId(long generationId)
generationId
- The new generation IDprotected void setSendWindowSize(int size)
size
- The provided window size.public void shutdown()
public UpdateMsg take() throws ChangelogException
ChangelogException
- If a problem occurs when reading the changelogpublic RSInfo toRSInfo()
public void updateWindow(WindowMsg windowMsg)
windowMsg
- The Window LocalizableMessage containing the information
necessary for updating the window size.protected void logStartHandshakeRCVandSND(StartMsg inStartMsg, StartMsg outStartMsg)
inStartMsg
- The message received first.outStartMsg
- The message sent in response.protected void logStartHandshakeSNDandRCV(StartMsg outStartMsg, StartMsg inStartMsg)
outStartMsg
- The message sent first.inStartMsg
- The message received in response.protected void logTopoHandshakeRCVandSND(TopologyMsg inTopoMsg, TopologyMsg outTopoMsg)
inTopoMsg
- The message received first.outTopoMsg
- The message sent in response.protected void logTopoHandshakeSNDandRCV(TopologyMsg outTopoMsg, TopologyMsg inTopoMsg)
outTopoMsg
- The message sent first.inTopoMsg
- The message received in response.protected void logStartSessionHandshake(StartSessionMsg inStartSessionMsg, TopologyMsg outTopoMsg)
inStartSessionMsg
- The message received first.outTopoMsg
- The message sent in response.protected void logStopReceived()
public long getReferenceGenId()
public void put(UpdateMsg update) throws IOException
update
- the update message received.IOException
- when it occurs.public void doStop()
protected ReplServerStartMsg createReplServerStartMsg()
public LocalizableMessage getBadlyDisconnectedErrorMessage()
protected UpdateMsg getNextMessage() throws ChangelogException
null
when queue is emptyChangelogException
- If a problem occurs when reading the changelogpublic CSN getOlderUpdateCSN()
public int getRcvMsgQueueSize()
public ServerState getServerState()
protected org.forgerock.opendj.ldap.Dn getBaseDN()
public void setConsumerActive(boolean active)
active
- the provided state of the consumer.public void setInitialServerState(ServerState serverState) throws DirectoryException
serverState
- the provided serverState.DirectoryException
- raised when a problem occurs.protected void setBaseDNAndDomain(org.forgerock.opendj.ldap.Dn baseDN, boolean isDataServer) throws DirectoryException
baseDN
- The provided baseDN.isDataServer
- The handler is a dataServerDirectoryException
- raised when a problem occurs.public byte getLocalGroupId()
public int getReplicationServerId()
public String getReplicationServerURL()
Copyright © 2010-2017 ForgeRock AS. All Rights Reserved.