当前位置: 首页>>代码示例>>Java>>正文


Java Operation.cancel方法代码示例

本文整理汇总了Java中net.spy.memcached.ops.Operation.cancel方法的典型用法代码示例。如果您正苦于以下问题:Java Operation.cancel方法的具体用法?Java Operation.cancel怎么用?Java Operation.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.spy.memcached.ops.Operation的用法示例。


在下文中一共展示了Operation.cancel方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addOp

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
public final void addOp(Operation op) {
  try {
    if (!authLatch.await(1, TimeUnit.SECONDS)) {
      op.cancel();
      getLogger().warn("Operation canceled because authentication "
              + "or reconnection and authentication has "
              + "taken more than one second to complete.");
      getLogger().debug("Canceled operation %s", op.toString());
      return;
    }
    if (!inputQueue.offer(op, opQueueMaxBlockTime, TimeUnit.MILLISECONDS)) {
      throw new IllegalStateException("Timed out waiting to add " + op
          + "(max wait=" + opQueueMaxBlockTime + "ms)");
    }
  } catch (InterruptedException e) {
    // Restore the interrupted status
    Thread.currentThread().interrupt();
    throw new IllegalStateException("Interrupted while waiting to add " + op);
  }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:21,代码来源:TCPMemcachedNodeImpl.java

示例2: addOp

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
public final void addOp(Operation op) {
	try {
		if (!authLatch.await(1, TimeUnit.SECONDS)) {
		    op.cancel("authentication timeout");
			getLogger().warn(
				"Operation canceled because authentication " +
				"or reconnection and authentication has " +
				"taken more than one second to complete.");
			getLogger().debug("Canceled operation %s", op.toString());
			return;
		}
		if(!inputQueue.offer(op, opQueueMaxBlockTime,
				TimeUnit.MILLISECONDS)) {
			throw new IllegalStateException("Timed out waiting to add "
					+ op + "(max wait=" + opQueueMaxBlockTime + "ms)");
		}
		addOpCount += 1;
	} catch(InterruptedException e) {
		// Restore the interrupted status
		Thread.currentThread().interrupt();
		throw new IllegalStateException("Interrupted while waiting to add "
				+ op);
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:25,代码来源:TCPMemcachedNodeImpl.java

示例3: setupResend

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
public final void setupResend() {
  // First, reset the current write op, or cancel it if we should
  // be authenticating
  Operation op = getCurrentWriteOp();
  if (shouldAuth && op != null) {
    op.cancel();
  } else if (op != null) {
    ByteBuffer buf = op.getBuffer();
    if (buf != null) {
      buf.reset();
    } else {
      getLogger().info("No buffer for current write op, removing");
      removeCurrentWriteOp();
    }
  }
  // Now cancel all the pending read operations. Might be better to
  // to requeue them.
  while (hasReadOp()) {
    op = removeCurrentReadOp();
    if (op != getCurrentWriteOp()) {
      getLogger().warn("Discarding partially completed op: %s", op);
      op.cancel();
    }
  }

  while (shouldAuth && hasWriteOp()) {
    op = removeCurrentWriteOp();
    getLogger().warn("Discarding partially completed op: %s", op);
    op.cancel();
  }

  getWbuf().clear();
  getRbuf().clear();
  toWrite = 0;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:36,代码来源:TCPMemcachedNodeImpl.java

示例4: cancel

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
public boolean cancel(boolean ign) {
  boolean rv = false;
  for (Operation op : ops) {
    rv |= op.getState() == OperationState.WRITE_QUEUED;
    op.cancel();
  }
  for (Future<T> v : rvMap.values()) {
    v.cancel(ign);
  }
  cancelled = true;
  status = new OperationStatus(false, "Cancelled");
  return rv;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:14,代码来源:BulkGetFuture.java

示例5: setupResend

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
public final void setupResend(boolean cancelWrite, String cause) {
	// First, reset the current write op, or cancel it if we should
	// be authenticating
	Operation op=getCurrentWriteOp();
	if((cancelWrite || shouldAuth) && op != null) {
	    op.cancel(cause);
	} else if(op != null) {
		ByteBuffer buf=op.getBuffer();
		if(buf != null) {
			buf.reset();
		} else {
			getLogger().info("No buffer for current write op, removing");
			removeCurrentWriteOp();
		}
	}
	// Now cancel all the pending read operations.  Might be better to
	// to requeue them.
	while(hasReadOp()) {
		op=removeCurrentReadOp();
		if (op != getCurrentWriteOp()) {
			getLogger().warn("Discarding partially completed op: %s", op);
			op.cancel(cause);
		}
	}

	while((cancelWrite || shouldAuth) && hasWriteOp()) {
		op=removeCurrentWriteOp();
		getLogger().warn("Discarding partially completed op: %s", op);
		op.cancel(cause);
	}


	getWbuf().clear();
	getRbuf().clear();
	toWrite=0;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:37,代码来源:TCPMemcachedNodeImpl.java

示例6: cancel

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
@Override
public boolean cancel(boolean ign) {
	boolean rv = false;
	for (Operation op : ops) {
		op.cancel("by application.");
		rv |= op.getState() == OperationState.WRITING;
	}
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:10,代码来源:CollectionGetBulkFuture.java

示例7: cancel

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
public boolean cancel(boolean ign) {
	boolean rv = false;
	for (Operation op : ops) {
		rv |= op.getState() == OperationState.WRITING;
		op.cancel("by application.");
	}
	for (Future<T> v : rvMap.values()) {
		v.cancel(ign);
	}
	cancelled = true;
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:13,代码来源:BulkGetFuture.java

示例8: cancelOperations

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
private void cancelOperations(Collection<Operation> ops) {
  for (Operation op : ops) {
    op.cancel();
  }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:6,代码来源:MemcachedConnection.java

示例9: run

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
@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());
      }
    }
  }
  return;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:57,代码来源:AuthThread.java

示例10: cancelOperations

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
private void cancelOperations(Collection<Operation> ops, String cause) {
	for(Operation op : ops) {
		op.cancel(cause);
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:6,代码来源:MemcachedConnection.java

示例11: run

import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
@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("interruption to authentication" + e);
			}
			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());
			}
		}
	}
	return;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:59,代码来源:AuthThread.java


注:本文中的net.spy.memcached.ops.Operation.cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。