Package net.spy.memcached.ops

Examples of net.spy.memcached.ops.OperationCallback


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

  public Future<Boolean> delete(String key) {
    final CountDownLatch latch=new CountDownLatch(1);
    final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
      operationTimeout);
    DeleteOperation op=opFact.delete(key,
        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

      = 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) {
                // 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().isEmpty()) {
            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.