use of com.linkedin.d2.balancer.clients.TrackerClientImpl in project rest.li by linkedin.
the class LoadBalancerStrategyBenchmark method createTrackerClients.
private static Map<URI, TrackerClient> createTrackerClients(int numHosts) {
Map<URI, TrackerClient> trackerClients = new HashMap<>();
for (int i = 0; i < numHosts; i++) {
URI uri = URI.create(URI_PREFIX + i + URI_SUFFIX);
trackerClients.put(uri, new TrackerClientImpl(uri, DEFAULT_PARTITION_DATA_MAP, new BaseTransportTestClient(), CLOCK, RelativeLoadBalancerStrategyFactory.DEFAULT_UPDATE_INTERVAL_MS, (status) -> status >= 500 && status <= 599));
}
return trackerClients;
}
use of com.linkedin.d2.balancer.clients.TrackerClientImpl in project rest.li by linkedin.
the class LoadBalancerStrategyTestRunnerBuilder method buildRelativeStrategy.
private LoadBalancerStrategyTestRunner buildRelativeStrategy() {
if (_serviceProperties == null) {
setRelativeLoadBalancerStrategies(new D2RelativeStrategyProperties());
}
_strategy = new RelativeLoadBalancerStrategyFactory(_clockedExecutor, null, new ArrayList<>(), null, _clockedExecutor).newLoadBalancer(_serviceProperties);
_transportClients = _uris.stream().map(uri -> new MockTransportClient(_clockedExecutor, _latencyManager, _errorCountManager, uri, INTERVAL_IN_MILLIS, _currentErrorCountMap, _lastRequestCountMap, _callCountMap, _latencySumMap)).collect(Collectors.toList());
Map<URI, TrackerClient> trackerClientMap = _transportClients.stream().map(transportClient -> {
// If partition map is not specified, by default we only support one partition
Map<Integer, PartitionData> partitionDataMap = _partitionDataMap.getOrDefault(transportClient.getUri(), DEFAULT_PARTITION_DATA_MAP);
return new TrackerClientImpl(transportClient.getUri(), partitionDataMap, transportClient, _clockedExecutor, INTERVAL_IN_MILLIS, (status) -> status >= 500 && status <= 599);
}).collect(Collectors.toMap(TrackerClient::getUri, trackerClient -> trackerClient));
return buildInternal(trackerClientMap);
}
Aggregations