From d5193b4f72a86a30a116b4629d1db5231dd42992 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Mon, 26 Mar 2007 07:17:13 +0000
Subject: [PATCH] This commit allows to complete issues 504, 505 and 507 by using the new import/export/backup/restore interface to get notifications of import and restore and then resynchronize the server approprietely.
---
opends/src/server/org/opends/server/synchronization/plugin/MultimasterSynchronization.java | 177 +++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 131 insertions(+), 46 deletions(-)
diff --git a/opends/src/server/org/opends/server/synchronization/plugin/MultimasterSynchronization.java b/opends/src/server/org/opends/server/synchronization/plugin/MultimasterSynchronization.java
index bce232b..e71fd3b 100644
--- a/opends/src/server/org/opends/server/synchronization/plugin/MultimasterSynchronization.java
+++ b/opends/src/server/org/opends/server/synchronization/plugin/MultimasterSynchronization.java
@@ -30,9 +30,14 @@
import java.util.List;
import java.util.Map;
+import org.opends.server.api.Backend;
+import org.opends.server.api.BackupTaskListener;
import org.opends.server.api.ConfigAddListener;
import org.opends.server.api.ConfigChangeListener;
import org.opends.server.api.ConfigDeleteListener;
+import org.opends.server.api.ExportTaskListener;
+import org.opends.server.api.ImportTaskListener;
+import org.opends.server.api.RestoreTaskListener;
import org.opends.server.api.SynchronizationProvider;
import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
@@ -47,8 +52,12 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.Operation;
+import org.opends.server.types.BackupConfig;
import org.opends.server.types.ConfigChangeResult;
+import org.opends.server.types.LDIFExportConfig;
+import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.Modification;
+import org.opends.server.types.RestoreConfig;
import org.opends.server.types.ResultCode;
import org.opends.server.types.SynchronizationProviderResult;
@@ -63,7 +72,10 @@
* as pre-op, conflictRsolution, and post-op.
*/
public class MultimasterSynchronization extends SynchronizationProvider
- implements ConfigAddListener, ConfigDeleteListener, ConfigChangeListener
+ implements ConfigAddListener, ConfigDeleteListener, ConfigChangeListener,
+ BackupTaskListener, RestoreTaskListener, ImportTaskListener,
+ ExportTaskListener
+
{
static String CHANGELOG_DN = "cn=Changelog Server," +
"cn=Multimaster Synchronization, cn=Synchronization Providers, cn=config";
@@ -131,6 +143,11 @@
{
processSchemaChange(offlineSchemaChanges);
}
+
+ DirectoryServer.registerBackupTaskListener(this);
+ DirectoryServer.registerRestoreTaskListener(this);
+ DirectoryServer.registerExportTaskListener(this);
+ DirectoryServer.registerImportTaskListener(this);
}
/**
@@ -453,6 +470,11 @@
// shutdown the Changelog Service if necessary
if (changelog != null)
changelog.shutdown();
+
+ DirectoryServer.deregisterBackupTaskListener(this);
+ DirectoryServer.deregisterRestoreTaskListener(this);
+ DirectoryServer.deregisterExportTaskListener(this);
+ DirectoryServer.deregisterImportTaskListener(this);
}
/**
@@ -504,51 +526,6 @@
return;
}
-
- /**
- * Handle a Notification of restore start from the core server.
- *
- * @param dn The baseDn of the restore.
- */
- public static void notificationRestoreStart(DN dn)
- {
- SynchronizationDomain domain = findDomain(dn, null);
- domain.disable();
- }
-
- /**
- * Handle a Notification of restore end from the core server.
- *
- * @param dn The baseDn of the restore.
- */
- public static void notificationRestoreEnd(DN dn)
- {
- SynchronizationDomain domain = findDomain(dn, null);
- domain.enable();
- }
-
- /**
- * Handle a Notification of backup start from the core server.
- *
- * @param dn The baseDn of the backup.
- */
- public static void notificationBackupStart(DN dn)
- {
- SynchronizationDomain domain = findDomain(dn, null);
- domain.backupStart();
- }
-
- /**
- * Handle a Notification of backup end from the core server.
- *
- * @param dn The baseDn of the backup.
- */
- public static void notificationBackupEnd(DN dn)
- {
- SynchronizationDomain domain = findDomain(dn, null);
- domain.backupEnd();
- }
-
/**
* This method is called whenever the server detects a modification
* of the schema done by directly modifying the backing files
@@ -566,6 +543,114 @@
if (domain != null)
domain.synchronizeModifications(modifications);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public void processBackupBegin(Backend backend, BackupConfig config)
+ {
+ for (DN dn : backend.getBaseDNs())
+ {
+ SynchronizationDomain domain = findDomain(dn, null);
+ if (domain != null)
+ domain.backupStart();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void processBackupEnd(Backend backend, BackupConfig config,
+ boolean successful)
+ {
+ for (DN dn : backend.getBaseDNs())
+ {
+ SynchronizationDomain domain = findDomain(dn, null);
+ if (domain != null)
+ domain.backupEnd();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void processRestoreBegin(Backend backend, RestoreConfig config)
+ {
+ for (DN dn : backend.getBaseDNs())
+ {
+ SynchronizationDomain domain = findDomain(dn, null);
+ if (domain != null)
+ domain.disable();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void processRestoreEnd(Backend backend, RestoreConfig config,
+ boolean successful)
+ {
+ for (DN dn : backend.getBaseDNs())
+ {
+ SynchronizationDomain domain = findDomain(dn, null);
+ if (domain != null)
+ domain.enable();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void processImportBegin(Backend backend, LDIFImportConfig config)
+ {
+ for (DN dn : backend.getBaseDNs())
+ {
+ SynchronizationDomain domain = findDomain(dn, null);
+ if (domain != null)
+ domain.disable();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void processImportEnd(Backend backend, LDIFImportConfig config,
+ boolean successful)
+ {
+ for (DN dn : backend.getBaseDNs())
+ {
+ SynchronizationDomain domain = findDomain(dn, null);
+ if (domain != null)
+ domain.enable();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void processExportBegin(Backend backend, LDIFExportConfig config)
+ {
+ for (DN dn : backend.getBaseDNs())
+ {
+ SynchronizationDomain domain = findDomain(dn, null);
+ if (domain != null)
+ domain.backupStart();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void processExportEnd(Backend backend, LDIFExportConfig config,
+ boolean successful)
+ {
+ for (DN dn : backend.getBaseDNs())
+ {
+ SynchronizationDomain domain = findDomain(dn, null);
+ if (domain != null)
+ domain.backupEnd();
+ }
+ }
}
--
Gitblit v1.10.0