Search in sources :

Example 1 with LoadBalancerStateItem

use of com.linkedin.d2.balancer.LoadBalancerStateItem in project rest.li by linkedin.

the class SimpleLoadBalancer method getClient.

/**
   * Given a Request, returns a TransportClient that can handle requests for the Request.
   *
   *
   * @param request
   *          A request whose URI is a URL of the format "d2://>servicename</optional/path".
   * @param requestContext context for this request
   * @return A client that can be called to retrieve data for the URN.
   * @throws ServiceUnavailableException
   *           If the load balancer can't figure out how to reach a service for the given
   *           URN, an ServiceUnavailableException will be thrown.
   */
@Override
public TransportClient getClient(Request request, RequestContext requestContext) throws ServiceUnavailableException {
    TransportClient client;
    URI uri = request.getURI();
    debug(_log, "get client for uri: ", uri);
    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);
    if (targetService == null) {
        LoadBalancerStateItem<UriProperties> uriItem = getUriItem(serviceName, clusterName, cluster);
        UriProperties uris = uriItem.getProperty();
        List<LoadBalancerState.SchemeStrategyPair> orderedStrategies = _state.getStrategiesForService(serviceName, service.getPrioritizedSchemes());
        TrackerClient trackerClient = chooseTrackerClient(request, requestContext, serviceName, clusterName, cluster, uriItem, uris, orderedStrategies, service);
        String clusterAndServiceUriString = trackerClient.getUri() + service.getPath();
        client = new RewriteClient(serviceName, URI.create(clusterAndServiceUriString), trackerClient);
        _serviceAvailableStats.inc();
    } else {
        _log.debug("service hint found, using generic client for target: {}", targetService);
        TransportClient transportClient = _state.getClient(serviceName, targetService.getScheme());
        client = new RewriteClient(serviceName, targetService, transportClient);
    }
    return client;
}
Also used : ServiceProperties(com.linkedin.d2.balancer.properties.ServiceProperties) TransportClient(com.linkedin.r2.transport.common.bridge.client.TransportClient) TrackerClient(com.linkedin.d2.balancer.clients.TrackerClient) UriProperties(com.linkedin.d2.balancer.properties.UriProperties) ClusterProperties(com.linkedin.d2.balancer.properties.ClusterProperties) URI(java.net.URI) RewriteClient(com.linkedin.d2.balancer.clients.RewriteClient)

Example 2 with LoadBalancerStateItem

use of com.linkedin.d2.balancer.LoadBalancerStateItem in project rest.li by linkedin.

the class SimpleLoadBalancerState method refreshTransportClientsPerService.

void refreshTransportClientsPerService(ServiceProperties serviceProperties) {
    String serviceName = serviceProperties.getServiceName();
    //create new TransportClients
    Map<String, TransportClient> newTransportClients = createAndInsertTransportClientTo(serviceProperties);
    // clients-by-scheme map is never edited, only replaced.
    newTransportClients = Collections.unmodifiableMap(newTransportClients);
    final Map<String, TransportClient> oldTransportClients = _serviceClients.put(serviceName, newTransportClients);
    // gets the information for configuring the parameter for how DegraderImpl should behave for
    // each tracker clients that we instantiate here. If there's no such information, then we'll instantiate
    // each tracker clients with default configuration
    DegraderImpl.Config config = null;
    if (serviceProperties.getDegraderProperties() != null && !serviceProperties.getDegraderProperties().isEmpty()) {
        config = DegraderConfigFactory.toDegraderConfig(serviceProperties.getDegraderProperties());
    } else {
        debug(_log, "trying to see if there's a special degraderImpl properties but serviceInfo.getDegraderImpl() is null" + " for service name = " + serviceName + " so we'll set config to default");
    }
    Clock clk = SystemClock.instance();
    if (serviceProperties.getLoadBalancerStrategyProperties() != null) {
        Map<String, Object> loadBalancerStrategyProperties = serviceProperties.getLoadBalancerStrategyProperties();
        clk = MapUtil.getWithDefault(loadBalancerStrategyProperties, PropertyKeys.CLOCK, SystemClock.instance(), Clock.class);
    }
    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>(CollectionUtils.getMapInitialCapacity(uris.size(), 0.75f), 0.75f, 1);
        long trackerClientInterval = getTrackerClientInterval(serviceProperties);
        String errorStatusPattern = getErrorStatusPattern(serviceProperties);
        for (URI uri : uris) {
            TrackerClient trackerClient = getTrackerClient(serviceName, uri, uriProperties.getPartitionDataMap(uri), config, clk, trackerClientInterval, errorStatusPattern);
            if (trackerClient != null) {
                newTrackerClients.put(uri, trackerClient);
            }
        }
    } else {
        // clients-by-uri map may be edited later by UriPropertiesListener.handlePut
        newTrackerClients = new ConcurrentHashMap<URI, TrackerClient>(16, 0.75f, 1);
    }
    //override the oldTrackerClients with newTrackerClients
    _trackerClients.put(serviceName, newTrackerClients);
    // No need to shut down oldTrackerClients, because they all point directly to the TransportClient for the service
    // We do need to shut down the old transport clients
    shutdownTransportClients(oldTransportClients, serviceName);
}
Also used : TransportClient(com.linkedin.r2.transport.common.bridge.client.TransportClient) DegraderImpl(com.linkedin.util.degrader.DegraderImpl) SystemClock(com.linkedin.util.clock.SystemClock) Clock(com.linkedin.util.clock.Clock) URI(java.net.URI) TrackerClient(com.linkedin.d2.balancer.clients.TrackerClient) UriProperties(com.linkedin.d2.balancer.properties.UriProperties)

Example 3 with LoadBalancerStateItem

use of com.linkedin.d2.balancer.LoadBalancerStateItem in project rest.li by linkedin.

the class SimpleLoadBalancer method getRings.

@Override
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());
    if (!orderedStrategies.isEmpty()) {
        PartitionAccessor accessor = getPartitionAccessor(serviceName, clusterName);
        // first distribute keys to partitions
        Map<Integer, Set<K>> partitionSet = new HashMap<>();
        List<MapKeyResult.UnmappedKey<K>> unmappedKeys = new ArrayList<>();
        for (final K key : keys) {
            int partitionId;
            try {
                partitionId = accessor.getPartitionId(key.toString());
            } catch (PartitionAccessException e) {
                unmappedKeys.add(new MapKeyResult.UnmappedKey<>(key, MapKeyResult.ErrorType.FAIL_TO_FIND_PARTITION));
                continue;
            }
            Set<K> set = partitionSet.computeIfAbsent(partitionId, k -> new HashSet<>());
            set.add(key);
        }
        // then we find the ring for each partition and create a map of Ring<URI> to Set<K>
        final Map<Ring<URI>, Collection<K>> ringMap = new HashMap<>(partitionSet.size() * 2);
        for (Map.Entry<Integer, Set<K>> entry : partitionSet.entrySet()) {
            int partitionId = entry.getKey();
            Ring<URI> ring = null;
            for (LoadBalancerState.SchemeStrategyPair pair : orderedStrategies) {
                TrackerClientSubsetItem subsetItem = getPotentialClients(serviceName, service, cluster, uris, pair.getScheme(), partitionId, uriItem.getVersion());
                ring = pair.getStrategy().getRing(uriItem.getVersion(), partitionId, subsetItem.getWeightedSubset(), subsetItem.shouldForceUpdate());
                if (!ring.isEmpty()) {
                    // don't fallback to the next strategy if there are already hosts in the current one
                    break;
                }
            }
            // make sure the same ring is not used in other partition
            ringMap.put(ring, entry.getValue());
        }
        return new MapKeyResult<>(ringMap, unmappedKeys);
    } else {
        throw new ServiceUnavailableException(serviceName, "PEGA_1002. Unable to find a load balancer strategy. " + "Server Schemes: [" + String.join(", ", service.getPrioritizedSchemes()) + ']');
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ServiceUnavailableException(com.linkedin.d2.balancer.ServiceUnavailableException) URI(java.net.URI) LoadBalancerState(com.linkedin.d2.balancer.LoadBalancerState) UriProperties(com.linkedin.d2.balancer.properties.UriProperties) MapKeyResult(com.linkedin.d2.balancer.util.MapKeyResult) ServiceProperties(com.linkedin.d2.balancer.properties.ServiceProperties) PartitionAccessor(com.linkedin.d2.balancer.util.partitions.PartitionAccessor) Ring(com.linkedin.d2.balancer.util.hashing.Ring) ClusterProperties(com.linkedin.d2.balancer.properties.ClusterProperties) Collection(java.util.Collection) PartitionAccessException(com.linkedin.d2.balancer.util.partitions.PartitionAccessException) Map(java.util.Map) DarkClusterConfigMap(com.linkedin.d2.DarkClusterConfigMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 4 with LoadBalancerStateItem

use of com.linkedin.d2.balancer.LoadBalancerStateItem in project rest.li by linkedin.

the class SimpleLoadBalancer method getClient.

/**
 * Given a Request, returns a TransportClient that can handle requests for the Request.
 * The callback is given a client that can be called to retrieve data for the URN.
 *
 * @param request
 *          A request whose URI is a URL of the format "d2://&gt;servicename&lt;/optional/path".
 * @param requestContext context for this request
 * @throws ServiceUnavailableException
 *           If the load balancer can't figure out how to reach a service for the given
 *           URN, an ServiceUnavailableException will be thrown.
 */
@Override
public void getClient(Request request, RequestContext requestContext, Callback<TransportClient> clientCallback) {
    URI uri = request.getURI();
    debug(_log, "get client for uri: ", uri);
    if (!D2_SCHEME_NAME.equalsIgnoreCase(uri.getScheme())) {
        throw new IllegalArgumentException("Unsupported scheme in URI " + uri);
    }
    // get the service for this uri
    String extractedServiceName = LoadBalancerUtil.getServiceNameFromUri(uri);
    listenToServiceAndCluster(extractedServiceName, Callbacks.handle(service -> {
        String serviceName = service.getServiceName();
        String clusterName = service.getClusterName();
        try {
            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. This mechanism is deprecated;
            // use host override list instead.
            @SuppressWarnings("deprecation") URI targetService = LoadBalancerUtil.TargetHints.getRequestContextTargetService(requestContext);
            // Checks if we have a host override list provided in the request context. If present,
            // get the override URI available override for the current cluster and service names.
            HostOverrideList overrides = (HostOverrideList) requestContext.getLocalAttr(HOST_OVERRIDE_LIST);
            URI override = overrides == null ? null : overrides.getOverride(clusterName, serviceName);
            if (targetService == null && override == null) {
                LoadBalancerStateItem<UriProperties> uriItem = getUriItem(serviceName, clusterName, cluster);
                UriProperties uris = uriItem.getProperty();
                List<LoadBalancerState.SchemeStrategyPair> orderedStrategies = _state.getStrategiesForService(serviceName, service.getPrioritizedSchemes());
                TrackerClient trackerClient = chooseTrackerClient(request, requestContext, serviceName, clusterName, cluster, uriItem, uris, orderedStrategies, service);
                String clusterAndServiceUriString = trackerClient.getUri() + service.getPath();
                _serviceAvailableStats.inc();
                clientCallback.onSuccess(new RewriteLoadBalancerClient(serviceName, URI.create(clusterAndServiceUriString), trackerClient));
            } else {
                URI target = override == null ? targetService : URI.create(override + service.getPath());
                if (targetService != null && override != null) {
                    _log.warn("Both TargetHints and HostOverrideList are found. HostOverList will take precedence %s.", target);
                }
                if (_log.isDebugEnabled()) {
                    _log.debug("Rewrite URI as specified in the TargetHints/HostOverrideList {} for cluster {} and service {}.", target, clusterName, serviceName);
                }
                TransportClient transportClient = _state.getClient(serviceName, target.getScheme());
                if (transportClient == null) {
                    throw new ServiceUnavailableException(serviceName, String.format("PEGA_1001. Cannot find transportClient for service %s and scheme %s with URI specified in" + "TargetHints/HostOverrideList %s", serviceName, target.getScheme(), target));
                }
                clientCallback.onSuccess(new RewriteLoadBalancerClient(serviceName, target, transportClient));
            }
        } catch (ServiceUnavailableException e) {
            clientCallback.onError(e);
        }
    }, clientCallback));
}
Also used : LoadBalancerStateListenerCallback(com.linkedin.d2.balancer.LoadBalancerState.LoadBalancerStateListenerCallback) NullStateListenerCallback(com.linkedin.d2.balancer.LoadBalancerState.NullStateListenerCallback) LoadBalancerStrategy(com.linkedin.d2.balancer.strategies.LoadBalancerStrategy) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) Random(java.util.Random) KeysAndHosts(com.linkedin.d2.balancer.util.KeysAndHosts) Request(com.linkedin.r2.message.Request) LoadBalancerStateItem(com.linkedin.d2.balancer.LoadBalancerStateItem) TransportClientFactory(com.linkedin.r2.transport.common.TransportClientFactory) Map(java.util.Map) URI(java.net.URI) HashFunction(com.linkedin.d2.balancer.util.hashing.HashFunction) ClusterProperties(com.linkedin.d2.balancer.properties.ClusterProperties) Collection(java.util.Collection) LogUtil.warn(com.linkedin.d2.discovery.util.LogUtil.warn) UriProperties(com.linkedin.d2.balancer.properties.UriProperties) Set(java.util.Set) Collectors(java.util.stream.Collectors) TimeoutCallback(com.linkedin.r2.transport.http.client.TimeoutCallback) RewriteLoadBalancerClient(com.linkedin.d2.balancer.clients.RewriteLoadBalancerClient) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) None(com.linkedin.common.util.None) LoadBalancer(com.linkedin.d2.balancer.LoadBalancer) LoadBalancerState(com.linkedin.d2.balancer.LoadBalancerState) PropertyEventShutdownCallback(com.linkedin.d2.discovery.event.PropertyEventThread.PropertyEventShutdownCallback) PartitionData(com.linkedin.d2.balancer.properties.PartitionData) ServiceProperties(com.linkedin.d2.balancer.properties.ServiceProperties) PartitionInfoProvider(com.linkedin.d2.balancer.util.partitions.PartitionInfoProvider) Callbacks(com.linkedin.common.callback.Callbacks) DarkClusterConfigMap(com.linkedin.d2.DarkClusterConfigMap) PartitionAccessException(com.linkedin.d2.balancer.util.partitions.PartitionAccessException) LogUtil.debug(com.linkedin.d2.discovery.util.LogUtil.debug) FutureCallback(com.linkedin.common.callback.FutureCallback) PartitionAccessor(com.linkedin.d2.balancer.util.partitions.PartitionAccessor) Callback(com.linkedin.common.callback.Callback) TransportClient(com.linkedin.r2.transport.common.bridge.client.TransportClient) HashMap(java.util.HashMap) LoadBalancerClusterListener(com.linkedin.d2.balancer.LoadBalancerClusterListener) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) HashRingProvider(com.linkedin.d2.balancer.util.hashing.HashRingProvider) ClusterInfoProvider(com.linkedin.d2.balancer.util.ClusterInfoProvider) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Ring(com.linkedin.d2.balancer.util.hashing.Ring) HostOverrideList(com.linkedin.d2.balancer.util.HostOverrideList) ClientFactoryProvider(com.linkedin.d2.balancer.util.ClientFactoryProvider) SubsettingState(com.linkedin.d2.balancer.subsetting.SubsettingState) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Stats(com.linkedin.d2.discovery.util.Stats) HostToKeyMapper(com.linkedin.d2.balancer.util.HostToKeyMapper) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) WarmUpService(com.linkedin.d2.balancer.WarmUpService) RequestContext(com.linkedin.r2.message.RequestContext) TreeMap(java.util.TreeMap) LogUtil.info(com.linkedin.d2.discovery.util.LogUtil.info) KeyMapper(com.linkedin.d2.balancer.KeyMapper) MapKeyResult(com.linkedin.d2.balancer.util.MapKeyResult) ServiceUnavailableException(com.linkedin.d2.balancer.ServiceUnavailableException) Collections(java.util.Collections) TrackerClient(com.linkedin.d2.balancer.clients.TrackerClient) LoadBalancerUtil(com.linkedin.d2.balancer.util.LoadBalancerUtil) TransportClient(com.linkedin.r2.transport.common.bridge.client.TransportClient) RewriteLoadBalancerClient(com.linkedin.d2.balancer.clients.RewriteLoadBalancerClient) ServiceUnavailableException(com.linkedin.d2.balancer.ServiceUnavailableException) URI(java.net.URI) LoadBalancerState(com.linkedin.d2.balancer.LoadBalancerState) TrackerClient(com.linkedin.d2.balancer.clients.TrackerClient) UriProperties(com.linkedin.d2.balancer.properties.UriProperties) HostOverrideList(com.linkedin.d2.balancer.util.HostOverrideList) ClusterProperties(com.linkedin.d2.balancer.properties.ClusterProperties) LoadBalancerStateItem(com.linkedin.d2.balancer.LoadBalancerStateItem) List(java.util.List) ArrayList(java.util.ArrayList) HostOverrideList(com.linkedin.d2.balancer.util.HostOverrideList)

Example 5 with LoadBalancerStateItem

use of com.linkedin.d2.balancer.LoadBalancerStateItem in project rest.li by linkedin.

the class SimpleLoadBalancer method getPartitionInformation.

/**
 * If given a collection of keys, the method will maps keys to partitions and
 * return the servers that belongs to that partition up to limitHostPerPartition.
 *
 * If no keys are specified, the method will return hosts in all partitions
 *
 * @param serviceUri for example d2://articles
 * @param keys all the keys we want to find the partition for
 * @param limitHostPerPartition the number of hosts that we should return for this partition. Must be larger than 0.
 * @param hash this will be used to create Iterator for the hosts in the hash ring
 * @return Number of hosts in requested partitions. See {@link com.linkedin.d2.balancer.util.HostToKeyMapper} for more details.
 * @throws ServiceUnavailableException
 */
@Override
public <K> HostToKeyMapper<K> getPartitionInformation(URI serviceUri, Collection<K> keys, int limitHostPerPartition, int hash) throws ServiceUnavailableException {
    if (limitHostPerPartition <= 0) {
        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 = _state.getStrategiesForService(serviceName, service.getPrioritizedSchemes());
    Map<Integer, Integer> partitionWithoutEnoughHost = new HashMap<>();
    if (!orderedStrategies.isEmpty()) {
        // get the partitionId -> keys mapping
        final PartitionAccessor accessor = getPartitionAccessor(serviceName, clusterName);
        int maxPartitionId = accessor.getMaxPartitionId();
        List<K> unmappedKeys = new ArrayList<>();
        Map<Integer, Set<K>> partitionSet = getPartitionSet(keys, accessor, unmappedKeys);
        // get the partitionId -> host URIs list
        Map<Integer, KeysAndHosts<K>> partitionDataMap = new HashMap<>();
        for (Integer partitionId : partitionSet.keySet()) {
            for (LoadBalancerState.SchemeStrategyPair pair : orderedStrategies) {
                TrackerClientSubsetItem subsetItem = getPotentialClients(serviceName, service, cluster, uris, pair.getScheme(), partitionId, uriItem.getVersion());
                Map<URI, TrackerClient> trackerClients = subsetItem.getWeightedSubset();
                int size = Math.min(trackerClients.size(), limitHostPerPartition);
                List<URI> rankedUri = new ArrayList<>(size);
                Ring<URI> ring = pair.getStrategy().getRing(uriItem.getVersion(), partitionId, trackerClients, subsetItem.shouldForceUpdate());
                Iterator<URI> iterator = ring.getIterator(hash);
                while (iterator.hasNext() && rankedUri.size() < size) {
                    URI uri = iterator.next();
                    if (!rankedUri.contains(uri)) {
                        rankedUri.add(uri);
                    }
                }
                if (rankedUri.size() < limitHostPerPartition) {
                    partitionWithoutEnoughHost.put(partitionId, limitHostPerPartition - rankedUri.size());
                }
                KeysAndHosts<K> keysAndHosts = new KeysAndHosts<>(partitionSet.get(partitionId), rankedUri);
                partitionDataMap.put(partitionId, keysAndHosts);
                if (!rankedUri.isEmpty()) {
                    // don't go to the next strategy if there are already hosts in the current one
                    break;
                }
            }
        }
        return new HostToKeyMapper<>(unmappedKeys, partitionDataMap, limitHostPerPartition, maxPartitionId + 1, partitionWithoutEnoughHost);
    } else {
        throw new ServiceUnavailableException(serviceName, "PEGA_1009. Unable to find a load balancer strategy" + "Server Schemes: [" + String.join(", ", service.getPrioritizedSchemes()) + ']');
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KeysAndHosts(com.linkedin.d2.balancer.util.KeysAndHosts) ServiceUnavailableException(com.linkedin.d2.balancer.ServiceUnavailableException) URI(java.net.URI) LoadBalancerState(com.linkedin.d2.balancer.LoadBalancerState) TrackerClient(com.linkedin.d2.balancer.clients.TrackerClient) UriProperties(com.linkedin.d2.balancer.properties.UriProperties) HostToKeyMapper(com.linkedin.d2.balancer.util.HostToKeyMapper) ServiceProperties(com.linkedin.d2.balancer.properties.ServiceProperties) PartitionAccessor(com.linkedin.d2.balancer.util.partitions.PartitionAccessor) ClusterProperties(com.linkedin.d2.balancer.properties.ClusterProperties)

Aggregations

URI (java.net.URI)11 UriProperties (com.linkedin.d2.balancer.properties.UriProperties)10 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)9 TrackerClient (com.linkedin.d2.balancer.clients.TrackerClient)7 ClusterProperties (com.linkedin.d2.balancer.properties.ClusterProperties)7 HashMap (java.util.HashMap)6 LoadBalancerState (com.linkedin.d2.balancer.LoadBalancerState)5 ServiceUnavailableException (com.linkedin.d2.balancer.ServiceUnavailableException)5 PartitionAccessor (com.linkedin.d2.balancer.util.partitions.PartitionAccessor)5 TransportClient (com.linkedin.r2.transport.common.bridge.client.TransportClient)5 Map (java.util.Map)5 Set (java.util.Set)5 PartitionData (com.linkedin.d2.balancer.properties.PartitionData)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 LoadBalancerStateItem (com.linkedin.d2.balancer.LoadBalancerStateItem)3 Ring (com.linkedin.d2.balancer.util.hashing.Ring)3 PartitionAccessException (com.linkedin.d2.balancer.util.partitions.PartitionAccessException)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 FutureCallback (com.linkedin.common.callback.FutureCallback)2