Search in sources :

Example 1 with LoadBalancerEchoServer

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

Example 2 with LoadBalancerEchoServer

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

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

Example 4 with LoadBalancerEchoServer

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);
}
Also used : LoadBalancerClientCli(com.linkedin.d2.balancer.util.LoadBalancerClientCli) LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer) D2BaseTest(com.linkedin.d2.D2BaseTest) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 5 with LoadBalancerEchoServer

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);
}
Also used : LoadBalancerClientCli(com.linkedin.d2.balancer.util.LoadBalancerClientCli) HashMap(java.util.HashMap) LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer) D2BaseTest(com.linkedin.d2.D2BaseTest) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

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