| | |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.getTracer; |
| | | import static org.opends.server.util.StaticUtils.getExceptionMessage; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.StringReader; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.admin.std.server.LocalDBBackendCfg; |
| | | import org.opends.server.admin.std.server.ReplicationServerCfg; |
| | | import org.opends.server.admin.std.server.ReplicationSynchronizationProviderCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.std.server.SynchronizationProviderCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.SynchronizationProvider; |
| | | import org.opends.server.backends.jeb.BackupManager; |
| | |
| | | // The set of supported features for this backend. |
| | | private HashSet<String> supportedFeatures; |
| | | |
| | | // The directory associated with this backend. |
| | | private BackupDirectory backendDirectory; |
| | | |
| | | ReplicationServer server; |
| | | private ReplicationServer server; |
| | | |
| | | /** |
| | | * The configuration of this backend. |
| | | */ |
| | | private LocalDBBackendCfg cfg; |
| | | private BackendCfg cfg; |
| | | |
| | | /** |
| | | * The number of milliseconds between job progress reports. |
| | |
| | | if (config != null) |
| | | { |
| | | Validator.ensureTrue(config instanceof BackendCfg); |
| | | cfg = (LocalDBBackendCfg)config; |
| | | cfg = (BackendCfg)config; |
| | | DN[] baseDNs = new DN[cfg.getBaseDN().size()]; |
| | | cfg.getBaseDN().toArray(baseDNs); |
| | | setBaseDNs(baseDNs); |
| | | backendDirectory = new BackupDirectory( |
| | | cfg.getDBDirectory(), null); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | server = retrievesReplicationServer(); |
| | | server = getReplicationServer(); |
| | | if (server == null) |
| | | { |
| | | return 0; |
| | |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | BackupManager backupManager = |
| | | new BackupManager(getBackendID()); |
| | | backupManager.createBackup(cfg, backupConfig); |
| | | BackupManager backupManager = new BackupManager(getBackendID()); |
| | | File backendDir = getFileForPath(getReplicationServerCfg() |
| | | .getReplicationDBDirectory()); |
| | | backupManager.createBackup(backendDir, backupConfig); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | BackupManager backupManager = |
| | | new BackupManager(getBackendID()); |
| | | backupManager.removeBackup(this.backendDirectory, backupID); |
| | | backupManager.removeBackup(backupDirectory, backupID); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | BackupManager backupManager = |
| | | new BackupManager(getBackendID()); |
| | | backupManager.restoreBackup(cfg, restoreConfig); |
| | | File backendDir = getFileForPath(getReplicationServerCfg() |
| | | .getReplicationDBDirectory()); |
| | | backupManager.restoreBackup(backendDir, restoreConfig); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * This class reports progress of the export job at fixed intervals. |
| | | */ |
| | | class ProgressTask extends TimerTask |
| | | private final class ProgressTask extends TimerTask |
| | | { |
| | | /** |
| | | * The number of entries that had been exported at the time of the |
| | |
| | | |
| | | if (server==null) |
| | | { |
| | | server = retrievesReplicationServer(); |
| | | server = getReplicationServer(); |
| | | |
| | | if (server == null) |
| | | { |
| | |
| | | * @return The server retrieved |
| | | * @throws DirectoryException When it occurs. |
| | | */ |
| | | protected static ReplicationServer retrievesReplicationServer() |
| | | throws DirectoryException |
| | | private ReplicationServer getReplicationServer() throws DirectoryException |
| | | { |
| | | ReplicationServer replicationServer = null; |
| | | |
| | | DirectoryServer.getSynchronizationProviders(); |
| | | for (SynchronizationProvider provider : |
| | | for (SynchronizationProvider<?> provider : |
| | | DirectoryServer.getSynchronizationProviders()) |
| | | { |
| | | if (provider instanceof MultimasterReplication) |
| | |
| | | return replicationServer; |
| | | } |
| | | |
| | | // Find the replication server configuration associated with this |
| | | // replication backend. |
| | | private ReplicationServerCfg getReplicationServerCfg() |
| | | throws DirectoryException { |
| | | RootCfg root = ServerManagementContext.getInstance().getRootConfiguration(); |
| | | |
| | | for (String name : root.listSynchronizationProviders()) { |
| | | SynchronizationProviderCfg cfg; |
| | | try { |
| | | cfg = root.getSynchronizationProvider(name); |
| | | } catch (ConfigException e) { |
| | | throw new DirectoryException(ResultCode.OPERATIONS_ERROR, |
| | | ERR_REPLICATION_SERVER_CONFIG_NOT_FOUND.get(), e); |
| | | } |
| | | if (cfg instanceof ReplicationSynchronizationProviderCfg) { |
| | | ReplicationSynchronizationProviderCfg scfg = |
| | | (ReplicationSynchronizationProviderCfg) cfg; |
| | | try { |
| | | return scfg.getReplicationServer(); |
| | | } catch (ConfigException e) { |
| | | throw new DirectoryException(ResultCode.OPERATIONS_ERROR, |
| | | ERR_REPLICATION_SERVER_CONFIG_NOT_FOUND.get(), e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // No replication server found. |
| | | throw new DirectoryException(ResultCode.OPERATIONS_ERROR, |
| | | ERR_REPLICATION_SERVER_CONFIG_NOT_FOUND.get()); |
| | | } |
| | | |
| | | /** |
| | | * Writer class to read/write from/to a bytearray. |
| | | */ |