use of com.linkedin.common.stats.LongStats in project rest.li by linkedin.
the class ChannelPoolLifecycle method getStats.
@Override
public PoolStats.LifecycleStats getStats() {
synchronized (_createTimeTracker) {
LongStats stats = _createTimeTracker.getStats();
_createTimeTracker.reset();
return new AsyncPoolLifecycleStats(stats.getAverage(), stats.get50Pct(), stats.get95Pct(), stats.get99Pct());
}
}
use of com.linkedin.common.stats.LongStats in project rest.li by linkedin.
the class PrintResultsTask method run.
public void run() {
final Stats stats = _statsRef.get();
LongStats snapshot = stats.getLatencyStats();
long elapsedTime = stats.getElapsedTime();
double timePerReq = stats.getSuccessCount() != 0 ? elapsedTime / (double) stats.getSuccessCount() : 0;
double reqPerSec = timePerReq != 0 ? 1000.0 / timePerReq : 0;
System.out.println();
System.out.println();
System.out.println("DONE");
System.out.println();
System.out.println("Results");
System.out.println("-------");
System.out.println(" Total Requests: " + stats.getSentCount());
System.out.println(" Elapsed: " + elapsedTime);
System.out.println(" Mean latency (in millis): " + snapshot.getAverage() / 10E6);
System.out.println(" Reqs / Sec: " + reqPerSec);
System.out.println(" Errors: " + stats.getErrorCount());
System.out.println(" Min latency: " + snapshot.getMinimum() / 10E6);
System.out.println(" 50% latency: " + snapshot.get50Pct() / 10E6);
System.out.println(" 90% latency: " + snapshot.get90Pct() / 10E6);
System.out.println(" 95% latency: " + snapshot.get95Pct() / 10E6);
System.out.println(" 99% latency: " + snapshot.get99Pct() / 10E6);
System.out.println(" Max latency: " + snapshot.getMaximum() / 10E6);
}
use of com.linkedin.common.stats.LongStats in project rest.li by linkedin.
the class AsyncPoolStatsTracker method getStats.
public AsyncPoolStats getStats() {
long now = _clock.currentTimeMillis();
if (now - _lastSamplingTime > MINIMUM_SAMPLING_PERIOD) {
_sampleMaxCheckedOut = _currentMaxCheckedOut;
_sampleMaxPoolSize = _currentMaxPoolSize;
_sampleMaxWaitTime = _currentMaxWaitTime;
_currentMaxCheckedOut = _checkedOutSupplier.get();
_currentMaxPoolSize = _poolSizeSupplier.get();
_currentMaxWaitTime = 0L;
_lastSamplingTime = now;
}
LongStats waitTimeStats = _waitTimeTracker.getStats();
AsyncPoolStats stats = new AsyncPoolStats(_totalCreated, _totalDestroyed, _totalCreateErrors, _totalDestroyErrors, _totalBadDestroyed, _totalTimedOut, _totalWaiterTimedOut, _totalCreationIgnored, _checkedOutSupplier.get(), _maxSizeSupplier.get(), _minSizeSupplier.get(), _poolSizeSupplier.get(), _sampleMaxCheckedOut, _sampleMaxPoolSize, _sampleMaxWaitTime, _idleSizeSupplier.get(), waitTimeStats.getAverage(), waitTimeStats.get50Pct(), waitTimeStats.get95Pct(), waitTimeStats.get99Pct(), _lifecycleStatsSupplier.get());
_waitTimeTracker.reset();
return stats;
}
use of com.linkedin.common.stats.LongStats in project rest.li by linkedin.
the class TrackerClientMockHelper method mockTrackerClients.
/**
* Mock a list of {@link TrackerClient} for testing
*
* @param numTrackerClients The number of {@link TrackerClient} to be mocked
* @param callCountList The call count that each host receives
* @param outstandingCallCountList The outstanding call count that each host receives
* @param latencyList The latency of each host
* @param outstandingLatencyList The outstanding latency of each host
* @param errorCountList The error count of each host
* @return A list of mocked {@link TrackerClient}
*/
public static List<TrackerClient> mockTrackerClients(int numTrackerClients, List<Integer> callCountList, List<Integer> outstandingCallCountList, List<Long> latencyList, List<Long> outstandingLatencyList, List<Integer> errorCountList, boolean doNotSlowStart, List<Boolean> doNotLoadBalance) {
List<TrackerClient> trackerClients = new ArrayList<>();
for (int index = 0; index < numTrackerClients; index++) {
URI uri = URI.create("URI/" + index);
TrackerClient trackerClient = Mockito.mock(TrackerClient.class);
CallTracker callTracker = Mockito.mock(CallTracker.class);
LongStats longStats = new LongStats(callCountList.get(index), latencyList.get(index), 0, 0, 0, 0, 0, 0, 0);
Map<ErrorType, Integer> errorTypeCounts = new HashMap<>();
errorTypeCounts.put(ErrorType.SERVER_ERROR, errorCountList.get(index));
CallTrackerImpl.CallTrackerStats callStats = new CallTrackerImpl.CallTrackerStats(RelativeLoadBalancerStrategyFactory.DEFAULT_UPDATE_INTERVAL_MS, 0, RelativeLoadBalancerStrategyFactory.DEFAULT_UPDATE_INTERVAL_MS, callCountList.get(index), 0, 0, errorCountList.get(index), errorCountList.get(index), 1, RelativeLoadBalancerStrategyFactory.DEFAULT_UPDATE_INTERVAL_MS - outstandingLatencyList.get(index), outstandingCallCountList.get(index), longStats, errorTypeCounts, errorTypeCounts);
Mockito.when(trackerClient.getCallTracker()).thenReturn(callTracker);
Mockito.when(callTracker.getCallStats()).thenReturn(callStats);
Mockito.when(trackerClient.getUri()).thenReturn(uri);
Mockito.when(trackerClient.getPartitionWeight(anyInt())).thenReturn(1.0);
Mockito.when(trackerClient.getSubsetWeight(anyInt())).thenReturn(1.0);
Mockito.when(trackerClient.doNotSlowStart()).thenReturn(doNotSlowStart);
Mockito.when(trackerClient.doNotLoadBalance()).thenReturn(doNotLoadBalance.get(index));
trackerClients.add(trackerClient);
}
return trackerClients;
}
Aggregations