Package net.spy.memcached.ops

Examples of net.spy.memcached.ops.OperationStatus


        try {
          observePoll(key, future.getCas(), req, rep, false);
          observeFuture.set(casr, future.getStatus());
        } catch (ObservedException e) {
          observeFuture.set(CASResponse.OBSERVE_ERROR_IN_ARGS,
            new OperationStatus(false, e.getMessage()));
        } catch (ObservedTimeoutException e) {
          observeFuture.set(CASResponse.OBSERVE_TIMEOUT,
            new OperationStatus(false, e.getMessage()));
        } catch (ObservedModifiedException e) {
          observeFuture.set(CASResponse.OBSERVE_MODIFIED,
            new OperationStatus(false, e.getMessage()));
        }

        latch.countDown();
        observeFuture.signalComplete();
      }
View Full Code Here


  @Override
  public void handleResponse(HttpResponse response) {
    String json = getEntityString(response);
    int errorcode = response.getStatusLine().getStatusCode();
    try {
      OperationStatus status = parseViewForStatus(json, errorcode);
      ViewResponse vr = null;
      if (status.isSuccess()) {
        vr = parseResult(json);
      } else {
        parseError(json, errorcode);
      }
View Full Code Here

          String error = "Error Code: " + errorcode + " Error: "
            + base.getString("error");
          if (base.has("reason")) {
            error += " Reason: " + base.getString("reason");
          }
          return new OperationStatus(false, error);
        } else {
          return new OperationStatus(true, "Error Code: " + errorcode);
        }
      } catch (JSONException e) {
        throw new ParseException("Cannot read json: " + json, 0);
      }
    }
    return new OperationStatus(false, "Error Code: " + errorcode
        + "No entity");
  }
View Full Code Here

          observeFuture.set(replaceStatus, future.getStatus());
          if (future.getCas() != null) {
            observeFuture.setCas(future.getCas());
          }
        } catch (InterruptedException e) {
          observeFuture.set(false, new OperationStatus(false, prefix + " get "
            + "timed out"));
        } catch (ExecutionException e) {
          if(e.getCause() instanceof CancellationException) {
            observeFuture.set(false, new OperationStatus(false, prefix + " get "
              + "cancellation exception "));
          } else {
            observeFuture.set(false, new OperationStatus(false, prefix + " get "
              + "execution exception "));
          }
        }

        if (!replaceStatus) {
          latch.countDown();
          observeFuture.signalComplete();
          return;
        }

        try {
          observePoll(key, future.getCas(), req, rep, delete);
          observeFuture.set(true, future.getStatus());
        } catch (ObservedException e) {
          observeFuture.set(false, new OperationStatus(false, e.getMessage()));
        } catch (ObservedTimeoutException e) {
          observeFuture.set(false, new OperationStatus(false, e.getMessage()));
        } catch (ObservedModifiedException e) {
          observeFuture.set(false, new OperationStatus(false, e.getMessage()));
        }

        latch.countDown();
        observeFuture.signalComplete();
      }
View Full Code Here

        try {
          observePoll(key, future.getCas(), req, rep, false);
          observeFuture.set(casr, future.getStatus());
        } catch (ObservedException e) {
          observeFuture.set(CASResponse.OBSERVE_ERROR_IN_ARGS,
            new OperationStatus(false, e.getMessage()));
        } catch (ObservedTimeoutException e) {
          observeFuture.set(CASResponse.OBSERVE_TIMEOUT,
            new OperationStatus(false, e.getMessage()));
        } catch (ObservedModifiedException e) {
          observeFuture.set(CASResponse.OBSERVE_MODIFIED,
            new OperationStatus(false, e.getMessage()));
        }

        latch.countDown();
        observeFuture.signalComplete();
      }
View Full Code Here

  @Override
  public T get() throws InterruptedException, ExecutionException {
    try {
      return get(timeout, TimeUnit.MILLISECONDS);
    } catch (TimeoutException e) {
      status = new OperationStatus(false, "Timed out");
      throw new RuntimeException("Timed out waiting for operation", e);
    }
  }
View Full Code Here

    throws InterruptedException, TimeoutException, ExecutionException {
    if (!latch.await(duration, units)) {
      if (op != null) {
        op.timeOut();
      }
      status = new OperationStatus(false, "Timed out");
      throw new TimeoutException("Timed out waiting for operation");
    }

    if (op != null && op.hasErrored()) {
      status = new OperationStatus(false, op.getException().getMessage());
      throw new ExecutionException(op.getException());
    }

    if (op != null && op.isCancelled()) {
      status = new OperationStatus(false, "Operation Cancelled");
      throw new ExecutionException(new CancellationException("Cancelled"));
    }

    if (op != null && op.isTimedOut()) {
      status = new OperationStatus(false, "Timed out");
      throw new ExecutionException(new CheckedOperationTimeoutException(
          "Operation timed out.", (Operation)op));
    }
  }
View Full Code Here

  public OperationStatus getStatus() {
    if (status == null) {
      try {
        get();
      } catch (InterruptedException e) {
        status = new OperationStatus(false, "Interrupted");
        Thread.currentThread().isInterrupted();
      } catch (ExecutionException e) {
        getLogger().warn("Error getting status of operation", e);
      }
    }
View Full Code Here

  @Override
  public void handleResponse(HttpResponse response) {
    String json = getEntityString(response);
    int errorcode = response.getStatusLine().getStatusCode();
    try {
      OperationStatus status = parseViewForStatus(json, errorcode);
      ViewResponse vr = null;
      if (status.isSuccess()) {
        vr = parseResult(json);
      } else {
        parseError(json, errorcode);
      }
View Full Code Here

TOP

Related Classes of net.spy.memcached.ops.OperationStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.