Examples of UriProperties


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

        else
        {
          warn(_log, _store, " marked down for cluster ", clusterName, "with uri: ", uri);
          Map<URI, Map<Integer, PartitionData>> partitionData = new HashMap<URI, Map<Integer, PartitionData>>(2);
          partitionData.put(uri, Collections.<Integer, PartitionData>emptyMap());
          _store.removePartial(clusterName, new UriProperties(clusterName, partitionData), callback);
        }

      }

      @Override
View Full Code Here

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

    URI targetService = LoadBalancerUtil.TargetHints.getRequestContextTargetService(requestContext);

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

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

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

    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());

    if (! orderedStrategies.isEmpty())
View Full Code Here

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

    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());

    if (! orderedStrategies.isEmpty())
    {
      final LoadBalancerState.SchemeStrategyPair pair = orderedStrategies.get(0);
      final PartitionAccessor accessor = getPartitionAccessor(serviceName, clusterName);
      int maxPartitionId = accessor.getMaxPartitionId();
      Map<Integer, Ring<URI>> ringMap = new HashMap<Integer, Ring<URI>>((maxPartitionId + 1) * 2);
      for (int partitionId = 0; partitionId <= maxPartitionId; partitionId++)
      {
        Set<URI> possibleUris = uris.getUriBySchemeAndPartition(pair.getScheme(), partitionId);
        List<TrackerClient> trackerClients = getPotentialClients(serviceName, service, possibleUris);
        Ring<URI> ring = pair.getStrategy().getRing(uriItem.getVersion(), partitionId, trackerClients);
        // ring will never be null; it can be empty
        ringMap.put(partitionId, ring);
      }
View Full Code Here

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

    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());
    Map<Integer, Integer> partitionWithoutEnoughHost = new HashMap<Integer, Integer>();
    int maxPartitionId = 0;

    //get the partitionId -> host URIs list
    Map<Integer, List<URI>> hostList = new HashMap<Integer, List<URI>>();
    if (! orderedStrategies.isEmpty())
    {
      final LoadBalancerState.SchemeStrategyPair pair = orderedStrategies.get(0);
      final PartitionAccessor accessor = getPartitionAccessor(serviceName, clusterName);
      maxPartitionId = accessor.getMaxPartitionId();
      int hash = hashProvider.nextHash();
      for (int partitionId = 0; partitionId <= maxPartitionId; partitionId++)
      {
        Set<URI> possibleUris = uris.getUriBySchemeAndPartition(pair.getScheme(), partitionId);
        List<TrackerClient> trackerClients = getPotentialClients(serviceName, service, possibleUris);
        int size = trackerClients.size() <= numHostPerPartition ? trackerClients.size() : numHostPerPartition;
        List<URI> rankedUri = new ArrayList<URI>(size);

        Ring<URI> ring = pair.getStrategy().getRing(uriItem.getVersion(), partitionId, trackerClients);
View Full Code Here

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

    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());
    List<K> unmappedKeys = new ArrayList<K>();

    if (! orderedStrategies.isEmpty())
    {
      //DANGER we assume that the first strategy in the list has to support partitioning. If not then,
      //this function may fail. The reason why we don't check whether the strategy support partitioning
      //is because the downstream code will check it for us and the user will be notified about
      //this problem. Plus it doesn't make sense for a user to have partitioning but didn't specify a
      //strategy that supports partitioning
      final LoadBalancerState.SchemeStrategyPair pair = orderedStrategies.get(0);
      final PartitionAccessor accessor = getPartitionAccessor(serviceName, clusterName);

      //get the partitionId -> keys mapping
      Map<Integer, Set<K>> partitionSet = new TreeMap<Integer, Set<K>>();
      for (final K key : keys)
      {
        int partitionId;
        try
        {
          partitionId = accessor.getPartitionId(key.toString());
        }
        catch (PartitionAccessException e)
        {
          unmappedKeys.add(key);
          continue;
        }

        Set<K> set = partitionSet.get(partitionId);
        if (set == null)
        {
          set = new HashSet<K>();
          partitionSet.put(partitionId, set);
        }
        set.add(key);
      }

      Collection<Integer> partitionWithoutEnoughHost = new HashSet<Integer>();

      int hash = hashProvider.nextHash();

      //get the partitionId -> host URIs list
      Map<Integer, List<URI>> hostList = new HashMap<Integer, List<URI>>();
      for (Integer partitionId : partitionSet.keySet())
      {
        Set<URI> possibleUris = uris.getUriBySchemeAndPartition(pair.getScheme(), partitionId);
        List<TrackerClient> trackerClients = getPotentialClients(serviceName, service, possibleUris);
        int size = trackerClients.size() <= limitHostPerPartition ? trackerClients.size() : limitHostPerPartition;
        List<URI> rankedUri = new ArrayList<URI>(size);

        Ring<URI> ring = pair.getStrategy().getRing(uriItem.getVersion(), partitionId, trackerClients);
View Full Code Here

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

                                                        Collections.<String,Object>emptyMap(),
                                                        null,
                                                        null,
                                                        prioritizedSchemes,
                                                        null));
      uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));

      URI expectedUri1 = URI.create("http://test.qa1.com:1234/foo");
      URI expectedUri2 = URI.create("http://test.qa2.com:2345/foo");
      URI expectedUri3 = URI.create("http://test.qa3.com:6789/foo");
View Full Code Here

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

                                                        null,
                                                        null,
                                                        prioritizedSchemes,
                                                        null));

      uriRegistry.put("cluster-1", new UriProperties("cluster-1", partitionDesc));

      if (partitionMethod == 3)
      {
        Map<Integer, Ring<URI>> ringMap = loadBalancer.getRings(URI.create("d2://foo"));
        assertEquals(ringMap.size(), 4);
View Full Code Here

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

    Map<URI,TrackerClient> newTrackerClients;

    // update all tracker clients to use new configs
    LoadBalancerStateItem<UriProperties> uriItem = _uriProperties.get(serviceProperties.getClusterName());
    UriProperties uriProperties = uriItem == null ? null : uriItem.getProperty();
    if (uriProperties != null)
    {
      Set<URI> uris = uriProperties.Uris();
      // clients-by-uri map may be edited later by UriPropertiesListener.handlePut
      newTrackerClients = new ConcurrentHashMap<URI, TrackerClient>((int)Math.ceil(uris.size() / 0.75f), 0.75f, 1);
      long trackerClientInterval = getTrackerClientInterval (serviceProperties);
      for (URI uri : uris)
      {
        TrackerClient trackerClient = getTrackerClient(serviceName, uri, uriProperties.getPartitionDataMap(uri),
                                                       config, trackerClientInterval);
        if (trackerClient != null)
        {
          newTrackerClients.put(uri, trackerClient);
        }
View Full Code Here

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

    clusterRegistry.put("testcluster", new ClusterProperties("testcluster"));
    clusterRegistry.put("badcluster", new ClusterProperties("badcluster"));


    uriRegistry.put("testcluster", new UriProperties("testcluster", createUriData("http://localhost:1338")));
    uriRegistry.put("badcluster", new UriProperties("badcluster", createUriData("http://localhost:1337")));
    // create the load balancer
    return new SimpleLoadBalancer(state);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.