Search in sources :

Example 1 with IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT

use of org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT 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);
    }
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) Transaction(org.apache.ignite.transactions.Transaction) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) HashMap(java.util.HashMap) CacheRebalanceMode(org.apache.ignite.cache.CacheRebalanceMode) Function(java.util.function.Function) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) IGNITE_LONG_TRANSACTION_TIME_DUMP_THRESHOLD(org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_TRANSACTION_TIME_DUMP_THRESHOLD) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) LogListener.matches(org.apache.ignite.testframework.LogListener.matches) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) Collections.singletonMap(java.util.Collections.singletonMap) IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_COEFFICIENT(org.apache.ignite.IgniteSystemProperties.IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_COEFFICIENT) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) F(org.apache.ignite.internal.util.typedef.F) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT(org.apache.ignite.IgniteSystemProperties.IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT) IGNITE_TX_OWNER_DUMP_REQUESTS_ALLOWED(org.apache.ignite.IgniteSystemProperties.IGNITE_TX_OWNER_DUMP_REQUESTS_ALLOWED) IGNITE_DUMP_TX_COLLISIONS_INTERVAL(org.apache.ignite.IgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVAL) Test(org.junit.Test) TransactionProxyImpl(org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) TransactionsMXBean(org.apache.ignite.mxbean.TransactionsMXBean) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) Serializable(java.io.Serializable) TimeUnit(java.util.concurrent.TimeUnit) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) Serializable(java.io.Serializable) HashMap(java.util.HashMap) CountDownLatch(java.util.concurrent.CountDownLatch) TransactionsMXBean(org.apache.ignite.mxbean.TransactionsMXBean) List(java.util.List) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Aggregations

Serializable (java.io.Serializable)1 Collections.singletonMap (java.util.Collections.singletonMap)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 TimeUnit (java.util.concurrent.TimeUnit)1 BiConsumer (java.util.function.BiConsumer)1 Function (java.util.function.Function)1 IGNITE_DUMP_TX_COLLISIONS_INTERVAL (org.apache.ignite.IgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVAL)1 IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT (org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT)1 IGNITE_LONG_TRANSACTION_TIME_DUMP_THRESHOLD (org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_TRANSACTION_TIME_DUMP_THRESHOLD)1 IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_COEFFICIENT (org.apache.ignite.IgniteSystemProperties.IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_COEFFICIENT)1 IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT (org.apache.ignite.IgniteSystemProperties.IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT)1 IGNITE_TX_OWNER_DUMP_REQUESTS_ALLOWED (org.apache.ignite.IgniteSystemProperties.IGNITE_TX_OWNER_DUMP_REQUESTS_ALLOWED)1 TRANSACTIONAL (org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL)1 CacheRebalanceMode (org.apache.ignite.cache.CacheRebalanceMode)1 FULL_SYNC (org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC)1 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)1 ACTIVE (org.apache.ignite.cluster.ClusterState.ACTIVE)1