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

Jean-Noel Rouvignac
20.01.2013 52317580a916ab802042937dd3edd604a18f6c4b
Code cleanup


ReplicationDomain.java:
Added missing curly brackets.
Added IEContext.setExceptionIfNoneExist() + used it throughout.

LDAPReplicationDomain.java:
In decodeSource(), removed insane control flow.
Called StaticUtils.stackTraceToSingleLineString() instead of Exception.getLocalizedMessage() or Exception.getMessage().
Collapsed @inheritDoc javadocs.
2 files modified
358 ■■■■ changed files
opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java 212 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/service/ReplicationDomain.java 146 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -345,9 +345,7 @@
          + ") state checkpointer for domain \"" + getBaseDNString() + "\"");
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public void run()
    {
@@ -400,9 +398,7 @@
      this.startCSN = replServerMaxCSN;
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public void run()
    {
@@ -510,7 +506,7 @@
    catch (DirectoryException e)
    {
      logError(ERR_LOADING_GENERATION_ID.get(
          getBaseDNString(), e.getLocalizedMessage()));
          getBaseDNString(), stackTraceToSingleLineString(e)));
    }
    /*
@@ -665,9 +661,8 @@
      // Should not happen as normally already called without problem in
      // isConfigurationChangeAcceptable or isConfigurationAcceptable
      // if we come up to this method
      Message message = NOTE_ERR_FRACTIONAL.get(getBaseDNString(),
        e.getLocalizedMessage());
      logError(message);
      logError(NOTE_ERR_FRACTIONAL.get(getBaseDNString(),
          stackTraceToSingleLineString(e)));
      return;
    }
@@ -685,9 +680,8 @@
    catch  (ConfigException e)
    {
      // Should not happen
      Message message = NOTE_ERR_FRACTIONAL.get(getBaseDNString(),
        e.getLocalizedMessage());
      logError(message);
      logError(NOTE_ERR_FRACTIONAL.get(getBaseDNString(),
          stackTraceToSingleLineString(e)));
      return;
    }
@@ -875,9 +869,9 @@
    {
      // Should not happen as configuration in domain root entry is flushed
      // from valid configuration in local variables
      Message message = NOTE_ERR_FRACTIONAL.get(
        fractionalConfig.getBaseDn().toString(), e.getLocalizedMessage());
      logError(message);
      logError(NOTE_ERR_FRACTIONAL.get(
          fractionalConfig.getBaseDn().toString(),
          stackTraceToSingleLineString(e)));
      return false;
    }
@@ -909,9 +903,9 @@
      // Should not happen as configuration in domain root entry is flushed
      // from valid configuration in local variables so both should have already
      // been checked
      Message message = NOTE_ERR_FRACTIONAL.get(
        fractionalConfig.getBaseDn().toString(), e.getLocalizedMessage());
      logError(message);
      logError(NOTE_ERR_FRACTIONAL.get(
          fractionalConfig.getBaseDn().toString(),
          stackTraceToSingleLineString(e)));
      return false;
    }
  }
@@ -934,27 +928,21 @@
      this.attrValIt = attrValIt;
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public boolean hasNext()
    {
      return attrValIt.hasNext();
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public String next()
    {
      return attrValIt.next().getValue().toString();
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    // Should not be needed anyway
    @Override
    public void remove()
@@ -1526,9 +1514,8 @@
    }
    catch(DirectoryException e)
    {
      Message message = NOTE_ERR_FRACTIONAL.get(getBaseDNString(),
        e.getLocalizedMessage());
      logError(message);
      logError(NOTE_ERR_FRACTIONAL.get(getBaseDNString(),
          stackTraceToSingleLineString(e)));
      return FRACTIONAL_HAS_NO_FRACTIONAL_FILTERED_ATTRIBUTES;
    }
    Set<ObjectClass> entryClasses = entryToModify.getObjectClasses().keySet();
@@ -2797,20 +2784,16 @@
      {
        AttributeType modAttrType = mod.getAttribute().getAttributeType();
        if ((mod.getModificationType() == ModificationType.DELETE
            || mod.getModificationType() == ModificationType.REPLACE)
              || mod.getModificationType() == ModificationType.REPLACE)
            && currentRDN.hasAttributeType(modAttrType))
        {
          if (currentRDN.hasAttributeType(modAttrType))
          {
            // the attribute can't be deleted because it is used
            // in the RDN, turn this operation is a replace with the
            // current RDN value(s);
            mod.setModificationType(ModificationType.REPLACE);
            Attribute newAttribute = mod.getAttribute();
            AttributeBuilder attrBuilder = new AttributeBuilder(newAttribute);
            attrBuilder.add(currentRDN.getAttributeValue(modAttrType));
            mod.setAttribute(attrBuilder.toAttribute());
          }
          // the attribute can't be deleted because it is used in the RDN,
          // turn this operation is a replace with the current RDN value(s);
          mod.setModificationType(ModificationType.REPLACE);
          Attribute newAttribute = mod.getAttribute();
          AttributeBuilder attrBuilder = new AttributeBuilder(newAttribute);
          attrBuilder.add(currentRDN.getAttributeValue(modAttrType));
          mod.setAttribute(attrBuilder.toAttribute());
        }
      }
      msg.setMods(mods);
@@ -3188,7 +3171,7 @@
      mb.append(" ");
      mb.append(String.valueOf(conflictOp));
      mb.append(" ");
      mb.append(e.getLocalizedMessage());
      mb.append(stackTraceToSingleLineString(e));
      logError(mb.toMessage());
    }
@@ -3423,7 +3406,7 @@
       * should we stop the modifications ?
       */
      logError(ERR_LOADING_GENERATION_ID.get(
          getBaseDNString(), e.getLocalizedMessage()));
          getBaseDNString(), stackTraceToSingleLineString(e)));
      return;
    }
@@ -3448,9 +3431,7 @@
    return genId;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public long getGenerationID()
  {
@@ -3600,9 +3581,8 @@
            }
            catch(Exception e)
            {
              Message message = ERR_LOADING_GENERATION_ID.get(
                getBaseDNString(), e.getLocalizedMessage());
              logError(message);
              logError(ERR_LOADING_GENERATION_ID.get(
                  getBaseDNString(), stackTraceToSingleLineString(e)));
            }
          }
        }
@@ -3690,16 +3670,15 @@
        Message message = ERR_LDIFEXPORT_CANNOT_LOCK_BACKEND.get(
            backend.getBackendID(), String.valueOf(failureReason));
        logError(message);
        throw new DirectoryException(ResultCode.OTHER, message, null);
        throw new DirectoryException(ResultCode.OTHER, message);
      }
    }
    catch (Exception e)
    {
      Message message =
          ERR_LDIFEXPORT_CANNOT_LOCK_BACKEND.get(
                  backend.getBackendID(), e.getLocalizedMessage());
      Message message = ERR_LDIFEXPORT_CANNOT_LOCK_BACKEND.get(
          backend.getBackendID(), stackTraceToSingleLineString(e));
      logError(message);
      throw new DirectoryException(ResultCode.OTHER, message, null);
      throw new DirectoryException(ResultCode.OTHER, message);
    }
    long numberOfEntries = backend.numSubordinates(getBaseDN(), true) + 1;
@@ -3762,7 +3741,7 @@
        Message message =
            ERR_LDIFEXPORT_ERROR_DURING_EXPORT.get(de.getMessageObject());
        logError(message);
        throw new DirectoryException(ResultCode.OTHER, message, null);
        throw new DirectoryException(ResultCode.OTHER, message);
      }
    }
    catch (Exception e)
@@ -3770,7 +3749,7 @@
      Message message = ERR_LDIFEXPORT_ERROR_DURING_EXPORT.get(
          stackTraceToSingleLineString(e));
      logError(message);
      throw new DirectoryException(ResultCode.OTHER, message, null);
      throw new DirectoryException(ResultCode.OTHER, message);
    }
    finally
    {
@@ -3793,7 +3772,7 @@
          Message message = WARN_LDIFEXPORT_CANNOT_UNLOCK_BACKEND.get(
              backend.getBackendID(), String.valueOf(failureReason));
          logError(message);
          throw new DirectoryException(ResultCode.OTHER, message, null);
          throw new DirectoryException(ResultCode.OTHER, message);
        }
      }
      catch (Exception e)
@@ -3801,7 +3780,7 @@
        Message message = WARN_LDIFEXPORT_CANNOT_UNLOCK_BACKEND.get(
            backend.getBackendID(), stackTraceToSingleLineString(e));
        logError(message);
        throw new DirectoryException(ResultCode.OTHER, message, null);
        throw new DirectoryException(ResultCode.OTHER, message);
      }
    }
    return genID;
@@ -3862,10 +3841,8 @@
    {
      if (!backend.supportsLDIFImport())
      {
        Message message = ERR_INIT_IMPORT_NOT_SUPPORTED.get(
            backend.getBackendID());
        if (ieContext.getException() == null)
          ieContext.setException(new DirectoryException(OTHER, message));
        ieContext.setExceptionIfNoneSet(new DirectoryException(OTHER,
            ERR_INIT_IMPORT_NOT_SUPPORTED.get(backend.getBackendID())));
      }
      else
      {
@@ -3898,10 +3875,8 @@
    }
    catch(Exception e)
    {
      if (ieContext.getException() == null)
        ieContext.setException(new DirectoryException(
            ResultCode.OTHER,
            ERR_INIT_IMPORT_FAILURE.get(e.getLocalizedMessage())));
      ieContext.setExceptionIfNoneSet(new DirectoryException(ResultCode.OTHER,
          ERR_INIT_IMPORT_FAILURE.get(stackTraceToSingleLineString(e))));
    }
    finally
    {
@@ -3933,10 +3908,9 @@
        // so we don't bother about the new Exception.
        // However if there was no Exception before we want
        // to return this Exception to the task creator.
        if (ieContext.getException() == null)
          ieContext.setException(new DirectoryException(
              ResultCode.OTHER,
              ERR_INIT_IMPORT_FAILURE.get(fe.getLocalizedMessage())));
        ieContext.setExceptionIfNoneSet(new DirectoryException(
            ResultCode.OTHER,
            ERR_INIT_IMPORT_FAILURE.get(stackTraceToSingleLineString(fe))));
      }
    }
@@ -3983,7 +3957,7 @@
    for (SynchronizationProvider<?> provider :
      DirectoryServer.getSynchronizationProviders())
    {
      if (!( provider instanceof MultimasterReplication))
      if (!(provider instanceof MultimasterReplication))
      {
        Message message = ERR_INVALID_PROVIDER.get();
        throw new DirectoryException(ResultCode.OTHER, message);
@@ -4071,16 +4045,14 @@
    LDAPReplicationDomain domain = MultimasterReplication.findDomain(dn, null);
    if (domain != null && domain.getBaseDN().equals(dn))
    {
      Message message = ERR_SYNC_INVALID_DN.get();
      unacceptableReasons.add(message);
      unacceptableReasons.add(ERR_SYNC_INVALID_DN.get());
      return false;
    }
    // Check that the base DN is configured as a base-dn of the directory server
    if (retrievesBackend(dn) == null)
    {
      Message message = ERR_UNKNOWN_DN.get(dn.toString());
      unacceptableReasons.add(message);
      unacceptableReasons.add(ERR_UNKNOWN_DN.get(dn.toString()));
      return false;
    }
@@ -4097,9 +4069,7 @@
    return true;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
         ReplicationDomainCfg configuration)
@@ -4125,9 +4095,7 @@
    return new ConfigChangeResult(ResultCode.SUCCESS, false);
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
         ReplicationDomainCfg configuration, List<Message> unacceptableReasons)
@@ -4153,9 +4121,7 @@
    }
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public Map<String, String> getAlerts()
  {
@@ -4166,9 +4132,7 @@
    return alerts;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public String getClassName()
  {
@@ -4176,9 +4140,7 @@
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public DN getComponentEntryDN()
  {
@@ -4214,10 +4176,8 @@
    catch(Exception e)
    {
      TRACER.debugCaught(DebugLogLevel.ERROR, e);
      MessageBuilder mb = new MessageBuilder();
      mb.append(e.getMessage());
      Message msg = ERR_CHECK_CREATE_REPL_BACKEND_FAILED.get(mb.toString());
      logError(msg);
      logError(ERR_CHECK_CREATE_REPL_BACKEND_FAILED.get(
          stackTraceToSingleLineString(e)));
    }
  }
@@ -4279,11 +4239,11 @@
        eclDomain = new ExternalChangelogDomain(this, eclDomCfg);
      }
    }
    catch (Exception de)
    catch (Exception e)
    {
      throw new ConfigException(NOTE_ERR_UNABLE_TO_ENABLE_ECL.get(
          "Replication Domain on " + getBaseDNString(),
          de.getMessage() + " " + de.getCause().getMessage()), de);
          stackTraceToSingleLineString(e)), e);
    }
  }
@@ -4298,9 +4258,7 @@
    return buffer.toString();
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public void sessionInitiated(
      ServerStatus initStatus,
@@ -4330,10 +4288,9 @@
      }
      catch (DirectoryException de)
      {
        Message message = NOTE_ERR_UNABLE_TO_ENABLE_ECL.get(
        logError(NOTE_ERR_UNABLE_TO_ENABLE_ECL.get(
            "Replication Domain on " + getBaseDNString(),
            de.getMessage() + " " + de.getCause().getMessage());
        logError(message);
            stackTraceToSingleLineString(de)));
        // and go on
      }
    }
@@ -4344,9 +4301,7 @@
      // Go into bad data set status
      setNewStatus(StatusMachineEvent.TO_BAD_GEN_ID_STATUS_EVENT);
      broker.signalStatusChange(status);
      Message message = NOTE_FRACTIONAL_BAD_DATA_SET_NEED_RESYNC.get(
        getBaseDNString());
      logError(message);
      logError(NOTE_FRACTIONAL_BAD_DATA_SET_NEED_RESYNC.get(getBaseDNString()));
      return; // Do not send changes to the replication server
    }
@@ -4384,9 +4339,8 @@
      }
    } catch (Exception e)
    {
      Message message = ERR_PUBLISHING_FAKE_OPS.get(getBaseDNString(),
          e.getLocalizedMessage() + " " + stackTraceToSingleLineString(e));
      logError(message);
      logError(ERR_PUBLISHING_FAKE_OPS.get(getBaseDNString(),
          stackTraceToSingleLineString(e)));
    }
  }
@@ -4592,18 +4546,15 @@
    Backend backend = retrievesBackend(getBaseDN());
    if (!backend.supportsLDIFExport())
    {
      Message message = ERR_INIT_EXPORT_NOT_SUPPORTED.get(
                          backend.getBackendID());
      logError(message);
      throw new DirectoryException(ResultCode.OTHER, message);
      Message msg = ERR_INIT_EXPORT_NOT_SUPPORTED.get(backend.getBackendID());
      logError(msg);
      throw new DirectoryException(ResultCode.OTHER, msg);
    }
    return backend.numSubordinates(getBaseDN(), true) + 1;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean processUpdate(UpdateMsg updateMsg, AtomicBoolean shutdown)
  {
@@ -4685,8 +4636,7 @@
   */
  public int decodeSource(String sourceString) throws DirectoryException
  {
    int  source = 0;
    Throwable cause = null;
    int source = 0;
    try
    {
      source = Integer.decode(sourceString);
@@ -4698,22 +4648,17 @@
        return source;
      }
    }
    catch(Exception e)
    {
      cause = e;
    }
    ResultCode resultCode = ResultCode.OTHER;
    if (cause != null)
    catch (Exception e)
    {
      Message message = ERR_INVALID_IMPORT_SOURCE.get(
          getBaseDNString(), Integer.toString(getServerId()),
          Integer.toString(source), "Details: " + cause.getLocalizedMessage());
      throw new DirectoryException(resultCode, message, cause);
          sourceString, stackTraceToSingleLineString(e));
      throw new DirectoryException(ResultCode.OTHER, message, e);
    }
    Message message = ERR_INVALID_IMPORT_SOURCE.get(getBaseDNString(),
        Integer.toString(getServerId()), Integer.toString(source), "");
    throw new DirectoryException(resultCode, message);
    throw new DirectoryException(ResultCode.OTHER, message);
  }
  /**
@@ -5081,13 +5026,10 @@
      Map<String, Set<String>> fractionalSpecificClassesAttributes,
      Set<String> fractionalAllClassesAttributes) throws ConfigException
    {
      int fractionalMode;
      // Determine if fractional-exclude or fractional-include property is used:
      // only one of them is allowed
      int fractionalMode;
      Iterator<String> iterator;
      // Deduce the wished fractional mode
      if (exclIt != null && exclIt.hasNext())
      {
        if (inclIt != null && inclIt.hasNext())
@@ -5189,8 +5131,8 @@
        return false;
      // Compare modes
      if ((cfg1.isFractional() != cfg2.isFractional())
          || (cfg1.isFractionalExclusive() != cfg2.isFractionalExclusive()))
      if (cfg1.isFractional() != cfg2.isFractional()
          || cfg1.isFractionalExclusive() != cfg2.isFractionalExclusive())
        return false;
      // Compare all classes attributes
opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
@@ -582,8 +582,12 @@
  public DSInfo isRemoteDSConnected(int serverId)
  {
    for (DSInfo remoteDS : getReplicasList())
    {
      if (remoteDS.getDsId() == serverId)
      {
        return remoteDS;
      }
    }
    return null;
  }
@@ -644,7 +648,9 @@
  int getNumProcessedUpdates()
  {
    if (numProcessedUpdates != null)
    {
      return numProcessedUpdates.get();
    }
    return 0;
  }
@@ -656,7 +662,9 @@
  int getNumRcvdUpdates()
  {
    if (numRcvdUpdates != null)
    {
      return numRcvdUpdates.get();
    }
    return 0;
  }
@@ -668,7 +676,9 @@
  int getNumSentUpdates()
  {
    if (numSentUpdates != null)
    {
      return numSentUpdates.get();
    }
    return 0;
  }
@@ -961,11 +971,17 @@
          case SAFE_READ_MODE:
            assuredSrNotAcknowledgedUpdates.incrementAndGet();
            if (hasTimeout)
            {
              assuredSrTimeoutUpdates.incrementAndGet();
            }
            if (hasReplayErrors)
            {
              assuredSrReplayErrorUpdates.incrementAndGet();
            }
            if (hasWrongStatus)
            {
              assuredSrWrongStatusUpdates.incrementAndGet();
            }
            if (failedServers != null) // This should always be the case !
            {
              for(Integer sid : failedServers)
@@ -978,7 +994,9 @@
          case SAFE_DATA_MODE:
            // The only possible cause of ack error in safe data mode is timeout
            if (hasTimeout) // So should always be the case
            {
              assuredSdTimeoutUpdates.incrementAndGet();
            }
            if (failedServers != null) // This should always be the case !
            {
              for(Integer sid : failedServers)
@@ -1135,7 +1153,7 @@
     * Flow control during initialization: for each remote server, counter of
     * messages received.
     */
    private final HashMap<Integer, Integer> ackVals =
    private final Map<Integer, Integer> ackVals =
      new HashMap<Integer, Integer>();
    /**
     * ServerId of the slowest server (the one with the smallest non null
@@ -1263,6 +1281,20 @@
    }
    /**
     * Only sets the exception that occurred during the import/export if none
     * was already set on this object.
     *
     * @param exception the exception that occurred during the import/export.
     */
    public void setExceptionIfNoneSet(DirectoryException exception)
    {
      if (exception == null)
      {
        this.exception = exception;
      }
    }
    /**
     * Set the id of the EntryMsg acknowledged from a receiver (importer)server.
     * (updated via the listener thread)
     * @param serverId serverId of the acknowledger/receiver/importer server.
@@ -1278,8 +1310,12 @@
      // Recompute the server with the minAck returned,means the slowest server.
      slowestServerId = serverId;
      for (Integer sid : ieContext.ackVals.keySet())
      {
        if (this.ackVals.get(sid) < this.ackVals.get(slowestServerId))
        {
          slowestServerId = sid;
        }
      }
    }
    /**
@@ -1296,7 +1332,9 @@
      return this.slowestServerId;
    }
}
  }
  /**
   * Verifies that the given string represents a valid source
   * from which this server can be initialized.
@@ -1395,13 +1433,17 @@
      logError(msg);
      for (DSInfo dsi : getReplicasList())
      {
        ieContext.startList.add(dsi.getDsId());
      }
      // We manage the list of servers with which a flow control can be enabled
      for (DSInfo dsi : getReplicasList())
      {
        if (dsi.getProtocolVersion()>= ProtocolVersion.REPLICATION_PROTOCOL_V4)
        {
          ieContext.setAckVal(dsi.getDsId(), 0);
        }
      }
    }
    else
@@ -1417,7 +1459,9 @@
      {
        if (dsi.getDsId() == serverToInitialize &&
            dsi.getProtocolVersion()>= ProtocolVersion.REPLICATION_PROTOCOL_V4)
        {
          ieContext.setAckVal(dsi.getDsId(), 0);
        }
      }
    }
@@ -1430,7 +1474,9 @@
      {
        ieContext.exportTarget = serverToInitialize;
        if (initTask != null)
        {
          ieContext.initializeTask = initTask;
        }
        ieContext.initializeCounters(this.countEntries());
        ieContext.msgCnt = 0;
        ieContext.initNumLostConnections = broker.getNumLostConnections();
@@ -1465,10 +1511,8 @@
      catch(DirectoryException exportException)
      {
        // Give priority to the first exception raised - stored in the context
        if (ieContext.exception != null)
          exportRootException = ieContext.exception;
        else
          exportRootException = exportException;
        final DirectoryException ieEx = ieContext.exception;
        exportRootException = ieEx != null ? ieEx : exportException;
      }
      if (debugEnabled())
@@ -1499,8 +1543,10 @@
            int att=0;
            while (!broker.shuttingDown() && !broker.isConnected()
                && ++att < 100)
            {
              try { Thread.sleep(100); }
              catch(Exception e){ /* do nothing */ }
            }
          }
          if (initTask != null && broker.isConnected()
@@ -1655,7 +1701,9 @@
    and the others
    */
    for (DSInfo dsi : getReplicasList())
    {
      replicasWeAreWaitingFor.add(dsi.getDsId());
    }
    boolean done;
    do
@@ -1713,10 +1761,12 @@
      // loop and wait
      if (!done)
      {
        try { Thread.sleep(1000); }
        catch (InterruptedException e) {
          Thread.currentThread().interrupt();
        } // 1sec
      }
    }
    while (!done && !broker.shuttingDown()); // infinite wait
@@ -1769,11 +1819,8 @@
    if (ieContext != null && ieContext.exportTarget != RoutableMsg.ALL_SERVERS)
    {
      // The ErrorMsg is received while we have started an initialization
      if (ieContext.getException() == null)
      {
        ieContext.setException(
            new DirectoryException(ResultCode.OTHER, errorMsg.getDetails()));
      }
      ieContext.setExceptionIfNoneSet(new DirectoryException(
          ResultCode.OTHER, errorMsg.getDetails()));
      /*
       * This can happen :
@@ -1814,9 +1861,11 @@
        msg = broker.receive(false, false, true);
        if (debugEnabled())
        {
          TRACER.debugInfo("[IE] In "
              + broker.getReplicationMonitorInstanceName()
              + ", receiveEntryBytes " + msg);
        }
        if (msg == null)
        {
@@ -1828,11 +1877,9 @@
          else
          {
            // Handle connection issues
            if (ieContext.getException() == null)
              ieContext.setException(new DirectoryException(
                  ResultCode.OTHER,
                  ERR_INIT_RS_DISCONNECTION_DURING_IMPORT.get(
                      broker.getReplicationServer())));
            ieContext.setExceptionIfNoneSet(new DirectoryException(
                ResultCode.OTHER, ERR_INIT_RS_DISCONNECTION_DURING_IMPORT
                    .get(broker.getReplicationServer())));
            return null;
          }
        }
@@ -1850,11 +1897,10 @@
            // check the msgCnt of the msg received to check ordering
            if (++ieContext.msgCnt != entryMsg.getMsgId())
            {
              if (ieContext.getException() == null)
                ieContext.setException(new DirectoryException(ResultCode.OTHER,
                    ERR_INIT_BAD_MSG_ID_SEQ_DURING_IMPORT.get(
                        String.valueOf(ieContext.msgCnt),
                        String.valueOf(entryMsg.getMsgId()))));
              ieContext.setExceptionIfNoneSet(new DirectoryException(
                  ResultCode.OTHER, ERR_INIT_BAD_MSG_ID_SEQ_DURING_IMPORT.get(
                      String.valueOf(ieContext.msgCnt),
                      String.valueOf(entryMsg.getMsgId()))));
              return null;
            }
@@ -1867,9 +1913,11 @@
                  ieContext.msgCnt);
              broker.publish(amsg, false);
              if (debugEnabled())
              {
                TRACER.debugInfo("[IE] In "
                    + broker.getReplicationMonitorInstanceName()
                    + ", publish InitializeRcvAckMsg" + amsg);
              }
            }
          }
          return entryBytes;
@@ -1912,17 +1960,16 @@
                      getBaseDNString(),
                      Integer.toString(this.serverID),
                      Integer.toString(ieContext.importSource)));
            if (ieContext.getException()==null)
              ieContext.setException(new DirectoryException(ResultCode.OTHER,
                errMsg));
            ieContext.setExceptionIfNoneSet(new DirectoryException(
                ResultCode.OTHER, errMsg));
            return null;
          }
        }
      }
      catch(Exception e)
      {
        if (ieContext.getException() == null)
          ieContext.setException(new DirectoryException(ResultCode.OTHER,
        ieContext.setExceptionIfNoneSet(new DirectoryException(
            ResultCode.OTHER,
            ERR_INIT_IMPORT_FAILURE.get(e.getLocalizedMessage())));
      }
    }
@@ -1995,7 +2042,9 @@
      we just abandon the export by throwing an exception.
      */
      if (ieContext.getException() != null)
      {
        throw new IOException(ieContext.getException().getMessage());
      }
      int slowestServerId = ieContext.getSlowestServer();
      if (isRemoteDSConnected(slowestServerId)==null)
@@ -2032,8 +2081,7 @@
          DirectoryException de = new DirectoryException(ResultCode.OTHER,
              ERR_INIT_RS_DISCONNECTION_DURING_EXPORT.get(
                  Integer.toString(broker.getRsServerId())));
          if (ieContext.getException() == null)
            ieContext.setException(de);
          ieContext.setExceptionIfNoneSet(de);
          // .. and abandon the export by throwing an exception.
          throw new IOException(de.getMessage());
        }
@@ -2061,8 +2109,7 @@
      DirectoryException de = new DirectoryException(ResultCode.OTHER,
          ERR_INIT_RS_DISCONNECTION_DURING_EXPORT.get(
              Integer.toString(broker.getRsServerId())));
      if (ieContext.getException() == null)
        ieContext.setException(de);
      ieContext.setExceptionIfNoneSet(de);
      // .. and abandon the export by throwing an exception.
      throw new IOException(de.getMessage());
    }
@@ -2074,9 +2121,7 @@
    }
    catch (DirectoryException de)
    {
      // store the error in the ieContext ...
      if (ieContext.getException() == null)
        ieContext.setException(de);
      ieContext.setExceptionIfNoneSet(de);
      // .. and abandon the export by throwing an exception.
      throw new IOException(de.getMessage());
    }
@@ -2157,7 +2202,9 @@
    Message errMsg = null;
    if (debugEnabled())
    {
      TRACER.debugInfo("[IE] Entering initializeFromRemote for " + this);
    }
    if (!broker.isConnected())
    {
@@ -2238,7 +2285,9 @@
    InitializeTask initFromTask = null;
    if (debugEnabled())
    {
      TRACER.debugInfo("[IE] Entering initialize - domain=" + this);
    }
    int source = initTargetMsgReceived.getSenderID();
@@ -2281,15 +2330,16 @@
      Store the exception raised. It will be considered if no other exception
      has been previously stored in  the context
      */
      if (ieContext.getException() == null)
        ieContext.setException(e);
      ieContext.setExceptionIfNoneSet(e);
    }
    finally
    {
      if (debugEnabled())
      {
        TRACER.debugInfo("[IE] Domain=" + this
          + " ends import with exception=" + ieContext.getException()
          + " connected=" + broker.isConnected());
      }
      /*
      It is necessary to restart (reconnect to RS) for different reasons
@@ -2351,11 +2401,13 @@
      // No new attempt case
      if (debugEnabled())
      {
        TRACER.debugInfo("[IE] Domain=" + this
          + " ends initialization with exception=" + ieContext.getException()
          + " connected=" + broker.isConnected()
          + " task=" + initFromTask
          + " attempt=" + ieContext.attemptCnt);
      }
      try
      {
@@ -2433,14 +2485,18 @@
      lastStatusChangeDate = new Date();
      // Reset monitoring counters if reconnection
      if (newStatus == ServerStatus.NOT_CONNECTED_STATUS)
      {
        resetMonitoringCounters();
      }
      // Store new status
      status = newStatus;
      if (debugEnabled())
      {
        TRACER.debugInfo("Replication domain " + baseDN + " new status is: "
            + status);
      }
      // Perform whatever actions are needed to apply properties for being
      // compliant with new status
@@ -2557,8 +2613,10 @@
      throws DirectoryException
  {
    if (debugEnabled())
    {
      TRACER.debugInfo("Server id " + serverID + " and domain " + baseDN
          + " resetGenerationId " + generationIdNewValue);
    }
    ResetGenerationIdMsg genIdMessage =
        new ResetGenerationIdMsg(getGenId(generationIdNewValue));
@@ -2602,7 +2660,9 @@
  int getMaxRcvWindow()
  {
    if (broker != null)
    {
      return broker.getMaxRcvWindow();
    }
    return 0;
  }
@@ -2614,7 +2674,9 @@
  int getCurrentRcvWindow()
  {
    if (broker != null)
    {
      return broker.getCurrentRcvWindow();
    }
    return 0;
  }
@@ -2626,7 +2688,9 @@
  int getMaxSendWindow()
  {
    if (broker != null)
    {
      return broker.getMaxSendWindow();
    }
    return 0;
  }
@@ -2638,7 +2702,9 @@
  int getCurrentSendWindow()
  {
    if (broker != null)
    {
      return broker.getCurrentSendWindow();
    }
    return 0;
  }
@@ -2649,7 +2715,9 @@
  int getNumLostConnections()
  {
    if (broker != null)
    {
      return broker.getNumLostConnections();
    }
    return 0;
  }
@@ -2713,7 +2781,9 @@
  public String getReplicationServer()
  {
    if (broker != null)
    {
      return broker.getReplicationServer();
    }
    return ReplicationBroker.NO_CONNECTED_SERVER;
  }
@@ -3230,7 +3300,9 @@
      msg.setAssured(true);
      msg.setAssuredMode(assuredMode);
      if (assuredMode == AssuredMode.SAFE_DATA_MODE)
      {
        msg.setSafeDataLevel(assuredSdLevel);
      }
      // Add the assured message to the list of update that are waiting for acks
      waitingAckMsgs.put(msg.getCSN(), msg);
@@ -3453,7 +3525,9 @@
  long getLeftEntryCount()
  {
    if (ieContext != null)
    {
      return ieContext.entryLeftCount;
    }
    return 0;
  }
@@ -3479,7 +3553,9 @@
  long getTotalEntryCount()
  {
    if (ieContext != null)
    {
      return ieContext.entryCount;
    }
    return 0;
  }