本文整理汇总了Java中net.spy.memcached.ops.Operation.getHandlingNode方法的典型用法代码示例。如果您正苦于以下问题:Java Operation.getHandlingNode方法的具体用法?Java Operation.getHandlingNode怎么用?Java Operation.getHandlingNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.spy.memcached.ops.Operation
的用法示例。
在下文中一共展示了Operation.getHandlingNode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTimeout
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
/**
* helper method: do some error checking and set timeout boolean.
*
* @param op
* @param isTimeout
*/
private static void setTimeout(Operation op, boolean isTimeout) {
try {
if (op == null || op.isTimedOutUnsent()) {
return; // op may be null in some cases, e.g. flush
}
MemcachedNode node = op.getHandlingNode();
if (node == null) {
LoggerFactory.getLogger(MemcachedConnection.class).warn(
"handling node for operation is not set");
} else {
node.setContinuousTimeout(isTimeout);
}
} catch (Exception e) {
LoggerFactory.getLogger(MemcachedConnection.class).error(e.getMessage());
}
}
示例2: createMessage
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
private static String
createMessage(String message, Collection<Operation> ops) {
StringBuilder rv = new StringBuilder(message);
rv.append(" - failing node");
rv.append(ops.size() == 1 ? ": " : "s: ");
boolean first = true;
for (Operation op : ops) {
if (first) {
first = false;
} else {
rv.append(", ");
}
MemcachedNode node = op == null ? null : op.getHandlingNode();
rv.append(node == null ? "<unknown>" : node.getSocketAddress());
}
return rv.toString();
}
示例3: setTimeout
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
/**
* helper method: do some error checking and set timeout boolean
*
* @param op
* @param isTimeout
*/
private static void setTimeout(Operation op, boolean isTimeout) {
try {
if (op == null) {
LoggerFactory.getLogger(MemcachedConnection.class).debug("op is null.");
return; // op may be null in some cases, e.g. flush
}
MemcachedNode node = op.getHandlingNode();
if (node == null) {
LoggerFactory.getLogger(MemcachedConnection.class).debug("handling node for operation is not set");
}
else {
if (isTimeout || !op.isCancelled())
node.setContinuousTimeout(isTimeout);
}
} catch (Exception e) {
LoggerFactory.getLogger(MemcachedConnection.class).error(e.getMessage());
}
}
示例4: doInAfterTrace
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
@Override
public void doInAfterTrace(RecordableTrace trace, Object target, Object[] args, Object result, Throwable throwable) {
if (parameterExtractor != null) {
final int index = parameterExtractor.getIndex();
final Object recordObject = parameterExtractor.extractObject(args);
trace.recordApi(getMethodDescriptor(), recordObject, index);
} else {
trace.recordApi(getMethodDescriptor());
}
// find the target node
if (result instanceof Future && !(result instanceof FrontCacheGetFuture)) {
final Operation op = getOperation(result);
if (op != null) {
MemcachedNode handlingNode = op.getHandlingNode();
SocketAddress socketAddress = handlingNode.getSocketAddress();
if (socketAddress instanceof InetSocketAddress) {
InetSocketAddress address = (InetSocketAddress) socketAddress;
trace.recordEndPoint(address.getHostName() + ":" + address.getPort());
}
} else {
logger.info("operation not found");
}
}
// determine the service type
final String serviceCode = getServiceCode(target);
if (serviceCode != null) {
trace.recordDestinationId(serviceCode);
trace.recordServiceType(ServiceType.ARCUS);
} else {
trace.recordDestinationId("MEMCACHED");
trace.recordServiceType(ServiceType.MEMCACHED);
}
trace.markAfterTime();
}
示例5: doInAfterTrace
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordApi(methodDescriptor);
recorder.recordDestinationId("MEMCACHED");
recorder.recordServiceType(ArcusConstants.MEMCACHED_FUTURE_GET);
if (!(target instanceof OperationAccessor)) {
logger.info("operation not found");
return;
}
// find the target node
final Operation op = ((OperationAccessor) target)._$PINPOINT$_getOperation();
if (op == null) {
logger.info("operation is null");
return;
}
recorder.recordException(op.getException());
final MemcachedNode handlingNode = op.getHandlingNode();
if (handlingNode != null) {
final String endPoint = getEndPoint(handlingNode);
if (endPoint != null) {
recorder.recordEndPoint(endPoint);
}
recorder.recordException(op.getException());
} else {
logger.info("no handling node");
}
if (op instanceof ServiceCodeAccessor) {
// determine the service type
String serviceCode = ((ServiceCodeAccessor) op)._$PINPOINT$_getServiceCode();
if (serviceCode != null) {
recorder.recordDestinationId(serviceCode);
recorder.recordServiceType(ArcusConstants.ARCUS_FUTURE_GET);
}
}
}
示例6: createMessage
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
private static String createMessage(String message,
Collection<Operation> ops) {
StringBuilder rv = new StringBuilder(message);
rv.append(" - failing node");
rv.append(ops.size() == 1 ? ": " : "s: ");
boolean first = true;
for(Operation op : ops) {
if(first) {
first = false;
} else {
rv.append(", ");
}
MemcachedNode node = op == null ? null : op.getHandlingNode();
rv.append(node == null ? "<unknown>" : node.getSocketAddress());
if (op != null) {
rv.append(" [").append(op.getState()).append("]");
}
if (node != null) {
rv.append(" [").append(node.getStatus()).append("]");
}
// if (op != null && op.getBuffer() != null) {
// rv.append(" [")
// .append(new String(op.getBuffer().array()).replace(
// "\r\n", "\\n")).append("]");
// }
}
return rv.toString();
}
示例7: after
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
trace.recordApi(methodDescriptor);
// Do not record because it's not important.
// String annotation = "future.get() timeout:" + args[0] + " " + ((TimeUnit)args[1]).name();
// trace.recordAttribute(AnnotationKey.ARCUS_COMMAND, annotation);
// find the target node
final Operation op = getOperation(target);
if (op != null) {
MemcachedNode handlingNode = op.getHandlingNode();
if (handlingNode != null) {
SocketAddress socketAddress = handlingNode.getSocketAddress();
if (socketAddress instanceof InetSocketAddress) {
InetSocketAddress address = (InetSocketAddress) socketAddress;
trace.recordEndPoint(address.getHostName() + ":" + address.getPort());
}
trace.recordException(op.getException());
} else {
logger.info("no handling node");
}
} else {
logger.info("operation not found");
}
// determine the service type
final String serviceCode = getServiceCode(op);
if (serviceCode != null) {
trace.recordDestinationId(serviceCode);
trace.recordServiceType(ServiceType.ARCUS_FUTURE_GET);
} else {
trace.recordDestinationId("MEMCACHED");
trace.recordServiceType(ServiceType.MEMCACHED_FUTURE_GET);
}
// When it's canceled, doen't it throw exception?
// if (op.isCancelled()) {
// trace.recordAttribute(AnnotationKey.EXCEPTION, "cancelled by user");
// }
trace.markAfterTime();
} finally {
trace.traceBlockEnd();
}
}
示例8: after
import net.spy.memcached.ops.Operation; //导入方法依赖的package包/类
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
if (traceKey) {
final Object recordObject = args[keyIndex];
recorder.recordApi(methodDescriptor, recordObject, keyIndex);
} else {
recorder.recordApi(methodDescriptor);
}
recorder.recordException(throwable);
// find the target node
if (result instanceof Future && result instanceof OperationAccessor) {
final Operation op = ((OperationAccessor)result)._$PINPOINT$_getOperation();
if (op != null) {
final MemcachedNode handlingNode = op.getHandlingNode();
if (handlingNode != null) {
final String endPoint = getEndPoint(handlingNode);
if (endPoint != null) {
recorder.recordEndPoint(endPoint);
}
}
} else {
logger.info("operation not found");
}
}
if (target instanceof ServiceCodeAccessor) {
// determine the service type
String serviceCode = ((ServiceCodeAccessor)target)._$PINPOINT$_getServiceCode();
if (serviceCode != null) {
recorder.recordDestinationId(serviceCode);
recorder.recordServiceType(ArcusConstants.ARCUS);
} else {
recorder.recordDestinationId("MEMCACHED");
recorder.recordServiceType(ArcusConstants.MEMCACHED);
}
} else {
recorder.recordDestinationId("MEMCACHED");
recorder.recordServiceType(ArcusConstants.MEMCACHED);
}
try {
if (isAsynchronousInvocation(target, args, result, throwable)) {
// set asynchronous trace
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
// type check isAsynchronousInvocation
((AsyncContextAccessor)result)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set AsyncContext {}", asyncContext);
}
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER error. Caused:{}", th.getMessage(), th);
}
} finally {
trace.traceBlockEnd();
}
}