Search in sources :

Example 6 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class JmxExporterSpiTest method testHistogramExport.

/**
 */
@Test
public void testHistogramExport() throws Exception {
    MetricRegistry mreg = ignite.context().metric().registry("histogramTest");
    createTestHistogram(mreg);
    DynamicMBean bean = metricRegistry(ignite.name(), null, "histogramTest");
    MBeanAttributeInfo[] attrs = bean.getMBeanInfo().getAttributes();
    assertEquals(6, attrs.length);
    assertEquals(1L, bean.getAttribute("histogram_0_50"));
    assertEquals(2L, bean.getAttribute("histogram_50_500"));
    assertEquals(3L, bean.getAttribute("histogram_500_inf"));
    assertEquals(1L, bean.getAttribute("histogram_with_underscore_0_50"));
    assertEquals(2L, bean.getAttribute("histogram_with_underscore_50_500"));
    assertEquals(3L, bean.getAttribute("histogram_with_underscore_500_inf"));
}
Also used : DynamicMBean(javax.management.DynamicMBean) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) Test(org.junit.Test)

Example 7 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class JmxExporterSpiTest method testHistogramSearchByName.

/**
 */
@Test
public void testHistogramSearchByName() throws Exception {
    MetricRegistry mreg = new MetricRegistry("test", name -> null, name -> null, null);
    createTestHistogram(mreg);
    assertEquals(Long.valueOf(1), searchHistogram("histogram_0_50", mreg));
    assertEquals(Long.valueOf(2), searchHistogram("histogram_50_500", mreg));
    assertEquals(Long.valueOf(3), searchHistogram("histogram_500_inf", mreg));
    assertEquals(Long.valueOf(1), searchHistogram("histogram_with_underscore_0_50", mreg));
    assertEquals(Long.valueOf(2), searchHistogram("histogram_with_underscore_50_500", mreg));
    assertEquals(Long.valueOf(3), searchHistogram("histogram_with_underscore_500_inf", mreg));
    assertNull(searchHistogram("unknown", mreg));
    assertNull(searchHistogram("unknown_0", mreg));
    assertNull(searchHistogram("unknown_0_50", mreg));
    assertNull(searchHistogram("unknown_test", mreg));
    assertNull(searchHistogram("unknown_test_test", mreg));
    assertNull(searchHistogram("unknown_0_inf", mreg));
    assertNull(searchHistogram("histogram", mreg));
    assertNull(searchHistogram("histogram_0", mreg));
    assertNull(searchHistogram("histogram_0_100", mreg));
    assertNull(searchHistogram("histogram_0_inf", mreg));
    assertNull(searchHistogram("histogram_0_500", mreg));
    assertNull(searchHistogram("histogram_with_underscore", mreg));
    assertNull(searchHistogram("histogram_with_underscore_0", mreg));
    assertNull(searchHistogram("histogram_with_underscore_0_100", mreg));
    assertNull(searchHistogram("histogram_with_underscore_0_inf", mreg));
    assertNull(searchHistogram("histogram_with_underscore_0_500", mreg));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) Test(org.junit.Test)

Example 8 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class JmxExporterSpiTest method testIgniteKernal.

/**
 * @throws Exception If failed.
 */
@Test
public void testIgniteKernal() throws Exception {
    DynamicMBean mbn = metricRegistry(ignite.name(), null, IGNITE_METRICS);
    assertNotNull(mbn);
    assertEquals(36, mbn.getMBeanInfo().getAttributes().length);
    assertFalse(stream(mbn.getMBeanInfo().getAttributes()).anyMatch(a -> F.isEmpty(a.getDescription())));
    assertFalse(F.isEmpty((String) mbn.getAttribute("fullVersion")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("copyright")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("osInformation")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("jdkInformation")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("vmName")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("discoverySpiFormatted")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("communicationSpiFormatted")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("deploymentSpiFormatted")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("checkpointSpiFormatted")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("collisionSpiFormatted")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("eventStorageSpiFormatted")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("failoverSpiFormatted")));
    assertFalse(F.isEmpty((String) mbn.getAttribute("loadBalancingSpiFormatted")));
    assertEquals(System.getProperty("user.name"), (String) mbn.getAttribute("osUser"));
    assertNotNull(DateFormat.getDateTimeInstance().parse((String) mbn.getAttribute("startTimestampFormatted")));
    assertNotNull(LocalTime.parse((String) mbn.getAttribute("uptimeFormatted")));
    assertTrue((boolean) mbn.getAttribute("isRebalanceEnabled"));
    assertTrue((boolean) mbn.getAttribute("isNodeInBaseline"));
    assertTrue((boolean) mbn.getAttribute("active"));
    assertTrue((long) mbn.getAttribute("startTimestamp") > 0);
    assertTrue((long) mbn.getAttribute("uptime") > 0);
    assertEquals(ignite.name(), (String) mbn.getAttribute("instanceName"));
    assertEquals(Collections.emptyList(), mbn.getAttribute("userAttributesFormatted"));
    assertEquals(Collections.emptyList(), mbn.getAttribute("lifecycleBeansFormatted"));
    assertEquals(Collections.emptyMap(), mbn.getAttribute("longJVMPauseLastEvents"));
    assertEquals(0L, mbn.getAttribute("longJVMPausesCount"));
    assertEquals(0L, mbn.getAttribute("longJVMPausesTotalDuration"));
    long clusterStateChangeTime = (long) mbn.getAttribute("lastClusterStateChangeTime");
    assertTrue(0 < clusterStateChangeTime && clusterStateChangeTime < System.currentTimeMillis());
    assertEquals(String.valueOf(ignite.configuration().getPublicThreadPoolSize()), mbn.getAttribute("executorServiceFormatted"));
    assertEquals(ignite.configuration().isPeerClassLoadingEnabled(), mbn.getAttribute("isPeerClassLoadingEnabled"));
    assertTrue(((String) mbn.getAttribute("currentCoordinatorFormatted")).contains(ignite.localNode().id().toString()));
    assertEquals(ignite.configuration().getIgniteHome(), (String) mbn.getAttribute("igniteHome"));
    assertEquals(ignite.localNode().id(), mbn.getAttribute("localNodeId"));
    assertEquals(ignite.configuration().getGridLogger().toString(), (String) mbn.getAttribute("gridLoggerFormatted"));
    assertEquals(ignite.configuration().getMBeanServer().toString(), (String) mbn.getAttribute("mBeanServerFormatted"));
    assertEquals(ClusterState.ACTIVE.toString(), mbn.getAttribute("clusterState"));
}
Also used : Arrays(java.util.Arrays) GridCacheUtils.cacheId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId) TestObjectEnum(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum) Map(java.util.Map) FILTER_OPERATION(org.apache.ignite.internal.managers.systemview.SystemViewMBean.FILTER_OPERATION) IgniteUtils.toStringSafe(org.apache.ignite.internal.util.IgniteUtils.toStringSafe) CACHE_METRICS(org.apache.ignite.internal.processors.cache.CacheMetricsImpl.CACHE_METRICS) GC_CPU_LOAD_DESCRIPTION(org.apache.ignite.internal.processors.metric.GridMetricManager.GC_CPU_LOAD_DESCRIPTION) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) MBeanOperationInfo(javax.management.MBeanOperationInfo) Set(java.util.Set) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TEST_TRANSFORMER(org.apache.ignite.internal.metric.SystemViewSelfTest.TEST_TRANSFORMER) MBeanFeatureInfo(javax.management.MBeanFeatureInfo) QueryCursor(org.apache.ignite.cache.query.QueryCursor) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) DynamicMBean(javax.management.DynamicMBean) VIEWS(org.apache.ignite.internal.managers.systemview.SystemViewMBean.VIEWS) ScanQuery(org.apache.ignite.cache.query.ScanQuery) CPU_LOAD_DESCRIPTION(org.apache.ignite.internal.processors.metric.GridMetricManager.CPU_LOAD_DESCRIPTION) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) BINARY_METADATA_VIEW(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.BINARY_METADATA_VIEW) DISTRIBUTED_METASTORE_VIEW(org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl.DISTRIBUTED_METASTORE_VIEW) IgniteClient(org.apache.ignite.client.IgniteClient) TEST_PREDICATE(org.apache.ignite.internal.metric.SystemViewSelfTest.TEST_PREDICATE) TestTransformer(org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer) STREAM_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.STREAM_POOL_QUEUE_VIEW) TASKS_VIEW(org.apache.ignite.internal.processors.task.GridTaskProcessor.TASKS_VIEW) Properties(java.util.Properties) CompositeData(javax.management.openmbean.CompositeData) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) Test(org.junit.Test) Field(java.lang.reflect.Field) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) SCAN_QRY_SYS_VIEW(org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW) CPU_LOAD(org.apache.ignite.internal.processors.metric.GridMetricManager.CPU_LOAD) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CachePagesListViewWalker(org.apache.ignite.internal.managers.systemview.walker.CachePagesListViewWalker) CQ_SYS_VIEW(org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) IgniteJdbcThinDriver(org.apache.ignite.IgniteJdbcThinDriver) StripedExecutor(org.apache.ignite.internal.util.StripedExecutor) Connection(java.sql.Connection) ProtocolVersion(org.apache.ignite.internal.client.thin.ProtocolVersion) JmxMetricExporterSpi(org.apache.ignite.spi.metric.jmx.JmxMetricExporterSpi) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) Transaction(org.apache.ignite.transactions.Transaction) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) CACHE_GRP_PAGE_LIST_VIEW(org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_PAGE_LIST_VIEW) IgniteEx(org.apache.ignite.internal.IgniteEx) METASTORE_VIEW(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.METASTORE_VIEW) REPEATABLE_READ(org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LocalTime(java.time.LocalTime) MetricUtils.metricName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName) DateFormat(java.text.DateFormat) Collectors.toSet(java.util.stream.Collectors.toSet) CyclicBarrier(java.util.concurrent.CyclicBarrier) SVCS_VIEW(org.apache.ignite.internal.processors.service.IgniteServiceProcessor.SVCS_VIEW) CLI_CONN_VIEW(org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLI_CONN_VIEW) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) IGNITE_METRICS(org.apache.ignite.internal.processors.metric.GridMetricManager.IGNITE_METRICS) MetricRegistryMBean.searchHistogram(org.apache.ignite.spi.metric.jmx.MetricRegistryMBean.searchHistogram) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Objects(java.util.Objects) List(java.util.List) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Optional(java.util.Optional) ACTIVE(org.apache.ignite.transactions.TransactionState.ACTIVE) RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) SYS_METRICS(org.apache.ignite.internal.processors.metric.GridMetricManager.SYS_METRICS) DummyService(org.apache.ignite.internal.processors.service.DummyService) Arrays.stream(java.util.Arrays.stream) GridCacheUtils.cacheGroupId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheGroupId) MBeanParameterInfo(javax.management.MBeanParameterInfo) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) CACHES_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHES_VIEW) Iterators(com.google.common.collect.Iterators) HashSet(java.util.HashSet) SYS_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.SYS_POOL_QUEUE_VIEW) TestRunnable(org.apache.ignite.internal.metric.SystemViewSelfTest.TestRunnable) GC_CPU_LOAD(org.apache.ignite.internal.processors.metric.GridMetricManager.GC_CPU_LOAD) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) TestPredicate(org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate) F(org.apache.ignite.internal.util.typedef.F) TXS_MON_LIST(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.TXS_MON_LIST) JdbcConnectionContext(org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext) CACHE_GRPS_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHE_GRPS_VIEW) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) Consumer(java.util.function.Consumer) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) Ignition(org.apache.ignite.Ignition) MetricUtils(org.apache.ignite.internal.processors.metric.impl.MetricUtils) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) DynamicMBean(javax.management.DynamicMBean) Test(org.junit.Test)

Example 9 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class CacheMetricsAddRemoveTest method checkMetricsNotEmpty.

/**
 */
private void checkMetricsNotEmpty(String cachePrefix) {
    for (int i = 0; i < 2; i++) {
        GridMetricManager mmgr = metricManager(i);
        MetricRegistry mreg = mmgr.registry(cachePrefix);
        assertNotNull(mreg.findMetric(CACHE_GETS));
        assertNotNull(mreg.findMetric(CACHE_PUTS));
        assertNotNull(mreg.findMetric(GET_TIME));
        assertArrayEquals(BOUNDS, mreg.<HistogramMetric>findMetric(GET_TIME).bounds());
        if (nearEnabled) {
            mreg = mmgr.registry(metricName(cachePrefix, "near"));
            assertNotNull(mreg.findMetric(CACHE_GETS));
            assertNotNull(mreg.findMetric(CACHE_PUTS));
            assertNotNull(mreg.findMetric(GET_TIME));
            assertArrayEquals(BOUNDS, mreg.<HistogramMetric>findMetric(GET_TIME).bounds());
        }
    }
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager)

Example 10 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class IoStatisticsCacheSelfTest method logicalReads.

/**
 * @param mmgr Metric manager.
 * @param type Staticstics type.
 * @param id Metric registry id.
 * @return Logical reads count.
 */
public static long logicalReads(GridMetricManager mmgr, IoStatisticsType type, String id) {
    MetricRegistry mreg = mmgr.registry(metricName(type.metricGroupName(), id));
    if (type == CACHE_GROUP)
        return mreg.<LongMetric>findMetric(LOGICAL_READS).value();
    else {
        long leaf = mreg.<LongMetric>findMetric(LOGICAL_READS_LEAF).value();
        long inner = mreg.<LongMetric>findMetric(LOGICAL_READS_INNER).value();
        return leaf + inner;
    }
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) ReadOnlyMetricRegistry(org.apache.ignite.spi.metric.ReadOnlyMetricRegistry) LongMetric(org.apache.ignite.spi.metric.LongMetric)

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