Search in sources :

Example 26 with MetricRegistry

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()));
}
Also used : BooleanMetric(org.apache.ignite.spi.metric.BooleanMetric) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) IntMetric(org.apache.ignite.spi.metric.IntMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 27 with MetricRegistry

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());
}
Also used : BooleanMetric(org.apache.ignite.spi.metric.BooleanMetric) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) ConnectorConfiguration(org.apache.ignite.configuration.ConnectorConfiguration) ClientConnectorConfiguration(org.apache.ignite.configuration.ClientConnectorConfiguration) IntMetric(org.apache.ignite.spi.metric.IntMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 28 with MetricRegistry

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);
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) IgniteEx(org.apache.ignite.internal.IgniteEx) LongMetric(org.apache.ignite.spi.metric.LongMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 29 with MetricRegistry

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("");
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) RejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) SecurityAwareStripedThreadPoolExecutor(org.apache.ignite.internal.processors.security.thread.SecurityAwareStripedThreadPoolExecutor) SecurityAwareThreadPoolExecutor(org.apache.ignite.internal.processors.security.thread.SecurityAwareThreadPoolExecutor) IgniteStripedThreadPoolExecutor(org.apache.ignite.thread.IgniteStripedThreadPoolExecutor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) IgniteThreadPoolExecutor(org.apache.ignite.thread.IgniteThreadPoolExecutor)

Example 30 with MetricRegistry

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.");
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry)

Aggregations

MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)86 Test (org.junit.Test)52 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)29 IgniteEx (org.apache.ignite.internal.IgniteEx)26 LongMetric (org.apache.ignite.spi.metric.LongMetric)26 List (java.util.List)11 CountDownLatch (java.util.concurrent.CountDownLatch)11 UUID (java.util.UUID)10 Map (java.util.Map)8 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)8 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 ArrayList (java.util.ArrayList)7 IgniteException (org.apache.ignite.IgniteException)7 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)7 IntMetric (org.apache.ignite.spi.metric.IntMetric)7 IgniteCache (org.apache.ignite.IgniteCache)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 Arrays (java.util.Arrays)5 HashSet (java.util.HashSet)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5