Search in sources :

Example 6 with LoadBalancerEchoServer

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();
        }
    }
}
Also used : ServiceProperties(com.linkedin.d2.balancer.properties.ServiceProperties) ArrayList(java.util.ArrayList) ClusterProperties(com.linkedin.d2.balancer.properties.ClusterProperties) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer)

Example 7 with LoadBalancerEchoServer

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;
}
Also used : LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer)

Example 8 with LoadBalancerEchoServer

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.");
    }
}
Also used : LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer) URISyntaxException(java.net.URISyntaxException) PartitionAccessException(com.linkedin.d2.balancer.util.partitions.PartitionAccessException) PropertyStoreException(com.linkedin.d2.discovery.stores.PropertyStoreException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) AfterMethod(org.testng.annotations.AfterMethod)

Example 9 with LoadBalancerEchoServer

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;
}
Also used : HashMap(java.util.HashMap) LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer)

Example 10 with LoadBalancerEchoServer

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;
}
Also used : LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer)

Aggregations

LoadBalancerEchoServer (com.linkedin.d2.balancer.util.LoadBalancerEchoServer)14 HashMap (java.util.HashMap)5 D2BaseTest (com.linkedin.d2.D2BaseTest)3 LoadBalancerClientCli (com.linkedin.d2.balancer.util.LoadBalancerClientCli)3 AfterTest (org.testng.annotations.AfterTest)3 Test (org.testng.annotations.Test)3 Map (java.util.Map)2 ClusterProperties (com.linkedin.d2.balancer.properties.ClusterProperties)1 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)1 PartitionAccessException (com.linkedin.d2.balancer.util.partitions.PartitionAccessException)1 PropertyStoreException (com.linkedin.d2.discovery.stores.PropertyStoreException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 KeeperException (org.apache.zookeeper.KeeperException)1 AfterMethod (org.testng.annotations.AfterMethod)1