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


Java Operation类代码示例

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


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

示例1: onCallbackComplete

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
public void onCallbackComplete(Operation operation) {
  Long startTime = removeObjectProperty(operation, OPERATION_PROPERTY_NAME);
  if (startTime == null) {
    return;//re-entrant
  }

  String op = Operations.getOperationName(operation);

  long t = clock.getTick() - startTime;
  Timer timer = opVsTimer.computeIfAbsent(op, s -> {
    String metricName = ROOT_NAME.withTags("command", op).toString();
    return RegistryService.getMetricRegistry().timer(metricName);
  });
  timer.update(t, TimeUnit.NANOSECONDS);

}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:17,代码来源:SpymemcachedRuleHelper.java

示例2: getOperationName

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
public static <T extends Operation> String getOperationName(T operation) {

      //TODO optimize. Convert multiple if/else to switch or map.get()
      String op;
      if (operation instanceof StoreOperation) {
        op = ((StoreOperation) operation).getStoreType().name();
      } else if (operation instanceof ConcatenationOperation) {
        op = ((ConcatenationOperation) operation).getStoreType().name();
      } else if (operation instanceof GetsOperation) {
        op = "get";
      } else if (operation instanceof GetOperation) {
        op = "get";
      } else if (operation instanceof GetAndTouchOperation) {
        op = "gat";
      } else if (operation instanceof MutatorOperation) {
        op = ((MutatorOperation) operation).getType().name();
      } else {
        op = Operations.getOperationName(operation.getClass());
      }
      return op;
    }
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:22,代码来源:SpymemcachedRuleHelper.java

示例3: getNextWritableOp

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
private Operation getNextWritableOp() {
  Operation o = getCurrentWriteOp();
  while (o != null && o.getState() == OperationState.WRITE_QUEUED) {
    synchronized(o) {
      if (o.isCancelled()) {
        getLogger().debug("Not writing cancelled op.");
        Operation cancelledOp = removeCurrentWriteOp();
        assert o == cancelledOp;
      } else if (o.isTimedOut(defaultOpTimeout)) {
        getLogger().debug("Not writing timed out op.");
        Operation timedOutOp = removeCurrentWriteOp();
        assert o == timedOutOp;
      } else {
        o.writing();
        if (!(o instanceof TapAckOperationImpl)) {
          readQ.add(o);
        }
        return o;
      }
      o = getCurrentWriteOp();
    }
  }
  return o;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:25,代码来源:TCPMemcachedNodeImpl.java

示例4: 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

示例5: redistributeOperations

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
private void redistributeOperations(Collection<Operation> ops) {
  for (Operation op : ops) {
    if (op.isCancelled() || op.isTimedOut()) {
      continue;
    }
    if (op instanceof KeyedOperation) {
      KeyedOperation ko = (KeyedOperation) op;
      int added = 0;
      for (String k : ko.getKeys()) {
        for (Operation newop : opFact.clone(ko)) {
          addOperation(k, newop);
          added++;
        }
      }
      assert added > 0 : "Didn't add any new operations when redistributing";
    } else {
      // Cancel things that don't have definite targets.
      op.cancel();
    }
  }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:22,代码来源:MemcachedConnection.java

示例6: 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());
  }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:23,代码来源:MemcachedConnection.java

示例7: waitForQueues

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
/**
 * Wait for the queues to die down.
 *
 * @param timeout the amount of time time for shutdown
 * @param unit the TimeUnit for the timeout
 * @return result of the request for the wait
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
public boolean waitForQueues(long timeout, TimeUnit unit) {
  CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
    public Operation newOp(final MemcachedNode n,
        final CountDownLatch latch) {
      return opFact.noop(new OperationCallback() {
        public void complete() {
          latch.countDown();
        }

        public void receivedStatus(OperationStatus s) {
          // Nothing special when receiving status, only
          // necessary to complete the interface
        }
      });
    }
  }, conn.getLocator().getAll(), false);
  try {
    // XXX: Perhaps IllegalStateException should be caught here
    // and the check retried.
    return blatch.await(timeout, unit);
  } catch (InterruptedException e) {
    throw new RuntimeException("Interrupted waiting for queues", e);
  }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:34,代码来源:TapConnectionProvider.java

示例8: 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();
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:18,代码来源:CheckedOperationTimeoutException.java

示例9: 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

示例10: getAllOperations

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
private BlockingQueue<Operation> getAllOperations() {
	BlockingQueue<Operation> allOp = new LinkedBlockingQueue<Operation>();

	if (hasReadOp()) {
		readQ.drainTo(allOp);
	}

	while (hasWriteOp()) {
		/* large byte operation
		 * may exist write queue & read queue
		 */
		Operation op = removeCurrentWriteOp();
		if (!allOp.contains(op)) {
			allOp.add(op);
		} else {
			getLogger().warn("Duplicate operation exist in " + this + " : " + op);
		}
	}

	if (inputQueue.size() > 0) {
		inputQueue.drainTo(allOp);
	}

	return allOp;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:26,代码来源:TCPMemcachedNodeImpl.java

示例11: waitForQueues

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
/**
 * Wait for the queues to die down.
 *
 * @param timeout the amount of time time for shutdown
 * @param unit the TimeUnit for the timeout
 * @return result of the request for the wait
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public boolean waitForQueues(long timeout, TimeUnit unit) {
	CountDownLatch blatch = broadcastOp(new BroadcastOpFactory(){
		public Operation newOp(final MemcachedNode n,
				final CountDownLatch latch) {
			return opFact.noop(
					new OperationCallback() {
						public void complete() {
							latch.countDown();
						}
						public void receivedStatus(OperationStatus s) {
							// Nothing special when receiving status, only
							// necessary to complete the interface
						}
					});
		}}, conn.getLocator().getAll(), false);
	try {
		// XXX:  Perhaps IllegalStateException should be caught here
		// and the check retried.
		return blatch.await(timeout, unit);
	} catch (InterruptedException e) {
		throw new RuntimeException("Interrupted waiting for queues", e);
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:33,代码来源:MemcachedClient.java

示例12: cloneGet

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
@Override
protected Collection<? extends Operation> cloneGet(KeyedOperation op) {
	Collection<Operation> rv=new ArrayList<Operation>();
	GetOperation.Callback getCb = null;
	GetsOperation.Callback getsCb = null;
	if(op.getCallback() instanceof GetOperation.Callback) {
		getCb=new MultiGetOperationCallback(
				op.getCallback(), op.getKeys().size());
	} else {
		getsCb=new MultiGetsOperationCallback(
				op.getCallback(), op.getKeys().size());
	}
	for(String k : op.getKeys()) {
		rv.add(getCb == null ? gets(k, getsCb) : get(k, getCb));
	}
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:18,代码来源:BinaryOperationFactory.java

示例13: testMultipleGetOperationFanout

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
public void testMultipleGetOperationFanout() {
	Collection<String> keys = Arrays.asList("k1", "k2", "k3");
	Mock m = mock(GetOperation.Callback.class);
	OperationStatus st=new OperationStatus(true, "blah");
	m.expects(once()).method("complete");
	m.expects(once()).method("receivedStatus").with(same(st));
	m.expects(once()).method("gotData")
		.with(eq("k1"), eq(1), isA(byte[].class));
	m.expects(once()).method("gotData")
		.with(eq("k2"), eq(2), isA(byte[].class));
	m.expects(once()).method("gotData")
		.with(eq("k3"), eq(3), isA(byte[].class));

	GetOperation.Callback callback = (GetOperation.Callback)m.proxy();
	GetOperation op = ofact.get(keys, callback);

	// Transition each operation callback into the complete state.
	Iterator<String> ki = keys.iterator();
	int i=0;
	for(Operation o : ofact.clone(op)) {
		GetOperation.Callback cb = (GetOperation.Callback)o.getCallback();
		cb.gotData(ki.next(), ++i, new byte[3]);
		cb.receivedStatus(st);
		cb.complete();
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:27,代码来源:OperationFactoryTestBase.java

示例14: redistributeOperations

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
private void redistributeOperations(Collection<Operation> ops, String cause) {
	for(Operation op : ops) {
		if(op instanceof KeyedOperation) {
			KeyedOperation ko = (KeyedOperation)op;
			int added = 0;
			for(String k : ko.getKeys()) {
				for(Operation newop : opFact.clone(ko)) {
					addOperation(k, newop);
					added++;
				}
			}
			assert added > 0
				: "Didn't add any new operations when redistributing";
		} else {
			// Cancel things that don't have definite targets.
			op.cancel(cause);
		}
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:20,代码来源:MemcachedConnection.java

示例15: getReplicaPick

import net.spy.memcached.ops.Operation; //导入依赖的package包/类
private ReplicaPick getReplicaPick(final Operation o) {
	ReplicaPick pick = ReplicaPick.MASTER;
	
	if (o.isReadOperation()) {
		ReadPriority readPriority = f.getAPIReadPriority().get(o.getAPIType());
		if (readPriority != null) {
			if (readPriority == ReadPriority.SLAVE)
				pick = ReplicaPick.SLAVE;
			else if (readPriority == ReadPriority.RR)
				pick = ReplicaPick.RR;
		} else {
			pick = getReplicaPick();
		}
	}

	return pick;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:18,代码来源:MemcachedConnection.java


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