@Override
    public URL select(List<URL> urls, String serviceId, String tag, String requestKey) {
        String key = tag == null ? serviceId : serviceId + "|" + tag;
    	// search for a URL in the same ip first
        List<URL> localUrls = searchLocalUrls(urls, ip);
        if(localUrls.size() > 0) {
             if(localUrls.size() == 1) {
                 return localUrls.get(0);
             } else {
                // round robin within localUrls
                 return doSelect(localUrls, key);
             }
        } else {
            // round robin within urls
            return doSelect(urls, key);
        }
    }
@Test
    public void testSelectFirstThenRoundRobin() throws Exception{
        List<URL> urls = new ArrayList<>();
        urls.add(new URLImpl("http", "127.0.0.10", 8081, "v1", new HashMap<String, String>()));
        urls.add(new URLImpl("http", "127.0.0.10", 8082, "v1", new HashMap<String, String>()));
        urls.add(new URLImpl("http", "127.0.0.10", 8083, "v1", new HashMap<String, String>()));
        urls.add(new URLImpl("http", "127.0.0.10", 8084, "v1", new HashMap<String, String>()));

        // no local host URL available, go round-robin
        URL url = loadBalance.select(urls, "serviceId", "tag", null);
        Assert.assertTrue(urls.contains(url));
    }