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

boli
18.37.2008 5d6b56353ce3a2816410052d4b2b531c0c676c06
Enhancement to fix for issue 2499. Added nanosecond processing time method to AbstractOperation API. Removed the dashes in the etime resolution configuration enum values. Added get/setUseNanoTime methods to DirectoryServer class

Fix for issue 2499
9 files modified
220 ■■■■■ changed files
opends/resource/config/config.ldif 2 ●●● patch | view | raw | blame | history
opends/src/admin/defn/org/opends/server/admin/std/GlobalConfiguration.xml 10 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/CoreConfigManager.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/DirectoryServer.java 33 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/OperationWrapper.java 10 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/SearchOperationBasis.java 14 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java 49 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/AbstractOperation.java 84 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/Operation.java 14 ●●●●● patch | view | raw | blame | history
opends/resource/config/config.ldif
@@ -49,7 +49,7 @@
ds-cfg-return-bind-error-messages: false
ds-cfg-idle-time-limit: 0 seconds
ds-cfg-save-config-on-successful-startup: true
ds-cfg-etime-resolution: milli-seconds
ds-cfg-etime-resolution: milliseconds
ds-cfg-allowed-task: org.opends.server.tasks.AddSchemaFileTask
ds-cfg-allowed-task: org.opends.server.tasks.BackupTask
ds-cfg-allowed-task: org.opends.server.tasks.DisconnectClientTask
opends/src/admin/defn/org/opends/server/admin/std/GlobalConfiguration.xml
@@ -786,20 +786,20 @@
    <adm:default-behavior>
      <adm:defined>
        <adm:value>
          milli-seconds
          milliseconds
        </adm:value>
      </adm:defined>
    </adm:default-behavior>
    <adm:syntax>
      <adm:enumeration>
        <adm:value name="milli-seconds">
        <adm:value name="milliseconds">
          <adm:synopsis>
            Use milli-second resolution.
            Use millisecond resolution.
          </adm:synopsis>
        </adm:value>
        <adm:value name="nano-seconds">
        <adm:value name="nanoseconds">
          <adm:synopsis>
            Use nano-second resolution.
            Use nanosecond resolution.
          </adm:synopsis>
        </adm:value>
      </adm:enumeration>
opends/src/server/org/opends/server/core/CoreConfigManager.java
@@ -353,8 +353,8 @@
      DirectoryServer.setWorkflowConfigurationMode(newMode);
    }
    AbstractOperation.setUseNanoTime(globalConfig.getEtimeResolution() ==
      GlobalCfgDefn.EtimeResolution.NANO_SECONDS);
    DirectoryServer.setUseNanoTime(globalConfig.getEtimeResolution() ==
      GlobalCfgDefn.EtimeResolution.NANOSECONDS);
  }
opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -572,6 +572,9 @@
  // a search.
  private int lookthroughLimit;
  // Whether to use collect operation processing times in nanosecond resolution
  private boolean useNanoTime;
  // The key manager provider configuration manager for the Directory Server.
  private KeyManagerProviderConfigManager keyManagerProviderConfigManager;
@@ -8913,6 +8916,36 @@
  /**
   * Specifies whether to collect nanosecond resolution processing times for
   * operations.
   *
   * @param useNanoTime  <code>true</code> if nanosecond resolution times
   *                     should be collected or <code>false</code> to
   *                     only collect in millisecond resolution.
   */
  public static void setUseNanoTime(boolean useNanoTime)
  {
    directoryServer.useNanoTime = useNanoTime;
  }
  /**
   * Retrieves whether operation processing times should be collected with
   * nanosecond resolution.
   *
   * @return  <code>true</code> if nanosecond resolution times are collected
   *          or <code>false</code> if only millisecond resolution times are
   *          being collected.
   */
  public static boolean getUseNanoTime()
  {
    return directoryServer.useNanoTime;
  }
  /**
   * Retrieves the writability mode for the Directory Server.  This will only
   * be applicable for user suffixes.
   *
opends/src/server/org/opends/server/core/OperationWrapper.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.core;
@@ -273,6 +273,14 @@
  /**
   * {@inheritDoc}
   */
  public long getProcessingNanoTime()
  {
    return operation.getProcessingNanoTime();
  }
  /**
   * {@inheritDoc}
   */
  public List<String> getReferralURLs()
  {
    return operation.getReferralURLs();
opends/src/server/org/opends/server/core/SearchOperationBasis.java
@@ -627,9 +627,8 @@
    // See if the time limit has expired.  If so, then don't send the entry and
    // indicate that the search should end.
    if ((getTimeLimit() > 0) &&
        ((getUseNanoTime() ? TimeThread.getNanoTime() :
                             TimeThread.getTime()) >= getTimeLimitExpiration()))
    if ((getTimeLimit() > 0) && (TimeThread.getTime() >=
                                                getTimeLimitExpiration()))
    {
      setResultCode(ResultCode.TIME_LIMIT_EXCEEDED);
      appendErrorMessage(ERR_SEARCH_TIME_LIMIT_EXCEEDED.get(getTimeLimit()));
@@ -1055,9 +1054,8 @@
    // See if the time limit has expired.  If so, then don't send the entry and
    // indicate that the search should end.
    if ((getTimeLimit() > 0) &&
        ((getUseNanoTime() ? TimeThread.getNanoTime() :
                             TimeThread.getTime()) >= getTimeLimitExpiration()))
    if ((getTimeLimit() > 0) && (TimeThread.getTime() >=
                                                getTimeLimitExpiration()))
    {
      setResultCode(ResultCode.TIME_LIMIT_EXCEEDED);
      appendErrorMessage(ERR_SEARCH_TIME_LIMIT_EXCEEDED.get(getTimeLimit()));
@@ -1625,8 +1623,8 @@
    else
    {
      // FIXME -- Factor in the user's effective time limit.
      timeLimitExpiration = getProcessingStartTime() +
          ((getUseNanoTime() ? 1000000000L : 1000L) * timeLimit);
      timeLimitExpiration =
        getProcessingStartTime() + (1000L * timeLimit);
    }
    setTimeLimitExpiration(timeLimitExpiration);
opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
@@ -796,7 +796,12 @@
    }
    buffer.append("\" etime=");
    buffer.append(bindOperation.getProcessingTime());
    long etime = bindOperation.getProcessingNanoTime();
    if(etime <= -1)
    {
      etime = bindOperation.getProcessingTime();
    }
    buffer.append(etime);
    writer.writeRecord(buffer.toString());
  }
@@ -915,7 +920,12 @@
    }
    buffer.append("\" etime=");
    buffer.append(compareOperation.getProcessingTime());
    long etime = compareOperation.getProcessingNanoTime();
    if(etime <= -1)
    {
      etime = compareOperation.getProcessingTime();
    }
    buffer.append(etime);
    writer.writeRecord(buffer.toString());
  }
@@ -1034,7 +1044,12 @@
    }
    buffer.append("\" etime=");
    buffer.append(deleteOperation.getProcessingTime());
    long etime = deleteOperation.getProcessingNanoTime();
    if(etime <= -1)
    {
      etime = deleteOperation.getProcessingTime();
    }
    buffer.append(etime);
    writer.writeRecord(buffer.toString());
  }
@@ -1156,7 +1171,12 @@
    }
    buffer.append("\" etime=");
    buffer.append(extendedOperation.getProcessingTime());
    long etime = extendedOperation.getProcessingNanoTime();
    if(etime <= -1)
    {
      etime = extendedOperation.getProcessingTime();
    }
    buffer.append(etime);
    writer.writeRecord(buffer.toString());
  }
@@ -1276,7 +1296,12 @@
    }
    buffer.append("\" etime=");
    buffer.append(modifyOperation.getProcessingTime());
    long etime = modifyOperation.getProcessingNanoTime();
    if(etime <= -1)
    {
      etime = modifyOperation.getProcessingTime();
    }
    buffer.append(etime);
    writer.writeRecord(buffer.toString());
  }
@@ -1407,7 +1432,12 @@
    }
    buffer.append("\" etime=");
    buffer.append(modifyDNOperation.getProcessingTime());
    long etime = modifyDNOperation.getProcessingNanoTime();
    if(etime <= -1)
    {
      etime = modifyDNOperation.getProcessingTime();
    }
    buffer.append(etime);
    writer.writeRecord(buffer.toString());
  }
@@ -1586,7 +1616,12 @@
    }
    buffer.append(" etime=");
    buffer.append(searchOperation.getProcessingTime());
    long etime = searchOperation.getProcessingNanoTime();
    if(etime <= -1)
    {
      etime = searchOperation.getProcessingTime();
    }
    buffer.append(etime);
    writer.writeRecord(buffer.toString());
  }
opends/src/server/org/opends/server/types/AbstractOperation.java
@@ -30,7 +30,6 @@
import static org.opends.server.core.CoreConstants.*;
import static org.opends.server.util.ServerConstants.*;
import java.util.ArrayList;
import java.util.HashMap;
@@ -68,12 +67,6 @@
  protected static final List<Control> NO_RESPONSE_CONTROLS =
       new ArrayList<Control>(0);
  /**
   * Indicates whether to use nanoTime instead of
   * currentTimeMillis when setting processing start and stop times.
   */
  protected static boolean useNanoTime = false;
  /**
   * The client connection with which this operation is associated.
@@ -97,7 +90,7 @@
  /**
   * Wether nanotime was used for this operation.
   */
  protected final boolean usingNanoTime;
  protected final boolean useNanoTime;
@@ -143,12 +136,22 @@
  // other copies of the data.
  private boolean dontSynchronizeFlag;
  // The time that processing started on this operation.
  // The time that processing started on this operation in
  // milliseconds.
  private long processingStartTime;
  // The time that processing ended on this operation.
  // The time that processing ended on this operation in
  // milliseconds.
  private long processingStopTime;
  // The time that processing started on this operation in
  // nanoseconds.
  private long processingStartNanoTime;
  // The time that processing ended on this operation in
  // nanoseconds.
  private long processingStopNanoTime;
  /**
   * Creates a new operation with the provided information.
   *
@@ -168,7 +171,7 @@
    this.clientConnection = clientConnection;
    this.operationID      = operationID;
    this.messageID        = messageID;
    this.usingNanoTime    = useNanoTime;
    this.useNanoTime = DirectoryServer.getUseNanoTime();
    if (requestControls == null)
    {
@@ -1042,13 +1045,10 @@
   */
  public final void setProcessingStartTime()
  {
    if(usingNanoTime)
    processingStartTime = System.currentTimeMillis();
    if(useNanoTime)
    {
      processingStartTime = System.nanoTime();
    }
    else
    {
      processingStartTime = System.currentTimeMillis();
      processingStartNanoTime = System.nanoTime();
    }
  }
@@ -1075,25 +1075,22 @@
   */
  public final void setProcessingStopTime()
  {
    if(usingNanoTime)
    this.processingStopTime = System.currentTimeMillis();
    if(useNanoTime)
    {
      this.processingStopTime = System.nanoTime();
    }
    else
    {
      this.processingStopTime = System.currentTimeMillis();
      this.processingStopNanoTime = System.nanoTime();
    }
  }
  /**
   * Retrieves the length of time in milliseconds or nanoseconds that
   * Retrieves the length of time in milliseconds that
   * the server spent processing this operation.  This should not be
   * called until after the server has sent the response to the
   * client.
   *
   * @return  The length of time in milliseconds or nanoseconds that
   * @return  The length of time in milliseconds that
   *          the server spent processing this operation.
   */
  public final long getProcessingTime()
@@ -1104,30 +1101,25 @@
  /**
   * Set whether to use nanoTime for the processing time methods.
   * Retrieves the length of time in nanoseconds that
   * the server spent processing this operation if available.
   * This should not be called until after the server has sent the
   * response to the client.
   *
   * @param useNanoTime <code>true</code> to use System.nanoTime
   *                    or <code>false</code> to use
   *                    System.currentTimeMillis
   * @return  The length of time in nanoseconds that the server
   *          spent processing this operation or -1 if its not
   *          available.
   */
  public static void setUseNanoTime(boolean useNanoTime)
  public final long getProcessingNanoTime()
  {
    AbstractOperation.useNanoTime = useNanoTime;
  }
  /**
   * Get whether this operation used System.nanoTime or
   * System.currentTimeMillis for the processing time methods.
   *
   * @return  <code>true</code> if System.nanoTime is used or
   *          <code>false</code> if System.currentTimeMillis
   *          was used.
   */
  public final boolean getUseNanoTime()
  {
    return usingNanoTime;
    if(useNanoTime)
    {
      return (processingStopNanoTime - processingStartNanoTime);
    }
    else
    {
      return -1;
    }
  }
opends/src/server/org/opends/server/types/Operation.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.types;
import org.opends.messages.Message;
@@ -512,6 +512,18 @@
  public abstract long getProcessingTime();
  /**
   * Retrieves the length of time in nanoseconds that
   * the server spent processing this operation if available.
   * This should not be called until after the server has sent the
   * response to the client.
   *
   * @return  The length of time in nanoseconds that the server
   *          spent processing this operation or -1 if its not
   *          available.
   */
  public abstract long getProcessingNanoTime();
  /**
   * Indicates that processing on this operation has completed
   * successfully and that the client should perform any associated
   * cleanup work.