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

mmarie
18.35.2008 d93627ee43ca3e694a7c4275d63c0571c4ec83dd
issue 3640 : Refactor Replication code to make it more generic

It contains three minor changes :
- a reload() method for ServerState.
- minor change in the EntryMsg code allowing non-ascii content
- implements the read() method in ReplInputStream()

3 files modified
44 ■■■■ changed files
opends/src/server/org/opends/server/replication/common/ServerState.java 25 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/EntryMsg.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/service/ReplInputStream.java 17 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/common/ServerState.java
@@ -172,6 +172,31 @@
  }
  /**
   * Replace the Server State with another ServerState.
   *
   * @param serverState The ServerState.
   *
   * @return a boolean indicating if the update was meaningful.
   */
  public boolean reload(ServerState serverState) {
    if (serverState == null) {
      return false;
    }
    boolean result = false;
    clear();
    for (Short id : serverState) {
      ChangeNumber maxChangeNumber = getMaxChangeNumber(id);
      if (update(maxChangeNumber)) {
        result = true;
      }
    }
    return (result);
  }
  /**
   * return a Set of String usable as a textual representation of
   * a Server state.
   * format : time seqnum id
opends/src/server/org/opends/server/replication/protocol/EntryMsg.java
@@ -107,7 +107,7 @@
      pos += length +1;
      // entry
      length = getNextLength(in, pos);
      length = in.length - (pos + 1);
      this.entryByteArray = new byte[length];
      for (int i=0; i<length; i++)
      {
opends/src/server/org/opends/server/replication/service/ReplInputStream.java
@@ -146,11 +146,18 @@
   *                       use by this input stream.
   */
  public int read()
         throws IOException
          throws IOException
  {
    // This method is not supposed to be called to make an LDIF import
    // for replication.
    throw new IOException("Not implemented");
    if (closed) {
      return -1;
    }
    byte[] b = new byte[1];
    if (read(b, 0, 1) == 0) {
      throw new IOException();
    }
    return ((int)b[0]);
  }
}