Package com.linkedin.d2.balancer

Examples of com.linkedin.d2.balancer.PartitionedLoadBalancerTestState


      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


    //setup the partition accessor which is used to get partitionId -> keys
    PartitionAccessor accessor = new TestPartitionAccessor();

    URI serviceURI = new URI("d2://" + serviceName);
    SimpleLoadBalancer balancer = new SimpleLoadBalancer(new PartitionedLoadBalancerTestState(
        clusterName, serviceName, path, strategyName, partitionDescriptions, orderedStrategies,
        accessor
    ));

    List<Integer> keys = new ArrayList<Integer>();
View Full Code Here

    //setup the partition accessor which is used to get partitionId -> keys
    PartitionAccessor accessor = new TestPartitionAccessor();

    URI serviceURI = new URI("d2://" + serviceName);
    SimpleLoadBalancer balancer = new SimpleLoadBalancer(new PartitionedLoadBalancerTestState(
            clusterName, serviceName, path, strategyName, partitionDescriptions, orderedStrategies,
            accessor
    ));

    ConsistentHashKeyMapper mapper = new ConsistentHashKeyMapper(balancer, balancer);
View Full Code Here

    List<LoadBalancerState.SchemeStrategyPair> orderedStrategies = new ArrayList<LoadBalancerState.SchemeStrategyPair>();
    orderedStrategies.add(new LoadBalancerState.SchemeStrategyPair("http", strategy));

    PartitionAccessor accessor = new TestDeadlockPartitionAccessor(numPartitions);

    SimpleLoadBalancer balancer = new SimpleLoadBalancer(new PartitionedLoadBalancerTestState(
            clusterName, serviceName, path, strategyName, partitionDescriptions, orderedStrategies,
            accessor
    ));
    ConsistentHashKeyMapper mapper = new ConsistentHashKeyMapper(balancer, balancer);
View Full Code Here

      {
        throw new UnsupportedOperationException();
      }
    };
    URI serviceURI = new URI("d2://" + serviceName);
    SimpleLoadBalancer balancer = new SimpleLoadBalancer(new PartitionedLoadBalancerTestState(
        clusterName, serviceName, path, strategyName, partitionDescriptions, orderedStrategies,
        accessor
    ));
    List<Integer> keys = new ArrayList<Integer>();
    keys.add(1);
View Full Code Here

    //setup the partition accessor which is used to get partitionId -> keys
    PartitionAccessor accessor = new TestPartitionAccessor();

    URI serviceURI = new URI("d2://" + serviceName);
    SimpleLoadBalancer balancer = new SimpleLoadBalancer(new PartitionedLoadBalancerTestState(
        clusterName, serviceName, path, strategyName, partitionDescriptions, orderedStrategies,
        accessor
    ));

    List<Integer> keys = new ArrayList<Integer>();
View Full Code Here

    //setup the partition accessor which is used to get partitionId -> keys
    PartitionAccessor accessor = new TestPartitionAccessor();

    URI serviceURI = new URI("d2://" + serviceName);
    SimpleLoadBalancer balancer = new SimpleLoadBalancer(new PartitionedLoadBalancerTestState(
        clusterName, serviceName, path, strategyName, partitionDescriptions, orderedStrategies,
        accessor
    ));

    AllPartitionsMultipleHostsResult<URI> result = balancer.
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

TOP

Related Classes of com.linkedin.d2.balancer.PartitionedLoadBalancerTestState

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.