Skip to content

Commit

Permalink
GG-22320 Print information about a striped pool in local node metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmekhanikov committed Aug 21, 2019
1 parent 8c39399 commit 712038f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Expand Up @@ -166,8 +166,8 @@
import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
import org.apache.ignite.internal.processors.rest.GridRestProcessor;
import org.apache.ignite.internal.processors.security.GridSecurityProcessor;
import org.apache.ignite.internal.processors.security.IgniteSecurity;
import org.apache.ignite.internal.processors.security.IgniteSecurityProcessor;
import org.apache.ignite.internal.processors.security.IgniteSecurity;
import org.apache.ignite.internal.processors.security.NoOpIgniteSecurityProcessor;
import org.apache.ignite.internal.processors.segmentation.GridSegmentationProcessor;
import org.apache.ignite.internal.processors.service.GridServiceProcessor;
Expand Down Expand Up @@ -1390,7 +1390,7 @@ private long checkPoolStarvation(
private final DecimalFormat dblFmt = new DecimalFormat("#.##");

@Override public void run() {
ackNodeMetrics(dblFmt, execSvc, sysExecSvc, customExecSvcs);
ackNodeMetrics(dblFmt, execSvc, sysExecSvc, stripedExecSvc, customExecSvcs);
}
}, metricsLogFreq, metricsLogFreq);
}
Expand Down Expand Up @@ -1447,19 +1447,26 @@ private GridProcessor securityProcessor() throws IgniteCheckedException {
* @param execSvc service to create a description for
*/
private String createExecutorDescription(String execSvcName, ExecutorService execSvc) {
int poolSize = 0;
int poolActiveThreads = 0;
int poolIdleThreads = 0;
int poolQSize = 0;

if (execSvc instanceof ThreadPoolExecutor) {
ThreadPoolExecutor exec = (ThreadPoolExecutor)execSvc;

int poolSize = exec.getPoolSize();

poolSize = exec.getPoolSize();
poolActiveThreads = Math.min(poolSize, exec.getActiveCount());
poolIdleThreads = poolSize - poolActiveThreads;
poolQSize = exec.getQueue().size();
}
else if (execSvc instanceof StripedExecutor) {
StripedExecutor exec = (StripedExecutor) execSvc;

poolSize = exec.stripes();
poolActiveThreads = exec.activeStripesCount();
poolQSize = exec.queueSize();
}

int poolIdleThreads = poolSize - poolActiveThreads;

return execSvcName + " [active=" + poolActiveThreads + ", idle=" + poolIdleThreads + ", qSize=" + poolQSize + "]";
}
Expand Down Expand Up @@ -2164,6 +2171,7 @@ private void ackLanguageRuntime() {
private void ackNodeMetrics(DecimalFormat dblFmt,
ExecutorService execSvc,
ExecutorService sysExecSvc,
ExecutorService stripedExecSvc,
Map<String, ? extends ExecutorService> customExecSvcs
) {
if (!log.isInfoEnabled())
Expand Down Expand Up @@ -2291,7 +2299,8 @@ private void ackNodeMetrics(DecimalFormat dblFmt,
pdsInfo +
" ^-- Outbound messages queue [size=" + m.getOutboundMessagesQueueSize() + "]" + NL +
" ^-- " + createExecutorDescription("Public thread pool", execSvc) + NL +
" ^-- " + createExecutorDescription("System thread pool", sysExecSvc);
" ^-- " + createExecutorDescription("System thread pool", sysExecSvc) + NL +
" ^-- " + createExecutorDescription("Striped thread pool", stripedExecSvc);

if (customExecSvcs != null) {
StringBuilder customSvcsMsg = new StringBuilder();
Expand Down
Expand Up @@ -117,6 +117,7 @@ protected void checkNodeMetricsFormat(String fullLog) {
assertTrue(msg, fullLog.matches("(?s).*Outbound messages queue \\[size=.*].*"));
assertTrue(msg, fullLog.matches("(?s).*Public thread pool \\[active=.*, idle=.*, qSize=.*].*"));
assertTrue(msg, fullLog.matches("(?s).*System thread pool \\[active=.*, idle=.*, qSize=.*].*"));
assertTrue(msg, fullLog.matches("(?s).*Striped thread pool \\[active=.*, idle=.*, qSize=.*].*"));
assertTrue(msg, fullLog.matches("(?s).*" + CUSTOM_EXECUTOR_0 + " \\[active=.*, idle=.*, qSize=.*].*"));
assertTrue(msg, fullLog.matches("(?s).*" + CUSTOM_EXECUTOR_1 + " \\[active=.*, idle=.*, qSize=.*].*"));
}
Expand Down

0 comments on commit 712038f

Please sign in to comment.