| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | |
| | |
| | | */ |
| | | public class MsgQueue |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private TreeMap<CSN, UpdateMsg> map = new TreeMap<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Add an UpdateMsg to this MessageQueue. |
| | | * |
| | |
| | | || msgSameCSN.isAssured() != update.isAssured() |
| | | || msgSameCSN.getVersion() != update.getVersion()) |
| | | { |
| | | // Adding 2 msgs with the same CSN is ok only when |
| | | // the 2 msgs are the same |
| | | // Adding 2 msgs with the same CSN is ok only when the 2 msgs are the same |
| | | bytesCount += update.size() - msgSameCSN.size(); |
| | | logger.error(ERR_RSQUEUE_DIFFERENT_MSGS_WITH_SAME_CN, msgSameCSN.getCSN(), msgSameCSN, update); |
| | | logger.error(ERR_RSQUEUE_DIFFERENT_MSGS_WITH_SAME_CSN, msgSameCSN.getCSN(), msgSameCSN, update); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | * |
| | | * @return <tt>true</tt> if this map contains an UpdateMsg |
| | | * with the same CSN as the given UpdateMsg. |
| | | * |
| | | */ |
| | | public boolean contains(UpdateMsg msg) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Removes all UpdateMsg form this queue. |
| | | */ |
| | | /** Removes all UpdateMsg form this queue. */ |
| | | public void clear() |
| | | { |
| | | synchronized (lock) |
| | |
| | | while (!finalCSN.equals(msg.getCSN())); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return getClass().getSimpleName() + " bytesCount=" + bytesCount + " queue=" |
| | | + map.values(); |
| | | return getClass().getSimpleName() + " bytesCount=" + bytesCount + " queue=" + map.values(); |
| | | } |
| | | } |