use of org.apache.ignite.mxbean.TransactionsMXBean in project ignite by apache.
the class TransactionsMXBeanImplTest method checkLongOperationsDumpTimeoutViaTxMxBean.
/**
* Checking changes and receiving lrt through MXBean.
*
* @param defTimeout Default lrt timeout.
* @param newTimeout New lrt timeout.
* @param waitTimeTx Waiting time for a lrt.
* @param expectTx Expect or not a lrt to log.
* @throws Exception If failed.
*/
private void checkLongOperationsDumpTimeoutViaTxMxBean(long defTimeout, long newTimeout, long waitTimeTx, boolean expectTx) throws Exception {
IgniteEx ignite = startGrid(0);
IgniteEx ignite1 = startGrid(1);
ignite.cluster().state(ACTIVE);
TransactionsMXBean txMXBean = txMXBean(0);
TransactionsMXBean txMXBean1 = txMXBean(1);
assertEquals(defTimeout, txMXBean.getLongOperationsDumpTimeout());
assertEquals(defTimeout, txMXBean1.getLongOperationsDumpTimeout());
Transaction tx = ignite.transactions().txStart();
LogListener lrtLogLsnr = matches("First 10 long running transactions [total=1]").build();
LogListener txLogLsnr = matches(((TransactionProxyImpl) tx).tx().xidVersion().toString()).build();
testLog.registerListener(lrtLogLsnr);
testLog.registerListener(txLogLsnr);
txMXBean.setLongOperationsDumpTimeout(newTimeout);
assertEquals(newTimeout, ignite.context().cache().context().tm().longOperationsDumpTimeout());
assertEquals(newTimeout, ignite1.context().cache().context().tm().longOperationsDumpTimeout());
if (expectTx)
assertTrue(waitForCondition(() -> lrtLogLsnr.check() && txLogLsnr.check(), waitTimeTx));
else
assertFalse(waitForCondition(() -> lrtLogLsnr.check() && txLogLsnr.check(), waitTimeTx));
}
use of org.apache.ignite.mxbean.TransactionsMXBean in project ignite by apache.
the class GridCacheLongRunningTransactionDiagnosticsTest method testLrtChangeSetting.
/**
* Tests transaction mx bean and its ability to turn on and off thread dump requests
* from local node to near node.
*
* @throws Exception if grids start failed.
*/
@Test
public void testLrtChangeSetting() throws Exception {
startGridsMultiThreaded(2);
TransactionsMXBean tMXBean0 = txMXBean(0);
TransactionsMXBean tMXBean1 = txMXBean(1);
assertTrue(tMXBean0.getTxOwnerDumpRequestsAllowed());
assertTrue(tMXBean1.getTxOwnerDumpRequestsAllowed());
tMXBean0.setTxOwnerDumpRequestsAllowed(false);
assertFalse(tMXBean0.getTxOwnerDumpRequestsAllowed());
assertFalse(tMXBean1.getTxOwnerDumpRequestsAllowed());
imitateLongTransaction(false);
}
use of org.apache.ignite.mxbean.TransactionsMXBean in project ignite by apache.
the class SetTxTimeoutOnPartitionMapExchangeTest method testJmxSetTxTimeoutOnPartitionMapExchange.
/**
*/
@Test
public void testJmxSetTxTimeoutOnPartitionMapExchange() throws Exception {
startGrid(1);
startGrid(2);
TransactionsMXBean mxBean1 = txMXBean(1);
TransactionsMXBean mxBean2 = txMXBean(2);
final long expTimeout1 = 20_000L;
final long expTimeout2 = 30_000L;
mxBean1.setTxTimeoutOnPartitionMapExchange(expTimeout1);
assertTxTimeoutOnPartitionMapExchange(expTimeout1);
assertEquals(expTimeout1, mxBean1.getTxTimeoutOnPartitionMapExchange());
mxBean2.setTxTimeoutOnPartitionMapExchange(expTimeout2);
assertTxTimeoutOnPartitionMapExchange(expTimeout2);
assertEquals(expTimeout2, mxBean2.getTxTimeoutOnPartitionMapExchange());
}
use of org.apache.ignite.mxbean.TransactionsMXBean in project ignite by apache.
the class SetTxTimeoutOnPartitionMapExchangeTest method checkSetTxTimeoutDuringPartitionMapExchange.
/**
* @param ig Ignite instance where deadlock tx will start.
* @throws Exception If fails.
*/
private void checkSetTxTimeoutDuringPartitionMapExchange(IgniteEx ig) throws Exception {
final long longTimeout = 600_000L;
final long shortTimeout = 5_000L;
TransactionsMXBean mxBean = txMXBean(0);
// Case 1: set very long txTimeoutOnPME, transaction should be rolled back.
mxBean.setTxTimeoutOnPartitionMapExchange(longTimeout);
assertTxTimeoutOnPartitionMapExchange(longTimeout);
AtomicReference<Exception> txEx = new AtomicReference<>();
IgniteInternalFuture<Long> fut = startDeadlock(ig, txEx, 0);
startGridAsync(2);
waitForExchangeStarted(ig);
mxBean.setTxTimeoutOnPartitionMapExchange(shortTimeout);
awaitPartitionMapExchange();
fut.get();
assertTrue("Transaction should be rolled back", hasCause(txEx.get(), TransactionRollbackException.class));
// Case 2: txTimeoutOnPME will be set to 0 after starting of PME, transaction should be cancelled on timeout.
mxBean.setTxTimeoutOnPartitionMapExchange(longTimeout);
assertTxTimeoutOnPartitionMapExchange(longTimeout);
fut = startDeadlock(ig, txEx, 10000L);
startGridAsync(3);
waitForExchangeStarted(ig);
mxBean.setTxTimeoutOnPartitionMapExchange(0);
fut.get();
assertTrue("Transaction should be canceled on timeout", hasCause(txEx.get(), TransactionTimeoutException.class));
}
Aggregations