Search in sources :

Example 1 with IgniteProcessProxy

use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.

the class IgniteWalRecoveryTest method testRecoveryNoCheckpoint.

/**
 * @throws Exception if failed.
 */
public void testRecoveryNoCheckpoint() throws Exception {
    try {
        IgniteEx ctrlGrid = startGrid(0);
        fork = true;
        IgniteEx cacheGrid = startGrid(1);
        ctrlGrid.active(true);
        ctrlGrid.compute(ctrlGrid.cluster().forRemotes()).run(new LoadRunnable(false));
        info("Killing remote process...");
        ((IgniteProcessProxy) cacheGrid).kill();
        final IgniteEx g0 = ctrlGrid;
        GridTestUtils.waitForCondition(new PA() {

            /**
             * {@inheritDoc}
             */
            @Override
            public boolean apply() {
                return g0.cluster().nodes().size() == 1;
            }
        }, getTestTimeout());
        fork = false;
        // Now start the grid and verify that updates were restored from WAL.
        cacheGrid = startGrid(1);
        IgniteCache<Object, Object> cache = cacheGrid.cache("partitioned");
        for (int i = 0; i < 10_000; i++) assertEquals(new IndexedObject(i), cache.get(i));
        List<List<?>> res = cache.query(new SqlFieldsQuery("select count(iVal) from IndexedObject")).getAll();
        assertEquals(1, res.size());
        assertEquals(10_000L, res.get(0).get(0));
    } finally {
        stopAllGrids();
    }
}
Also used : PA(org.apache.ignite.internal.util.typedef.PA) IgniteEx(org.apache.ignite.internal.IgniteEx) List(java.util.List) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) IgniteProcessProxy(org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy)

Example 2 with IgniteProcessProxy

use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.

the class IgniteWalRecoveryTest method testRandomCrash.

/**
 * @throws Exception if failed.
 */
public void testRandomCrash() throws Exception {
    try {
        IgniteEx ctrlGrid = startGrid(0);
        fork = true;
        IgniteEx cacheGrid = startGrid(1);
        ctrlGrid.active(true);
        IgniteCompute rmt = ctrlGrid.compute(ctrlGrid.cluster().forRemotes());
        rmt.run(new LoadRunnable(false));
        info(">>> Finished cache population.");
        rmt.run(new AsyncLoadRunnable());
        Thread.sleep(20_000);
        info(">>> Killing remote process...");
        ((IgniteProcessProxy) cacheGrid).kill();
        startGrid(1);
        Boolean res = rmt.call(new VerifyCallable());
        assertTrue(res);
    } finally {
        stopAllGrids();
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCompute(org.apache.ignite.IgniteCompute) IgniteProcessProxy(org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy)

Example 3 with IgniteProcessProxy

use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.

the class IgniteWalRecoveryTest method testLargeRandomCrash.

/**
 * @throws Exception if failed.
 */
public void testLargeRandomCrash() throws Exception {
    try {
        IgniteEx ctrlGrid = startGrid(0);
        fork = true;
        IgniteEx cacheGrid = startGrid(1);
        ctrlGrid.active(true);
        IgniteCompute rmt = ctrlGrid.compute(ctrlGrid.cluster().forRemotes());
        rmt.run(new LargeLoadRunnable(false));
        info(">>> Finished cache population.");
        rmt.run(new AsyncLargeLoadRunnable());
        Thread.sleep(20_000);
        info(">>> Killing remote process...");
        ((IgniteProcessProxy) cacheGrid).kill();
        startGrid(1);
        Boolean res = rmt.call(new VerifyLargeCallable());
        assertTrue(res);
    } finally {
        stopAllGrids();
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCompute(org.apache.ignite.IgniteCompute) IgniteProcessProxy(org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy)

Example 4 with IgniteProcessProxy

use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.

the class IgniteWalRecoveryTest method testRecoveryLargeNoCheckpoint.

/**
 * @throws Exception if failed.
 */
public void testRecoveryLargeNoCheckpoint() throws Exception {
    try {
        IgniteEx ctrlGrid = startGrid(0);
        fork = true;
        IgniteEx cacheGrid = startGrid(1);
        ctrlGrid.active(true);
        ctrlGrid.compute(ctrlGrid.cluster().forRemotes()).run(new LargeLoadRunnable(false));
        info("Killing remote process...");
        ((IgniteProcessProxy) cacheGrid).kill();
        final IgniteEx g0 = ctrlGrid;
        GridTestUtils.waitForCondition(new PA() {

            /**
             * {@inheritDoc}
             */
            @Override
            public boolean apply() {
                return g0.cluster().nodes().size() == 1;
            }
        }, getTestTimeout());
        fork = false;
        // Now start the grid and verify that updates were restored from WAL.
        cacheGrid = startGrid(1);
        IgniteCache<Object, Object> cache = cacheGrid.cache("partitioned");
        for (int i = 0; i < 1000; i++) {
            final long[] data = new long[LARGE_ARR_SIZE];
            Arrays.fill(data, i);
            final long[] loaded = (long[]) cache.get(i);
            Assert.assertArrayEquals(data, loaded);
        }
    } finally {
        stopAllGrids();
    }
}
Also used : PA(org.apache.ignite.internal.util.typedef.PA) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteProcessProxy(org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy)

Example 5 with IgniteProcessProxy

use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.

the class GridAbstractTest method stopGrid.

/**
 * @param igniteInstanceName Ignite instance name.
 * @param cancel Cancel flag.
 * @param awaitTop Await topology change flag.
 */
@SuppressWarnings({ "deprecation" })
protected void stopGrid(@Nullable String igniteInstanceName, boolean cancel, boolean awaitTop) {
    try {
        IgniteEx ignite = grid(igniteInstanceName);
        assert ignite != null : "Ignite returned null grid for name: " + igniteInstanceName;
        UUID id = ignite instanceof IgniteProcessProxy ? ignite.localNode().id() : ignite.context().localNodeId();
        info(">>> Stopping grid [name=" + ignite.name() + ", id=" + id + ']');
        if (!isRemoteJvm(igniteInstanceName))
            G.stop(igniteInstanceName, cancel);
        else
            IgniteProcessProxy.stop(igniteInstanceName, cancel);
        if (awaitTop)
            awaitTopologyChange();
    } catch (IllegalStateException ignored) {
    // Ignore error if grid already stopped.
    } catch (Throwable e) {
        error("Failed to stop grid [igniteInstanceName=" + igniteInstanceName + ", cancel=" + cancel + ']', e);
        stopGridErr = true;
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) UUID(java.util.UUID) IgniteProcessProxy(org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy)

Aggregations

IgniteProcessProxy (org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy)10 IgniteEx (org.apache.ignite.internal.IgniteEx)8 UUID (java.util.UUID)4 Ignite (org.apache.ignite.Ignite)4 ArrayList (java.util.ArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 IgniteCompute (org.apache.ignite.IgniteCompute)2 PA (org.apache.ignite.internal.util.typedef.PA)2 File (java.io.File)1 ObjectStreamException (java.io.ObjectStreamException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 TimeUnit (java.util.concurrent.TimeUnit)1