Package net.spy.memcached.ops

Examples of net.spy.memcached.ops.Operation


    super(sa, c, bufSize, rq, wq, iq, opQueueMaxBlockTimeNs, waitForAuth, dt);
  }

  @Override
  protected void optimize() {
    Operation firstOp = writeQ.peek();
    if (firstOp instanceof GetOperation) {
      optimizeGets();
    } else if (firstOp instanceof CASOperation) {
      optimizeSets();
    }
View Full Code Here


                 int exp, T value, Transcoder<T> tc) {
    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() {
View Full Code Here

      T value, Transcoder<T> tc) {
    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() {
View Full Code Here

      Transcoder<T> tc) {
    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) {
View Full Code Here

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

    Operation op=opFact.get(key,
        new GetOperation.Callback() {
      private T val=null;
      public void receivedStatus(OperationStatus status) {
        rv.set(val);
      }
View Full Code Here

    final CountDownLatch latch=new CountDownLatch(1);
    final OperationFuture<CASValue<T>> rv=
      new OperationFuture<CASValue<T>>(latch, operationTimeout);

    Operation op=opFact.gets(key,
        new GetsOperation.Callback() {
      private CASValue<T> val=null;
      public void receivedStatus(OperationStatus status) {
        rv.set(val);
      }
View Full Code Here

    final Map<MemcachedNode, Operation> mops=
      new HashMap<MemcachedNode, Operation>();

    for(Map.Entry<MemcachedNode, Collection<String>> me
        : chunks.entrySet()) {
      Operation op=opFact.get(me.getValue(), cb);
      mops.put(me.getKey(), op);
      ops.add(op);
    }
    assert mops.size() == chunks.size();
    checkState();
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();
          }});
        ops.add(op);
        return op;
      }});
    return new OperationFuture<Boolean>(blatch, flushResult,
        operationTimeout) {
      @Override
      public boolean cancel(boolean ign) {
        boolean rv=false;
        for(Operation op : ops) {
          op.cancel();
          rv |= op.getState() == OperationState.WRITING;
        }
        return rv;
      }
      @Override
      public boolean isCancelled() {
        boolean rv=false;
        for(Operation op : ops) {
          rv |= op.isCancelled();
        }
        return rv;
      }
      @Override
      public boolean isDone() {
        boolean rv=true;
        for(Operation op : ops) {
          rv &= op.getState() == OperationState.COMPLETE;
        }
        return rv || isCancelled();
      }
    };
  }
View Full Code Here

  /* (non-Javadoc)
   * @see net.spy.memcached.MemcachedNode#setupResend()
   */
  public final void setupResend() {
    // First, reset the current write op.
    Operation op=getCurrentWriteOp();
    if(op != null) {
      op.getBuffer().reset();
    }
    // Now cancel all the pending read operations.  Might be better to
    // to requeue them.
    while(hasReadOp()) {
      op=removeCurrentReadOp();
      getLogger().warn("Discarding partially completed op: %s", op);
      op.cancel();
    }

    getWbuf().clear();
    getRbuf().clear();
    toWrite=0;
View Full Code Here

  private boolean preparePending() {
    // Copy the input queue into the write queue.
    copyInputQueue();

    // Now check the ops
    Operation nextOp=getCurrentWriteOp();
    while(nextOp != null && nextOp.isCancelled()) {
      getLogger().info("Removing cancelled operation: %s", nextOp);
      removeCurrentWriteOp();
      nextOp=getCurrentWriteOp();
    }
    return nextOp != null;
View Full Code Here

TOP

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

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.