| | |
| | | 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.replication.protocol.ProtocolVersion.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | |
| | | { |
| | | try |
| | | { |
| | | protocolVersion = ProtocolVersion.minWithCurrent( |
| | | inECLStartMsg.getVersion()); |
| | | generationId = inECLStartMsg.getGenerationId(); |
| | | session.setProtocolVersion(getCompatibleVersion(inECLStartMsg |
| | | .getVersion())); |
| | | serverURL = inECLStartMsg.getServerURL(); |
| | | setInitialServerState(inECLStartMsg.getServerState()); |
| | | setSendWindowSize(inECLStartMsg.getWindowSize()); |
| | | if (protocolVersion > ProtocolVersion.REPLICATION_PROTOCOL_V1) |
| | | if (getProtocolVersion() > ProtocolVersion.REPLICATION_PROTOCOL_V1) |
| | | { |
| | | // We support connection from a V1 RS |
| | | // Only V2 protocol has the group id in repl server start message |
| | |
| | | } |
| | | |
| | | /** |
| | | * Send the ReplServerStartDSMsg to the remote ECL server. |
| | | * @param requestedProtocolVersion The provided protocol version. |
| | | * Sends a start message to the remote ECL server. |
| | | * |
| | | * @return The StartMsg sent. |
| | | * @throws IOException When an exception occurs. |
| | | * @throws IOException |
| | | * When an exception occurs. |
| | | */ |
| | | private StartMsg sendStartToRemote(short requestedProtocolVersion) |
| | | throws IOException |
| | | private StartMsg sendStartToRemote() throws IOException |
| | | { |
| | | final StartMsg startMsg; |
| | | |
| | | // Before V4 protocol, we sent a ReplServerStartMsg |
| | | if (protocolVersion < ProtocolVersion.REPLICATION_PROTOCOL_V4) |
| | | if (getProtocolVersion() < ProtocolVersion.REPLICATION_PROTOCOL_V4) |
| | | { |
| | | |
| | | // Peer DS uses protocol < V4 : send it a ReplServerStartMsg |
| | | ReplServerStartMsg outReplServerStartMsg |
| | | = new ReplServerStartMsg( |
| | | replicationServerId, |
| | | replicationServerURL, |
| | | getServiceId(), |
| | | maxRcvWindow, |
| | | startMsg = new ReplServerStartMsg(replicationServerId, |
| | | replicationServerURL, getServiceId(), maxRcvWindow, |
| | | replicationServerDomain.getDbServerState(), |
| | | protocolVersion, |
| | | localGenerationId, |
| | | sslEncryption, |
| | | getLocalGroupId(), |
| | | replicationServerDomain. |
| | | getReplicationServer().getDegradedStatusThreshold()); |
| | | |
| | | session.publish(outReplServerStartMsg, requestedProtocolVersion); |
| | | |
| | | return outReplServerStartMsg; |
| | | localGenerationId, sslEncryption, getLocalGroupId(), |
| | | replicationServerDomain.getReplicationServer() |
| | | .getDegradedStatusThreshold()); |
| | | } |
| | | else |
| | | { |
| | | // Peer DS uses protocol V4 : send it a ReplServerStartDSMsg |
| | | ReplServerStartDSMsg outReplServerStartDSMsg |
| | | = new ReplServerStartDSMsg( |
| | | replicationServerId, |
| | | replicationServerURL, |
| | | getServiceId(), |
| | | maxRcvWindow, |
| | | new ServerState(), |
| | | protocolVersion, |
| | | localGenerationId, |
| | | sslEncryption, |
| | | getLocalGroupId(), |
| | | 0, |
| | | replicationServer.getWeight(), |
| | | 0); |
| | | |
| | | |
| | | session.publish(outReplServerStartDSMsg); |
| | | return outReplServerStartDSMsg; |
| | | startMsg = new ReplServerStartDSMsg(replicationServerId, |
| | | replicationServerURL, getServiceId(), maxRcvWindow, |
| | | new ServerState(), localGenerationId, sslEncryption, |
| | | getLocalGroupId(), 0, replicationServer.getWeight(), 0); |
| | | } |
| | | |
| | | send(startMsg); |
| | | return startMsg; |
| | | } |
| | | |
| | | /** |
| | |
| | | processStartFromRemote(inECLStartMsg); |
| | | |
| | | // lock with timeout |
| | | if (this.replicationServerDomain != null) |
| | | if (replicationServerDomain != null) |
| | | { |
| | | lockDomain(true); |
| | | } |
| | | |
| | | this.localGenerationId = -1; |
| | | localGenerationId = -1; |
| | | |
| | | // send start to remote |
| | | StartMsg outStartMsg = |
| | | sendStartToRemote(protocolVersion); |
| | | StartMsg outStartMsg = sendStartToRemote(); |
| | | |
| | | // log |
| | | logStartHandshakeRCVandSND(inECLStartMsg, outStartMsg); |