| | |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.getTracer; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | import java.util.concurrent.Semaphore; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.opends.messages.Category; |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | import org.opends.messages.Severity; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.DSInfo; |
| | |
| | | * out which one is the best to connect to. |
| | | */ |
| | | if (debugEnabled()) |
| | | debugInfo("serverId: " + serverId + |
| | | " phase 1 : will perform PhaseOneH with each RS in " + |
| | | " order to elect the preferred one"); |
| | | TRACER.debugInfo("serverId: " + serverId |
| | | + " phase 1 : will perform PhaseOneH with each RS in " |
| | | + " order to elect the preferred one"); |
| | | |
| | | // Get info from every available replication servers |
| | | replicationServerInfos = collectReplicationServersInfo(); |
| | |
| | | |
| | | // Best found, now initialize connection to this one (handshake phase 1) |
| | | if (debugEnabled()) |
| | | debugInfo("serverId: " + serverId + |
| | | " phase 2 : will perform PhaseOneH with the preferred RS=" |
| | | + electedRsInfo); |
| | | TRACER.debugInfo("serverId: " + serverId |
| | | + " phase 2 : will perform PhaseOneH with the preferred RS=" |
| | | + electedRsInfo); |
| | | electedRsInfo = performPhaseOneHandshake( |
| | | electedRsInfo.getServerURL(), true, false); |
| | | |
| | |
| | | |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("RB for dn " + baseDn + |
| | | " and with server id " + Integer.toString(serverId) + " computed " + |
| | | Integer.toString(nChanges) + " changes late."); |
| | | TRACER.debugInfo("RB for dn " + baseDn |
| | | + " and with server id " + Integer.toString(serverId) |
| | | + " computed " + Integer.toString(nChanges) + " changes late."); |
| | | } |
| | | |
| | | /* |
| | |
| | | ReplicationMsg msg = localSession.receive(); |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("In RB for " + baseDn + "\nRB HANDSHAKE SENT:\n" |
| | | + serverStartMsg.toString() + "\nAND RECEIVED:\n" |
| | | + msg.toString()); |
| | | TRACER.debugInfo("In RB for " + baseDn + "\nRB HANDSHAKE SENT:\n" |
| | | + serverStartMsg.toString() + "\nAND RECEIVED:\n" |
| | | + msg.toString()); |
| | | } |
| | | |
| | | // Wrap received message in a server info object |
| | |
| | | |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo(errorMessage.toString()); |
| | | TRACER.debugInfo(errorMessage.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("In RB for " + baseDn + |
| | | "\nRB HANDSHAKE SENT:\n" + startECLSessionMsg.toString()); |
| | | // + "\nAND RECEIVED:\n" + topologyMsg.toString()); |
| | | TRACER.debugInfo("In RB for " + baseDn |
| | | + "\nRB HANDSHAKE SENT:\n" + startECLSessionMsg.toString()); |
| | | } |
| | | |
| | | // Alright set the timeout to the desired value |
| | |
| | | |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("In RB for " + baseDn + |
| | | "\nRB HANDSHAKE SENT:\n" + startSessionMsg.toString() + |
| | | "\nAND RECEIVED:\n" + topologyMsg.toString()); |
| | | TRACER.debugInfo("In RB for " + baseDn |
| | | + "\nRB HANDSHAKE SENT:\n" + startSessionMsg.toString() |
| | | + "\nAND RECEIVED:\n" + topologyMsg.toString()); |
| | | } |
| | | |
| | | // Alright set the timeout to the desired value |
| | |
| | | { |
| | | if (firstConnection) |
| | | { |
| | | // We are no connected to a server yet |
| | | // We are not connected to a server yet |
| | | return computeBestServerForWeight(bestServers, -1, -1); |
| | | } else |
| | | { |
| | |
| | | |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo(this + " end restart : connected=" + connected + " with RSid=" |
| | | + this.getRsServerId() + " genid=" + this.generationID); |
| | | TRACER.debugInfo(this + " end restart : connected=" + connected |
| | | + " with RSid=" + this.getRsServerId() + " genid=" + this.generationID); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("ReplicationBroker.publish() Publishing a " + |
| | | "message is not possible due to existing connection error."); |
| | | TRACER.debugInfo("ReplicationBroker.publish() Publishing a " |
| | | + "message is not possible due to existing connection error."); |
| | | } |
| | | |
| | | return false; |
| | |
| | | // ignore |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("ReplicationBroker.publish() " + |
| | | "Interrupted exception raised : " + e.getLocalizedMessage()); |
| | | TRACER.debugInfo("ReplicationBroker.publish() " |
| | | + "Interrupted exception raised : " + e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | // just loop. |
| | | if (debugEnabled()) |
| | | { |
| | | debugInfo("ReplicationBroker.publish() " + |
| | | "Interrupted exception raised." + e.getLocalizedMessage()); |
| | | TRACER.debugInfo("ReplicationBroker.publish() " |
| | | + "Interrupted exception raised." + e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void stop() |
| | | { |
| | | if (debugEnabled()) |
| | | debugInfo("ReplicationBroker " + serverId + " is stopping and will" + |
| | | " close the connection to replication server " + rsServerId + " for" + |
| | | " domain " + baseDn); |
| | | TRACER.debugInfo("ReplicationBroker " + serverId + " is stopping and will" |
| | | + " close the connection to replication server " + rsServerId + " for" |
| | | + " domain " + baseDn); |
| | | |
| | | synchronized (startStopLock) |
| | | { |
| | |
| | | return connected; |
| | | } |
| | | |
| | | private boolean debugEnabled() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | private static void debugInfo(String s) |
| | | { |
| | | logError(Message.raw(Category.SYNC, Severity.NOTICE, s)); |
| | | TRACER.debugInfo(s); |
| | | } |
| | | |
| | | /** |
| | | * Determine whether the connection to the replication server is encrypted. |
| | | * @return true if the connection is encrypted, false otherwise. |
| | |
| | | public void receiveTopo(TopologyMsg topoMsg) |
| | | { |
| | | if (debugEnabled()) |
| | | debugInfo(this + " receive TopologyMsg=" + topoMsg); |
| | | TRACER.debugInfo(this + " receive TopologyMsg=" + topoMsg); |
| | | |
| | | // Store new DS list |
| | | dsList = topoMsg.getDsList(); |
| | |
| | | } else |
| | | { |
| | | if (debugEnabled()) |
| | | debugInfo(this + |
| | | " is not configured to send CN heartbeat interval"); |
| | | TRACER.debugInfo(this |
| | | + " is not configured to send CN heartbeat interval"); |
| | | } |
| | | } |
| | | |