Package net.spy.memcached.ops

Examples of net.spy.memcached.ops.OperationStatus


  }

  @Override
  public void handleLine(String line) {
    getLogger().debug("Result:  %s", line);
    OperationStatus found=null;
    if(line.equals("NOT_FOUND")) {
      found=NOT_FOUND;
    } else {
      found=new OperationStatus(true, line);
    }
    getCallback().receivedStatus(found);
    transitionState(OperationState.COMPLETE);
  }
View Full Code Here


    prepareBuffer(key, 0, EMPTY_BYTES, by, defBytes, exp);
  }

  @Override
  protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl) {
        OperationStatus baseStatus = super.getStatusForErrorCode(errCode, errPl);
        if (baseStatus != null) {
            return baseStatus;
        }
    return errCode == ERR_NOT_FOUND ? NOT_FOUND_STATUS : null;
  }
View Full Code Here

    return errCode == ERR_NOT_FOUND ? NOT_FOUND_STATUS : null;
  }

  @Override
  protected void decodePayload(byte[] pl) {
    getCallback().receivedStatus(new OperationStatus(true,
      String.valueOf(decodeLong(pl, 0))));
  }
View Full Code Here

    start();
  }

  @Override
  public void run() {
    OperationStatus priorStatus = null;
    final AtomicBoolean done = new AtomicBoolean();

    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();
            getLogger().info("Authenticated to "
                + node.getSocketAddress());
          } else {
            foundStatus.set(val);
          }
        }

        public void complete() {
          latch.countDown();
        }
      };

      // Get the prior status to create the correct operation.
      final Operation op = buildOperation(priorStatus, cb);

      conn.insertOperation(node, op);

      try {
        latch.await();
        Thread.sleep(100);
      } catch(InterruptedException e) {
        // we can be interrupted if we were in the
        // process of auth'ing and the connection is
        // lost or dropped due to bad auth
        Thread.currentThread().interrupt();
        if (op != null) {
          op.cancel();
        }
        done.set(true); // If we were interrupted, tear down.
      }

      // Get the new status to inspect it.
      priorStatus = foundStatus.get();
      if(priorStatus != null) {
        if(!priorStatus.isSuccess()) {
          getLogger().warn("Authentication failed to "
              + node.getSocketAddress());
        }
      }
    }
View Full Code Here

      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

    resetInput();
  }

  @Override
  protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl) {
    OperationStatus rv=null;
    switch(errCode) {
      case ERR_EXISTS:
        rv=EXISTS_STATUS;
        break;
      case ERR_NOT_FOUND:
View Full Code Here

  }

  @Override
  protected void decodePayload(byte[] pl) {
    getCallback().receivedStatus(
        new OperationStatus(true, new String(pl)));
  }
View Full Code Here

    prepareBuffer("", 0, EMPTY_BYTES);
  }

  @Override
  protected void decodePayload(byte[] pl) {
    getCallback().receivedStatus(new OperationStatus(true, new String(pl)));
  }
View Full Code Here

  @Override
  public void handleLine(String line) {
    assert line.startsWith("VERSION ");
    getCallback().receivedStatus(
        new OperationStatus(true, line.substring("VERSION ".length())));
    transitionState(OperationState.COMPLETE);
  }
View Full Code Here

    return Collections.singleton(key);
  }

  @Override
  protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl) {
        OperationStatus baseStatus = super.getStatusForErrorCode(errCode, errPl);
        if (baseStatus != null) {
            return baseStatus;
        }
    OperationStatus rv=null;
    switch(errCode) {
      case ERR_EXISTS:
        rv=EXISTS_STATUS;
        break;
      case ERR_NOT_FOUND:
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.