use of org.olat.admin.sysinfo.model.SessionStatsSample in project openolat by klemens.
the class SessionStatsManager method getSessionsStatsLast.
public SessionsStats getSessionsStatsLast(int numOfSeconds) {
if (currentSample == null) {
return new SessionsStats();
}
double polls = 0l;
double clicks = 0l;
double requests = 0l;
long lastTime = 0l;
long fromTimestamp = 0l;
synchronized (this) {
if (sessionStatsSamples.isEmpty()) {
return new SessionsStats();
}
polls = currentSample.getAuthenticatedPollerCalls();
clicks = currentSample.getAuthenticatedClick();
requests = currentSample.getRequests();
fromTimestamp = lastTime = System.currentTimeMillis();
double toTimestamp = fromTimestamp - (numOfSeconds * 1000.0d);
for (int i = sessionStatsSamples.size(); i-- > 0 && lastTime > toTimestamp; ) {
SessionStatsSample lastSample = sessionStatsSamples.get(i);
polls += lastSample.getAuthenticatedPollerCalls();
clicks += lastSample.getAuthenticatedClick();
requests += lastSample.getRequests();
lastTime = lastSample.getTimestamp();
}
}
double duration = (fromTimestamp - lastTime) / 1000;
double pollPerSlot = (polls / duration) * numOfSeconds;
double clickPerSlot = (clicks / duration) * numOfSeconds;
double requestPerSlot = (requests / duration) * numOfSeconds;
SessionsStats stats = new SessionsStats();
stats.setAuthenticatedClickCalls(Math.round(clickPerSlot));
stats.setAuthenticatedPollerCalls(Math.round(pollPerSlot));
stats.setRequests(Math.round(requestPerSlot));
return stats;
}
use of org.olat.admin.sysinfo.model.SessionStatsSample in project OpenOLAT by OpenOLAT.
the class SessionStatsManager method getSessionsStatsLast.
public SessionsStats getSessionsStatsLast(int numOfSeconds) {
if (currentSample == null) {
return new SessionsStats();
}
double polls = 0l;
double clicks = 0l;
double requests = 0l;
long lastTime = 0l;
long fromTimestamp = 0l;
synchronized (this) {
if (sessionStatsSamples.isEmpty()) {
return new SessionsStats();
}
polls = currentSample.getAuthenticatedPollerCalls();
clicks = currentSample.getAuthenticatedClick();
requests = currentSample.getRequests();
fromTimestamp = lastTime = System.currentTimeMillis();
double toTimestamp = fromTimestamp - (numOfSeconds * 1000.0d);
for (int i = sessionStatsSamples.size(); i-- > 0 && lastTime > toTimestamp; ) {
SessionStatsSample lastSample = sessionStatsSamples.get(i);
polls += lastSample.getAuthenticatedPollerCalls();
clicks += lastSample.getAuthenticatedClick();
requests += lastSample.getRequests();
lastTime = lastSample.getTimestamp();
}
}
double duration = (fromTimestamp - lastTime) / 1000;
double pollPerSlot = (polls / duration) * numOfSeconds;
double clickPerSlot = (clicks / duration) * numOfSeconds;
double requestPerSlot = (requests / duration) * numOfSeconds;
SessionsStats stats = new SessionsStats();
stats.setAuthenticatedClickCalls(Math.round(clickPerSlot));
stats.setAuthenticatedPollerCalls(Math.round(pollPerSlot));
stats.setRequests(Math.round(requestPerSlot));
return stats;
}
Aggregations