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

Jean-Noel Rouvignac
19.04.2014 2c977273201717e109f7373cd60979cdc435f6e9
opendj3-server-dev/src/server/org/opends/server/replication/server/ECLServerWriter.java
@@ -143,13 +143,17 @@
        }
        if (shutdown)
        {
          return;
        }
        // Not suspended
        doIt();
        if (shutdown)
        {
          return;
        }
        suspendWriter();
      }
@@ -171,12 +175,14 @@
    }
    finally
    {
      if (session!=null)
      if (session != null)
      {
        session.close();
      }
      if (replicationServerDomain != null)
      {
        replicationServerDomain.stopServer(handler, false);
      }
    }
  }
@@ -188,24 +194,10 @@
   */
  private void doIt() throws IOException, InterruptedException
  {
    while (true)
    while (!shutdown && !suspended)
    {
      if (shutdown || suspended)
      {
        return;
      }
      ECLUpdateMsg update = null;
      try
      {
        update = handler.takeECLUpdate();
      }
      catch(DirectoryException de)
      {
        logger.traceException(de);
      }
      if (update == null)
      final ECLUpdateMsg updateMsg = takeECLUpdate(handler);
      if (updateMsg == null)
      {
        if (session != null && handler.isInitPhaseDone())
        {
@@ -225,14 +217,25 @@
      }
      else
      {
        // Publish the update to the remote server using a protocol version it
        // supports
        publish(update);
        update = null;
        // Publish the update to the remote server using a protocol version it supports
        publish(updateMsg);
      }
    }
  }
  private ECLUpdateMsg takeECLUpdate(ECLServerHandler handler)
  {
    try
    {
      return handler.takeECLUpdate();
    }
    catch(DirectoryException de)
    {
      logger.traceException(de);
      return null;
    }
  }
  /**
   * Shutdown the writer.
   */
@@ -248,7 +251,9 @@
  private void publish(ECLUpdateMsg msg) throws IOException
  {
    if (logger.isTraceEnabled())
    {
      logger.trace(getName() + " publishes msg=[" + msg + "]");
    }
    if (session != null)
    {
@@ -258,8 +263,10 @@
    {
      try
      {
        // Using processAdd() because all ECLUpdateMsgs are adds to the external changelog
        // (even though the underlying changes can be adds, deletes, modifies or modDNs)
        Entry eclEntry = ECLSearchOperation.createEntryFromMsg(msg);
        mypsearch.processAdd(eclEntry, -1);
        mypsearch.processAdd(eclEntry);
      }
      catch (Exception e)
      {