Search in sources :

Example 1 with MvccRecoveryFinishedMessage

use of org.apache.ignite.internal.processors.cache.mvcc.msg.MvccRecoveryFinishedMessage in project ignite by apache.

the class MvccStructuresOverheadTest method restartClients.

/**
 * Starts cluster and restarts several clients over it.
 *
 * @throws Exception If failed.
 */
private void restartClients() throws Exception {
    IgniteEx ignite = startGrid(0);
    AtomicBoolean mvccMessageTranslated = new AtomicBoolean();
    ignite.context().io().addMessageListener(GridTopic.TOPIC_CACHE_COORDINATOR, (nodeId, msg, plc) -> {
        if (msg instanceof MvccRecoveryFinishedMessage)
            mvccMessageTranslated.set(true);
    });
    Map recoveryBallotBoxes = U.field(ignite.context().coordinators(), "recoveryBallotBoxes");
    for (int i = 0; i < CLIENT_RESTARTS; i++) {
        IgniteEx client = startClientGrid(1);
        IgniteCache cache = client.cache(DEFAULT_CACHE_NAME);
        cache.put(i, i);
        client.close();
        if (isMvccCache) {
            assertTrue(GridTestUtils.waitForCondition(mvccMessageTranslated::get, 10_000));
            assertTrue("Size of recoveryBallotBoxes " + recoveryBallotBoxes.size(), recoveryBallotBoxes.isEmpty());
            mvccMessageTranslated.compareAndSet(true, false);
        } else {
            assertFalse(mvccMessageTranslated.get());
            assertTrue("Size of recoveryBallotBoxes " + recoveryBallotBoxes.size(), recoveryBallotBoxes.isEmpty());
        }
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCache(org.apache.ignite.IgniteCache) Map(java.util.Map) MvccRecoveryFinishedMessage(org.apache.ignite.internal.processors.cache.mvcc.msg.MvccRecoveryFinishedMessage)

Aggregations

Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 IgniteCache (org.apache.ignite.IgniteCache)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 MvccRecoveryFinishedMessage (org.apache.ignite.internal.processors.cache.mvcc.msg.MvccRecoveryFinishedMessage)1