Package com.linkedin.d2.balancer.properties

Examples of com.linkedin.d2.balancer.properties.ClusterProperties


    assertEquals(d2Conf.runDiscovery(_zkHosts), 0);

    verifyPartitionProperties("partitioned-cluster", partitionProperties);

    final ClusterProperties clusterprops = getClusterProperties(_zkclient, "partitioned-cluster" );
    final PartitionAccessor accessor = PartitionAccessorFactory.getPartitionAccessor(clusterprops.getPartitionProperties());
    try
    {
      accessor.getPartitionId(-1 + "");
      fail("Exception expected");
    }
View Full Code Here


    assertEquals(d2Conf.runDiscovery(_zkHosts), 0);

    verifyPartitionProperties("partitioned-cluster", partitionProperties);

    final ClusterProperties clusterprops = getClusterProperties(_zkclient, "partitioned-cluster" );
    final PartitionAccessor accessor = PartitionAccessorFactory.getPartitionAccessor(clusterprops.getPartitionProperties());

    assertEquals(0, accessor.getPartitionId(0 + ""));
    assertEquals(9, accessor.getPartitionId(99 + ""));
    assertEquals(6, accessor.getPartitionId(176 + ""));
    assertEquals(3, accessor.getPartitionId(833 + ""));
View Full Code Here

    return zkUriRegistry.get(cluster);
  }

  public static void verifyClusterProperties(String cluster) throws IOException, URISyntaxException, PropertyStoreException
  {
    ClusterProperties clusterprops = getClusterProperties(_zkclient, cluster);

    assertEquals(clusterprops.getClusterName(), cluster);
    assertEquals(clusterprops.getPrioritizedSchemes(), Arrays.asList(new String[] {"http"}));
    assertEquals(clusterprops.getProperties().get("requestTimeout"), String.valueOf(10000));
    assertEquals(clusterprops.getBanned(), new TreeSet<URI>());
  }
View Full Code Here

      }
      else
      {
        ServiceProperties serviceProperties =
            _expectedServiceProperties.get(possibleService);
        ClusterProperties clusterProperties =
            _expectedClusterProperties.get(serviceProperties.getClusterName());
        UriProperties uriProperties =
            _expectedUriProperties.get(serviceProperties.getClusterName());

        assertEquals(_state.getServiceProperties(possibleService).getProperty(),
                     serviceProperties);

        // verify round robin'ing of the hosts for this service
        for (int i = 0; i < 100; ++i)
        {
          try
          {
            // this call will queue up messages if we're not listening to the service, but
            // it's ok, because all of the messengers have been stopped.
            final TransportClient client =
                _loadBalancer.getClient(new URIRequest("d2://" + possibleService +
                    random(_possiblePaths)), new RequestContext());

            // if we didn't receive service unavailable, we should
            // get a client back
            assertNotNull(client);
          }
          catch (ServiceUnavailableException e)
          {
            if (uriProperties != null && clusterProperties != null)
            {
              // only way to get here is if the prioritized
              // schemes could find no available uris in the
              // cluster. let's see if we can find a URI that
              // matches a prioritized scheme in the cluster.
              Set<String> schemes = new HashSet<String>();

              for (URI uri : uriProperties.Uris())
              {
                schemes.add(uri.getScheme());
              }

              for (String scheme : clusterProperties.getPrioritizedSchemes())
              {
                // if we got null, then we must not have a
                // matching scheme, or we must be missing a
                // client factory

                // TODO if you're not using round robin
                // strategy, it's possible that the strategy
                // could return null (even though a factory is
                // available), but i am not checking for this at
                // the moment. See SimpleLoadBalancer.java to trace
                // the code.
                if (schemes.contains(scheme) && _clientFactories.containsKey(scheme))
                {
                  break;
                }

                assertFalse(schemes.contains(scheme)
                                && _clientFactories.containsKey(scheme),
                            "why couldn't a client be found for schemes "
                                + clusterProperties.getPrioritizedSchemes()
                                + " with URIs: " + uriProperties.Uris());
              }
            }
          }
        }
View Full Code Here

  // cluster simulation
  public void addCluster(String clusterName,
                         List<String> prioritizedSchemes,
                         List<URI> uris)
  {
    ClusterProperties clusterProperties =
        new ClusterProperties(clusterName, prioritizedSchemes);

    // weight the uris randomly between 1 and 2
    Map<URI, Map<Integer, PartitionData>> uriData = new HashMap<URI, Map<Integer, PartitionData>>();

    for (URI uri : uris)
View Full Code Here

    {
      List<String> schemes = new ArrayList<String>();

      schemes.add("http");

      putCluster(new ClusterProperties(servers.getKey(), schemes));

      for (final LoadBalancerEchoServer server : servers.getValue())
      {
        for (int i = 1; i <= 3; ++i)
        {
View Full Code Here

    ServiceProperties service = listenToServiceAndCluster(uri);

    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    ClusterProperties cluster = getClusterProperties(serviceName, clusterName);

    // Check if we want to override the service URL and bypass choosing among the existing
    // tracker clients. This is useful when the service we want is not announcing itself to
    // the cluster, ie a private service for a set of clients.
    URI targetService = LoadBalancerUtil.TargetHints.getRequestContextTargetService(requestContext);
View Full Code Here

  public <K> MapKeyResult<Ring<URI>, K> getRings(URI serviceUri, Iterable<K> keys) throws ServiceUnavailableException
  {
    ServiceProperties service = listenToServiceAndCluster(serviceUri);
    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    ClusterProperties cluster = getClusterProperties(serviceName, clusterName);
    LoadBalancerStateItem<UriProperties> uriItem = getUriItem(serviceName, clusterName, cluster);
    UriProperties uris = uriItem.getProperty();

    List<LoadBalancerState.SchemeStrategyPair> orderedStrategies =
        _state.getStrategiesForService(serviceName, service.getPrioritizedSchemes());
View Full Code Here

  public Map<Integer, Ring<URI>> getRings(URI serviceUri) throws ServiceUnavailableException
  {
    ServiceProperties service = listenToServiceAndCluster(serviceUri);
    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    ClusterProperties cluster = getClusterProperties(serviceName, clusterName);

    LoadBalancerStateItem<UriProperties> uriItem = getUriItem(serviceName, clusterName, cluster);
    UriProperties uris = uriItem.getProperty();

    List<LoadBalancerState.SchemeStrategyPair> orderedStrategies =
View Full Code Here

      throw new IllegalArgumentException("limitHostPartition cannot be 0 or less");
    }
    ServiceProperties service = listenToServiceAndCluster(serviceUri);
    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    ClusterProperties cluster = getClusterProperties(serviceName, clusterName);

    LoadBalancerStateItem<UriProperties> uriItem = getUriItem(serviceName, clusterName, cluster);
    UriProperties uris = uriItem.getProperty();

    List<LoadBalancerState.SchemeStrategyPair> orderedStrategies =
View Full Code Here

TOP

Related Classes of com.linkedin.d2.balancer.properties.ClusterProperties

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.