| | |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | // and to take appropriate actions. |
| | | DirectoryServer.notifyRestoreBeginning(backend, restoreConfig); |
| | | |
| | | // Disable the backend. |
| | | if ( !verifyOnly) |
| | | { |
| | | try |
| | | { |
| | | TaskUtils.disableBackend(backendID); |
| | | } catch (DirectoryException e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | logger.error(e.getMessageObject()); |
| | | return TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | } |
| | | |
| | | // From here we must make sure to re-enable the backend before returning. |
| | | /* |
| | | * From here the listeners must be told that the restore is over whichever way this |
| | | * method returns: a listener which took something offline when it began - a |
| | | * replication domain disables itself - gets no other chance to put it back. |
| | | */ |
| | | boolean backendDisabled = false; |
| | | boolean errorsEncountered = false; |
| | | try |
| | | { |
| | | // Disable the backend. From here the finally below re-enables it before returning. |
| | | if ( !verifyOnly) |
| | | { |
| | | try |
| | | { |
| | | TaskUtils.disableBackend(backendID); |
| | | backendDisabled = true; |
| | | } catch (DirectoryException e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | logger.error(e.getMessageObject()); |
| | | errorsEncountered = true; |
| | | return TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | } |
| | | |
| | | // Acquire an exclusive lock for the backend. |
| | | if (verifyOnly || lockBackend(backend)) |
| | | { |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | DirectoryServer.notifyRestoreEnded(backend, restoreConfig, false); |
| | | logger.error(ERR_RESTOREDB_ERROR_DURING_BACKUP, backupID, backupDir.getPath(), de.getMessageObject()); |
| | | errorsEncountered = true; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | DirectoryServer.notifyRestoreEnded(backend, restoreConfig, false); |
| | | logger.error(ERR_RESTOREDB_ERROR_DURING_BACKUP, backupID, backupDir.getPath(), getExceptionMessage(e)); |
| | | errorsEncountered = true; |
| | | } |
| | |
| | | } |
| | | finally |
| | | { |
| | | // Enable the backend. |
| | | if (! verifyOnly) |
| | | // Enable the backend, if it was this task which disabled it. |
| | | if (backendDisabled) |
| | | { |
| | | try |
| | | { |
| | |
| | | errorsEncountered = true; |
| | | } |
| | | } |
| | | DirectoryServer.notifyRestoreEnded(backend, restoreConfig, true); |
| | | // Notified once, after the backend is back, so that a listener can read it again. |
| | | DirectoryServer.notifyRestoreEnded(backend, restoreConfig, !errorsEncountered); |
| | | } |
| | | |
| | | if (errorsEncountered) |