use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class NodeSslConnectionMetricTest method testDiscovery.
/**
* Tests SSL discovery metrics produced by node connection.
*/
@Test
public void testDiscovery() throws Exception {
MetricRegistry reg = mreg(startClusterNode(0), DISCO_METRICS);
startGrid(nodeConfiguration(1, true, "client", "trustone", CIPHER_SUITE, "TLSv1.2"));
assertTrue(reg.<BooleanMetric>findMetric("SslEnabled").value());
assertEquals(0, reg.<IntMetric>findMetric("RejectedSslConnectionsCount").value());
// Tests untrusted certificate.
checkNodeJoinFails(2, true, "thinClient", "trusttwo", CIPHER_SUITE, "TLSv1.2");
checkNodeJoinFails(2, false, "thinClient", "trusttwo", CIPHER_SUITE, "TLSv1.2");
// Tests untrusted cipher suites.
checkNodeJoinFails(2, true, "client", "trustone", UNSUPPORTED_CIPHER_SUITE, "TLSv1.2");
checkNodeJoinFails(2, false, "node01", "trustone", UNSUPPORTED_CIPHER_SUITE, "TLSv1.2");
// Tests mismatched protocol versions.
checkNodeJoinFails(2, true, "client", "trustone", null, "TLSv1.1");
checkNodeJoinFails(2, false, "node01", "trustone", null, "TLSv1.1");
// In case of an SSL error, the client and server nodes make 2 additional connection attempts.
assertTrue(waitForCondition(() -> 18 == reg.<IntMetric>findMetric("RejectedSslConnectionsCount").value(), getTestTimeout()));
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class NodeSslConnectionMetricTest method testSslDisabled.
/**
* Checks the status of the SSL metric if SSL is not configured on the node.
*/
@Test
public void testSslDisabled() throws Exception {
IgniteEx srv = startGrid();
MetricRegistry discoReg = mreg(srv, DISCO_METRICS);
assertFalse(discoReg.<BooleanMetric>findMetric("SslEnabled").value());
assertEquals(0, discoReg.<IntMetric>findMetric("RejectedSslConnectionsCount").value());
MetricRegistry commReg = mreg(srv, COMMUNICATION_METRICS_GROUP_NAME);
assertFalse(commReg.<BooleanMetric>findMetric(SSL_ENABLED_METRIC_NAME).value());
assertNull(commReg.<IntMetric>findMetric(SSL_REJECTED_SESSIONS_CNT_METRIC_NAME));
assertNull(commReg.<HistogramMetric>findMetric(SSL_HANDSHAKE_DURATION_HISTOGRAM_METRIC_NAME));
assertEquals(0, commReg.<IntMetric>findMetric(SESSIONS_CNT_METRIC_NAME).value());
MetricRegistry cliConnReg = mreg(srv, CLIENT_CONNECTOR_METRICS);
assertFalse(cliConnReg.<BooleanMetric>findMetric(SSL_ENABLED_METRIC_NAME).value());
assertNull(cliConnReg.<IntMetric>findMetric(SSL_REJECTED_SESSIONS_CNT_METRIC_NAME));
assertNull(cliConnReg.<HistogramMetric>findMetric(SSL_HANDSHAKE_DURATION_HISTOGRAM_METRIC_NAME));
assertEquals(0, cliConnReg.<IntMetric>findMetric(SESSIONS_CNT_METRIC_NAME).value());
MetricRegistry restConnReg = mreg(srv, REST_CONNECTOR_METRIC_REGISTRY_NAME);
assertNull(restConnReg.<BooleanMetric>findMetric(SSL_ENABLED_METRIC_NAME));
assertNull(restConnReg.<IntMetric>findMetric(SSL_REJECTED_SESSIONS_CNT_METRIC_NAME));
assertNull(restConnReg.<HistogramMetric>findMetric(SSL_HANDSHAKE_DURATION_HISTOGRAM_METRIC_NAME));
assertNull(restConnReg.<IntMetric>findMetric(SESSIONS_CNT_METRIC_NAME));
stopAllGrids();
srv = startGrid(getConfiguration().setConnectorConfiguration(new ConnectorConfiguration()));
restConnReg = mreg(srv, REST_CONNECTOR_METRIC_REGISTRY_NAME);
assertFalse(restConnReg.<BooleanMetric>findMetric(SSL_ENABLED_METRIC_NAME).value());
assertEquals(0, restConnReg.<IntMetric>findMetric(SESSIONS_CNT_METRIC_NAME).value());
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class NodeSslConnectionMetricTest method testCommunication.
/**
* Tests SSL communication metrics produced by node connection.
*/
@Test
public void testCommunication() throws Exception {
MetricRegistry reg = mreg(startClusterNode(0), COMMUNICATION_METRICS_GROUP_NAME);
assertEquals(0, reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value());
assertEquals(0, reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value());
checkSslCommunicationMetrics(reg, 0, 0, 0);
try (IgniteEx cliNode = startGrid(nodeConfiguration(1, true, "client", "trustone", CIPHER_SUITE, "TLSv1.2"));
IgniteEx srvNode = startGrid(nodeConfiguration(2, false, "node01", "trustone", CIPHER_SUITE, "TLSv1.2"))) {
checkSslCommunicationMetrics(reg, 2, 2, 0);
MetricRegistry cliNodeReg = mreg(cliNode, COMMUNICATION_METRICS_GROUP_NAME);
checkSslCommunicationMetrics(cliNodeReg, 0, 1, 0);
assertTrue(cliNodeReg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value() > 0);
assertTrue(cliNodeReg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value() > 0);
MetricRegistry srvNodeReg = mreg(srvNode, COMMUNICATION_METRICS_GROUP_NAME);
checkSslCommunicationMetrics(srvNodeReg, 0, 1, 0);
assertTrue(srvNodeReg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value() > 0);
assertTrue(srvNodeReg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value() > 0);
}
assertTrue(reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value() > 0);
assertTrue(reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value() > 0);
checkSslCommunicationMetrics(reg, 2, 0, 0);
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class PoolProcessor method monitorExecutor.
/**
* Creates a {@link MetricRegistry} for an executor.
*
* @param name Name of the metric to register.
* @param execSvc Executor to register a metric for.
*/
private void monitorExecutor(String name, ExecutorService execSvc) {
MetricRegistry mreg = ctx.metric().registry(metricName(THREAD_POOLS, name));
if (execSvc instanceof ThreadPoolExecutor) {
ThreadPoolExecutor exec = (ThreadPoolExecutor) execSvc;
mreg.register("ActiveCount", exec::getActiveCount, ACTIVE_COUNT_DESC);
mreg.register("CompletedTaskCount", exec::getCompletedTaskCount, COMPLETED_TASK_DESC);
mreg.register("CorePoolSize", exec::getCorePoolSize, CORE_SIZE_DESC);
mreg.register("LargestPoolSize", exec::getLargestPoolSize, LARGEST_SIZE_DESC);
mreg.register("MaximumPoolSize", exec::getMaximumPoolSize, MAX_SIZE_DESC);
mreg.register("PoolSize", exec::getPoolSize, POOL_SIZE_DESC);
mreg.register("TaskCount", exec::getTaskCount, TASK_COUNT_DESC);
mreg.register("QueueSize", () -> exec.getQueue().size(), QUEUE_SIZE_DESC);
mreg.register("KeepAliveTime", () -> exec.getKeepAliveTime(MILLISECONDS), KEEP_ALIVE_TIME_DESC);
mreg.register("Shutdown", exec::isShutdown, IS_SHUTDOWN_DESC);
mreg.register("Terminated", exec::isTerminated, IS_TERMINATED_DESC);
mreg.register("Terminating", exec::isTerminating, IS_TERMINATING_DESC);
mreg.register("RejectedExecutionHandlerClass", () -> {
RejectedExecutionHandler hnd = exec.getRejectedExecutionHandler();
return hnd == null ? "" : hnd.getClass().getName();
}, String.class, REJ_HND_DESC);
mreg.register("ThreadFactoryClass", () -> {
ThreadFactory factory = exec.getThreadFactory();
return factory == null ? "" : factory.getClass().getName();
}, String.class, THRD_FACTORY_DESC);
} else {
mreg.longMetric("ActiveCount", ACTIVE_COUNT_DESC).value(0);
mreg.longMetric("CompletedTaskCount", COMPLETED_TASK_DESC).value(0);
mreg.longMetric("CorePoolSize", CORE_SIZE_DESC).value(0);
mreg.longMetric("LargestPoolSize", LARGEST_SIZE_DESC).value(0);
mreg.longMetric("MaximumPoolSize", MAX_SIZE_DESC).value(0);
mreg.longMetric("PoolSize", POOL_SIZE_DESC).value(0);
mreg.longMetric("TaskCount", TASK_COUNT_DESC);
mreg.longMetric("QueueSize", QUEUE_SIZE_DESC).value(0);
mreg.longMetric("KeepAliveTime", KEEP_ALIVE_TIME_DESC).value(0);
mreg.register("Shutdown", execSvc::isShutdown, IS_SHUTDOWN_DESC);
mreg.register("Terminated", execSvc::isTerminated, IS_TERMINATED_DESC);
mreg.longMetric("Terminating", IS_TERMINATING_DESC);
mreg.objectMetric("RejectedExecutionHandlerClass", String.class, REJ_HND_DESC).value("");
mreg.objectMetric("ThreadFactoryClass", String.class, THRD_FACTORY_DESC).value("");
}
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class PoolProcessor method monitorStripedPool.
/**
* Creates a {@link MetricRegistry} for a stripped executor.
*
* @param name name of the bean to register
* @param svc Executor.
*/
private void monitorStripedPool(String name, StripedExecutor svc) {
MetricRegistry mreg = ctx.metric().registry(metricName(THREAD_POOLS, name));
mreg.register("DetectStarvation", svc::detectStarvation, "True if possible starvation in striped pool is detected.");
mreg.register("StripesCount", svc::stripesCount, "Stripes count.");
mreg.register("Shutdown", svc::isShutdown, "True if this executor has been shut down.");
mreg.register("Terminated", svc::isTerminated, "True if all tasks have completed following shut down.");
mreg.register("TotalQueueSize", svc::queueSize, "Total queue size of all stripes.");
mreg.register("TotalCompletedTasksCount", svc::completedTasks, "Completed tasks count of all stripes.");
mreg.register("StripesCompletedTasksCounts", svc::stripesCompletedTasks, long[].class, "Number of completed tasks per stripe.");
mreg.register("ActiveCount", svc::activeStripesCount, "Number of active tasks of all stripes.");
mreg.register("StripesActiveStatuses", svc::stripesActiveStatuses, boolean[].class, "Number of active tasks per stripe.");
mreg.register("StripesQueueSizes", svc::stripesQueueSizes, int[].class, "Size of queue per stripe.");
}
Aggregations