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

Gaetan Boismal
29.44.2014 26475fe227db50b6bdad15b7ed48f9d6e0140a7d
OPENDJ-1536 Apply consequence of the renaming of the FutureResult classes hierarchy
3 files modified
118 ■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/protocols/http/CollectClientConnectionsFilter.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/protocols/http/HTTPClientConnection.java 81 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java 35 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/protocols/http/CollectClientConnectionsFilter.java
@@ -206,7 +206,7 @@
                if (bindDN == null)
                {
                  sendAuthenticationFailure(ctx);
                  return newFailedPromise(newErrorResult(ResultCode.CANCELLED));
                  return newFailedPromise(newLdapException(ResultCode.CANCELLED));
                }
                else
                {
opendj3-server-dev/src/server/org/opends/server/protocols/http/HTTPClientConnection.java
@@ -40,7 +40,7 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.LdapException;
import org.forgerock.opendj.ldap.FutureResultImpl;
import org.forgerock.opendj.ldap.spi.LdapPromiseImpl;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchResultHandler;
import org.forgerock.opendj.ldap.responses.Result;
@@ -99,18 +99,18 @@
  /**
   * Class grouping together an {@link Operation} and its associated
   * {@link PromiseImpl} to ensure they are both atomically added
   * {@link LdapPromiseImpl} to ensure they are both atomically added
   * and removed from the {@link HTTPClientConnection#operationsInProgress} Map.
   */
  private static class OperationWithFutureResult
  private static class OperationWithPromise
  {
    final Operation operation;
    final FutureResultImpl<Result> futureResult;
    final LdapPromiseImpl<Result> promise;
    public OperationWithFutureResult(Operation operation, FutureResultImpl<Result> futureResult)
    public OperationWithPromise(Operation operation, LdapPromiseImpl<Result> promise)
    {
      this.operation = operation;
      this.futureResult = futureResult;
      this.promise = promise;
    }
    @Override
@@ -121,15 +121,15 @@
  }
  /** {@inheritDoc} */
  private static final class SearchOperationWithFutureResult extends OperationWithFutureResult
  private static final class SearchOperationWithPromise extends OperationWithPromise
  {
    final SearchResultHandler entryHandler;
    public SearchOperationWithFutureResult(Operation operation, FutureResultImpl<Result> future,
    public SearchOperationWithPromise(Operation operation, LdapPromiseImpl<Result> promise,
        SearchResultHandler entryHandler)
    {
      super(operation, future);
      super(operation, promise);
      this.entryHandler = entryHandler;
    }
  }
@@ -163,11 +163,11 @@
  private final boolean keepStats;
  /**
   * The Map (messageID => {@link OperationWithFutureResult}) of all operations
   * The Map (messageID => {@link OperationWithPromise}) of all operations
   * currently in progress on this connection.
   */
  private final Map<Integer, OperationWithFutureResult> operationsInProgress =
      new ConcurrentHashMap<Integer, OperationWithFutureResult>();
  private final Map<Integer, OperationWithPromise> operationsInProgress =
      new ConcurrentHashMap<Integer, OperationWithPromise>();
  /**
   * The number of operations performed on this connection. Used to compare with
@@ -405,13 +405,12 @@
          .getOperationType(), time);
    }
    OperationWithFutureResult op =
        this.operationsInProgress.get(operation.getMessageID());
    OperationWithPromise op = this.operationsInProgress.get(operation.getMessageID());
    if (op != null)
    {
      try
      {
        op.futureResult.handleResult(getResponseResult(operation));
        op.promise.handleResult(getResponseResult(operation));
        if (keepStats)
        {
@@ -421,7 +420,7 @@
      }
      catch (LdapException e)
      {
        op.futureResult.handleError(e);
        op.promise.handleError(e);
      }
    }
  }
@@ -478,8 +477,8 @@
  public void sendSearchEntry(SearchOperation operation,
      SearchResultEntry searchEntry) throws DirectoryException
  {
    SearchOperationWithFutureResult op =
        (SearchOperationWithFutureResult) this.operationsInProgress.get(operation.getMessageID());
    SearchOperationWithPromise op =
        (SearchOperationWithPromise) this.operationsInProgress.get(operation.getMessageID());
    if (op != null)
    {
      op.entryHandler.handleEntry(from(searchEntry));
@@ -496,9 +495,8 @@
  public boolean sendSearchReference(SearchOperation operation,
      SearchResultReference searchReference) throws DirectoryException
  {
    SearchOperationWithFutureResult op =
        (SearchOperationWithFutureResult) this.operationsInProgress.get(operation.getMessageID());
    SearchOperationWithPromise op =
        (SearchOperationWithPromise) this.operationsInProgress.get(operation.getMessageID());
    if (op != null)
    {
      op.entryHandler.handleReference(from(searchReference));
@@ -623,10 +621,9 @@
  @Override
  public Collection<Operation> getOperationsInProgress()
  {
    Collection<OperationWithFutureResult> values =
        operationsInProgress.values();
    Collection<OperationWithPromise> values = operationsInProgress.values();
    Collection<Operation> results = new ArrayList<Operation>(values.size());
    for (OperationWithFutureResult op : values)
    for (OperationWithPromise op : values)
    {
      results.add(op.operation);
    }
@@ -637,7 +634,7 @@
  @Override
  public Operation getOperationInProgress(int messageID)
  {
    OperationWithFutureResult op = operationsInProgress.get(messageID);
    OperationWithPromise op = operationsInProgress.get(messageID);
    if (op != null)
    {
      return op.operation;
@@ -647,31 +644,31 @@
  /**
   * Adds the passed in search operation to the in progress list along with the
   * associated future and the {@code SearchResultHandler}.
   * associated promise and the {@code SearchResultHandler}.
   *
   * @param operation
   *          the operation to add to the in progress list
   * @param futureResult
   *          the future associated to the operation
   * @param promise
   *          the promise associated to the operation
   * @param searchResultHandler
   *          the search result handler associated to the future result
   *          the search result handler associated to the promise result
   * @throws DirectoryException
   *           If an error occurs
   */
  void addOperationInProgress(Operation operation, FutureResultImpl<Result> futureResult,
  void addOperationInProgress(Operation operation, LdapPromiseImpl<Result> promise,
      SearchResultHandler searchResultHandler) throws DirectoryException
  {
    if (searchResultHandler != null)
    {
      addOperationWithFutureResult(new SearchOperationWithFutureResult(operation, futureResult, searchResultHandler));
      addOperationWithPromise(new SearchOperationWithPromise(operation, promise, searchResultHandler));
    }
    else
    {
      addOperationWithFutureResult(new OperationWithFutureResult(operation, futureResult));
      addOperationWithPromise(new OperationWithPromise(operation, promise));
    }
  }
  private void addOperationWithFutureResult(OperationWithFutureResult opFuture) throws DirectoryException
  private void addOperationWithPromise(OperationWithPromise opPromise) throws DirectoryException
  {
    synchronized (opsInProgressLock)
    {
@@ -682,7 +679,7 @@
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
      }
      operationsInProgress.put(opFuture.operation.getMessageID(), opFuture);
      operationsInProgress.put(opPromise.operation.getMessageID(), opPromise);
    }
  }
@@ -690,8 +687,7 @@
  @Override
  public boolean removeOperationInProgress(int messageID)
  {
    final OperationWithFutureResult previousValue =
        operationsInProgress.remove(messageID);
    final OperationWithPromise previousValue = operationsInProgress.remove(messageID);
    if (previousValue != null)
    {
      operationsPerformed.incrementAndGet();
@@ -710,13 +706,12 @@
  /** {@inheritDoc} */
  @Override
  public CancelResult cancelOperation(int messageID,
      CancelRequest cancelRequest)
  public CancelResult cancelOperation(int messageID, CancelRequest cancelRequest)
  {
    OperationWithFutureResult op = operationsInProgress.remove(messageID);
    OperationWithPromise op = operationsInProgress.remove(messageID);
    if (op != null)
    {
      op.futureResult.handleError(newErrorResult(ResultCode.CANCELLED));
      op.promise.handleError(newLdapException(ResultCode.CANCELLED));
      return op.operation.cancel(cancelRequest);
    }
    return new CancelResult(ResultCode.NO_SUCH_OPERATION, null);
@@ -751,11 +746,11 @@
    {
      try
      {
        for (OperationWithFutureResult op : operationsInProgress.values())
        for (OperationWithPromise op : operationsInProgress.values())
        {
          try
          {
            op.futureResult.handleError(newErrorResult(ResultCode.CANCELLED));
            op.promise.handleError(newLdapException(ResultCode.CANCELLED));
            op.operation.abort(cancelRequest);
            if (keepStats)
@@ -785,7 +780,7 @@
  {
    synchronized (opsInProgressLock)
    {
      OperationWithFutureResult toKeep = operationsInProgress.remove(messageID);
      OperationWithPromise toKeep = operationsInProgress.remove(messageID);
      try
      {
        cancelAllOperations(cancelRequest);
opendj3-server-dev/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java
@@ -34,8 +34,8 @@
import org.forgerock.opendj.ldap.AbstractAsynchronousConnection;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConnectionEventListener;
import org.forgerock.opendj.ldap.FutureResult;
import org.forgerock.opendj.ldap.FutureResultImpl;
import org.forgerock.opendj.ldap.LdapPromise;
import org.forgerock.opendj.ldap.spi.LdapPromiseImpl;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchResultHandler;
@@ -95,6 +95,7 @@
import static org.forgerock.opendj.adapter.server3x.Converters.*;
import static org.forgerock.opendj.ldap.ByteString.*;
import static org.forgerock.opendj.ldap.LdapException.*;
import static org.forgerock.opendj.ldap.spi.LdapPromiseImpl.*;
/**
 * Adapter class between LDAP SDK's {@link org.forgerock.opendj.ldap.Connection}
@@ -139,15 +140,15 @@
            .getCurrentConfig().getMaxConcurrentOpsPerConnection());
  }
  private <R> FutureResult<R> enqueueOperation(Operation operation)
  private <R> LdapPromise<R> enqueueOperation(Operation operation)
  {
    return enqueueOperation(operation, null);
  }
  @SuppressWarnings({ "rawtypes", "unchecked" })
  private <R> FutureResult<R> enqueueOperation(Operation operation, SearchResultHandler entryHandler)
  private <R> LdapPromise<R> enqueueOperation(Operation operation, SearchResultHandler entryHandler)
  {
    final FutureResultImpl<R> futureResult = new FutureResultImpl(operation.getMessageID());
    final LdapPromiseImpl<R> promise = newLdapPromiseImpl(operation.getMessageID());
    try
    {
@@ -162,7 +163,7 @@
      // need this raw cast here to fool the compiler's generic type safety
      // Problem here is due to the generic type R on enqueueOperation()
      clientConnection.addOperationInProgress(operation, (FutureResultImpl) futureResult, entryHandler);
      clientConnection.addOperationInProgress(operation, (LdapPromiseImpl) promise, entryHandler);
      queueingStrategy.enqueueRequest(operation);
    }
    catch (Exception e)
@@ -170,10 +171,10 @@
      logger.traceException(e);
      clientConnection.removeOperationInProgress(operation.getMessageID());
      // TODO JNR add error message??
      futureResult.handleError(newErrorResult(ResultCode.OPERATIONS_ERROR, e));
      promise.handleError(newLdapException(ResultCode.OPERATIONS_ERROR, e));
    }
    return futureResult;
    return promise;
  }
  private ProtocolOp toRequestProtocolOp(Operation operation)
@@ -240,7 +241,7 @@
  /** {@inheritDoc} */
  @Override
  public FutureResult<Void> abandonAsync(AbandonRequest request)
  public LdapPromise<Void> abandonAsync(AbandonRequest request)
  {
    final int messageID = nextMessageID.getAndIncrement();
    return enqueueOperation(new AbandonOperationBasis(clientConnection, messageID, messageID,
@@ -249,7 +250,7 @@
  /** {@inheritDoc} */
  @Override
  public FutureResult<Result> addAsync(AddRequest request, IntermediateResponseHandler intermediateResponseHandler)
  public LdapPromise<Result> addAsync(AddRequest request, IntermediateResponseHandler intermediateResponseHandler)
  {
    final int messageID = nextMessageID.getAndIncrement();
    return enqueueOperation(new AddOperationBasis(clientConnection, messageID, messageID, to(request.getControls()),
@@ -265,7 +266,7 @@
  /** {@inheritDoc} */
  @Override
  public FutureResult<BindResult> bindAsync(BindRequest request,
  public LdapPromise<BindResult> bindAsync(BindRequest request,
      IntermediateResponseHandler intermediateResponseHandler)
  {
    final int messageID = nextMessageID.getAndIncrement();
@@ -305,7 +306,7 @@
  /** {@inheritDoc} */
  @Override
  public FutureResult<CompareResult> compareAsync(CompareRequest request,
  public LdapPromise<CompareResult> compareAsync(CompareRequest request,
      IntermediateResponseHandler intermediateResponseHandler)
  {
    final int messageID = nextMessageID.getAndIncrement();
@@ -317,7 +318,7 @@
  /** {@inheritDoc} */
  @Override
  public FutureResult<Result> deleteAsync(DeleteRequest request,
  public LdapPromise<Result> deleteAsync(DeleteRequest request,
      IntermediateResponseHandler intermediateResponseHandler)
  {
    final int messageID = nextMessageID.getAndIncrement();
@@ -327,7 +328,7 @@
  /** {@inheritDoc} */
  @Override
  public <R extends ExtendedResult> FutureResult<R> extendedRequestAsync(ExtendedRequest<R> request,
  public <R extends ExtendedResult> LdapPromise<R> extendedRequestAsync(ExtendedRequest<R> request,
      IntermediateResponseHandler intermediateResponseHandler)
  {
    final int messageID = nextMessageID.getAndIncrement();
@@ -362,7 +363,7 @@
  /** {@inheritDoc} */
  @Override
  public FutureResult<Result> modifyAsync(ModifyRequest request,
  public LdapPromise<Result> modifyAsync(ModifyRequest request,
      IntermediateResponseHandler intermediateResponseHandler)
  {
    final int messageID = nextMessageID.getAndIncrement();
@@ -373,7 +374,7 @@
  /** {@inheritDoc} */
  @Override
  public FutureResult<Result> modifyDNAsync(ModifyDNRequest request,
  public LdapPromise<Result> modifyDNAsync(ModifyDNRequest request,
      IntermediateResponseHandler intermediateResponseHandler)
  {
    final int messageID = nextMessageID.getAndIncrement();
@@ -392,7 +393,7 @@
  /** {@inheritDoc} */
  @Override
  public FutureResult<Result> searchAsync(final SearchRequest request,
  public LdapPromise<Result> searchAsync(final SearchRequest request,
      final IntermediateResponseHandler intermediateResponseHandler, final SearchResultHandler entryHandler)
  {
    final int messageID = nextMessageID.getAndIncrement();