From 3a85b7fa73c0a50348e7adfcda4af929ce52a30d Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Tue, 25 Sep 2007 07:29:24 +0000
Subject: [PATCH] some replication hardening : - fix some race conditions in namingConflict test - add some cleanup at the end of ReplicationServerDynamicConfTest and IsolationTest - don't use anymore 2 statics in the replication code that could cause problem when in-core restart are done. - improve the shutdown by making sure that all threads are done before returning
---
opendj-sdk/opends/src/server/org/opends/server/replication/plugin/Historical.java | 50 +++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/Historical.java b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/Historical.java
index c5b60bb..2f740df 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/Historical.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/Historical.java
@@ -82,15 +82,9 @@
public static final String HISTORICAL = "ds-synch-historical";
/**
- * The AttributeType associated to the attribute used to store
- * hitorical information.
+ * The name of the entryuuid attribute.
*/
- public static final AttributeType historicalAttrType =
- DirectoryServer.getSchema().getAttributeType(HISTORICALATTRIBUTENAME);
-
static final String ENTRYUIDNAME = "entryuuid";
- static final AttributeType entryuuidAttrType =
- DirectoryServer.getSchema().getAttributeType(ENTRYUIDNAME);
/*
@@ -177,7 +171,7 @@
Modification mod;
mod = new Modification(ModificationType.REPLACE, attr);
mods.add(mod);
- modifiedEntry.removeAttribute(historicalAttrType);
+ modifiedEntry.removeAttribute(attr.getAttributeType());
modifiedEntry.addAttribute(attr, null);
}
@@ -194,7 +188,7 @@
private AttributeInfo getAttrInfo(Modification mod)
{
Attribute modAttr = mod.getAttribute();
- if (modAttr.getAttributeType().equals(Historical.historicalAttrType))
+ if (isHistoricalAttribute(modAttr))
{
// Don't keep historical information for the attribute that is
// used to store the historical information.
@@ -229,6 +223,8 @@
*/
public Attribute encode()
{
+ AttributeType historicalAttrType =
+ DirectoryServer.getSchema().getAttributeType(HISTORICALATTRIBUTENAME);
LinkedHashSet<AttributeValue> hist = new LinkedHashSet<AttributeValue>();
for (Map.Entry<AttributeType, AttrInfoWithOptions> entryWithOptions :
@@ -344,7 +340,7 @@
*/
public static Historical load(Entry entry)
{
- List<Attribute> hist = entry.getAttribute(historicalAttrType);
+ List<Attribute> hist = getHistoricalAttr(entry);
Historical histObj = new Historical();
AttributeType lastAttrType = null;
Set<String> lastOptions = new HashSet<String>();
@@ -441,7 +437,7 @@
{
TreeMap<ChangeNumber, FakeOperation> operations =
new TreeMap<ChangeNumber, FakeOperation>();
- List<Attribute> attrs = entry.getOperationalAttribute(historicalAttrType);
+ List<Attribute> attrs = getHistoricalAttr(entry);
if (attrs != null)
{
for (Attribute attr : attrs)
@@ -478,6 +474,19 @@
}
/**
+ * Get the Attribute used to store the historical information from
+ * the given Entry.
+ *
+ * @param entry The entry containing the historical information.
+ *
+ * @return The Attribute used to store the historical information.
+ */
+ public static List<Attribute> getHistoricalAttr(Entry entry)
+ {
+ return entry.getAttribute(HISTORICALATTRIBUTENAME);
+ }
+
+ /**
* Get the entry unique Id in String form.
*
* @param entry The entry for which the unique id should be returned.
@@ -487,6 +496,8 @@
public static String getEntryUuid(Entry entry)
{
String uuidString = null;
+ AttributeType entryuuidAttrType =
+ DirectoryServer.getSchema().getAttributeType(ENTRYUIDNAME);
List<Attribute> uuidAttrs =
entry.getOperationalAttribute(entryuuidAttrType);
if (uuidAttrs != null)
@@ -513,6 +524,8 @@
{
String uuidString = null;
Map<AttributeType, List<Attribute>> attrs = op.getOperationalAttributes();
+ AttributeType entryuuidAttrType =
+ DirectoryServer.getSchema().getAttributeType(ENTRYUIDNAME);
List<Attribute> uuidAttrs = attrs.get(entryuuidAttrType);
if (uuidAttrs != null)
@@ -526,5 +539,20 @@
}
return uuidString;
}
+
+ /**
+ * Check if a given attribute is an attribute used to store historical
+ * information.
+ *
+ * @param attr The attribute that needs to be checked.
+ *
+ * @return a boolean indicating if the given attribute is
+ * used to store historical information.
+ */
+ public static boolean isHistoricalAttribute(Attribute attr)
+ {
+ AttributeType attrType = attr.getAttributeType();
+ return attrType.getNameOrOID().equals(Historical.HISTORICALATTRIBUTENAME);
+ }
}
--
Gitblit v1.10.0