// The gets + puts below are OK because only one thread is doing it.
for (PoolGroupSchedulable poolGroup : poolGroupManager.getPoolGroups()) {
int poolGroupSessions = 0;
for (PoolSchedulable pool : poolGroup.getPools()) {
MetricsRecord poolRecord =
poolInfoToMetricsRecord.get(pool.getPoolInfo());
if (poolRecord == null) {
poolRecord = metrics.getContext().createRecord(
"pool-" + pool.getName());
poolInfoToMetricsRecord.put(pool.getPoolInfo(), poolRecord);
}
PoolInfoMetrics poolMetrics = new PoolInfoMetrics(pool.getPoolInfo(),
type, poolRecord);
poolMetrics.setCounter(
MetricName.GRANTED, pool.getGranted());
poolMetrics.setCounter(
MetricName.REQUESTED, pool.getRequested());
poolMetrics.setCounter(
MetricName.SHARE, (long) pool.getShare());
poolMetrics.setCounter(
MetricName.MIN, pool.getMinimum());
poolMetrics.setCounter(
MetricName.MAX, pool.getMaximum());
poolMetrics.setCounter(
MetricName.WEIGHT, (long) pool.getWeight());
poolMetrics.setCounter(
MetricName.SESSIONS, pool.getScheduleQueue().size());
poolMetrics.setCounter(
MetricName.STARVING, pool.getStarvingTime(now) / 1000);
Long averageFirstTypeMs =
poolInfoAverageFirstWaitMs.get(pool.getPoolInfo());
poolMetrics.setCounter(MetricName.AVE_FIRST_WAIT_MS,
(averageFirstTypeMs == null) ?
0 : averageFirstTypeMs.longValue());
newPoolNameToMetrics.put(pool.getPoolInfo(), poolMetrics);
poolGroupSessions += pool.getScheduleQueue().size();
}
MetricsRecord poolGroupRecord =
poolInfoToMetricsRecord.get(poolGroup.getName());
if (poolGroupRecord == null) {
poolGroupRecord = metrics.getContext().createRecord(
"poolgroup-" + poolGroup.getName());
poolInfoToMetricsRecord.put(poolGroup.getPoolInfo(), poolGroupRecord);