use of com.linkedin.util.degrader.CallTrackerImpl in project rest.li by linkedin.
the class ConsistentHashRingBenchmark method createCallTrackerMap.
private static Map<URI, CallTracker> createCallTrackerMap(URI mostWantedHost, int load) {
Map<URI, CallTracker> callTrackerMap = new HashMap<>();
CallTracker callTracker = new CallTrackerImpl(5000L);
IntStream.range(0, load).forEach(e -> callTracker.startCall());
callTrackerMap.put(mostWantedHost, callTracker);
return callTrackerMap;
}
use of com.linkedin.util.degrader.CallTrackerImpl in project rest.li by linkedin.
the class BoundedLoadConsistentHashTest method createCallTrackerMap.
private Map<URI, CallTracker> createCallTrackerMap(Map<URI, Integer> loadMap) {
Map<URI, CallTracker> callTrackerMap = new HashMap<>();
for (Map.Entry<URI, Integer> entry : loadMap.entrySet()) {
CallTracker callTracker = new CallTrackerImpl(5000L);
IntStream.range(0, entry.getValue()).forEach(e -> callTracker.startCall());
callTrackerMap.put(entry.getKey(), callTracker);
}
return callTrackerMap;
}
use of com.linkedin.util.degrader.CallTrackerImpl in project rest.li by linkedin.
the class TrackerClientMockHelper method mockTrackerClients.
/**
* Mock a list of {@link TrackerClient} without call stats
*
* @param numTrackerClients The number of hosts to be mocked
* @return A list of mocked {@link TrackerClient}
*/
public static List<TrackerClient> mockTrackerClients(int numTrackerClients) {
List<TrackerClient> trackerClients = new ArrayList<>();
for (int index = 0; index < numTrackerClients; index++) {
URI uri = URI.create("URI/" + index);
TrackerClient trackerClient = Mockito.mock(TrackerClient.class);
Mockito.when(trackerClient.getCallTracker()).thenReturn(new CallTrackerImpl(RelativeLoadBalancerStrategyFactory.DEFAULT_UPDATE_INTERVAL_MS));
Mockito.when(trackerClient.getUri()).thenReturn(uri);
Mockito.when(trackerClient.getPartitionWeight(anyInt())).thenReturn(1.0);
Mockito.when(trackerClient.getSubsetWeight(anyInt())).thenReturn(1.0);
trackerClients.add(trackerClient);
}
return trackerClients;
}
use of com.linkedin.util.degrader.CallTrackerImpl in project rest.li by linkedin.
the class ConsistentHashRingSimulator method initState.
private ConsistentHashRingState initState(RingFactory<String> ringFactory, Map<String, Integer> pointsMap) {
Map<String, CallTracker> callTrackerMap = new ConcurrentHashMap<>();
Map<String, List<Integer>> latencyMap = new ConcurrentHashMap<>();
for (String server : pointsMap.keySet()) {
CallTracker callTracker = new CallTrackerImpl(5000L);
callTrackerMap.put(server, callTracker);
latencyMap.put(server, new ArrayList<>());
}
Ring<String> ring = ringFactory.createRing(pointsMap, callTrackerMap);
return new ConsistentHashRingState(ring, callTrackerMap, latencyMap);
}
Aggregations