From 3ef361dfc380b2e3cb1bb522d750a4b9a48a4f4a Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 08 Jan 2014 10:17:03 +0000
Subject: [PATCH] Replaced/removed numerous fields and methods of ReplicationDomain by directly storing the config. Changed a lot of subclasses due to this change.

---
 opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java |  100 +++-----------------------------------------------
 1 files changed, 6 insertions(+), 94 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 5dbbd5c..7b9a5b4 100644
--- a/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -77,7 +77,6 @@
 import static org.opends.messages.ToolMessages.*;
 import static org.opends.server.loggers.ErrorLogger.*;
 import static org.opends.server.loggers.debug.DebugLogger.*;
-import static org.opends.server.replication.common.AssuredMode.*;
 import static org.opends.server.replication.plugin.EntryHistorical.*;
 import static org.opends.server.replication.protocol.OperationContext.*;
 import static org.opends.server.replication.service.ReplicationMonitor.*;
@@ -186,7 +185,6 @@
   private final PersistentServerState state;
   private int numReplayedPostOpCalled = 0;
 
-  private volatile long generationId = -1;
   private volatile boolean generationIdSavedStatus = false;
 
   private final CSNGenerator generator;
@@ -227,7 +225,6 @@
   private final SortedMap<CSN, FakeOperation> replayOperations =
     new TreeMap<CSN, FakeOperation>();
 
-  private ReplicationDomainCfg config;
   private ExternalChangelogDomain eclDomain;
 
   /**
@@ -471,11 +468,8 @@
   public LDAPReplicationDomain(ReplicationDomainCfg configuration,
       BlockingQueue<UpdateToReplay> updateToReplayQueue) throws ConfigException
   {
-    super(configuration.getBaseDN(),
-          configuration.getServerId(),
-          configuration.getInitializationWindowSize());
+    super(configuration, -1);
 
-    this.config = configuration;
     this.updateToReplayQueue = updateToReplayQueue;
 
     // Get assured configuration
@@ -484,12 +478,7 @@
     // Get fractional configuration
     fractionalConfig = new FractionalConfig(getBaseDN());
     readFractionalConfig(configuration, false);
-
-    setGroupId((byte)configuration.getGroupId());
-    setURLs(configuration.getReferralsUrl());
-
     storeECLConfiguration(configuration);
-
     solveConflictFlag = isSolveConflict(configuration);
 
     Backend backend = retrievesBackend(getBaseDN());
@@ -551,76 +540,6 @@
   }
 
   /**
-   * Gets and stores the assured replication configuration parameters. Returns
-   * a boolean indicating if the passed configuration has changed compared to
-   * previous values and the changes require a reconnection.
-   * @param configuration The configuration object
-   * @param allowReconnection Tells if one must reconnect if significant changes
-   *        occurred
-   */
-  private void readAssuredConfig(ReplicationDomainCfg configuration,
-    boolean allowReconnection)
-  {
-    final boolean needReconnection = needReconnection(configuration);
-
-    // Disconnect if required: changing configuration values before
-    // disconnection would make assured replication used immediately and
-    // disconnection could cause some timeouts error.
-    if (needReconnection && allowReconnection)
-      disableService();
-
-    switch (configuration.getAssuredType())
-    {
-    case NOT_ASSURED:
-      setAssured(false);
-      break;
-    case SAFE_DATA:
-      setAssured(true);
-      setAssuredMode(AssuredMode.SAFE_DATA_MODE);
-      break;
-    case SAFE_READ:
-      setAssured(true);
-      setAssuredMode(AssuredMode.SAFE_READ_MODE);
-      break;
-    }
-    setAssuredSdLevel((byte) configuration.getAssuredSdLevel());
-    setAssuredTimeout(configuration.getAssuredTimeout());
-
-    // Reconnect if required
-    if (needReconnection && allowReconnection)
-      enableService();
-  }
-
-  private boolean needReconnection(ReplicationDomainCfg cfg)
-  {
-    switch (cfg.getAssuredType())
-    {
-    case NOT_ASSURED:
-      if (isAssured())
-      {
-        return true;
-      }
-      break;
-    case SAFE_DATA:
-      if (!isAssured() || getAssuredMode() == SAFE_READ_MODE)
-      {
-        return true;
-      }
-      break;
-    case SAFE_READ:
-      if (!isAssured() || getAssuredMode() == SAFE_DATA_MODE)
-      {
-        return true;
-      }
-      break;
-    }
-
-    return isAssured()
-        && getAssuredMode() == SAFE_DATA_MODE
-        && cfg.getAssuredSdLevel() != getAssuredSdLevel();
-  }
-
-  /**
    * Sets the error message id to be used when online import is stopped with
    * error by the fractional replication ldif import plugin.
    * @param importErrorMessageId The message to use.
@@ -686,7 +605,8 @@
     }
 
     // Disable service if configuration changed
-    if (needReconnection && allowReconnection)
+    final boolean needRestart = needReconnection && allowReconnection;
+    if (needRestart)
     {
       disableService();
     }
@@ -713,7 +633,7 @@
     }
 
     // Reconnect if required
-    if (needReconnection && allowReconnection)
+    if (needRestart)
       enableService();
   }
 
@@ -1622,7 +1542,7 @@
 
     // FIXME should the next call use the initWindow parameter rather than the
     // instance variable?
-    super.initializeRemote(target, requestorID, initTask, this.initWindow);
+    super.initializeRemote(target, requestorID, initTask, getInitWindow());
   }
 
   /**
@@ -2377,7 +2297,7 @@
       DirectoryServer.deregisterAlertGenerator(this);
 
       // stop the ReplicationDomain
-      stopDomain();
+      disableService();
     }
 
     // wait for completion of the persistentServerState thread.
@@ -3412,14 +3332,6 @@
     return genId;
   }
 
-  /** {@inheritDoc} */
-  @Override
-  public long getGenerationID()
-  {
-    return generationId;
-  }
-
-
   /**
    * Run a modify operation to update the entry whose DN is given as
    * a parameter with the generationID information.

--
Gitblit v1.10.0