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

Jean-Noel Rouvignac
02.36.2013 953518994bcf57065afc7b9d8784eb0f0b922048
ECLSearchOperation.java:
Code cleanup.
Used StaticUtil.close()

ExternalChangeLogSession.java:
Now implements Closeable.

ReplicationServer.java:
Improved a logged message.
3 files modified
96 ■■■■■ changed files
opends/src/server/org/opends/server/replication/common/ExternalChangeLogSession.java 13 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServer.java 1 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java 82 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/common/ExternalChangeLogSession.java
@@ -23,9 +23,12 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 */
package org.opends.server.replication.common;
import java.io.Closeable;
import org.opends.server.replication.protocol.ECLUpdateMsg;
import org.opends.server.types.DirectoryException;
@@ -33,21 +36,19 @@
 * This interface defines a session used to search the external changelog
 * in the Directory Server.
 */
public interface ExternalChangeLogSession
public interface ExternalChangeLogSession extends Closeable
{
  /**
   * Returns the next message available for the ECL (blocking).
   * @return the next available message from the ECL.
   * @throws DirectoryException When an error occurs.
   */
  public abstract ECLUpdateMsg getNextUpdate()
  throws DirectoryException;
  ECLUpdateMsg getNextUpdate() throws DirectoryException;
  /**
   * Closes the session.
   * @throws DirectoryException when needed.
   */
  public abstract void close()
  throws DirectoryException;
  @Override
  void close();
}
opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -1966,6 +1966,7 @@
  {
    MessageBuilder mb = new MessageBuilder();
    mb.append(ERR_CHANGELOG_SHUTDOWN_DATABASE_ERROR.get());
    mb.append(".   ");
    mb.append(stackTraceToSingleLineString(e));
    logError(mb.toMessage());
    shutdown();
opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
@@ -27,8 +27,6 @@
 */
package org.opends.server.workflowelement.externalchangelog;
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.ErrorLogger.*;
@@ -62,8 +60,6 @@
import org.opends.server.types.operation.SearchReferenceSearchOperation;
import org.opends.server.util.ServerConstants;
/**
 * This class defines an operation used to search for entries in a local backend
 * of the Directory Server.
@@ -83,24 +79,17 @@
   */
  private StartECLSessionMsg startECLSessionMsg;
  //The set of supported controls for this WE
  private static final HashSet<String> CHANGELOG_SUPPORTED_CONTROLS;
  static
  {
    CHANGELOG_SUPPORTED_CONTROLS = new HashSet<String>(0);
    CHANGELOG_SUPPORTED_CONTROLS
        .add(ServerConstants.OID_SERVER_SIDE_SORT_REQUEST_CONTROL);
    CHANGELOG_SUPPORTED_CONTROLS.add(ServerConstants.OID_VLV_REQUEST_CONTROL);
  }
  /** The set of supported controls for this WE. */
  private static final Set<String> CHANGELOG_SUPPORTED_CONTROLS =
      new HashSet<String>(Arrays.asList(
          ServerConstants.OID_SERVER_SIDE_SORT_REQUEST_CONTROL,
          ServerConstants.OID_VLV_REQUEST_CONTROL));
  // The set of objectclasses that will be used in ECL root entry.
  /** The set of objectclasses that will be used in ECL root entry. */
  private static final HashMap<ObjectClass, String>
    CHANGELOG_ROOT_OBJECT_CLASSES;
    CHANGELOG_ROOT_OBJECT_CLASSES = new LinkedHashMap<ObjectClass, String>(2);
  static
  {
    CHANGELOG_ROOT_OBJECT_CLASSES = new LinkedHashMap<ObjectClass, String>(2);
    ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP, true);
    CHANGELOG_ROOT_OBJECT_CLASSES.put(topOC, OC_TOP);
@@ -108,13 +97,11 @@
    CHANGELOG_ROOT_OBJECT_CLASSES.put(containerOC, "container");
  }
  // The set of objectclasses that will be used in ECL entries.
  /** The set of objectclasses that will be used in ECL entries. */
  private static final HashMap<ObjectClass, String>
    CHANGELOG_ENTRY_OBJECT_CLASSES;
    CHANGELOG_ENTRY_OBJECT_CLASSES = new LinkedHashMap<ObjectClass, String>(2);
  static
  {
    CHANGELOG_ENTRY_OBJECT_CLASSES = new LinkedHashMap<ObjectClass, String>(2);
    ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP, true);
    CHANGELOG_ENTRY_OBJECT_CLASSES.put(topOC, OC_TOP);
@@ -124,22 +111,17 @@
  }
  // The attribute type for the "creatorsName" attribute.
  private static final AttributeType CREATORS_NAME_TYPE;
  /** The attribute type for the "creatorsName" attribute. */
  private static final AttributeType CREATORS_NAME_TYPE = DirectoryConfig
      .getAttributeType(OP_ATTR_CREATORS_NAME_LC, true);
  // The attribute type for the "modifiersName" attribute.
  private static final AttributeType MODIFIERS_NAME_TYPE;
  static
  {
    CREATORS_NAME_TYPE = DirectoryConfig.getAttributeType(
        OP_ATTR_CREATORS_NAME_LC, true);
  /** The attribute type for the "modifiersName" attribute. */
  private static final AttributeType
    MODIFIERS_NAME_TYPE = DirectoryConfig.getAttributeType(
        OP_ATTR_MODIFIERS_NAME_LC, true);
  }
  // The associated DN.
  /** The associated DN. */
  private static final DN CHANGELOG_ROOT_DN;
  static
  {
@@ -341,15 +323,8 @@
          persistentSearch.cancel();
          setSendResponse(true);
        }
        if (eclSession != null)
        {
          try
          {
            eclSession.close();
          }
          catch(Exception ignored){}
        }
          throw coe;
        close(eclSession);
        throw coe;
      }
      catch (Exception e)
      {
@@ -399,9 +374,8 @@
    List<Control> requestControls  = getRequestControls();
    if ((requestControls != null) && (! requestControls.isEmpty()))
    {
      for (int i=0; i < requestControls.size(); i++)
      for (Control c : requestControls)
      {
        Control c   = requestControls.get(i);
        String  oid = c.getOID();
        if (!AccessControlConfigManager.getInstance().getAccessControlHandler()
@@ -684,7 +658,7 @@
    {
      if (persistentSearch == null || abortECLSession)
      {
        eclSession.close();
        close(eclSession);
      }
    }
  }
@@ -1284,14 +1258,7 @@
  {
    if (debugEnabled())
      TRACER.debugInfo(this + " cancel() " + eclSession);
    if (eclSession != null)
    {
      try
      {
        eclSession.close();
      }
      catch(Exception e){}
    }
    close(eclSession);
    return super.cancel(cancelRequest);
  }
@@ -1303,14 +1270,7 @@
  {
    if (debugEnabled())
      TRACER.debugInfo(this + " abort() " + eclSession);
    if (eclSession != null)
    {
      try
      {
        eclSession.close();
      }
      catch(Exception e){}
    }
    close(eclSession);
  }
  /**