Search in sources :

Example 6 with LoadBalancerClientCli

use of com.linkedin.d2.balancer.util.LoadBalancerClientCli in project rest.li by linkedin.

the class TestD2ConfigWithSingleZKFailover method setup.

@BeforeTest
public void setup() throws IOException, Exception {
    // zkServer
    _zkServer = ZKTestUtil.startZKServer();
    _zkPort = _zkServer.getPort();
    _zkHosts = ZK_HOST + ":" + _zkPort;
    _zkUriString = "zk://" + _zkHosts;
    // Register clusters/services  (two services per cluster)
    LoadBalancerClientCli.runDiscovery(_zkHosts, "/d2", D2_CONFIG_DATA);
    // Get LoadBalancer Client
    _cli = new LoadBalancerClientCli(_zkHosts, "/d2");
    // Echo servers startup
    startAllEchoServers();
    assertAllEchoServersRunning(_echoServers);
    _client = _cli.createClient(_cli.getZKClient(), _zkUriString, "/d2", "service-1_1");
    _log.info(LoadBalancerClientCli.printStores(_cli.getZKClient(), _zkUriString, "/d2"));
    assertAllEchoServersRegistered(_cli.getZKClient(), _zkUriString, _echoServers);
}
Also used : LoadBalancerClientCli(com.linkedin.d2.balancer.util.LoadBalancerClientCli) BeforeTest(org.testng.annotations.BeforeTest)

Example 7 with LoadBalancerClientCli

use of com.linkedin.d2.balancer.util.LoadBalancerClientCli 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);
}
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

LoadBalancerClientCli (com.linkedin.d2.balancer.util.LoadBalancerClientCli)5 LoadBalancerEchoServer (com.linkedin.d2.balancer.util.LoadBalancerEchoServer)4 D2BaseTest (com.linkedin.d2.D2BaseTest)3 HashMap (java.util.HashMap)3 AfterTest (org.testng.annotations.AfterTest)3 Test (org.testng.annotations.Test)3 PropertyStoreException (com.linkedin.d2.discovery.stores.PropertyStoreException)1 ZKQuorum (com.linkedin.d2.quorum.ZKQuorum)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 BeforeTest (org.testng.annotations.BeforeTest)1