Search in sources :

Example 1 with WarmUpTestPluginProvider

use of org.apache.ignite.internal.processors.cache.warmup.WarmUpTestPluginProvider in project ignite by apache.

the class GridCommandHandlerTest method testSuccessStopWarmUp.

/**
 * Verification of successful warm-up stop.
 * <p/>
 * Steps:
 * 1)Starting node with warm-up;
 * 2)Stop warm-up;
 * 3)Waiting for a successful stop of warm-up and start of node.
 *
 * @throws Exception If failed.
 */
@Test
public void testSuccessStopWarmUp() throws Exception {
    WarmUpTestPluginProvider provider = new WarmUpTestPluginProvider();
    IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(0)).setPluginProviders(provider);
    cfg.getDataStorageConfiguration().setDefaultWarmUpConfiguration(new BlockedWarmUpConfiguration());
    cfg.getConnectorConfiguration().setHost("localhost");
    IgniteInternalFuture<IgniteEx> fut = runAsync(() -> startGrid(cfg));
    BlockedWarmUpStrategy blockedWarmUpStgy = (BlockedWarmUpStrategy) provider.strats.get(1);
    try {
        U.await(blockedWarmUpStgy.startLatch, 60, TimeUnit.SECONDS);
        // Arguments --user and --password are needed for additional sending of the GridClientAuthenticationRequest.
        assertEquals(EXIT_CODE_OK, execute("--warm-up", "--stop", "--yes", "--user", "user", "--password", "123"));
        assertEquals(0, blockedWarmUpStgy.stopLatch.getCount());
    } finally {
        blockedWarmUpStgy.stopLatch.countDown();
        fut.get(60_000);
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BlockedWarmUpConfiguration(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) WarmUpTestPluginProvider(org.apache.ignite.internal.processors.cache.warmup.WarmUpTestPluginProvider) BlockedWarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpStrategy) IgniteCacheGroupsWithRestartsTest(org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) Test(org.junit.Test)

Example 2 with WarmUpTestPluginProvider

use of org.apache.ignite.internal.processors.cache.warmup.WarmUpTestPluginProvider in project ignite by apache.

the class JettyRestProcessorBeforeNodeStartSelfTest method testStopWarmUp.

/**
 * Test checks that the warm-up will be stopped via an http request.
 *
 * @throws Exception If failed.
 */
@Test
public void testStopWarmUp() throws Exception {
    IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(gridCount()));
    cfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration().setWarmUpConfiguration(new BlockedWarmUpConfiguration());
    WarmUpTestPluginProvider warmUpProvider = (WarmUpTestPluginProvider) cfg.getPluginProviders()[0];
    BlockedWarmUpStrategy warmUpStrat = (BlockedWarmUpStrategy) warmUpProvider.strats.get(1);
    nextPort = true;
    IgniteInternalFuture<IgniteEx> startNodeFut = GridTestUtils.runAsync(() -> startGrid(cfg));
    try {
        U.await(warmUpStrat.startLatch, 1, MINUTES);
        JsonNode res = content(NODE_STATE_BEFORE_START, null);
        assertEquals(STATUS_SUCCESS, res.get("successStatus").intValue());
        res = content(WARM_UP, F.asMap("stopWarmUp", "true"));
        assertEquals(STATUS_SUCCESS, res.get("successStatus").intValue());
        assertEquals(0, warmUpStrat.stopLatch.getCount());
    } finally {
        warmUpStrat.stopLatch.countDown();
        startNodeFut.get(1, MINUTES).close();
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BlockedWarmUpConfiguration(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) WarmUpTestPluginProvider(org.apache.ignite.internal.processors.cache.warmup.WarmUpTestPluginProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) BlockedWarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpStrategy) Test(org.junit.Test)

Aggregations

IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 BlockedWarmUpConfiguration (org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpConfiguration)2 BlockedWarmUpStrategy (org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpStrategy)2 WarmUpTestPluginProvider (org.apache.ignite.internal.processors.cache.warmup.WarmUpTestPluginProvider)2 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 IgniteCacheGroupsWithRestartsTest (org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest)1 AbstractSnapshotSelfTest.doSnapshotCancellationTest (org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest)1