| | |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.Privilege; |
| | |
| | | // The degraded state is set(if present in args) |
| | | // during the initialization. |
| | | rebuildConfig.isClearDegradedState(isClearDegradedState); |
| | | boolean isBackendNeedToBeEnabled = false; |
| | | |
| | | if (tmpDirectory == null) |
| | | { |
| | |
| | | String lockFile = LockFileManager.getBackendLockFileName(backend); |
| | | StringBuilder failureReason = new StringBuilder(); |
| | | |
| | | // Disable the backend. |
| | | // Disable the backend |
| | | // Except in 'cleardegradedstate' mode we don't need to disable it. |
| | | if (!isClearDegradedState) |
| | | { |
| | |
| | | BackendImpl jebBackend = (BackendImpl) backend; |
| | | jebBackend.rebuildBackend(rebuildConfig); |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | // This exception catches all 'index not found' |
| | | // The backend needs to be re-enabled at the end of the process. |
| | | Message message = |
| | | ERR_REBUILDINDEX_ERROR_DURING_REBUILD.get(e.getMessage()); |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logError(message); |
| | | isBackendNeedToBeEnabled = true; |
| | | returnCode = TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | logError(message); |
| | | returnCode = TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | |
| | | // Release the lock on the backend. |
| | | finally |
| | | { |
| | | // Release the lock on the backend. |
| | | try |
| | | { |
| | | lockFile = LockFileManager.getBackendLockFileName(backend); |
| | |
| | | |
| | | // The backend must be enabled only if the task is successful |
| | | // for prevent potential risks of database corruption. |
| | | if (returnCode == TaskState.COMPLETED_SUCCESSFULLY && !isClearDegradedState) |
| | | if ((returnCode == TaskState.COMPLETED_SUCCESSFULLY |
| | | || (isBackendNeedToBeEnabled)) && !isClearDegradedState) |
| | | { |
| | | // Enable the backend. |
| | | try |