Package com.linkedin.d2.balancer.util

Examples of com.linkedin.d2.balancer.util.LoadBalancerClientCli


                                                            Collections.<String, Object>emptyMap(),
                                                            transportClientProperties, null, schemes, null));

    assertNull(_state.getClient("service-1", uri));

    _uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));

    TrackerClient client = _state.getClient("service-1", uri);

    assertNotNull(client);
    assertEquals(client.getUri(), uri);
View Full Code Here


                                                            Collections.<String, Object>emptyMap(),
                                                            transportClientProperties, null, schemes, null));

    assertNull(_state.getClient("service-1", uri));

    _uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));

    TrackerClient client = _state.getClient("service-1", uri);

    assertNotNull(client);
    assertEquals(client.getUri(), uri);
View Full Code Here

                                                            Collections.<String, Object>emptyMap(),
                                                             null, null, schemes, null));

    assertNull(_state.getClient("service-1", uri));

    _uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));

    TrackerClient client = _state.getClient("service-1", uri);

    assertNotNull(client);
    assertEquals(client.getUri(), uri);

    //now we publish an event that tells service-1 changes cluster. Now it's hosted in cluster-2
    _serviceRegistry.put("service-1", new ServiceProperties("service-1", "cluster-2",
                                                            "/test", "random", null,
                                                            Collections.<String, Object>emptyMap(),
                                                             null, null, schemes, null));

    //this time, since we haven't listened to cluster-2 and there's no uri in cluster-2, we get no client.
    assertNull(_state.getClient("service-1", uri));

    //we shouldn't be affected by any update to cluster-1 uris because now service-1 listen to cluster-2
    _uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));
    assertNull(_state.getClient("service-1", uri));

    //now let's create URI for cluster 2 and make the state listen to cluster_2
    _state.listenToCluster("cluster-2", new NullStateListenerCallback());

    URI uri2 = URI.create("http://cluster-2/test");
    Map<Integer, PartitionData> partitionData2 = new HashMap<Integer, PartitionData>(1);
    partitionData2.put(DefaultPartitionAccessor.DEFAULT_PARTITION_ID, new PartitionData(1d));
    Map<URI, Map<Integer, PartitionData>> uriData2 = new HashMap<URI, Map<Integer, PartitionData>>();
    uriData2.put(uri2, partitionData2);

    //if we start publishing new event to cluster-2 then we should get trackerClient
    _uriRegistry.put("cluster-2", new UriProperties("cluster-2", uriData2));

    client = _state.getClient("service-1", uri2);

    assertNotNull(client);
    assertEquals(client.getUri(), uri2);

    //just to make sure that any event from cluster-1 doesn't affect us anymore
    _uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));
    client = _state.getClient("service-1", uri2);

    assertNotNull(client);
    assertEquals(client.getUri(), uri2);
View Full Code Here

    // set up state
    CountDownLatch cdl2 = new CountDownLatch(1);
    _state.listenToCluster("cluster-1", new SimpleLoadBalancer.SimpleLoadBalancerCountDownCallback(cdl2));
    assertTrue(cdl2.await(60, TimeUnit.SECONDS));

    _uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));

    assertNull(_state.getClient("service-1", uri));

    _serviceRegistry.put("service-1", new ServiceProperties("service-1", "cluster-1",
                                                            "/test", "random", null,
View Full Code Here

        "/test", "random", null,
        Collections.<String, Object>emptyMap(),
        null, null, schemes, null));

    // first we announce uri with empty partition data map
    _uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));

    TrackerClient client = _state.getClient("service-1", uri);

    assertNotNull(client);
    assertEquals(client.getUri(), uri);
    // tracker client should see empty partition data map
    assertTrue(client.getParttitionDataMap().isEmpty());

    // then we update this uri to have a non-empty partition data map
    partitionDataMap.put(DefaultPartitionAccessor.DEFAULT_PARTITION_ID, new PartitionData(1d));
    _uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));

    TrackerClient updatedClient = _state.getClient("service-1", uri);

    assertNotNull(updatedClient);
    // should have got a different tracker client
View Full Code Here

    ZooKeeperPermanentStore<ClusterProperties> zkClusterRegistry = createPermanentStore(
            zkConnection, ZKFSUtil.clusterPath(_baseZKPath), new ClusterPropertiesJsonSerializer());
    ZooKeeperPermanentStore<ServiceProperties> zkServiceRegistry = createPermanentStore(
            zkConnection, ZKFSUtil.servicePath(_baseZKPath, _d2ServicePath), new ServicePropertiesJsonSerializer());
    ZooKeeperEphemeralStore<UriProperties> zkUriRegistry =  createEphemeralStore(
            zkConnection, ZKFSUtil.uriPath(_baseZKPath), new UriPropertiesJsonSerializer(), new UriPropertiesMerger());

    FileStore<ClusterProperties> fsClusterStore = createFileStore("clusters", new ClusterPropertiesJsonSerializer());
    FileStore<ServiceProperties> fsServiceStore = createFileStore(_d2ServicePath, new ServicePropertiesJsonSerializer());
    FileStore<UriProperties> fsUriStore = createFileStore("uris", new UriPropertiesJsonSerializer());

    PropertyEventBus<ClusterProperties> clusterBus = new PropertyEventBusImpl<ClusterProperties>(executorService);
    PropertyEventBus<ServiceProperties> serviceBus = new PropertyEventBusImpl<ServiceProperties>(executorService);
    PropertyEventBus<UriProperties> uriBus = new PropertyEventBusImpl<UriProperties>(executorService);
View Full Code Here

    ZooKeeperPermanentStore<ClusterProperties> zkClusterRegistry = createPermanentStore(
            zkConnection, ZKFSUtil.clusterPath(_baseZKPath), new ClusterPropertiesJsonSerializer());
    ZooKeeperPermanentStore<ServiceProperties> zkServiceRegistry = createPermanentStore(
            zkConnection, ZKFSUtil.servicePath(_baseZKPath, _d2ServicePath), new ServicePropertiesJsonSerializer());
    ZooKeeperEphemeralStore<UriProperties> zkUriRegistry =  createEphemeralStore(
            zkConnection, ZKFSUtil.uriPath(_baseZKPath), new UriPropertiesJsonSerializer(), new UriPropertiesMerger());

    FileStore<ClusterProperties> fsClusterStore = createFileStore("clusters", new ClusterPropertiesJsonSerializer());
    FileStore<ServiceProperties> fsServiceStore = createFileStore(_d2ServicePath, new ServicePropertiesJsonSerializer());
    FileStore<UriProperties> fsUriStore = createFileStore("uris", new UriPropertiesJsonSerializer());
View Full Code Here

    _announcer.setWeight(1d);

    return new ZooKeeperConnectionManager(_zkHostname + ":" + _zkPort,
                                          _sessionTimeoutInMs,
                                          _basePath,
                                          new ZKUriStoreFactory(),
                                          _announcer);
  }
View Full Code Here

  public ZooKeeperConnectionManager build()
  {
    _announcer.setWeight(1d);

    return new ZooKeeperConnectionManager(_zkHostname + ":" + _zkPort,
                                          _sessionTimeoutInMs,
                                          _basePath,
                                          new ZKUriStoreFactory(),
                                          _announcer);
  }
View Full Code Here

    // write D2-related configuration to ZooKeeper
    // all the configuration here are permanent, no need to re-write as long as ZooKeeper still has the data
    // therefore in real case, do this "discovery" step separately

    final HttpServer server = RestLiExampleBasicServer.createServer();
    final ZooKeeperConnectionManager zkConn = createZkConn();

    startServer(server, zkConn);

    System.out.println("Example server with D2 is running with URL " + RestLiExampleBasicServer.getServerUrl() + ". Press any key to stop server.");
    System.in.read();
View Full Code Here

TOP

Related Classes of com.linkedin.d2.balancer.util.LoadBalancerClientCli

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.