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


Java MemcachedNode类代码示例

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


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

示例1: createMessage

import net.spy.memcached.MemcachedNode; //导入依赖的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

示例2: getSocketAddressForNode

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
/**
 * Returns the socket address of a given MemcachedNode.
 *
 * @param node The node which we're interested in
 * @return String the socket address of that node.
 */
protected String getSocketAddressForNode(MemcachedNode node) {
  // Using the internal map retrieve the socket addresses
  // for given nodes.
  // I'm aware that this code is inherently thread-unsafe as
  // I'm using a HashMap implementation of the map, but the worst
  // case ( I believe) is we're slightly in-efficient when
  // a node has never been seen before concurrently on two different
  // threads, so it the socketaddress will be requested multiple times!
  // all other cases should be as fast as possible.
  String result = socketAddresses.get(node);
  if (result == null) {
    result = String.valueOf(node.getSocketAddress());
    if (result.startsWith("/")) {
      result = result.substring(1);
    }
    socketAddresses.put(node, result);
  }
  return result;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:26,代码来源:DefaultKetamaNodeLocatorConfiguration.java

示例3: testSuccessful

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
@Test
public void testSuccessful() {
    Long timeout = 1000L;
    TimeUnit unit = TimeUnit.MILLISECONDS;

    MockOperationFuture future = mock(MockOperationFuture.class);
    MockOperation operation = mock(MockOperation.class);

    try {
        when(operation.getException()).thenReturn(null);
        when(operation.isCancelled()).thenReturn(false);
        when(future.__getTraceObject1()).thenReturn(operation);

        MemcachedNode node = getMockMemcachedNode();
        when(operation.getHandlingNode()).thenReturn(node);

        interceptor.before(future, new Object[] { timeout, unit });
        interceptor.after(future, new Object[] { timeout, unit }, null, null);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:23,代码来源:FutureGetInterceptorTest.java

示例4: testTimeoutException

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
@Test
public void testTimeoutException() {
    Long timeout = 1000L;
    TimeUnit unit = TimeUnit.MILLISECONDS;

    MockOperationFuture future = mock(MockOperationFuture.class);
    MockOperation operation = mock(MockOperation.class);

    try {
        OperationException exception = new OperationException(OperationErrorType.GENERAL, "timed out");
        when(operation.getException()).thenReturn(exception);
        when(operation.isCancelled()).thenReturn(true);
        when(future.__getTraceObject1()).thenReturn(operation);

        MemcachedNode node = getMockMemcachedNode();
        when(operation.getHandlingNode()).thenReturn(node);

        interceptor.before(future, new Object[] { timeout, unit });
        interceptor.after(future, new Object[] { timeout, unit }, null, null);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:24,代码来源:FutureGetInterceptorTest.java

示例5: getEndPoint

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
private String getEndPoint(MemcachedNode handlingNode) {
    // TODO duplicated code : ApiInterceptor, FutureGetInterceptor
    final SocketAddress socketAddress = handlingNode.getSocketAddress();
    if (socketAddress instanceof InetSocketAddress) {
        final InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
        final String hostAddress = getHostAddress(inetSocketAddress);
        if (hostAddress == null) {
            // TODO return "Unknown Host"; ?
            logger.debug("hostAddress is null");
            return null;
        }
        return HostAndPort.toHostAndPortString(hostAddress, inetSocketAddress.getPort());

    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("invalid socketAddress:{}", socketAddress);
        }
        return null;
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:21,代码来源:ApiInterceptor.java

示例6: getEndPoint

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
private String getEndPoint(MemcachedNode handlingNode) {
    // TODO duplicated code : ApiInterceptor, FutureGetInterceptor
    final SocketAddress socketAddress = handlingNode.getSocketAddress();
    if (socketAddress instanceof InetSocketAddress) {
        final InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
        final String hostAddress = getHostAddress(inetSocketAddress);
        if (hostAddress == null) {
            // TODO return "Unknown Host";
            logger.debug("hostAddress is null");
            return null;
        }
        return HostAndPort.toHostAndPortString(hostAddress, inetSocketAddress.getPort());

    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("invalid socketAddress:{}", socketAddress);
        }
        return null;
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:21,代码来源:FutureGetInterceptor.java

示例7: getSocketAddressForNode

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
/**
 * Returns the socket address of a given MemcachedNode.
 *
 * @param node The node which we're interested in
 * @return String the socket address of that node.
 */
protected String getSocketAddressForNode(MemcachedNode node) {
	// Using the internal map retrieve the socket addresses
	// for given nodes.
	// I'm aware that this code is inherently thread-unsafe as
	// I'm using a HashMap implementation of the map, but the worst
	// case ( I believe) is we're slightly in-efficient when
	// a node has never been seen before concurrently on two different
	// threads, so it the socketaddress will be requested multiple times!
	// all other cases should be as fast as possible.
	String result=socketAddresses.get(node);
	if(result == null) {
		result=String.valueOf(node.getSocketAddress());
		result=result.substring(result.indexOf('/') + 1);
		socketAddresses.put(node, result);
	}
	return result;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:24,代码来源:DefaultKetamaNodeLocatorConfiguration.java

示例8: getNodeForKey

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
public MemcachedNode getNodeForKey(long _hash) {
    long start = (log.isDebugEnabled()) ? System.nanoTime() : 0;
    try {
        Long hash = Long.valueOf(_hash);
        hash = ketamaNodes.ceilingKey(hash);
        if (hash == null) {
            hash = ketamaNodes.firstKey();
        }
        return ketamaNodes.get(hash);
    } finally {
        if (log.isDebugEnabled()) {
            final long end = System.nanoTime();
            log.debug("getNodeForKey : \t" + (end - start) / 1000);
        }
    }
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:17,代码来源:EVCacheNodeLocator.java

示例9: appendOrAdd

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
public <T> Future<Boolean> appendOrAdd(String key, CachedData value, int timeToLive, EVCacheLatch evcacheLatch) throws Exception {
    final MemcachedNode node = evcacheMemcachedClient.getEVCacheNode(key);
    if (!ensureWriteQueueSize(node, key)) {
        if (log.isInfoEnabled()) log.info("Node : " + node + " is not active. Failing fast and dropping the write event.");
        final ListenableFuture<Boolean, OperationCompletionListener> defaultFuture = (ListenableFuture<Boolean, OperationCompletionListener>) getDefaultFuture();
        if (evcacheLatch != null && evcacheLatch instanceof EVCacheLatchImpl && !isInWriteOnly()) ((EVCacheLatchImpl) evcacheLatch).addFuture(defaultFuture);
        return defaultFuture;
    }

    try {
        return evcacheMemcachedClient.asyncAppendOrAdd(key, timeToLive, value, evcacheLatch);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw e;
    }
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:17,代码来源:EVCacheClient.java

示例10: updateQueueStats

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
private void updateQueueStats() {
    for (ServerGroup serverGroup : memcachedInstancesByServerGroup.keySet()) {
        List<EVCacheClient> clients = memcachedInstancesByServerGroup.get(serverGroup);
        for(EVCacheClient client : clients) {
            final int wSize = client.getWriteQueueLength();
            EVCacheMetricsFactory.getLongGauge("EVCacheClientPool-WriteQueueSize", client.getTagList()).set(Long.valueOf(wSize));
            final int rSize = client.getReadQueueLength();
            EVCacheMetricsFactory.getLongGauge("EVCacheClientPool-ReadQueueSize", client.getTagList()).set(Long.valueOf(rSize));
            if(refreshConnectionOnReadQueueFull.get()) {
                final Collection<MemcachedNode> allNodes = client.getNodeLocator().getAll();
                for (MemcachedNode node : allNodes) {
                    if (node instanceof EVCacheNodeImpl) {
                        final EVCacheNodeImpl evcNode = ((EVCacheNodeImpl) node);
                        if(evcNode.getReadQueueSize() >= refreshConnectionOnReadQueueFullSize.get().intValue()) {
                            EVCacheMetricsFactory.getCounter("EVCacheClientPool-REFRESH_ON_QUEUE_FULL", evcNode.getBaseTags()).increment();
                            client.getEVCacheMemcachedClient().reconnectNode(evcNode);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:24,代码来源:EVCacheClientPool.java

示例11: interruptOldAuth

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
private void interruptOldAuth(MemcachedNode nodeToStop) {
  AuthThread toStop = nodeMap.get(nodeToStop);
  if (toStop != null) {
    if (toStop.isAlive()) {
      getLogger().warn(
          "Incomplete authentication interrupted for node " + nodeToStop);
      toStop.interrupt();
    }
    nodeMap.remove(nodeToStop);
  }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:12,代码来源:AuthThreadMonitor.java

示例12: AuthThread

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
public AuthThread(MemcachedConnection c, OperationFactory o,
    AuthDescriptor a, MemcachedNode n) {
  conn = c;
  opFact = o;
  authDescriptor = a;
  node = n;
  start();
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:9,代码来源:AuthThread.java

示例13: TapAck

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
public TapAck(TapConnectionProvider conn, MemcachedNode node,
    TapOpcode opcode, int opaque, OperationCallback cb) {
  this.conn = conn;
  this.node = node;
  this.opcode = opcode;
  this.opaque = opaque;
  this.cb = cb;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:9,代码来源:TapAck.java

示例14: doInAfterTrace

import net.spy.memcached.MemcachedNode; //导入依赖的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();
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:39,代码来源:ApiInterceptor.java

示例15: getMockMemcachedNode

import net.spy.memcached.MemcachedNode; //导入依赖的package包/类
private MemcachedNode getMockMemcachedNode() throws IOException {
    java.nio.channels.SocketChannel socketChannel = java.nio.channels.SocketChannel.open();
    BlockingQueue<Operation> readQueue = new LinkedBlockingQueue<Operation>();
    BlockingQueue<Operation> writeQueue = new LinkedBlockingQueue<Operation> ();
    BlockingQueue<Operation> inputQueue = new LinkedBlockingQueue<Operation> ();

    return new AsciiMemcachedNodeImpl(new InetSocketAddress(11211), socketChannel, 128, readQueue, writeQueue, inputQueue, 1000L);
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:9,代码来源:FutureGetInterceptorTest.java


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