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

Jean-Noel Rouvignac
08.59.2013 19298042f99ef0a659f9271d022f58884a18704b
opends/src/server/org/opends/server/replication/server/MsgQueue.java
@@ -27,7 +27,7 @@
 */
package org.opends.server.replication.server;
import java.util.SortedMap;
import java.util.NavigableMap;
import java.util.TreeMap;
import org.opends.messages.Message;
@@ -43,7 +43,7 @@
 */
public class MsgQueue
{
  private SortedMap<CSN, UpdateMsg> map = new TreeMap<CSN, UpdateMsg>();
  private NavigableMap<CSN, UpdateMsg> map = new TreeMap<CSN, UpdateMsg>();
  private final Object lock = new Object();
  /** The total number of bytes for all the message in the queue. */
@@ -192,4 +192,24 @@
      bytesCount = 0;
    }
  }
  /**
   * Consumes all the messages in this queue up to and including the passed in
   * message. If the passed in message is not contained in the current queue,
   * then all messages will be removed from it.
   *
   * @param msg
   *          the final message to reach when consuming messages from this queue
   */
  public void consumeUpTo(UpdateMsg msg)
  {
    UpdateMsg msg1;
    do
    {
      // FIXME this code could be more efficient if the msgQueue could call the
      // following code (to be tested):
      // map.headMap(msg.getCSN(), true).clear()
      msg1 = removeFirst();
    } while (!msg.getCSN().equals(msg1.getCSN()));
  }
}