| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.admin.std.server.ReplicationDomainCfg; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.replication.common.*; |
| | | import org.opends.server.replication.plugin.MultimasterReplication; |
| | | import org.opends.server.replication.protocol.*; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.HostPort; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.replication.server.ReplicationServer.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * The tracer object for the debug logger. |
| | | */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | private volatile boolean shutdown = false; |
| | | private final Object startStopLock = new Object(); |
| | | private volatile ReplicationDomainCfg config; |
| | |
| | | * Connect to each replication server and get their ServerState then find |
| | | * out which one is the best to connect to. |
| | | */ |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("phase 1 : will perform PhaseOneH with each RS in order to " |
| | | + "elect the preferred one"); |
| | | |
| | |
| | | replicationServerInfos, serverId, getGroupId(), getGenerationID()); |
| | | |
| | | // Best found, now initialize connection to this one (handshake phase 1) |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("phase 2 : will perform PhaseOneH with the preferred RS=" |
| | | + evals.getBestRS()); |
| | | |
| | |
| | | */ |
| | | |
| | | int nChanges = ServerState.diffChanges(rsState, state); |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("computed " + nChanges + " changes late."); |
| | | } |
| | |
| | | // Read the ReplServerStartMsg or ReplServerStartDSMsg that should |
| | | // come back. |
| | | ReplicationMsg msg = newSession.receive(); |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("RB HANDSHAKE SENT:\n" + serverStartMsg + "\nAND RECEIVED:\n" |
| | | + msg); |
| | |
| | | logError(errorMessage); |
| | | } |
| | | |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | TRACER.debugInfo(errorMessage.toString()); |
| | | logger.trace(errorMessage.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | rs.session.publish(startECLSessionMsg); |
| | | |
| | | // FIXME ECL In the handshake phase two, should RS send back a topo msg ? |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("RB HANDSHAKE SENT:\n" + startECLSessionMsg); |
| | | } |
| | |
| | | // Read the TopologyMsg that should come back. |
| | | final TopologyMsg topologyMsg = (TopologyMsg) session.receive(); |
| | | |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("RB HANDSHAKE SENT:\n" + startSessionMsg |
| | | + "\nAND RECEIVED:\n" + topologyMsg); |
| | |
| | | } |
| | | } |
| | | |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("end restart : connected=" + rs.isConnected() + " with RS(" |
| | | + rs.getServerId() + ") genId=" + generationID); |
| | |
| | | fix the problem when we finally connect. |
| | | */ |
| | | |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("publish(): Publishing a message is not possible due to" |
| | | + " existing connection error."); |
| | |
| | | } catch (InterruptedException e1) |
| | | { |
| | | // ignore |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("publish(): Interrupted exception raised : " |
| | | + e.getLocalizedMessage()); |
| | |
| | | } catch (InterruptedException e) |
| | | { |
| | | // just loop. |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("publish(): Interrupted exception raised." |
| | | + e.getLocalizedMessage()); |
| | |
| | | evals.getEvaluation(bestRsServerId).toString()); |
| | | } |
| | | logError(message); |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("best replication servers evaluation results: " |
| | | + evals); |
| | | reStart(true); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | |
| | | if (!shutdown) |
| | | { |
| | |
| | | */ |
| | | public void stop() |
| | | { |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("is stopping and will close the connection to RS(" |
| | | + getRsServerId() + ")"); |
| | | |
| | |
| | | */ |
| | | private void receiveTopo(TopologyMsg topoMsg, int rsServerId) |
| | | { |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("receive TopologyMsg=" + topoMsg); |
| | | |
| | | // Store new DS list |
| | |
| | | } |
| | | else |
| | | { |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("is not configured to send CSN heartbeat interval"); |
| | | } |
| | | } |
| | |
| | | |
| | | private void debugInfo(String message) |
| | | { |
| | | TRACER.debugInfo(getClass().getSimpleName() + " for baseDN=" + getBaseDN() |
| | | logger.trace(getClass().getSimpleName() + " for baseDN=" + getBaseDN() |
| | | + " and serverId=" + getServerId() + " " + message); |
| | | } |
| | | } |