| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | 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.util.StaticUtils.*; |
| | | |
| | | import java.net.SocketException; |
| | | import java.util.NoSuchElementException; |
| | | |
| | |
| | | import org.opends.server.replication.protocol.Session; |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | |
| | | 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.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines a server writer, which is used to send changes to a |
| | |
| | | ReplicationServerDomain replicationServerDomain) |
| | | { |
| | | // Session may be null for ECLServerWriter. |
| | | super("Replication server RS(" |
| | | + handler.getReplicationServerId() |
| | | + ") writing to " |
| | | + handler.toString() |
| | | + " at " |
| | | + ((session != null) ? session.getReadableRemoteAddress() |
| | | : "unknown")); |
| | | super("Replication server RS(" + handler.getReplicationServerId() |
| | | + ") writing to " + handler + " at " |
| | | + (session != null ? session.getReadableRemoteAddress() : "unknown")); |
| | | |
| | | this.session = session; |
| | | this.handler = handler; |
| | |
| | | @Override |
| | | public void run() |
| | | { |
| | | Message errMessage = null; |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugInfo(this.getName() + " starting"); |
| | | TRACER.debugInfo(getName() + " starting"); |
| | | } |
| | | |
| | | Message errMessage = null; |
| | | try |
| | | { |
| | | while (true) |
| | |
| | | * mode (most of the time). |
| | | */ |
| | | ServerStatus dsStatus = handler.getStatus(); |
| | | if ((dsStatus == ServerStatus.BAD_GEN_ID_STATUS) || |
| | | (dsStatus == ServerStatus.FULL_UPDATE_STATUS)) |
| | | if (dsStatus == ServerStatus.BAD_GEN_ID_STATUS |
| | | || dsStatus == ServerStatus.FULL_UPDATE_STATUS) |
| | | { |
| | | long referenceGenerationId = |
| | | replicationServerDomain.getGenerationId(); |
| | |
| | | */ |
| | | long referenceGenerationId = |
| | | replicationServerDomain.getGenerationId(); |
| | | if ((referenceGenerationId != handler.getGenerationId()) || |
| | | (referenceGenerationId == -1) || (handler.getGenerationId() == -1)) |
| | | if (referenceGenerationId != handler.getGenerationId() |
| | | || referenceGenerationId == -1 |
| | | || handler.getGenerationId() == -1) |
| | | { |
| | | logError( |
| | | WARN_IGNORING_UPDATE_TO_RS.get( |
| | |
| | | } |
| | | } |
| | | |
| | | /* |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugInfo( |
| | | "In " + replicationServerDomain.getReplicationServer(). |
| | | getMonitorInstanceName() + |
| | | ", writer to " + this.handler.getMonitorInstanceName() + |
| | | " publishes msg=[" + update.toString() + "]"+ |
| | | " refgenId=" + referenceGenerationId + |
| | | " isAssured=" + update.isAssured() + |
| | | " server=" + handler.getServerId() + |
| | | " generationId=" + handler.getGenerationId()); |
| | | } |
| | | */ |
| | | |
| | | // Publish the update to the remote server using a protocol version he |
| | | // it supports |
| | | session.publish(update); |
| | |
| | | * An unexpected error happened. |
| | | * Log an error and close the connection. |
| | | */ |
| | | errMessage = ERR_WRITER_UNEXPECTED_EXCEPTION.get(handler.toString() + |
| | | errMessage = ERR_WRITER_UNEXPECTED_EXCEPTION.get(handler + |
| | | " " + stackTraceToSingleLineString(e)); |
| | | logError(errMessage); |
| | | } |
| | |
| | | replicationServerDomain.stopServer(handler, false); |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugInfo(this.getName() + " stopped " + errMessage); |
| | | TRACER.debugInfo(getName() + " stopped " + errMessage); |
| | | } |
| | | } |
| | | } |