Search in sources :

Example 1 with TransactionMetricsMxBean

use of org.apache.ignite.mxbean.TransactionMetricsMxBean 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();
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LongMetric(org.apache.ignite.spi.metric.LongMetric) CountDownLatch(java.util.concurrent.CountDownLatch) TransactionMetricsMxBean(org.apache.ignite.mxbean.TransactionMetricsMxBean) Transaction(org.apache.ignite.transactions.Transaction) IntMetric(org.apache.ignite.spi.metric.IntMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with TransactionMetricsMxBean

use of org.apache.ignite.mxbean.TransactionMetricsMxBean in project ignite by apache.

the class IgniteMBeansManager method registerMBeansAfterNodeStarted.

/**
 * Registers kernal MBeans (for kernal, metrics, thread pools) after node start.
 *
 * @throws IgniteCheckedException if fails to register any of the MBeans.
 */
public void registerMBeansAfterNodeStarted() throws IgniteCheckedException {
    if (U.IGNITE_MBEANS_DISABLED)
        return;
    // Kernal
    IgniteMXBean kernalMXBean = new IgniteMXBeanImpl(kernal);
    registerMBean("Kernal", IgniteKernal.class.getSimpleName(), kernalMXBean, IgniteMXBean.class);
    // Metrics
    ClusterMetricsMXBean locMetricsBean = new ClusterLocalNodeMetricsMXBeanImpl(ctx.discovery());
    registerMBean("Kernal", locMetricsBean.getClass().getSimpleName(), locMetricsBean, ClusterMetricsMXBean.class);
    ClusterMetricsMXBean metricsBean = new ClusterMetricsMXBeanImpl(kernal.cluster(), ctx);
    registerMBean("Kernal", metricsBean.getClass().getSimpleName(), metricsBean, ClusterMetricsMXBean.class);
    // Transaction metrics
    TransactionMetricsMxBean txMetricsMXBean = new TransactionMetricsMxBeanImpl(ctx.cache().transactions().metrics());
    registerMBean("TransactionMetrics", txMetricsMXBean.getClass().getSimpleName(), txMetricsMXBean, TransactionMetricsMxBean.class);
    // Transactions
    TransactionsMXBean txMXBean = new TransactionsMXBeanImpl(ctx);
    registerMBean("Transactions", txMXBean.getClass().getSimpleName(), txMXBean, TransactionsMXBean.class);
    // Queries management
    QueryMXBean qryMXBean = new QueryMXBeanImpl(ctx);
    registerMBean("Query", qryMXBean.getClass().getSimpleName(), qryMXBean, QueryMXBean.class);
    // Compute task management
    ComputeMXBean computeMXBean = new ComputeMXBeanImpl(ctx);
    registerMBean("Compute", computeMXBean.getClass().getSimpleName(), computeMXBean, ComputeMXBean.class);
    // Service management
    ServiceMXBean serviceMXBean = new ServiceMXBeanImpl(ctx);
    registerMBean("Service", serviceMXBean.getClass().getSimpleName(), serviceMXBean, ServiceMXBean.class);
    // Data storage
    DataStorageMXBean dataStorageMXBean = new DataStorageMXBeanImpl(ctx);
    registerMBean("DataStorage", dataStorageMXBean.getClass().getSimpleName(), dataStorageMXBean, DataStorageMXBean.class);
    // Baseline configuration
    BaselineAutoAdjustMXBean baselineAutoAdjustMXBean = new BaselineAutoAdjustMXBeanImpl(ctx);
    registerMBean("Baseline", baselineAutoAdjustMXBean.getClass().getSimpleName(), baselineAutoAdjustMXBean, BaselineAutoAdjustMXBean.class);
    // Encryption
    EncryptionMXBean encryptionMXBean = new EncryptionMXBeanImpl(ctx);
    registerMBean("Encryption", encryptionMXBean.getClass().getSimpleName(), encryptionMXBean, EncryptionMXBean.class);
    // Snapshot.
    SnapshotMXBean snpMXBean = new SnapshotMXBeanImpl(ctx);
    registerMBean("Snapshot", snpMXBean.getClass().getSimpleName(), snpMXBean, SnapshotMXBean.class);
    // Defragmentation.
    DefragmentationMXBean defragMXBean = new DefragmentationMXBeanImpl(ctx);
    registerMBean("Defragmentation", defragMXBean.getClass().getSimpleName(), defragMXBean, DefragmentationMXBean.class);
    // Metrics configuration
    MetricsMxBean metricsMxBean = new MetricsMxBeanImpl(ctx.metric(), log);
    registerMBean("Metrics", metricsMxBean.getClass().getSimpleName(), metricsMxBean, MetricsMxBean.class);
    ctx.pools().registerMxBeans(this);
    if (U.IGNITE_TEST_FEATURES_ENABLED) {
        WorkersControlMXBean workerCtrlMXBean = new WorkersControlMXBeanImpl(ctx.workersRegistry());
        registerMBean("Kernal", workerCtrlMXBean.getClass().getSimpleName(), workerCtrlMXBean, WorkersControlMXBean.class);
    }
    FailureHandlingMxBean blockOpCtrlMXBean = new FailureHandlingMxBeanImpl(ctx.workersRegistry(), ctx.cache().context().database());
    registerMBean("Kernal", blockOpCtrlMXBean.getClass().getSimpleName(), blockOpCtrlMXBean, FailureHandlingMxBean.class);
    if (ctx.query().moduleEnabled())
        ctx.query().getIndexing().registerMxBeans(this);
    PerformanceStatisticsMBeanImpl performanceStatMbean = new PerformanceStatisticsMBeanImpl(ctx);
    registerMBean("PerformanceStatistics", performanceStatMbean.getClass().getSimpleName(), performanceStatMbean, PerformanceStatisticsMBean.class);
}
Also used : QueryMXBean(org.apache.ignite.mxbean.QueryMXBean) TransactionMetricsMxBeanImpl(org.apache.ignite.internal.TransactionMetricsMxBeanImpl) QueryMXBeanImpl(org.apache.ignite.internal.QueryMXBeanImpl) ComputeMXBean(org.apache.ignite.mxbean.ComputeMXBean) ClusterLocalNodeMetricsMXBeanImpl(org.apache.ignite.internal.ClusterLocalNodeMetricsMXBeanImpl) EncryptionMXBeanImpl(org.apache.ignite.internal.managers.encryption.EncryptionMXBeanImpl) ServiceMXBean(org.apache.ignite.mxbean.ServiceMXBean) BaselineAutoAdjustMXBean(org.apache.ignite.mxbean.BaselineAutoAdjustMXBean) WorkersControlMXBeanImpl(org.apache.ignite.internal.worker.WorkersControlMXBeanImpl) SnapshotMXBeanImpl(org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotMXBeanImpl) DefragmentationMXBean(org.apache.ignite.mxbean.DefragmentationMXBean) DataStorageMXBeanImpl(org.apache.ignite.internal.processors.cache.persistence.DataStorageMXBeanImpl) EncryptionMXBean(org.apache.ignite.mxbean.EncryptionMXBean) IgniteKernal(org.apache.ignite.internal.IgniteKernal) TransactionsMXBeanImpl(org.apache.ignite.internal.TransactionsMXBeanImpl) ClusterMetricsMXBeanImpl(org.apache.ignite.internal.ClusterMetricsMXBeanImpl) ServiceMXBeanImpl(org.apache.ignite.internal.ServiceMXBeanImpl) IgniteMXBean(org.apache.ignite.mxbean.IgniteMXBean) DataStorageMXBean(org.apache.ignite.mxbean.DataStorageMXBean) PerformanceStatisticsMBeanImpl(org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsMBeanImpl) ComputeMXBeanImpl(org.apache.ignite.internal.ComputeMXBeanImpl) ClusterMetricsMXBean(org.apache.ignite.mxbean.ClusterMetricsMXBean) TransactionMetricsMxBean(org.apache.ignite.mxbean.TransactionMetricsMxBean) SnapshotMXBean(org.apache.ignite.mxbean.SnapshotMXBean) TransactionsMXBean(org.apache.ignite.mxbean.TransactionsMXBean) BaselineAutoAdjustMXBeanImpl(org.apache.ignite.internal.processors.cluster.BaselineAutoAdjustMXBeanImpl) WorkersControlMXBean(org.apache.ignite.mxbean.WorkersControlMXBean) FailureHandlingMxBean(org.apache.ignite.mxbean.FailureHandlingMxBean) TransactionMetricsMxBean(org.apache.ignite.mxbean.TransactionMetricsMxBean) MetricsMxBean(org.apache.ignite.mxbean.MetricsMxBean) TransactionMetricsMxBeanImpl(org.apache.ignite.internal.TransactionMetricsMxBeanImpl) MetricsMxBeanImpl(org.apache.ignite.internal.processors.metric.MetricsMxBeanImpl) DefragmentationMXBeanImpl(org.apache.ignite.internal.processors.cache.persistence.defragmentation.DefragmentationMXBeanImpl) IgniteMXBeanImpl(org.apache.ignite.internal.IgniteMXBeanImpl) FailureHandlingMxBeanImpl(org.apache.ignite.internal.worker.FailureHandlingMxBeanImpl)

Aggregations

TransactionMetricsMxBean (org.apache.ignite.mxbean.TransactionMetricsMxBean)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 ClusterLocalNodeMetricsMXBeanImpl (org.apache.ignite.internal.ClusterLocalNodeMetricsMXBeanImpl)1 ClusterMetricsMXBeanImpl (org.apache.ignite.internal.ClusterMetricsMXBeanImpl)1 ComputeMXBeanImpl (org.apache.ignite.internal.ComputeMXBeanImpl)1 IgniteKernal (org.apache.ignite.internal.IgniteKernal)1 IgniteMXBeanImpl (org.apache.ignite.internal.IgniteMXBeanImpl)1 QueryMXBeanImpl (org.apache.ignite.internal.QueryMXBeanImpl)1 ServiceMXBeanImpl (org.apache.ignite.internal.ServiceMXBeanImpl)1 TransactionMetricsMxBeanImpl (org.apache.ignite.internal.TransactionMetricsMxBeanImpl)1 TransactionsMXBeanImpl (org.apache.ignite.internal.TransactionsMXBeanImpl)1 EncryptionMXBeanImpl (org.apache.ignite.internal.managers.encryption.EncryptionMXBeanImpl)1 DataStorageMXBeanImpl (org.apache.ignite.internal.processors.cache.persistence.DataStorageMXBeanImpl)1 DefragmentationMXBeanImpl (org.apache.ignite.internal.processors.cache.persistence.defragmentation.DefragmentationMXBeanImpl)1 SnapshotMXBeanImpl (org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotMXBeanImpl)1 BaselineAutoAdjustMXBeanImpl (org.apache.ignite.internal.processors.cluster.BaselineAutoAdjustMXBeanImpl)1 MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)1 MetricsMxBeanImpl (org.apache.ignite.internal.processors.metric.MetricsMxBeanImpl)1 PerformanceStatisticsMBeanImpl (org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsMBeanImpl)1 FailureHandlingMxBeanImpl (org.apache.ignite.internal.worker.FailureHandlingMxBeanImpl)1