use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class CacheGroupReencryptionTest method validateMetrics.
/**
* @param node Grid.
* @param finished Expected reencryption status.
*/
private void validateMetrics(IgniteEx node, boolean finished) throws IgniteInterruptedCheckedException {
MetricRegistry registry = node.context().metric().registry(metricName(CacheGroupMetricsImpl.CACHE_GROUP_METRICS_PREFIX, cacheName()));
LongMetric bytesLeft = registry.findMetric("ReencryptionBytesLeft");
if (finished)
assertEquals(0, bytesLeft.value());
else
assertTrue(waitForCondition(() -> bytesLeft.value() > 0, MAX_AWAIT_MILLIS));
BooleanMetric reencryptionFinished = registry.findMetric("ReencryptionFinished");
assertEquals(finished, reencryptionFinished.value());
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class AbstractCdcTest method checkMetrics.
/**
*/
protected void checkMetrics(CdcMain cdc, int expCnt) throws Exception {
if (metricExporters() != null) {
IgniteConfiguration cfg = getFieldValue(cdc, "igniteCfg");
DynamicMBean jmxCdcReg = metricRegistry(cdcInstanceName(cfg.getIgniteInstanceName()), null, "cdc");
Function<String, ?> jmxVal = m -> {
try {
return jmxCdcReg.getAttribute(m);
} catch (Exception e) {
throw new IgniteException(e);
}
};
checkMetrics(expCnt, (Function<String, Long>) jmxVal, (Function<String, String>) jmxVal);
}
MetricRegistry mreg = getFieldValue(cdc, "mreg");
assertNotNull(mreg);
checkMetrics(expCnt, m -> mreg.<LongMetric>findMetric(m).value(), m -> mreg.<ObjectMetric<String>>findMetric(m).value());
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class SnapshotRestoreProcess method registerMetrics.
/**
* Register local metrics.
*/
protected void registerMetrics() {
assert !ctx.clientNode();
MetricRegistry mreg = ctx.metric().registry(SNAPSHOT_RESTORE_METRICS);
mreg.register("startTime", () -> lastOpCtx.startTime, "The system time of the start of the cluster snapshot restore operation on this node.");
mreg.register("endTime", () -> lastOpCtx.endTime, "The system time when the restore operation of a cluster snapshot on this node ended.");
mreg.register("snapshotName", () -> lastOpCtx.snpName, String.class, "The snapshot name of the last running cluster snapshot restore operation on this node.");
mreg.register("requestId", () -> Optional.ofNullable(lastOpCtx.reqId).map(UUID::toString).orElse(""), String.class, "The request ID of the last running cluster snapshot restore operation on this node.");
mreg.register("error", () -> Optional.ofNullable(lastOpCtx.err.get()).map(Throwable::toString).orElse(""), String.class, "Error message of the last running cluster snapshot restore operation on this node.");
mreg.register("totalPartitions", () -> lastOpCtx.totalParts, "The total number of partitions to be restored on this node.");
mreg.register("processedPartitions", () -> lastOpCtx.processedParts.get(), "The number of processed partitions on this node.");
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class TransactionMetricsTest method testNearTxInfo.
/**
*/
@Test
public void testNearTxInfo() throws Exception {
IgniteEx primaryNode1 = startGrid(0);
IgniteEx primaryNode2 = startGrid(1);
IgniteEx nearNode = startGrid(2);
MetricRegistry mreg = grid(2).context().metric().registry(TX_METRICS);
awaitPartitionMapExchange();
final IgniteCache<Integer, String> primaryCache1 = primaryNode1.cache(DEFAULT_CACHE_NAME);
final IgniteCache<Integer, String> primaryCache2 = primaryNode2.cache(DEFAULT_CACHE_NAME);
final List<Integer> primaryKeys1 = primaryKeys(primaryCache1, TRANSACTIONS);
final List<Integer> primaryKeys2 = primaryKeys(primaryCache2, TRANSACTIONS);
CountDownLatch commitAllower = new CountDownLatch(1);
CountDownLatch transactionStarter = new CountDownLatch(primaryKeys1.size());
for (int i = 0; i < primaryKeys1.size(); i++) new Thread(new TxThread(commitAllower, transactionStarter, nearNode, primaryKeys1.get(i), primaryKeys2.get(i))).start();
transactionStarter.await();
final Map<String, String> transactions = mreg.<ObjectGauge<Map<String, String>>>findMetric("AllOwnerTransactions").value();
assertEquals(TRANSACTIONS, transactions.size());
int match = 0;
for (String txInfo : transactions.values()) {
if (txInfo.contains("ACTIVE") && txInfo.contains("NEAR") && !txInfo.contains("REMOTE"))
match++;
}
assertEquals(TRANSACTIONS, match);
commitAllower.countDown();
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class TransactionMetricsTest method testTxMetric.
/**
*/
@Test
public void testTxMetric() throws Exception {
// given:
int keysNumber = 10;
IgniteEx ignite = startGrid(0);
startGrid(1);
IgniteEx client = startClientGrid(getConfiguration(getTestIgniteInstanceName(2)));
awaitPartitionMapExchange();
TransactionMetricsMxBean txMXBean = getMxBean(getTestIgniteInstanceName(0), "TransactionMetrics", TransactionMetricsMxBeanImpl.class, TransactionMetricsMxBean.class);
MetricRegistry mreg = grid(0).context().metric().registry(TX_METRICS);
final IgniteCache<Integer, String> cache = ignite.cache(DEFAULT_CACHE_NAME);
// when: one transaction commit
ignite.transactions().txStart().commit();
// then:
assertEquals(1, txMXBean.getTransactionsCommittedNumber());
assertEquals(1, mreg.<IntMetric>findMetric("txCommits").value());
// when: transaction is opening
final Transaction tx1 = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ);
int localKeysNum = 0;
for (int i = 0; i < keysNumber; i++) {
cache.put(i, "");
if (affinity(cache).isPrimary(ignite.localNode(), i))
localKeysNum++;
}
// then:
assertEquals(localKeysNum, mreg.<LongMetric>findMetric("LockedKeysNumber").value());
assertEquals(1, mreg.<LongMetric>findMetric("TransactionsHoldingLockNumber").value());
assertEquals(1, mreg.<LongMetric>findMetric("OwnerTransactionsNumber").value());
// when: transaction rollback
tx1.rollback();
// then:
assertEquals(1, txMXBean.getTransactionsRolledBackNumber());
assertEquals(1, mreg.<IntMetric>findMetric("txRollbacks").value());
assertEquals(0, mreg.<LongMetric>findMetric("LockedKeysNumber").value());
assertEquals(0, mreg.<LongMetric>findMetric("TransactionsHoldingLockNumber").value());
assertEquals(0, mreg.<LongMetric>findMetric("OwnerTransactionsNumber").value());
// when: keysNumber transactions from owner node + keysNumber transactions from client.
CountDownLatch commitAllower = new CountDownLatch(1);
CountDownLatch transactionStarter = new CountDownLatch(keysNumber + keysNumber);
int txNumFromOwner = 0;
for (int i = 0; i < keysNumber; i++) {
new Thread(new TxThread(commitAllower, transactionStarter, ignite, i, i)).start();
if (affinity(cache).isPrimary(ignite.localNode(), i))
txNumFromOwner++;
}
int txNumFromClient = 0;
for (int i = keysNumber; i < keysNumber * 2; i++) {
new Thread(new TxThread(commitAllower, transactionStarter, client, i, i)).start();
if (affinity(cache).isPrimary(ignite.localNode(), i))
txNumFromClient++;
}
transactionStarter.await();
// then:
assertEquals(txNumFromOwner + txNumFromClient, mreg.<LongMetric>findMetric("LockedKeysNumber").value());
assertEquals(keysNumber + txNumFromClient, mreg.<LongMetric>findMetric("TransactionsHoldingLockNumber").value());
assertEquals(keysNumber, mreg.<LongMetric>findMetric("OwnerTransactionsNumber").value());
commitAllower.countDown();
}
Aggregations