| | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.replication.common.AssuredMode.*; |
| | | import static org.opends.server.replication.plugin.EntryHistorical.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.service.ReplicationMonitor.*; |
| | |
| | | private final PersistentServerState state; |
| | | private int numReplayedPostOpCalled = 0; |
| | | |
| | | private volatile long generationId = -1; |
| | | private volatile boolean generationIdSavedStatus = false; |
| | | |
| | | private final CSNGenerator generator; |
| | |
| | | private final SortedMap<CSN, FakeOperation> replayOperations = |
| | | new TreeMap<CSN, FakeOperation>(); |
| | | |
| | | private ReplicationDomainCfg config; |
| | | private ExternalChangelogDomain eclDomain; |
| | | |
| | | /** |
| | |
| | | public LDAPReplicationDomain(ReplicationDomainCfg configuration, |
| | | BlockingQueue<UpdateToReplay> updateToReplayQueue) throws ConfigException |
| | | { |
| | | super(configuration.getBaseDN(), |
| | | configuration.getServerId(), |
| | | configuration.getInitializationWindowSize()); |
| | | super(configuration, -1); |
| | | |
| | | this.config = configuration; |
| | | this.updateToReplayQueue = updateToReplayQueue; |
| | | |
| | | // Get assured configuration |
| | |
| | | // Get fractional configuration |
| | | fractionalConfig = new FractionalConfig(getBaseDN()); |
| | | readFractionalConfig(configuration, false); |
| | | |
| | | setGroupId((byte)configuration.getGroupId()); |
| | | setURLs(configuration.getReferralsUrl()); |
| | | |
| | | storeECLConfiguration(configuration); |
| | | |
| | | solveConflictFlag = isSolveConflict(configuration); |
| | | |
| | | Backend backend = retrievesBackend(getBaseDN()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets and stores the assured replication configuration parameters. Returns |
| | | * a boolean indicating if the passed configuration has changed compared to |
| | | * previous values and the changes require a reconnection. |
| | | * @param configuration The configuration object |
| | | * @param allowReconnection Tells if one must reconnect if significant changes |
| | | * occurred |
| | | */ |
| | | private void readAssuredConfig(ReplicationDomainCfg configuration, |
| | | boolean allowReconnection) |
| | | { |
| | | final boolean needReconnection = needReconnection(configuration); |
| | | |
| | | // Disconnect if required: changing configuration values before |
| | | // disconnection would make assured replication used immediately and |
| | | // disconnection could cause some timeouts error. |
| | | if (needReconnection && allowReconnection) |
| | | disableService(); |
| | | |
| | | switch (configuration.getAssuredType()) |
| | | { |
| | | case NOT_ASSURED: |
| | | setAssured(false); |
| | | break; |
| | | case SAFE_DATA: |
| | | setAssured(true); |
| | | setAssuredMode(AssuredMode.SAFE_DATA_MODE); |
| | | break; |
| | | case SAFE_READ: |
| | | setAssured(true); |
| | | setAssuredMode(AssuredMode.SAFE_READ_MODE); |
| | | break; |
| | | } |
| | | setAssuredSdLevel((byte) configuration.getAssuredSdLevel()); |
| | | setAssuredTimeout(configuration.getAssuredTimeout()); |
| | | |
| | | // Reconnect if required |
| | | if (needReconnection && allowReconnection) |
| | | enableService(); |
| | | } |
| | | |
| | | private boolean needReconnection(ReplicationDomainCfg cfg) |
| | | { |
| | | switch (cfg.getAssuredType()) |
| | | { |
| | | case NOT_ASSURED: |
| | | if (isAssured()) |
| | | { |
| | | return true; |
| | | } |
| | | break; |
| | | case SAFE_DATA: |
| | | if (!isAssured() || getAssuredMode() == SAFE_READ_MODE) |
| | | { |
| | | return true; |
| | | } |
| | | break; |
| | | case SAFE_READ: |
| | | if (!isAssured() || getAssuredMode() == SAFE_DATA_MODE) |
| | | { |
| | | return true; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | return isAssured() |
| | | && getAssuredMode() == SAFE_DATA_MODE |
| | | && cfg.getAssuredSdLevel() != getAssuredSdLevel(); |
| | | } |
| | | |
| | | /** |
| | | * Sets the error message id to be used when online import is stopped with |
| | | * error by the fractional replication ldif import plugin. |
| | | * @param importErrorMessageId The message to use. |
| | |
| | | } |
| | | |
| | | // Disable service if configuration changed |
| | | if (needReconnection && allowReconnection) |
| | | final boolean needRestart = needReconnection && allowReconnection; |
| | | if (needRestart) |
| | | { |
| | | disableService(); |
| | | } |
| | |
| | | } |
| | | |
| | | // Reconnect if required |
| | | if (needReconnection && allowReconnection) |
| | | if (needRestart) |
| | | enableService(); |
| | | } |
| | | |
| | |
| | | |
| | | // FIXME should the next call use the initWindow parameter rather than the |
| | | // instance variable? |
| | | super.initializeRemote(target, requestorID, initTask, this.initWindow); |
| | | super.initializeRemote(target, requestorID, initTask, getInitWindow()); |
| | | } |
| | | |
| | | /** |
| | |
| | | DirectoryServer.deregisterAlertGenerator(this); |
| | | |
| | | // stop the ReplicationDomain |
| | | stopDomain(); |
| | | disableService(); |
| | | } |
| | | |
| | | // wait for completion of the persistentServerState thread. |
| | |
| | | return genId; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getGenerationID() |
| | | { |
| | | return generationId; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Run a modify operation to update the entry whose DN is given as |
| | | * a parameter with the generationID information. |