@Override
    public ProviderInfo doSelect(SofaRequest request, List<ProviderInfo> providerInfos) {
        String interfaceId = request.getInterfaceName();
        String method = request.getMethodName();
        String key = interfaceId + "#" + method;
        int hashcode = providerInfos.hashCode(); // 判断是否同样的服务列表
        Selector selector = selectorCache.get(key);
        if (selector == null // 原来没有
            ||
            selector.getHashCode() != hashcode) { // 或者服务列表已经变化
            selector = new Selector(interfaceId, method, providerInfos, hashcode);
            selectorCache.put(key, selector);
        }
        return selector.select(request);
    }
@Test
    public void doSelect() throws Exception {

        ConsistentHashLoadBalancer loadBalancer = new ConsistentHashLoadBalancer(null);

        Map<Integer, Integer> cnt = new HashMap<Integer, Integer>();
        int size = 20;
        int total = 100000;
        SofaRequest request = new SofaRequest();
        request.setInterfaceName(ConsistentHashLoadBalancerTest.class.getName());
        request.setMethod(ConsistentHashLoadBalancerTest.class.getMethod("doSelect"));
        for (int i = 0; i < size; i++) {
            cnt.put(9000 + i, 0);
        }
        List<ProviderInfo> providers = buildSameWeightProviderList(size);
        long start = System.currentTimeMillis();
        for (int i = 0; i < total; i++) {
            ProviderInfo provider = loadBalancer.doSelect(request, providers);
            int port = provider.getPort();
            cnt.put(port, cnt.get(port) + 1);
        }
        long end = System.currentTimeMillis();
        LOGGER.info("elapsed" + (end - start) + "ms");
        LOGGER.info("avg " + (end - start) * 1000 * 1000 / total + "ns");

        int count = 0;
        for (int i = 0; i < size; i++) {
            if (cnt.get(9000 + i) > 0) {
                count++;
            }
        }
        Assert.assertTrue(count == 1);// 应该落在一台机器上

    }