use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class R2D2Server method run.
public void run() throws Exception {
// start everything
for (Map.Entry<String, List<LoadBalancerEchoServer>> servers : _clusters.entrySet()) {
List<String> schemes = new ArrayList<String>();
schemes.add("http");
putCluster(new ClusterProperties(servers.getKey(), schemes));
for (final LoadBalancerEchoServer server : servers.getValue()) {
for (int i = 1; i <= 3; ++i) {
putService(new ServiceProperties("service-" + i + "-" + servers.getKey(), servers.getKey(), File.separator + "service-" + i + "-" + servers.getKey(), Arrays.asList("degrader")));
}
server.startServer();
server.markUp();
}
}
}
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, Map<Integer, Double> partitionWeight, String... services) throws Exception {
LoadBalancerEchoServer echoServer = new LoadBalancerEchoServer(ZK_HOST, ZK_PORT, ECHO_SERVER_HOST, echoServerPort, "http", "/d2", cluster, partitionWeight, services);
echoServer.startServer();
echoServer.markUp();
return echoServer;
}
use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class TestD2Config method teardown.
@AfterMethod
public void teardown() throws IOException, InterruptedException {
for (LoadBalancerEchoServer echoServer : _echoServerList) {
try {
echoServer.stopServer();
_log.info("Executed echoserver shutdown. ");
} catch (Exception e) {
_log.info("echoserver shutdown failed. EchoServer:" + echoServer);
e.printStackTrace();
}
}
try {
_zkclient.shutdown();
_log.info("Executed cli shutdown. ");
} catch (Exception e) {
_log.info("zkclient shutdown failed.");
}
try {
_zkServer.shutdown();
_log.info("Executed zkServer shutdown. ");
} catch (Exception e) {
_log.info("zk server shutdown failed.");
}
}
use of com.linkedin.d2.balancer.util.LoadBalancerEchoServer in project rest.li by linkedin.
the class D2BaseTest method createLatencyDataHash.
protected <T> Map<LoadBalancerEchoServer, T> createLatencyDataHash(List<LoadBalancerEchoServer> servers, T[] latency) {
Map<LoadBalancerEchoServer, T> hash = new HashMap<LoadBalancerEchoServer, T>();
int count = 0;
for (LoadBalancerEchoServer server : servers) {
if (count < latency.length) {
hash.put(server, latency[count++]);
} else {
break;
}
}
return hash;
}
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, String... services) throws Exception {
LoadBalancerEchoServer echoServer = new LoadBalancerEchoServer(zkHost, zkPort, echoServerHost, echoServerPort, "http", "/d2", cluster, services);
echoServer.startServer();
echoServer.markUp();
assertFalse(echoServer.isStopped());
return echoServer;
}
Aggregations