use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class D2BaseTest method assertServersWeighSetup.
protected void assertServersWeighSetup(Map<LoadBalancerEchoServer, Map<Integer, Double>> hostWeightMatrix, LoadBalancerClientCli cli, String zkConnectionString) throws Exception {
String stores = LoadBalancerClientCli.printStores(cli.getZKClient(), zkConnectionString, "/d2");
for (LoadBalancerEchoServer server : hostWeightMatrix.keySet()) {
String str = server.getHost() + ": " + server.getPort() + "/cluster-\\d+=" + hostWeightMatrix.get(server);
Pattern pattern = Pattern.compile(str, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(stores);
assertTrue(matcher.find(), "URIProperty '" + str + "' was not found is current active clusters.\n" + stores);
}
}
use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class D2BaseTest method createServerWeightDataMap.
protected static Map<LoadBalancerEchoServer, Map<Integer, Double>> createServerWeightDataMap(List<LoadBalancerEchoServer> servers, int partitionId, Double[] weight) {
Map<LoadBalancerEchoServer, Map<Integer, Double>> hash = new HashMap<LoadBalancerEchoServer, Map<Integer, Double>>();
int count = 0;
for (LoadBalancerEchoServer server : servers) {
if (count < weight.length) {
Map<Integer, Double> partitionWeight = new HashMap<Integer, Double>();
partitionWeight.put(new Integer(partitionId), weight[count]);
hash.put(server, partitionWeight);
count++;
} else {
break;
}
}
return hash;
}
use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class TestPartitionsWithZKQuorum method testRegisterUnregisterAllEchoServers.
@Test
public void testRegisterUnregisterAllEchoServers() throws IOException, URISyntaxException, PropertyStoreException, ExecutionException, TimeoutException, InterruptedException, Exception {
_echoServers = new ArrayList<LoadBalancerEchoServer>();
setup();
assertEquals(LoadBalancerClientCli.runDiscovery(_quorum.getHosts(), "/d2", D2_CONFIG_DATA), 0);
_cli = new LoadBalancerClientCli(_quorum.getHosts(), "/d2");
_client = _cli.createZKFSTogglingLBClient(_quorum.getHosts(), "/d2", null);
// Echo servers startup
Map<Integer, Double> partitionWeight = new HashMap<Integer, Double>();
partitionWeight.put(new Integer(1), new Double(1.0d));
startAllEchoServers(partitionWeight);
assertAllEchoServersRegistered(_cli.getZKClient(), _zkUriString, _echoServers);
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
// Markdown echo servers
stopAllEchoServers(_echoServers);
assertAllEchoServersUnregistered(_cli.getZKClient(), _zkUriString, _echoServers);
}
use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class TestD2Config method startEchoServer.
private static LoadBalancerEchoServer startEchoServer(int echoServerPort, String cluster, String... services) throws Exception {
LoadBalancerEchoServer echoServer = new LoadBalancerEchoServer(ZK_HOST, ZK_PORT, ECHO_SERVER_HOST, echoServerPort, "http", "/d2", cluster, services);
echoServer.startServer();
echoServer.markUp();
return echoServer;
}
Aggregations