From a460cfc30ac60de2b9f3c0435ec67d950da001f8 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 05 Sep 2013 07:54:17 +0000
Subject: [PATCH] OPENDJ-1116 Introduce abstraction for the changelog DB
---
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java | 15 ++--
opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java | 4
opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java | 32 ++--------
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java | 61 ++++++++------------
opends/src/server/org/opends/server/replication/protocol/StartECLSessionMsg.java | 25 +++----
5 files changed, 53 insertions(+), 84 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java b/opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java
index c053665..db47298 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java
@@ -59,7 +59,7 @@
* @param changeNumber The provided change number.
*/
public ECLUpdateMsg(LDAPUpdateMsg updateMsg, MultiDomainServerState cookie,
- String baseDN, int changeNumber)
+ String baseDN, long changeNumber)
{
this.cookie = cookie;
this.baseDN = baseDN;
@@ -184,7 +184,7 @@
{
byte[] byteCookie = String.valueOf(cookie).getBytes("UTF-8");
byte[] byteBaseDN = String.valueOf(baseDN).getBytes("UTF-8");
- // FIXME JNR Changing line below to use long would require a protocol
+ // FIXME JNR Changing the line below to use long would require a protocol
// version change. Leave it like this for now until the need arises.
byte[] byteChangeNumber =
Integer.toString((int) changeNumber).getBytes("UTF-8");
diff --git a/opends/src/server/org/opends/server/replication/protocol/StartECLSessionMsg.java b/opends/src/server/org/opends/server/replication/protocol/StartECLSessionMsg.java
index fb05cb7..5968ccb 100644
--- a/opends/src/server/org/opends/server/replication/protocol/StartECLSessionMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/StartECLSessionMsg.java
@@ -94,8 +94,8 @@
* When eclRequestType = FROM_CHANGE_NUMBER, specifies the provided change
* number first and last - [CHANGELOG].
*/
- private int firstChangeNumber = -1;
- private int lastChangeNumber = -1;
+ private long firstChangeNumber = -1;
+ private long lastChangeNumber = -1;
/**
* When eclRequestType = EQUALS_REPL_CHANGE_NUMBER, specifies the provided
@@ -148,21 +148,17 @@
eclRequestType = Short.valueOf(new String(in, pos, length, "UTF-8"));
pos += length +1;
- // sequenceNumber
length = getNextLength(in, pos);
firstChangeNumber = Integer.valueOf(new String(in, pos, length, "UTF-8"));
pos += length +1;
- // stopSequenceNumber
length = getNextLength(in, pos);
lastChangeNumber = Integer.valueOf(new String(in, pos, length, "UTF-8"));
pos += length +1;
- // replication CSN
length = getNextLength(in, pos);
- String csnStr = new String(in, pos, length, "UTF-8");
+ csn = new CSN(new String(in, pos, length, "UTF-8"));
pos += length + 1;
- csn = new CSN(csnStr);
// persistentSearch mode
length = getNextLength(in, pos);
@@ -174,7 +170,6 @@
crossDomainServerState = new String(in, pos, length, "UTF-8");
pos += length + 1;
- // operation id
length = getNextLength(in, pos);
operationId = new String(in, pos, length, "UTF-8");
pos += length + 1;
@@ -225,8 +220,10 @@
try
{
byte[] byteMode = toBytes(eclRequestType);
- byte[] byteChangeNumber = toBytes(firstChangeNumber);
- byte[] byteStopChangeNumber = toBytes(lastChangeNumber);
+ // FIXME JNR Changing the lines below to use long would require a protocol
+ // version change. Leave it like this for now until the need arises.
+ byte[] byteChangeNumber = toBytes((int) firstChangeNumber);
+ byte[] byteStopChangeNumber = toBytes((int) lastChangeNumber);
byte[] byteCSN = csn.toString().getBytes("UTF-8");
byte[] bytePsearch = toBytes(isPersistent);
byte[] byteGeneralizedState = toBytes(crossDomainServerState);
@@ -294,7 +291,7 @@
* Getter on the changer number start.
* @return the changer number start.
*/
- public int getFirstChangeNumber()
+ public long getFirstChangeNumber()
{
return firstChangeNumber;
}
@@ -303,7 +300,7 @@
* Getter on the changer number stop.
* @return the change number stop.
*/
- public int getLastChangeNumber()
+ public long getLastChangeNumber()
{
return lastChangeNumber;
}
@@ -312,7 +309,7 @@
* Setter on the first changer number (as defined by [CHANGELOG]).
* @param firstChangeNumber the provided first change number.
*/
- public void setFirstChangeNumber(int firstChangeNumber)
+ public void setFirstChangeNumber(long firstChangeNumber)
{
this.firstChangeNumber = firstChangeNumber;
}
@@ -321,7 +318,7 @@
* Setter on the last changer number (as defined by [CHANGELOG]).
* @param lastChangeNumber the provided last change number.
*/
- public void setLastChangeNumber(int lastChangeNumber)
+ public void setLastChangeNumber(long lastChangeNumber)
{
this.lastChangeNumber = lastChangeNumber;
}
diff --git a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
index 470fc12..8956353 100644
--- a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
@@ -388,12 +388,9 @@
ResultCode.UNAVAILABLE_CRITICAL_EXTENSION,
ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid));
}
- else
- {
- // We don't want to process this non-critical control, so remove it.
- removeRequestControl(c);
- continue;
- }
+ // We don't want to process this non-critical control, so remove it.
+ removeRequestControl(c);
+ continue;
}
if (oid.equals(OID_ECL_COOKIE_EXCHANGE_CONTROL))
@@ -715,14 +712,9 @@
{
return getFilter().matchesEntry(entry);
}
- else
- {
- return false;
- }
+ return false;
}
-
-
/**
* Create an ECL entry from a provided ECL msg.
*
@@ -1036,15 +1028,10 @@
addAttributeByType(ATTR_SUBSCHEMA_SUBENTRY_LC, ATTR_SUBSCHEMA_SUBENTRY_LC,
ConfigConstants.DN_DEFAULT_SCHEMA_ROOT, uAttrs, operationalAttrs);
- // numSubordinates
addAttributeByType("numsubordinates", "numSubordinates", "0", uAttrs,
operationalAttrs);
-
- // hasSubordinates
addAttributeByType("hassubordinates", "hasSubordinates", "false", uAttrs,
operationalAttrs);
-
- // entryDN
addAttributeByType("entrydn", "entryDN", dnString, uAttrs,
operationalAttrs);
@@ -1059,10 +1046,8 @@
String format = dateFormat.format(new Date(csn.getTime()));
addAttributeByType("changetime", "changeTime", format, uAttrs,
operationalAttrs);
-
addAttributeByType("changetype", "changeType", changetype, uAttrs,
operationalAttrs);
-
addAttributeByType("targetdn", "targetDN", targetDN.toNormalizedString(),
uAttrs, operationalAttrs);
@@ -1070,7 +1055,6 @@
addAttributeByType("replicationcsn", "replicationCSN", csn
.toString(), uAttrs, operationalAttrs);
-
addAttributeByType("replicaidentifier", "replicaIdentifier", Integer
.toString(csn.getServerId()), uAttrs, operationalAttrs);
@@ -1256,10 +1240,10 @@
// Here is the only binary operation we know how to optimize
Collection<SearchFilter> comps = sf.getFilterComponents();
SearchFilter sfs[] = comps.toArray(new SearchFilter[0]);
- int l1 = -1;
- int f1 = -1;
- int l2 = -1;
- int f2 = -1;
+ long l1 = -1;
+ long f1 = -1;
+ long l2 = -1;
+ long f2 = -1;
StartECLSessionMsg m1;
StartECLSessionMsg m2;
if (sfs.length > 0)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
index 853fb8d..50ce40a 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
@@ -2327,8 +2327,7 @@
debugInfo(tn, "Ending test successfully");
}
- private int ECLCompatWriteReadAllOps(int firstChangeNumber)
- throws Exception
+ private int ECLCompatWriteReadAllOps(long firstChangeNumber) throws Exception
{
String tn = "ECLCompatWriteReadAllOps/" + firstChangeNumber;
debugInfo(tn, "Starting test\n\n");
@@ -2418,7 +2417,7 @@
}
private void assertEntries(List<SearchResultEntry> entries,
- int firstChangeNumber, String tn, LDIFWriter ldifWriter,
+ long firstChangeNumber, String tn, LDIFWriter ldifWriter,
String user1entryUUID, CSN... csns) throws Exception
{
debugAndWriteEntries(ldifWriter, entries, tn);
@@ -2469,14 +2468,14 @@
}
}
- private void assertDnEquals(SearchResultEntry resultEntry, int changeNumber, int i)
+ private void assertDnEquals(SearchResultEntry resultEntry, long changeNumber, int i)
{
String actualDN = resultEntry.getDN().toNormalizedString();
String expectedDN = "changenumber=" + (changeNumber + i) + ",cn=changelog";
assertThat(actualDN).isEqualToIgnoringCase(expectedDN);
}
- private void ECLCompatReadFrom(int firstChangeNumber) throws Exception
+ private void ECLCompatReadFrom(long firstChangeNumber) throws Exception
{
String tn = "ECLCompatReadFrom/" + firstChangeNumber;
debugInfo(tn, "Starting test\n\n");
@@ -2516,7 +2515,7 @@
* Process similar search as but only check that there's no control returned
* as part of the entry.
*/
- private void ECLCompatNoControl(int firstChangeNumber) throws Exception
+ private void ECLCompatNoControl(long firstChangeNumber) throws Exception
{
String tn = "ECLCompatNoControl/" + firstChangeNumber;
debugInfo(tn, "Starting test\n\n");
@@ -2548,7 +2547,7 @@
* @param lastChangeNumber
* the higher limit
*/
- private void ECLCompatReadFromTo(int firstChangeNumber, int lastChangeNumber) throws Exception
+ private void ECLCompatReadFromTo(long firstChangeNumber, long lastChangeNumber) throws Exception
{
String tn = "ECLCompatReadFromTo/" + firstChangeNumber + "/" + lastChangeNumber;
debugInfo(tn, "Starting test\n\n");
@@ -2659,7 +2658,7 @@
}
private StartECLSessionMsg evaluateSearchParameters(DN baseDN,
- int firstChangeNumber, int lastChangeNumber, String filterString) throws Exception
+ long firstChangeNumber, long lastChangeNumber, String filterString) throws Exception
{
final StartECLSessionMsg startCLmsg = new StartECLSessionMsg();
ECLSearchOperation.evaluateSearchParameters(startCLmsg, baseDN,
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
index 2951680..8e8ec6e 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
@@ -666,7 +666,7 @@
CSN csn = new CSN(TimeThread.getTime(), 123, 45);
op.setAttachment(SYNCHROCONTEXT, new DeleteContext(csn, "uniqueid"));
DeleteMsg delmsg = new DeleteMsg(op);
- int changeNumber = 21;
+ long changeNumber = 21;
String baseDN = "dc=example,dc=com";
@@ -946,8 +946,7 @@
* Test TopologyMsg encoding and decoding.
*/
@Test(enabled=true,dataProvider = "createTopologyData")
- public void topologyMsgTest(List<DSInfo> dsList, List<RSInfo> rsList,
- Set<String> attrs)
+ public void topologyMsgTest(List<DSInfo> dsList, List<RSInfo> rsList, Set<String> attrs)
throws Exception
{
TopologyMsg msg = new TopologyMsg(dsList, rsList);
@@ -1317,8 +1316,7 @@
* Test StartSessionMsg encoding and decoding.
*/
@Test()
- public void startECLSessionMsgTest()
- throws Exception
+ public void startECLSessionMsgTest() throws Exception
{
// data
CSN csn = new CSN(TimeThread.getTime(), 123, 45);
@@ -1365,9 +1363,23 @@
@Test(enabled=false,dataProvider = "createAddData")
public void addMsgPerfs(String rawDN, boolean isAssured, AssuredMode assuredMode,
- byte safeDataLevel, List<Attribute> entryAttrList)
- throws Exception
+ byte safeDataLevel, List<Attribute> entryAttrList) throws Exception
{
+ Map<ObjectClass, String> objectClassList = new HashMap<ObjectClass, String>();
+ objectClassList.put(DirectoryServer.getObjectClass("organization"), "organization");
+
+ Attribute attr = Attributes.create("o", "com");
+ Map<AttributeType, List<Attribute>> userAttList = new HashMap<AttributeType, List<Attribute>>();
+ userAttList.put(attr.getAttributeType(), newList(attr));
+
+
+ attr = Attributes.create("creatorsname", "dc=creator");
+ Map<AttributeType, List<Attribute>> opList = new HashMap<AttributeType,List<Attribute>>();
+ opList.put(attr.getAttributeType(), newList(attr));
+
+ CSN csn = new CSN(TimeThread.getTime(), 123, 45);
+ DN dn = DN.decode(rawDN);
+
long createop = 0;
long createmsgfromop = 0;
long encodemsg = 0;
@@ -1376,27 +1388,6 @@
long buildnew = 0;
long t1,t2,t3,t31,t4,t5,t6 = 0;
- Map<ObjectClass, String> objectClassList =
- new HashMap<ObjectClass, String>();
- objectClassList.put(DirectoryServer.getObjectClass("organization"),
- "organization");
-
- Attribute attr = Attributes.create("o", "com");
- List<Attribute> userAttributes = newList(attr);
- Map<AttributeType, List<Attribute>> userAttList =
- new HashMap<AttributeType, List<Attribute>>();
- userAttList.put(attr.getAttributeType(), userAttributes);
-
-
- attr = Attributes.create("creatorsname", "dc=creator");
- List<Attribute> operationalAttributes = newList(attr);
- Map<AttributeType, List<Attribute>> opList =
- new HashMap<AttributeType,List<Attribute>>();
- opList.put(attr.getAttributeType(), operationalAttributes);
-
- CSN csn = new CSN(TimeThread.getTime(), 123, 45);
- DN dn = DN.decode(rawDN);
-
for (int i=1;i<perfRep;i++)
{
t1 = System.nanoTime();
@@ -1457,12 +1448,13 @@
}
@Test(enabled=false,dataProvider = "createModifyData")
- public void modMsgPerfs(CSN csn,
- String rawdn, List<Modification> mods,
- boolean isAssured, AssuredMode assuredMode,
- byte safeDataLevel, List<Attribute> entryAttrList)
- throws Exception
+ public void modMsgPerfs(CSN csn, String rawdn, List<Modification> mods,
+ boolean isAssured, AssuredMode assuredMode, byte safeDataLevel,
+ List<Attribute> entryAttrList) throws Exception
{
+ CSN csn2 = new CSN(TimeThread.getTime(), 123, 45);
+ DN dn = DN.decode(rawdn);
+
long createop = 0;
long createmsgfromop = 0;
long encodemsg = 0;
@@ -1471,9 +1463,6 @@
long buildnew = 0;
long t1,t2,t3,t31,t4,t5,t6 = 0;
- CSN csn2 = new CSN(TimeThread.getTime(), 123, 45);
- DN dn = DN.decode(rawdn);
-
for (int i=1;i<perfRep;i++)
{
t1 = System.nanoTime();
--
Gitblit v1.10.0