| | |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.replication.common.ServerStatus; |
| | | import org.opends.server.replication.protocol.ReplicaOfflineMsg; |
| | | import org.opends.server.replication.protocol.Session; |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | import org.opends.server.replication.service.DSRSShutdownSync; |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.replication.common.ServerStatus.*; |
| | |
| | | private final Session session; |
| | | private final ServerHandler handler; |
| | | private final ReplicationServerDomain replicationServerDomain; |
| | | |
| | | |
| | | private final DSRSShutdownSync dsrsShutdownSync; |
| | | |
| | | /** |
| | | * Create a ServerWriter. Then ServerWriter then waits on the ServerHandler |
| | |
| | | * handler for which the ServerWriter is created. |
| | | * @param replicationServerDomain |
| | | * The ReplicationServerDomain of this ServerWriter. |
| | | * @param dsrsShutdownSync Synchronization object for shutdown of combined DS/RS instances. |
| | | */ |
| | | public ServerWriter(Session session, ServerHandler handler, |
| | | ReplicationServerDomain replicationServerDomain) |
| | | ReplicationServerDomain replicationServerDomain, |
| | | DSRSShutdownSync dsrsShutdownSync) |
| | | { |
| | | // Session may be null for ECLServerWriter. |
| | | super("Replication server RS(" + handler.getReplicationServerId() |
| | |
| | | this.session = session; |
| | | this.handler = handler; |
| | | this.replicationServerDomain = replicationServerDomain; |
| | | this.dsrsShutdownSync = dsrsShutdownSync; |
| | | } |
| | | |
| | | /** |
| | |
| | | LocalizableMessage errMessage = null; |
| | | try |
| | | { |
| | | while (true) |
| | | boolean shutdown = false; |
| | | while (!shutdown |
| | | || !dsrsShutdownSync.canShutdown(replicationServerDomain.getBaseDN())) |
| | | { |
| | | final UpdateMsg updateMsg = replicationServerDomain.take(this.handler); |
| | | if (updateMsg == null) |
| | |
| | | // this connection is closing |
| | | errMessage = LocalizableMessage.raw( |
| | | "Connection closure: null update returned by domain."); |
| | | return; |
| | | shutdown = true; |
| | | } |
| | | else if (!isUpdateMsgFiltered(updateMsg)) |
| | | { |
| | | // Publish the update to the remote server using a protocol version it supports |
| | | session.publish(updateMsg); |
| | | if (updateMsg instanceof ReplicaOfflineMsg) |
| | | { |
| | | dsrsShutdownSync.replicaOfflineMsgForwarded(replicationServerDomain.getBaseDN()); |
| | | } |
| | | } |
| | | } |
| | | } |