本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例8: cancelOperations
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
private void cancelOperations(Collection<Operation> ops) {
for (Operation op : ops) {
op.cancel();
}
}
示例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;
}
示例10: cancelOperations
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
private void cancelOperations(Collection<Operation> ops, String cause) {
for(Operation op : ops) {
op.cancel(cause);
}
}
示例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;
}