@Override
 public Map<String, String> handleProbe(String... keys) {
   if (keys == null || keys.length == 0) {
     return null;
   }
   ThreadPoolExecutor exec = extract(executor);
   if (exec == null) {
     return null;
   }
   Map<String, String> map = new HashMap<>();
   for (String key : keys) {
     switch (key) {
       case KEY:
         map.put("active-thread", String.valueOf(exec.getActiveCount()));
         map.put("min-thread", String.valueOf(exec.getCorePoolSize()));
         map.put("max-thread", String.valueOf(exec.getMaximumPoolSize()));
         map.put("current-pool-size", String.valueOf(exec.getPoolSize()));
         map.put("largest-pool-size", String.valueOf(exec.getLargestPoolSize()));
         map.put("keep-alive", String.valueOf(exec.getKeepAliveTime(TimeUnit.MILLISECONDS)));
         map.put("queue-size", String.valueOf(exec.getQueue().size()));
         break;
     }
   }
   return map.isEmpty() ? null : map;
 }
Beispiel #2
0
 public long getKeepAliveTime() {
   return pool.getKeepAliveTime(TimeUnit.MILLISECONDS);
 }