Package net.spy.memcached.ops

Examples of net.spy.memcached.ops.OperationCallback


    // 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


    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

    CachedData co=tc.encode(value);
    final CountDownLatch latch=new CountDownLatch(1);
    final OperationFuture<CASResponse> rv=new OperationFuture<CASResponse>(
        latch, operationTimeout);
    Operation op=opFact.cas(key, casId, co.getFlags(),
        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)
    throws OperationTimeoutException {
    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(Long.valueOf(s.isSuccess() ? s.getMessage() : "-1"));
View Full Code Here

  public Future<Boolean> delete(String key, int hold) {
    final CountDownLatch latch=new CountDownLatch(1);
    final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
      operationTimeout);
    DeleteOperation op=opFact.delete(key, hold,
        new OperationCallback() {
          public void receivedStatus(OperationStatus s) {
            rv.set(s.isSuccess());
          }
          public void complete() {
            latch.countDown();
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() {
            latch.countDown();
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) {
                // Nothing special when receiving status, only
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

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.