use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class D2BaseTest method printDataMatrix.
protected static String printDataMatrix(Map<LoadBalancerEchoServer, ?> map) {
StringBuilder sb = new StringBuilder();
for (LoadBalancerEchoServer server : map.keySet()) {
sb.append(((sb.length() > 0) ? "," : ""));
sb.append("Server Port:");
sb.append(server.getPort());
sb.append(",Weight:");
sb.append(map.get(server));
}
return sb.toString();
}
use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class D2BaseTest method allEchoServersRunning.
public boolean allEchoServersRunning(List<LoadBalancerEchoServer> servers) throws Exception {
int count = 0;
for (LoadBalancerEchoServer server : servers) {
if (server.isStopped()) {
_log.info("Echo server (port " + server.getPort() + ") is stopped.");
count++;
}
}
if (count == 0) {
return true;
}
return false;
}
use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class D2BaseTest method startEchoServer.
protected static LoadBalancerEchoServer startEchoServer(String zkHost, int zkPort, String echoServerHost, int echoServerPort, String cluster, Map<Integer, Double> partitionWeight, String... services) throws Exception {
_log.debug("Starting echo server " + echoServerHost + " " + echoServerPort + " in cluster " + cluster);
LoadBalancerEchoServer echoServer = new LoadBalancerEchoServer(zkHost, zkPort, echoServerHost, echoServerPort, "http", "/d2", cluster, services);
echoServer.startServer();
echoServer.markUp(partitionWeight);
assertFalse(echoServer.isStopped());
return echoServer;
}
use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class TestPartitionsWithZKQuorum method testRegisterUnregisterDefaultPartitionEchoServers.
@Test
public void testRegisterUnregisterDefaultPartitionEchoServers() throws IOException, URISyntaxException, PropertyStoreException, ExecutionException, TimeoutException, InterruptedException, Exception {
_echoServers = new ArrayList<LoadBalancerEchoServer>();
setup();
assertEquals(LoadBalancerClientCli.runDiscovery(_quorum.getHosts(), "/d2", D2_CONFIG_DEFAULT_PARTITION_DATA), 0);
_cli = new LoadBalancerClientCli(_quorum.getHosts(), "/d2");
_client = _cli.createZKFSTogglingLBClient(_quorum.getHosts(), "/d2", null);
// Echo servers startup
startDefaultPartitionEchoServers();
assertAllEchoServersRunning(_echoServers);
assertAllEchoServersRegistered(_cli.getZKClient(), _zkUriString, _echoServers);
assertQuorumProcessAllRequests(D2_CONFIG_DEFAULT_PARTITION_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 TestPartitionsWithZKQuorum method testRegisterUnregisterCustomPartitionEchoServers.
@Test
public void testRegisterUnregisterCustomPartitionEchoServers() throws IOException, URISyntaxException, PropertyStoreException, ExecutionException, TimeoutException, InterruptedException, Exception {
_echoServers = new ArrayList<LoadBalancerEchoServer>();
setup();
assertEquals(LoadBalancerClientCli.runDiscovery(_quorum.getHosts(), "/d2", D2_CONFIG_CUSTOM_PARTITION_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));
startCustomPartitionEchoServers(partitionWeight);
assertAllEchoServersRegistered(_cli.getZKClient(), _zkUriString, _echoServers);
assertQuorumProcessAllRequests(D2_CONFIG_CUSTOM_PARTITION_DATA);
// Markdown echo servers
stopAllEchoServers(_echoServers);
assertAllEchoServersUnregistered(_cli.getZKClient(), _zkUriString, _echoServers);
}
Aggregations