use of org.apache.ignite.mxbean.TransactionsMXBean in project ignite by apache.
the class CacheMetricsManageTest method testKeyCollisionsMetricDifferentTimeout.
/**
* Tests metric change interval.
*/
@Test
public void testKeyCollisionsMetricDifferentTimeout() throws Exception {
Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9224", MvccFeatureChecker.forcedMvcc());
backups = 2;
useTestCommSpi = true;
Ignite ig = startGridsMultiThreaded(3);
int contCnt = (int) U.staticField(IgniteTxManager.class, "COLLISIONS_QUEUE_THRESHOLD") * 5;
CountDownLatch txLatch = new CountDownLatch(contCnt);
ig.cluster().active(true);
client = true;
Ignite cl = startGrid();
IgniteTransactions txMgr = cl.transactions();
CacheConfiguration<?, ?> dfltCacheCfg = getCacheConfiguration();
dfltCacheCfg.setStatisticsEnabled(true);
String cacheName = dfltCacheCfg.getName();
IgniteCache<Integer, Integer> cache = ig.cache(cacheName);
IgniteCache<Integer, Integer> cache0 = cl.cache(cacheName);
final Integer keyId = primaryKey(cache);
CountDownLatch blockOnce = new CountDownLatch(1);
for (Ignite ig0 : G.allGrids()) {
if (ig0.configuration().isClientMode())
continue;
TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ig0.configuration().getCommunicationSpi();
commSpi0.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
@Override
public boolean apply(ClusterNode node, Message msg) {
if (msg instanceof GridNearTxFinishResponse && blockOnce.getCount() > 0) {
blockOnce.countDown();
return true;
}
return false;
}
});
}
IgniteInternalFuture f = GridTestUtils.runAsync(() -> {
try (Transaction tx = txMgr.txStart(PESSIMISTIC, READ_COMMITTED)) {
cache0.put(keyId, 0);
tx.commit();
}
});
blockOnce.await();
GridCompoundFuture<?, ?> finishFut = new GridCompoundFuture<>();
for (int i = 0; i < contCnt; ++i) {
IgniteInternalFuture f0 = GridTestUtils.runAsync(() -> {
try (Transaction tx = txMgr.txStart(PESSIMISTIC, READ_COMMITTED)) {
cache0.put(keyId, 0);
tx.commit();
txLatch.countDown();
}
});
finishFut.add(f0);
}
finishFut.markInitialized();
for (Ignite ig0 : G.allGrids()) {
TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ig0.configuration().getCommunicationSpi();
if (ig0.configuration().isClientMode())
continue;
commSpi0.stopBlock();
}
CacheMetricsMXBean mxBeanCache = mxBean(0, cacheName, CacheLocalMetricsMXBeanImpl.class);
IgniteTxManager txManager = ((IgniteEx) ig).context().cache().context().tm();
final TransactionsMXBean txMXBean1 = txMXBean(0);
final TransactionsMXBean txMXBean2 = txMXBean(1);
for (int i = 0; i < 10; ++i) {
txMXBean1.setTxKeyCollisionsInterval(ThreadLocalRandom.current().nextInt(1000, 1100));
txMXBean2.setTxKeyCollisionsInterval(ThreadLocalRandom.current().nextInt(1000, 1100));
mxBeanCache.getTxKeyCollisions();
mxBeanCache.clear();
try {
U.invoke(IgniteTxManager.class, txManager, "collectTxCollisionsInfo");
} catch (IgniteCheckedException e) {
fail(e.toString());
}
U.sleep(500);
}
f.get();
finishFut.get();
txLatch.await();
}
use of org.apache.ignite.mxbean.TransactionsMXBean in project ignite by apache.
the class TransactionsMXBeanImplTest method testBasic.
/**
*/
@Test
public void testBasic() throws Exception {
IgniteEx ignite = startGrid(0);
ignite.cluster().state(ACTIVE);
TransactionsMXBean bean = txMXBean(0);
ignite.transactions().txStart();
ignite.cache(DEFAULT_CACHE_NAME).put(0, 0);
String res = bean.getActiveTransactions(null, null, null, null, null, null, null, null, false, false);
assertEquals("1", res);
res = bean.getActiveTransactions(null, null, null, null, null, null, null, null, true, false);
assertTrue(res.indexOf("Tx:") > 0);
res = bean.getActiveTransactions(null, null, null, null, null, null, null, null, false, true);
assertEquals("1", res);
doSleep(500);
res = bean.getActiveTransactions(null, null, null, null, null, null, null, null, false, false);
assertEquals("0", res);
}
use of org.apache.ignite.mxbean.TransactionsMXBean in project ignite by apache.
the class GridTransactionsSystemUserTimeMetricsTest method testJmxParametersSpreading.
/**
* Test that changing of JMX parameters spreads on cluster correctly.
*
* @throws Exception If failed.
*/
@Test
public void testJmxParametersSpreading() throws Exception {
IgniteEx client2 = startGrid(CLIENT_2);
try {
TransactionsMXBean tmMxBean = getMxBean(CLIENT, "Transactions", TransactionsMXBeanImpl.class, TransactionsMXBean.class);
TransactionsMXBean tmMxBean2 = getMxBean(CLIENT_2, "Transactions", TransactionsMXBeanImpl.class, TransactionsMXBean.class);
int oldLimit = tmMxBean.getTransactionTimeDumpSamplesPerSecondLimit();
long oldThreshold = tmMxBean.getLongTransactionTimeDumpThreshold();
double oldCoefficient = tmMxBean.getTransactionTimeDumpSamplesCoefficient();
try {
int newLimit = 1234;
long newThreshold = 99999;
double newCoefficient = 0.01;
applyJmxParameters(null, newCoefficient, newLimit);
applyJmxParameters(newThreshold, null, null, tmMxBean2, client2);
assertEquals(newLimit, tmMxBean2.getTransactionTimeDumpSamplesPerSecondLimit());
assertEquals(newThreshold, tmMxBean.getLongTransactionTimeDumpThreshold());
assertTrue(tmMxBean2.getTransactionTimeDumpSamplesCoefficient() - newCoefficient < 0.0001);
} finally {
applyJmxParameters(oldThreshold, oldCoefficient, oldLimit);
}
} finally {
// CLIENT grid is stopped in afterTest.
stopGrid(CLIENT_2);
}
}
use of org.apache.ignite.mxbean.TransactionsMXBean 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);
}
use of org.apache.ignite.mxbean.TransactionsMXBean in project ignite by apache.
the class TransactionsMXBeanImplTest method testChangeLongOperationsDumpTimeoutOnImmutableCluster.
/**
* Test to verify the correct change of {@link TransactionsMXBean#getLongOperationsDumpTimeout()}
* in an immutable cluster.
*
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, value = "100")
public void testChangeLongOperationsDumpTimeoutOnImmutableCluster() throws Exception {
Map<IgniteEx, TransactionsMXBean> allNodes = startGridAndActivate(2);
Map<IgniteEx, TransactionsMXBean> clientNodes = new HashMap<>();
Map<IgniteEx, TransactionsMXBean> srvNodes = new HashMap<>(allNodes);
clientNode = true;
for (int i = 2; i < 4; i++) {
IgniteEx igniteEx = startGrid(i);
TransactionsMXBean transactionsMXBean = txMXBean(i);
allNodes.put(igniteEx, transactionsMXBean);
clientNodes.put(igniteEx, transactionsMXBean);
}
// check for default value
checkPropertyValueViaTxMxBean(allNodes, 100L, TransactionsMXBean::getLongOperationsDumpTimeout);
// create property update latches for client nodes
Map<IgniteEx, List<CountDownLatch>> updateLatches = new HashMap<>();
clientNodes.keySet().forEach(ignite -> updateLatches.put(ignite, F.asList(new CountDownLatch(1), new CountDownLatch(1))));
clientNodes.forEach((igniteEx, bean) -> igniteEx.context().distributedMetastorage().listen((key) -> key.startsWith(DIST_CONF_PREFIX), (String key, Serializable oldVal, Serializable newVal) -> {
if ((long) newVal == 200)
updateLatches.get(igniteEx).get(0).countDown();
if ((long) newVal == 300)
updateLatches.get(igniteEx).get(1).countDown();
}));
long newTimeout = 200L;
// update value via server node
updatePropertyViaTxMxBean(allNodes, TransactionsMXBean::setLongOperationsDumpTimeout, newTimeout);
// check new value in server nodes
checkPropertyValueViaTxMxBean(srvNodes, newTimeout, TransactionsMXBean::getLongOperationsDumpTimeout);
// check new value in client nodes
for (List<CountDownLatch> list : updateLatches.values()) {
CountDownLatch countDownLatch = list.get(0);
countDownLatch.await(100, TimeUnit.MILLISECONDS);
}
newTimeout = 300L;
// update value via server node
updatePropertyViaTxMxBean(clientNodes, TransactionsMXBean::setLongOperationsDumpTimeout, newTimeout);
// check new value in server nodes
checkPropertyValueViaTxMxBean(srvNodes, newTimeout, TransactionsMXBean::getLongOperationsDumpTimeout);
// check new value on client nodes
for (List<CountDownLatch> list : updateLatches.values()) {
CountDownLatch countDownLatch = list.get(1);
countDownLatch.await(100, TimeUnit.MILLISECONDS);
}
}
Aggregations