mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
08.10.2013 fe7f48c4d11f7b4a003038f2e406a148eac48d1e
OPENDJ-1116 Introduce abstraction for the changelog DB

MultiDomainServerState.java
In update() removed the call to ServerState.duplicate() and let client code decide whether it needs to call it.
In toString(), use dSTringBuilder.
Code cleanup, removed use of "this" and useless parentheses.

ReplicationServer.java:
In getLastECLCookie(), made the code more efficient: called ReplicationServerDomain.getLatestServerState() only if the baseDN is not excluded.

ECLServerHandler.java:
In buildDomainContexts(), Call ServerState.duplicate() before calling MultiDomainServerState.update().
3 files modified
49 ■■■■ changed files
opends/src/server/org/opends/server/replication/common/MultiDomainServerState.java 35 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ECLServerHandler.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServer.java 12 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/common/MultiDomainServerState.java
@@ -29,6 +29,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import org.opends.messages.Category;
@@ -120,15 +121,18 @@
  }
  /**
   * Update the ServerState of the provided baseDN with the
   * provided server state.
   * Update the ServerState of the provided baseDN with the provided server
   * state. The provided server state will be owned by this instance, so care
   * must be taken by calling code to duplicate it if needed.
   *
   * @param baseDN       The provided baseDN.
   * @param serverState  The provided serverState.
   * @param baseDN
   *          The provided baseDN.
   * @param serverState
   *          The provided serverState.
   */
  public void update(DN baseDN, ServerState serverState)
  {
    list.put(baseDN, serverState.duplicate());
    list.put(baseDN, serverState);
  }
  /**
@@ -138,16 +142,16 @@
  @Override
  public String toString()
  {
    String res = "";
    if ((list != null) && (!list.isEmpty()))
    StringBuilder res = new StringBuilder();
    if (list != null && !list.isEmpty())
    {
      for (DN baseDN : list.keySet())
      for (Entry<DN, ServerState> entry : list.entrySet())
      {
        ServerState ss = list.get(baseDN);
        res += baseDN + ":" + ss + ";";
        res.append(entry.getKey()).append(":")
           .append(entry.getValue()).append(";");
      }
    }
    return res;
    return res.toString();
  }
  /**
@@ -156,7 +160,7 @@
   */
  public void toString(StringBuilder buffer)
  {
    buffer.append(this.toString());
    buffer.append(this);
  }
@@ -186,7 +190,7 @@
   */
  public boolean equalsTo(MultiDomainServerState other)
  {
    return ((this.cover(other)) && (other.cover(this)));
    return cover(other) && other.cover(this);
  }
  /**
@@ -200,7 +204,7 @@
    {
      ServerState state = list.get(baseDN);
      ServerState coveredState = covered.list.get(baseDN);
      if ((state==null)||(coveredState == null) || (!state.cover(coveredState)))
      if (state == null || coveredState == null || !state.cover(coveredState))
      {
        return false;
      }
@@ -220,8 +224,7 @@
      String multidomainserverstate) throws DirectoryException
  {
    Map<DN, ServerState> startStates = new TreeMap<DN, ServerState>();
    if ((multidomainserverstate != null)
        && (multidomainserverstate.length() > 0))
    if (multidomainserverstate != null && multidomainserverstate.length() > 0)
    {
      try
      {
opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
@@ -805,7 +805,7 @@
      newDomainCtxt.mh = mh;
      previousCookie.update(newDomainCtxt.rsDomain.getBaseDN(),
                            newDomainCtxt.startState);
                            newDomainCtxt.startState.duplicate());
      results.add(newDomainCtxt);
    }
opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -1506,14 +1506,14 @@
  {
    // Initialize start state for all running domains with empty state
    MultiDomainServerState result = new MultiDomainServerState();
    for (ReplicationServerDomain rsd : getReplicationServerDomains())
    for (ReplicationServerDomain rsDomain : getReplicationServerDomains())
    {
      final ServerState latestDBServerState = rsd.getLatestServerState();
      if (contains(excludedBaseDNs, rsd.getBaseDN().toNormalizedString())
          || latestDBServerState.isEmpty())
      if (contains(excludedBaseDNs, rsDomain.getBaseDN().toNormalizedString()))
        continue;
      result.update(rsd.getBaseDN(), latestDBServerState);
      final ServerState latestDBServerState = rsDomain.getLatestServerState();
      if (latestDBServerState.isEmpty())
        continue;
      result.update(rsDomain.getBaseDN(), latestDBServerState);
    }
    return result;
  }