| | |
| | | { |
| | | if (rsUpdater == this) |
| | | { |
| | | rsUpdater = null; |
| | | broker.setRecoveryRequired(false); |
| | | releasePublisher(); |
| | | startTheSessionAgain = true; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** Called under recoveryLock. Leaving the publisher does not prove delivery. */ |
| | | private void releasePublisher() |
| | | { |
| | | rsUpdater = null; |
| | | if (pendingChanges.isRecovering()) |
| | | { |
| | | broker.recoveryAborted(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Waits before the session restart a failed run asks for: one second more for each failure in a |
| | | * row, up to ten. A session which hands its start over meanwhile ends the wait, as it is the next |
| | |
| | | { |
| | | final RecoveryStart start = nextStart; |
| | | nextStart = null; |
| | | if (start == null || shutdown.get()) |
| | | if (start == null || stopRecoveryForShutdown()) |
| | | { |
| | | // RSUpdater thread has finished its work, let's remove it from memory |
| | | // so another RSUpdater thread can be started if needed. |
| | | rsUpdater = null; |
| | | broker.setRecoveryRequired(false); |
| | | releasePublisher(); |
| | | return null; |
| | | } |
| | | return start; |
| | |
| | | @Override |
| | | protected void importBackend(InputStream input) throws DirectoryException |
| | | { |
| | | importBackend(input, () -> { }); |
| | | } |
| | | |
| | | @Override |
| | | protected void importBackend(InputStream input, ImportPreparation onPrepared) throws DirectoryException |
| | | { |
| | | LocalBackend<?> backend = getBackend(); |
| | | |
| | | LDIFImportConfig importConfig = null; |
| | |
| | | ? ERR_INIT_PREPARATION_INTERRUPTED.get(getBaseDN()) |
| | | : ERR_INIT_OPERATIONS_NOT_DRAINED.get(getBaseDN()); |
| | | logger.error(reason); |
| | | ieCtx.setExceptionIfNoneSet(new DirectoryException(ResultCode.UNAVAILABLE, reason)); |
| | | ieCtx.failImportPreparation(new DirectoryException(ResultCode.UNAVAILABLE, reason)); |
| | | return; |
| | | } |
| | | onPrepared.reportReady(); |
| | | |
| | | if (!backend.supports(BackendOperation.LDIF_IMPORT)) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** A shutdown still announcing this replica may drain the replacement within the broker stop deadline. */ |
| | | private boolean stopRecoveryForShutdown() |
| | | { |
| | | return shutdown.get() && !pendingChanges.isPublishingOffline(); |
| | | } |
| | | |
| | | /** |
| | | * Has the changes of this replica which come after the provided CSN published on the session |
| | | * which starts: starts the thread which publishes them, or hands the start over to the one which |
| | |
| | | if (replServerMisses) |
| | | { |
| | | pendingChanges.setRecovering(true); |
| | | broker.setRecoveryRequired(true); |
| | | } |
| | | else if (!pendingChanges.isRecovering()) |
| | | { |
| | | // The publisher of an earlier session ended it since it was checked. |
| | | return; |
| | | } |
| | | broker.setRecoveryRequired(true); |
| | | if (rsUpdater == null) |
| | | { |
| | | rsUpdater = new RSUpdater(start); |
| | |
| | | boolean holdBackLocalChanges = false; |
| | | while (true) |
| | | { |
| | | if (shutdown.get() || missingChanges.startHandedOver()) |
| | | if (stopRecoveryForShutdown() || missingChanges.startHandedOver()) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | MissingChangesRound round = publish(fromCSN, true); |
| | | while (round != null && round.succeeded && !round.caughtUp) |
| | | { |
| | | if (shutdown.get()) |
| | | if (stopRecoveryForShutdown()) |
| | | { |
| | | return null; |
| | | } |
| | |
| | | { |
| | | for (LDAPUpdateMsg msg : recent.messages) |
| | | { |
| | | if (shutdown.get()) |
| | | if (stopRecoveryForShutdown()) |
| | | { |
| | | return null; |
| | | } |
| | |
| | | |
| | | for (FakeOperation opToSend : opsToSend.values()) |
| | | { |
| | | if (shutdown.get()) |
| | | if (stopRecoveryForShutdown()) |
| | | { |
| | | return null; |
| | | } |
| | |
| | | CSN publishedUpTo = fromCSN; |
| | | for (LDAPUpdateMsg msg : kept) |
| | | { |
| | | if (shutdown.get()) |
| | | if (stopRecoveryForShutdown()) |
| | | { |
| | | return null; |
| | | } |