Package net.spy.memcached.ops

Examples of net.spy.memcached.ops.OperationCallback


  private long mutate(Mutator m, String key, long by, long def, int exp) {
    final AtomicLong rv = new AtomicLong();
    final CountDownLatch latch = new CountDownLatch(1);
    enqueueOperation(key, opFact.mutate(m, key, by, def, exp,
        new OperationCallback() {
        public void receivedStatus(OperationStatus s) {
          // XXX: Potential abstraction leak.
          // The handling of incr/decr in the binary protocol
          // Allows us to avoid string processing.
          rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
View Full Code Here


      long def, int exp) {
    final CountDownLatch latch = new CountDownLatch(1);
    final OperationFuture<Long> rv =
        new OperationFuture<Long>(key, latch, operationTimeout);
    Operation op = opFact.mutate(m, key, by, def, exp,
        new OperationCallback() {
          public void receivedStatus(OperationStatus s) {
            rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"), s);
          }

          public void complete() {
View Full Code Here

   */
  public OperationFuture<Boolean> delete(String key) {
    final CountDownLatch latch = new CountDownLatch(1);
    final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(key,
        latch, operationTimeout);
    DeleteOperation op = opFact.delete(key, new OperationCallback() {
      public void receivedStatus(OperationStatus s) {
        rv.set(s.isSuccess(), s);
      }

      public void complete() {
View Full Code Here

    final ConcurrentLinkedQueue<Operation> ops =
        new ConcurrentLinkedQueue<Operation>();
    CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
      public Operation newOp(final MemcachedNode n,
          final CountDownLatch latch) {
        Operation op = opFact.flush(delay, new OperationCallback() {
          public void receivedStatus(OperationStatus s) {
            flushResult.set(s.isSuccess());
          }

          public void complete() {
View Full Code Here

    final ConcurrentMap<String, String> rv =
        new ConcurrentHashMap<String, String>();

    CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
      public Operation newOp(MemcachedNode n, final CountDownLatch latch) {
        return opFact.saslMechs(new OperationCallback() {
          public void receivedStatus(OperationStatus status) {
            for (String s : status.getMessage().split(" ")) {
              rv.put(s, s);
            }
          }
View Full Code Here

   */
  public boolean waitForQueues(long timeout, TimeUnit unit) {
    CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
      public Operation newOp(final MemcachedNode n,
          final CountDownLatch latch) {
        return opFact.noop(new OperationCallback() {
          public void complete() {
            latch.countDown();
          }

          public void receivedStatus(OperationStatus s) {
View Full Code Here

    while (!done.get()) {
      final CountDownLatch latch = new CountDownLatch(1);
      final AtomicReference<OperationStatus> foundStatus =
          new AtomicReference<OperationStatus>();

      final OperationCallback cb = new OperationCallback() {
        public void receivedStatus(OperationStatus val) {
          // If the status we found was null, we're done.
          if (val.getMessage().length() == 0) {
            done.set(true);
            node.authComplete();
View Full Code Here

   */
  public boolean waitForQueues(long timeout, TimeUnit unit) {
    CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
      public Operation newOp(final MemcachedNode n,
          final CountDownLatch latch) {
        return opFact.noop(new OperationCallback() {
          public void complete() {
            latch.countDown();
          }

          public void receivedStatus(OperationStatus s) {
View Full Code Here

        cb.receivedStatus(STATUS_OK);
        cb.complete();
      }
      transitionState(OperationState.COMPLETE);
    } else {
      OperationCallback cb = callbacks.remove(responseOpaque);
      assert cb != null : "No callback for " + responseOpaque;
      assert errorCode != 0 : "Got no error on a quiet mutation.";
      OperationStatus status = getStatusForErrorCode(errorCode, pl);
      assert status != null : "Got no status for a quiet mutation error";
      cb.receivedStatus(status);
      cb.complete();
    }
    resetInput();
  }
View Full Code Here

    readBuffer.get(this.data, this.readOffset, toRead);
    this.readOffset += toRead;   
  }
 
  void updateCallBackWithResponse(){
    OperationCallback cb = getCallback();
    if (cb instanceof GetConfigOperation.Callback) {
      GetConfigOperation.Callback gcb = (GetConfigOperation.Callback) cb;
      gcb.gotData(ConfigurationType.valueOf(this.currentType.toUpperCase()), this.currentFlags, this.data);
    } else {
      throw new ClassCastException("Couldn't convert " + cb
View Full Code Here

TOP

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

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.