From c5135432faf9bbbcd496ea160d59755fba31012c Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 21 Nov 2013 16:17:00 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1174 Transfer responsibility for populating the ChangeNumberIndexDB to ChangelogDB
---
opends/src/server/org/opends/server/replication/common/MultiDomainServerState.java | 65 ++++++++++++++++++++++++++------
1 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/common/MultiDomainServerState.java b/opends/src/server/org/opends/server/replication/common/MultiDomainServerState.java
index 7e2cea2..537cc34 100644
--- a/opends/src/server/org/opends/server/replication/common/MultiDomainServerState.java
+++ b/opends/src/server/org/opends/server/replication/common/MultiDomainServerState.java
@@ -69,8 +69,7 @@
* @param mdss The provided string representation of the state.
* @throws DirectoryException when the string has an invalid format
*/
- public MultiDomainServerState(String mdss)
- throws DirectoryException
+ public MultiDomainServerState(String mdss) throws DirectoryException
{
list = splitGenStateToServerStates(mdss);
}
@@ -105,18 +104,13 @@
synchronized(this)
{
- int serverId = csn.getServerId();
ServerState oldServerState = list.get(baseDN);
if (oldServerState == null)
- oldServerState = new ServerState();
-
- if (csn.isNewerThan(oldServerState.getCSN(serverId)))
{
- oldServerState.update(csn);
+ oldServerState = new ServerState();
list.put(baseDN, oldServerState);
- return true;
}
- return false;
+ return oldServerState.update(csn);
}
}
@@ -132,7 +126,24 @@
*/
public void update(DN baseDN, ServerState serverState)
{
- list.put(baseDN, serverState);
+ for (CSN csn : serverState)
+ {
+ update(baseDN, csn);
+ }
+ }
+
+ /**
+ * Update the current object with the provided multi domain server state.
+ *
+ * @param state
+ * The provided multi domain server state.
+ */
+ public void update(MultiDomainServerState state)
+ {
+ for (Entry<DN, ServerState> entry : state.list.entrySet())
+ {
+ update(entry.getKey(), entry.getValue());
+ }
}
/**
@@ -142,7 +153,7 @@
@Override
public String toString()
{
- StringBuilder res = new StringBuilder();
+ final StringBuilder res = new StringBuilder();
if (list != null && !list.isEmpty())
{
for (Entry<DN, ServerState> entry : list.entrySet())
@@ -163,7 +174,6 @@
buffer.append(this);
}
-
/**
* Tests if the state is empty.
*
@@ -182,6 +192,19 @@
}
/**
+ * Returns the ServerState associated to the provided replication domain's
+ * baseDN.
+ *
+ * @param baseDN
+ * the replication domain's baseDN
+ * @return the associated ServerState
+ */
+ public ServerState get(DN baseDN)
+ {
+ return list.get(baseDN);
+ }
+
+ /**
* Test if this object equals the provided other object.
* @param other The other object with which we want to test equality.
* @return Returns True if this equals other, else return false.
@@ -211,6 +234,22 @@
}
/**
+ * Test if this object covers the provided CSN for the provided baseDN.
+ *
+ * @param baseDN
+ * The provided baseDN.
+ * @param csn
+ * The provided CSN.
+ * @return true when this object covers the provided CSN for the provided
+ * baseDN.
+ */
+ public boolean cover(DN baseDN, CSN csn)
+ {
+ final ServerState state = list.get(baseDN);
+ return state != null && state.cover(csn);
+ }
+
+ /**
* Splits the provided generalizedServerState being a String with the
* following syntax: "domain1:state1;domain2:state2;..." to a Map of (domain
* DN, domain ServerState).
@@ -224,7 +263,7 @@
public static Map<DN, ServerState> splitGenStateToServerStates(
String multiDomainServerState) throws DirectoryException
{
- Map<DN, ServerState> startStates = new TreeMap<DN, ServerState>();
+ final Map<DN, ServerState> startStates = new TreeMap<DN, ServerState>();
if (multiDomainServerState != null && multiDomainServerState.length() > 0)
{
try
--
Gitblit v1.10.0