Search in sources :

Example 1 with MetricRegistry

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

the class DiskPageCompressionIntegrationTest method _testCompressionRatio.

/**
 */
public void _testCompressionRatio() throws Exception {
    IgniteEx ignite = startGrid(0);
    ignite.cluster().active(true);
    String cacheName = "test";
    CacheConfiguration<Integer, TestVal> ccfg = new CacheConfiguration<Integer, TestVal>().setName(cacheName).setBackups(0).setAtomicityMode(ATOMIC).setIndexedTypes(Integer.class, TestVal.class).setAffinity(new RendezvousAffinityFunction().setPartitions(10)).setDiskPageCompression(ZSTD);
    // .setDiskPageCompressionLevel(compressionLevel);
    ignite.getOrCreateCache(ccfg);
    IgniteInternalCache<Integer, TestVal> cache = ignite.cachex(cacheName);
    MetricRegistry mreg = ignite.context().metric().registry(metricName(CACHE_GROUP_METRICS_PREFIX, cacheName));
    GridCacheDatabaseSharedManager dbMgr = ((GridCacheDatabaseSharedManager) ignite.context().cache().context().database());
    int cnt = 20_000_000;
    for (int i = 0; i < cnt; i++) {
        assertTrue(cache.putIfAbsent(i, new TestVal(i)));
        if (i % 50_000 == 0) {
            dbMgr.forceCheckpoint("test").futureFor(FINISHED).get();
            long sparse = mreg.<LongMetric>findMetric("SparseStorageSize").value();
            long size = mreg.<LongMetric>findMetric("StorageSize").value();
            System.out.println(i + " >> " + sparse + " / " + size + " = " + ((double) sparse / size));
        }
    }
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 2 with MetricRegistry

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

the class CacheGroupMetricsImpl method onTopologyInitialized.

/**
 * Callback for initializing metrics after topology was initialized.
 */
public void onTopologyInitialized() {
    MetricRegistry mreg = ctx.shared().kernalContext().metric().registry(metricGroupName());
    mreg.register("MinimumNumberOfPartitionCopies", this::getMinimumNumberOfPartitionCopies, "Minimum number of partition copies for all partitions of this cache group.");
    mreg.register("MaximumNumberOfPartitionCopies", this::getMaximumNumberOfPartitionCopies, "Maximum number of partition copies for all partitions of this cache group.");
    mreg.register("LocalNodeOwningPartitionsCount", this::getLocalNodeOwningPartitionsCount, "Count of partitions with state OWNING for this cache group located on this node.");
    mreg.register("LocalNodeMovingPartitionsCount", this::getLocalNodeMovingPartitionsCount, "Count of partitions with state MOVING for this cache group located on this node.");
    mreg.register("LocalNodeRentingPartitionsCount", this::getLocalNodeRentingPartitionsCount, "Count of partitions with state RENTING for this cache group located on this node.");
    mreg.register("LocalNodeRentingEntriesCount", this::getLocalNodeRentingEntriesCount, "Count of entries remains to evict in RENTING partitions located on this node for this cache group.");
    mreg.register("OwningPartitionsAllocationMap", this::getOwningPartitionsAllocationMap, Map.class, "Allocation map of partitions with state OWNING in the cluster.");
    mreg.register("MovingPartitionsAllocationMap", this::getMovingPartitionsAllocationMap, Map.class, "Allocation map of partitions with state MOVING in the cluster.");
    mreg.register("AffinityPartitionsAssignmentMap", this::getAffinityPartitionsAssignmentMap, Map.class, "Affinity partitions assignment map.");
    mreg.register("PartitionIds", this::getPartitionIds, List.class, "Local partition ids.");
    mreg.register("TotalAllocatedSize", this::getTotalAllocatedSize, "Total size of memory allocated for group, in bytes.");
    if (ctx.config().isEncryptionEnabled()) {
        mreg.register("ReencryptionFinished", () -> !ctx.shared().kernalContext().encryption().reencryptionInProgress(ctx.groupId()), "The flag indicates whether reencryption is finished or not.");
        mreg.register("ReencryptionBytesLeft", () -> ctx.shared().kernalContext().encryption().getBytesLeftForReencryption(ctx.groupId()), "The number of bytes left for re-ecryption.");
    }
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry)

Example 3 with MetricRegistry

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

the class MetricsClusterActivationTest method checkCacheGroupsMetrics.

/**
 * Checks cache groups metrics.
 */
private void checkCacheGroupsMetrics(IgniteEx ignite) {
    MetricRegistry mreg = ignite.context().metric().registry(metricName(CACHE_GROUP_METRICS_PREFIX, DEFAULT_CACHE_NAME));
    if (!ignite.cluster().state().active()) {
        assertEquals(0, F.size(mreg.iterator()));
        return;
    }
    int minimumNumberOfPartitionCopies = mreg.<IntMetric>findMetric("MinimumNumberOfPartitionCopies").value();
    int maximumNumberOfPartitionCopies = mreg.<IntMetric>findMetric("MaximumNumberOfPartitionCopies").value();
    Map<Integer, List<String>> owningPartitionsAllocationMap = mreg.<ObjectMetric<Map<Integer, List<String>>>>findMetric("OwningPartitionsAllocationMap").value();
    Map<Integer, List<String>> movingPartitionsAllocationMap = mreg.<ObjectMetric<Map<Integer, List<String>>>>findMetric("MovingPartitionsAllocationMap").value();
    assertEquals(BACKUPS, minimumNumberOfPartitionCopies);
    assertEquals(BACKUPS, maximumNumberOfPartitionCopies);
    assertFalse(owningPartitionsAllocationMap.isEmpty());
    assertFalse(movingPartitionsAllocationMap.isEmpty());
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) List(java.util.List) Map(java.util.Map)

Example 4 with MetricRegistry

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

the class MetricsClusterActivationTest method checkCacheMetrics.

/**
 * Checks cache metrics.
 */
private void checkCacheMetrics(IgniteEx ignite, boolean expEntries) {
    MetricRegistry mreg = ignite.context().metric().registry(cacheMetricsRegistryName(DEFAULT_CACHE_NAME, false));
    if (!ignite.cluster().state().active()) {
        assertEquals(0, F.size(mreg.iterator()));
        return;
    }
    long offHeapEntriesCount = mreg.<LongMetric>findMetric("OffHeapEntriesCount").value();
    long offHeapPrimaryEntriesCount = mreg.<LongMetric>findMetric("OffHeapPrimaryEntriesCount").value();
    long offHeapBackupEntriesCount = mreg.<LongMetric>findMetric("OffHeapBackupEntriesCount").value();
    if (expEntries) {
        assertEquals(ENTRY_CNT, offHeapEntriesCount);
        assertTrue(offHeapPrimaryEntriesCount > 0);
        assertTrue(offHeapBackupEntriesCount > 0);
    } else {
        assertEquals(0, offHeapEntriesCount);
        assertEquals(0, offHeapPrimaryEntriesCount);
        assertEquals(0, offHeapBackupEntriesCount);
    }
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry)

Example 5 with MetricRegistry

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

the class MetricsSelfTest method testGetMetrics.

/**
 */
@Test
public void testGetMetrics() throws Exception {
    MetricRegistry mreg = new MetricRegistry("group", name -> null, name -> null, null);
    mreg.longMetric("test1", "");
    mreg.longMetric("test2", "");
    mreg.longMetric("test3", "");
    mreg.longMetric("test4", "");
    mreg.longMetric("test5", "");
    Set<String> names = new HashSet<>(asList("group.test1", "group.test2", "group.test3", "group.test4", "group.test5"));
    Set<String> res = StreamSupport.stream(Spliterators.spliteratorUnknownSize(mreg.iterator(), 0), false).map(Metric::name).collect(toSet());
    assertEquals(names, res);
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) HashSet(java.util.HashSet) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

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