Package com.linkedin.d2.balancer.util

Examples of com.linkedin.d2.balancer.util.LoadBalancerEchoServer$RpcDispatcher


      ZKFSLoadBalancer balancer = getBalancer();
      FutureCallback<None> callback = new FutureCallback<None>();
      balancer.start(callback);
      callback.get(30, TimeUnit.SECONDS);

      Directory dir = balancer.getDirectory();

      ZKConnection conn = new ZKConnection("localhost:" + PORT, 30000);
      conn.start();

      ZooKeeperPermanentStore<ServiceProperties> store =
              new ZooKeeperPermanentStore<ServiceProperties>(conn, new ServicePropertiesJsonSerializer(), ZKFSUtil.servicePath(BASE_PATH));
      callback = new FutureCallback<None>();
      store.start(callback);
      callback.get(30, TimeUnit.SECONDS);

      ServiceProperties props = new ServiceProperties(TEST_SERVICE_NAME, "someCluster", "/somePath", "someStrategy");
      store.put(TEST_SERVICE_NAME, props);

      FutureCallback<List<String>> serviceCallback = new FutureCallback<List<String>>();
      dir.getServiceNames(serviceCallback);

      Assert.assertEquals(serviceCallback.get(30, TimeUnit.SECONDS), Collections.singletonList(TEST_SERVICE_NAME));
    }
    finally
    {
View Full Code Here


      ZKFSLoadBalancer balancer = getBalancer();
      FutureCallback<None> callback = new FutureCallback<None>();
      balancer.start(callback);
      callback.get(30, TimeUnit.SECONDS);

      Directory dir = balancer.getDirectory();

      ZKConnection conn = new ZKConnection("localhost:" + PORT, 30000);
      conn.start();

      ZooKeeperPermanentStore<ClusterProperties> store =
              new ZooKeeperPermanentStore<ClusterProperties>(conn, new ClusterPropertiesJsonSerializer(),
                                                             ZKFSUtil.clusterPath(BASE_PATH));
      callback = new FutureCallback<None>();
      store.start(callback);
      callback.get(30, TimeUnit.SECONDS);

      ClusterProperties props = new ClusterProperties(TEST_CLUSTER_NAME);
      store.put(TEST_CLUSTER_NAME, props);

      FutureCallback<List<String>> clusterCallback = new FutureCallback<List<String>>();
      dir.getClusterNames(clusterCallback);

      Assert.assertEquals(clusterCallback.get(30, TimeUnit.SECONDS), Collections.singletonList(TEST_CLUSTER_NAME));
    }
    finally
    {
View Full Code Here

                  _config.clientServicesConfig,
                  _config.d2ServicePath);

    final LoadBalancerWithFacilities loadBalancer = loadBalancerFactory.create(cfg);

    D2Client d2Client = new DynamicClient(loadBalancer, loadBalancer);

    /**
     * If we created default transport client factories, we need to shut them down when d2Client
     * is being shut down.
     */
 
View Full Code Here

  public TrackerClient getClient(String serviceName, URI uri)
  {
    if (_partitionDescriptions.get(uri) != null)
    {
      // shorten the update interval to 20ms in order to increase the possibility of deadlock
      _trackerClients.putIfAbsent(uri, new TrackerClient(uri, _partitionDescriptions.get(uri), null, new SettableClock(), null, 20));

      return _trackerClients.get(uri);
    }
    return null;
  }
View Full Code Here

  @Override
  public TrackerClient getClient(String clusterName, URI uri)
  {
    Map<Integer, PartitionData> partitionDataMap = new HashMap<Integer, PartitionData>(2);
    partitionDataMap.put(DefaultPartitionAccessor.DEFAULT_PARTITION_ID, new PartitionData(1));
    return (getClient) ? new TrackerClient(uri, partitionDataMap, new TestClient()) : null;
  }
View Full Code Here

  @Override
  public TrackerClient getClient(String clusterName, URI uri)
  {
    Map<Integer, PartitionData> partitionDataMap = new HashMap<Integer, PartitionData>(2);
    partitionDataMap.put(DefaultPartitionAccessor.DEFAULT_PARTITION_ID, new PartitionData(1));
    return (getClient) ? new TrackerClient(uri, partitionDataMap, new TestClient()) : null;
  }
View Full Code Here

  }

  @Override
  public TransportClient getClient(String clusterName, String Scheme)
  {
    return (getClient) ? new TestClient() : null;
  }
View Full Code Here

  @Test
  public void testPathAppend()
  {
    URI uri = URI.create("http://test.linkedin.com:9876/test");
    String serviceName = "HistoryService";
    TestClient wrappedClient = new TestClient();
    RewriteClient client = new RewriteClient(serviceName, uri, wrappedClient);

    assertEquals(client.getUri(), uri);
    assertEquals(client.getServiceName(), serviceName);
    assertEquals(client.getWrappedClient(), wrappedClient);
View Full Code Here

  @Override
  public LoadBalancerStateItem<ClusterProperties> getClusterProperties(String clusterName)
  {
    List<String> prioritizedSchemes = new ArrayList<String>();
    prioritizedSchemes.add("http");
    ClusterProperties clusterProperties = new ClusterProperties(_cluster, prioritizedSchemes);
    return new LoadBalancerStateItem<ClusterProperties>(clusterProperties, 1, 1);
  }
View Full Code Here

  @Override
  public LoadBalancerStateItem<ClusterProperties> getClusterProperties(String clusterName)
  {
    return (getClusterProperties)
        ? new LoadBalancerStateItem<ClusterProperties>(new ClusterProperties("cluster-1"),
                                                       0,
                                                       0) : null;
  }
View Full Code Here

TOP

Related Classes of com.linkedin.d2.balancer.util.LoadBalancerEchoServer$RpcDispatcher

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.