Package net.spy.memcached.ops

Examples of net.spy.memcached.ops.OperationCallback


        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


    // Transition us into a ``looking for \r\n'' kind of state if we've
    // read enough and are still in a data state.
    if(readOffset == data.length && lookingFor == '\0') {
      // The callback is most likely a get callback.  If it's not, then
      // it's a gets callback.
      OperationCallback cb = getCallback();
      if (cb instanceof GetOperation.Callback) {
        GetOperation.Callback gcb=(GetOperation.Callback)cb;
        gcb.gotData(currentKey, currentFlags, data);
      } else if (cb instanceof GetsOperation.Callback) {
        GetsOperation.Callback gcb=(GetsOperation.Callback)cb;
View Full Code Here

  protected void decodePayload(byte[] pl) {
    final int flags=decodeInt(pl, 0);
    final byte[] data=new byte[pl.length - EXTRA_HDR_LEN];
    System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length-EXTRA_HDR_LEN);
    // Assume we're processing a get unless the cast fails.
    OperationCallback cb = getCallback();
    if (cb instanceof GetOperation.Callback) {
      GetOperation.Callback gcb=(GetOperation.Callback)cb;
      gcb.gotData(key, flags, data);
    } else if (cb instanceof GetsOperation.Callback) {
      GetsOperation.Callback gcb=(GetsOperation.Callback)cb;
View Full Code Here

    CachedData co=tc.encode(value);
    final CountDownLatch latch=new CountDownLatch(1);
    final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
        operationTimeout);
    Operation op=opFact.store(storeType, key, co.getFlags(),
        exp, co.getData(), new OperationCallback() {
          public void receivedStatus(OperationStatus val) {
            rv.set(val.isSuccess());
          }
          public void complete() {
            latch.countDown();
View Full Code Here

    CachedData co=tc.encode(value);
    final CountDownLatch latch=new CountDownLatch(1);
    final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
        operationTimeout);
    Operation op=opFact.cat(catType, cas, key, co.getData(),
        new OperationCallback() {
      public void receivedStatus(OperationStatus val) {
        rv.set(val.isSuccess());
      }
      public void complete() {
        latch.countDown();
View Full Code Here

      final Transcoder<T> tc) {
    final CountDownLatch latch=new CountDownLatch(1);
    final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
        operationTimeout);

    Operation op=opFact.touch(key, exp, new OperationCallback() {
      public void receivedStatus(OperationStatus status) {
        rv.set(status.isSuccess());
    }
      public void complete() {
        latch.countDown();
View Full Code Here

    CachedData co=tc.encode(value);
    final CountDownLatch latch=new CountDownLatch(1);
    final OperationFuture<CASResponse> rv=new OperationFuture<CASResponse>(
        latch, operationTimeout);
    Operation op=opFact.cas(StoreType.set, key, casId, co.getFlags(), exp,
        co.getData(), new OperationCallback() {
          public void receivedStatus(OperationStatus val) {
            if(val instanceof CASOperationStatus) {
              rv.set(((CASOperationStatus)val).getCASResponse());
            } else if(val instanceof CancelledOperationStatus) {
              // Cancelled, ignore and let it float up
View Full Code Here

    CountDownLatch blatch = broadcastOp(new BroadcastOpFactory(){
      public Operation newOp(final MemcachedNode n,
          final CountDownLatch latch) {
        final SocketAddress sa=n.getSocketAddress();
        return opFact.version(
            new OperationCallback() {
              public void receivedStatus(OperationStatus s) {
                rv.put(sa, s.getMessage());
              }
              public void complete() {
                latch.countDown();
View Full Code Here

  }

  private long mutate(Mutator m, String key, int by, long def, int exp) {
    final AtomicLong rv=new AtomicLong();
    final CountDownLatch latch=new CountDownLatch(1);
    addOp(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

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