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));
}
}
}
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.");
}
}
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());
}
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);
}
}
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);
}
Aggregations