From 974da949ded8b134a5612e4e99c16b9fedda264a Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Thu, 27 May 2010 13:52:54 +0000
Subject: [PATCH] Enhance the way ECL configuration changes are handled.
---
opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java | 9 +---
opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ExternalChangelogDomain.java | 29 ++++++++++----
opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java | 41 ++++++++++++++++----
3 files changed, 55 insertions(+), 24 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ExternalChangelogDomain.java b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ExternalChangelogDomain.java
index 653e96e..e50a690 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ExternalChangelogDomain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ExternalChangelogDomain.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2009 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.server.replication.plugin;
@@ -37,6 +37,7 @@
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DN;
import org.opends.server.types.ResultCode;
+import java.util.HashSet;
/**
* This class specifies the external changelog feature for a replication
@@ -63,8 +64,12 @@
this.isEnabled = configuration.isEnabled();
configuration.addChangeListener(this);
if (configuration.getECLInclude() != null)
+ {
+ HashSet<String> attrNames = new HashSet<String>(0);
for (AttributeType eclInclude : configuration.getECLInclude())
- domain.addEclInclude(eclInclude.getNormalizedPrimaryName());
+ attrNames.add(eclInclude.getNormalizedPrimaryName());
+ domain.setEclInclude(domain.getServerId(), attrNames);
+ }
}
@@ -90,9 +95,10 @@
}
this.isEnabled = configuration.isEnabled();
- if (configuration.getECLInclude() != null)
- for (AttributeType eclInclude : configuration.getECLInclude())
- domain.addEclInclude(eclInclude.getNormalizedPrimaryName());
+ HashSet<String> attrNames = new HashSet<String>(0);
+ for (AttributeType eclInclude : configuration.getECLInclude())
+ attrNames.add(eclInclude.getNormalizedPrimaryName());
+ domain.setEclInclude(domain.getServerId(), attrNames);
return new ConfigChangeResult(ResultCode.SUCCESS, false);
}
@@ -103,6 +109,12 @@
public ConfigChangeResult applyConfigurationChange(
ExternalChangelogDomainCfg configuration)
{
+ // How it works with dsconfig :
+ // - after dsconfig set-external-changelog-domain-prop --set ecl-include:xx
+ // configuration contains only attribute xx
+ // - after dsconfig set-external-changelog-domain-prop --add ecl-include:xx
+ // configuration contains attribute xx and the previous list
+ // Hence in all cases, it is the complete list of attributes.
try
{
if (domain==null)
@@ -114,9 +126,10 @@
}
this.isEnabled = configuration.isEnabled();
- if (configuration.getECLInclude() != null)
- for (AttributeType eclInclude : configuration.getECLInclude())
- domain.addEclInclude(eclInclude.getNormalizedPrimaryName());
+ HashSet<String> attrNames = new HashSet<String>(0);
+ for (AttributeType eclInclude : configuration.getECLInclude())
+ attrNames.add(eclInclude.getNormalizedPrimaryName());
+ domain.setEclInclude(domain.getServerId(), attrNames);
return new ConfigChangeResult(ResultCode.SUCCESS, false);
}
catch (Exception e)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
index 1b1f955..279e6db 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
@@ -1568,7 +1568,7 @@
domain.getAssuredMode(),
domain.getAssuredSdLevel());
startSessionMsg.setEclIncludes(
- domain.getEclInclude());
+ domain.getEclInclude(domain.getServerId()));
} else
{
startSessionMsg =
@@ -3027,12 +3027,7 @@
if (domain != null)
{
for (DSInfo info : dsList)
- {
- for (String attr : info.getEclIncludes())
- {
- domain.addEclInclude(attr);
- }
- }
+ domain.setEclInclude(info.getDsId(), info.getEclIncludes());
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
index b1a1150..57f1223 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
@@ -68,6 +68,7 @@
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -302,8 +303,9 @@
*/
private final ChangeNumberGenerator generator;
- Set<String> cfgEclIncludes = new HashSet<String>();
- Set<String> eClIncludes = new HashSet<String>();
+ private final Map<Integer, Set<String>> eclIncludeByServer =
+ new ConcurrentHashMap<Integer, Set<String>>();
+ Set<String> crossServersECLIncludes = new HashSet<String>();
/**
* Returns the {@link ChangeNumberGenerator} that will be used to
@@ -2893,21 +2895,42 @@
}
/**
- * Add an attribute to the list of attributes to include in the ECL.
- * @param attribute The attribute to add.
+ * Set the attributes configured on a server to be included in the ECL.
+ * @param serverId server where these attributes are configured.
+ * @param attributes the configured attributes.
*/
- synchronized public void addEclInclude(String attribute)
+ synchronized public void setEclInclude(int serverId, Set<String> attributes)
{
- eClIncludes.add(attribute);
+ eclIncludeByServer.put(serverId, attributes);
+
+ // and rebuild the global list to be ready for usage
+ crossServersECLIncludes.clear();
+ for (Set<String> attributesByServer : eclIncludeByServer.values())
+ for (String attribute : attributesByServer)
+ crossServersECLIncludes.add(attribute);
}
/**
- * Get the list of attributes to include in the ECL.
- * @return The list of attributes.
+ * Get the attributes to include in each change for the ECL.
+ * It's a set : an attribute appears once even if configured on more than one
+ * server.
+ * @return The attributes to include in each change for the ECL.
*/
public Set<String> getEclInclude()
{
- return eClIncludes;
+ System.out.println("cdECLIn=" + crossServersECLIncludes);
+ return crossServersECLIncludes;
+ }
+
+ /**
+ * Get the attributes to include in each change for the ECL
+ * for a given serverId.
+ * @param serverId The serverId for which we want the include attributes.
+ * @return The attributes.
+ */
+ public Set<String> getEclInclude(int serverId)
+ {
+ return eclIncludeByServer.get(serverId);
}
/**
--
Gitblit v1.10.0