Fixes #6140 - JMX total number of keys in SelectorManager

Added a new JMX property in SelectorManager that reports total number of keys from all ManagedSelectors

Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Almas Abdrazak 2023-06-11 10:07:08 -07:00 committed by GitHub
parent c29491e5ac
commit 082f5e042c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -139,6 +139,23 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
executor.execute(task);
}
/**
* Get total number of keys from each selector.
*
* @return total number of selector keys
*/
@ManagedAttribute(value = "Total number of keys in all selectors", readonly = true)
public int getTotalKeys()
{
int keys = 0;
for (final ManagedSelector selector : _selectors)
{
keys += selector.getTotalKeys();
}
return keys;
}
/**
* @return the number of selectors in use
*/
@ -506,4 +523,10 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
{
}
}
@Override
public String toString()
{
return String.format("%s@%x[keys=%d]", getClass().getSimpleName(), hashCode(), getTotalKeys());
}
}