Search in sources :

Example 1 with TestFailureHandler

use of org.apache.ignite.failure.TestFailureHandler in project ignite by apache.

the class IgniteClientRejoinTest method testClientsReconnectDisabled.

/**
 * @throws Exception If failed.
 */
@Test
public void testClientsReconnectDisabled() throws Exception {
    clientReconnectDisabled = true;
    Ignite srv1 = startGrid("server1");
    if (!tcpDiscovery())
        return;
    crd = ((IgniteKernal) srv1).localNode();
    Ignite srv2 = startGrid("server2");
    block = true;
    List<IgniteInternalFuture<Ignite>> futs = new ArrayList<>();
    final CountDownLatch latch = new CountDownLatch(1);
    final int CLIENTS_NUM = 5;
    final CountDownLatch failureHndLatch = new CountDownLatch(CLIENTS_NUM);
    for (int i = 0; i < CLIENTS_NUM; i++) {
        final int idx = i;
        IgniteInternalFuture<Ignite> fut = GridTestUtils.runAsync(new Callable<Ignite>() {

            @Override
            public Ignite call() throws Exception {
                latch.await();
                String igniteInstanceName = "client" + idx;
                return startClientGrid(igniteInstanceName, getConfiguration(igniteInstanceName).setFailureHandler(new TestFailureHandler(true, failureHndLatch)));
            }
        });
        futs.add(fut);
    }
    latch.countDown();
    for (final IgniteInternalFuture<Ignite> clientFut : futs) {
        // noinspection ThrowableNotThrown
        GridTestUtils.assertThrows(log, new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                clientFut.get();
                return null;
            }
        }, IgniteCheckedException.class, null);
    }
    assertTrue(failureHndLatch.await(1000, TimeUnit.MILLISECONDS));
    assertEquals(0, srv1.cluster().forClients().nodes().size());
    assertEquals(0, srv2.cluster().forClients().nodes().size());
}
Also used : ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) SocketException(java.net.SocketException) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException) IgniteSpiOperationTimeoutException(org.apache.ignite.spi.IgniteSpiOperationTimeoutException) TestFailureHandler(org.apache.ignite.failure.TestFailureHandler) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with TestFailureHandler

use of org.apache.ignite.failure.TestFailureHandler in project ignite by apache.

the class GridCacheContinuousQueryNodesFilteringTest method testNodeWithAttributeFailure.

/**
 * Test that node matched by filter and having filter instantiation problems fails for sure.
 *
 * @throws Exception if failed.
 */
@Test
public void testNodeWithAttributeFailure() throws Exception {
    try (Ignite node1 = startNodeWithCache()) {
        CountDownLatch latch = new CountDownLatch(1);
        FailureHandler failHnd = new TestFailureHandler(false, latch);
        IgniteConfiguration node2Cfg = getConfiguration("node2", true, null).setFailureHandler(failHnd);
        try (Ignite node2 = startGrid(node2Cfg)) {
            assertTrue("Failure handler hasn't been invoked on the joined node.", latch.await(5, TimeUnit.SECONDS));
        }
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TestFailureHandler(org.apache.ignite.failure.TestFailureHandler) FailureHandler(org.apache.ignite.failure.FailureHandler) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) TestFailureHandler(org.apache.ignite.failure.TestFailureHandler) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with TestFailureHandler

use of org.apache.ignite.failure.TestFailureHandler in project ignite by apache.

the class FailureProcessorLoggingTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TestFailureHandler hnd = new TestFailureHandler(false);
    testLog = new CustomTestLogger(log);
    hnd.setIgnoredFailureTypes(ImmutableSet.of(FailureType.SYSTEM_CRITICAL_OPERATION_TIMEOUT, FailureType.SYSTEM_WORKER_BLOCKED));
    cfg.setFailureHandler(hnd);
    cfg.setGridLogger(testLog);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TestFailureHandler(org.apache.ignite.failure.TestFailureHandler)

Example 4 with TestFailureHandler

use of org.apache.ignite.failure.TestFailureHandler in project ignite by apache.

the class IgniteWalFormatFileFailoverTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    cfg.setCacheConfiguration(new CacheConfiguration(TEST_CACHE).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
    DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(2048L * 1024 * 1024).setPersistenceEnabled(true)).setWalMode(fsync ? WALMode.FSYNC : WALMode.BACKGROUND).setWalBufferSize(1024 * 1024).setWalSegmentSize(512 * 1024).setFileIOFactory(new FailingFileIOFactory(failMtdNameRef));
    cfg.setDataStorageConfiguration(memCfg);
    cfg.setFailureHandler(new TestFailureHandler(false));
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TestFailureHandler(org.apache.ignite.failure.TestFailureHandler)

Example 5 with TestFailureHandler

use of org.apache.ignite.failure.TestFailureHandler in project ignite by apache.

the class FailureProcessorThreadDumpThrottlingTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TestFailureHandler hnd = new TestFailureHandler(false);
    hnd.setIgnoredFailureTypes(ImmutableSet.of(FailureType.SYSTEM_CRITICAL_OPERATION_TIMEOUT, SYSTEM_WORKER_BLOCKED));
    cfg.setFailureHandler(hnd);
    cfg.setGridLogger(testLog);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TestFailureHandler(org.apache.ignite.failure.TestFailureHandler)

Aggregations

TestFailureHandler (org.apache.ignite.failure.TestFailureHandler)7 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)3 Test (org.junit.Test)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Ignite (org.apache.ignite.Ignite)2 FailureHandler (org.apache.ignite.failure.FailureHandler)2 IOException (java.io.IOException)1 SocketException (java.net.SocketException)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)1 IgniteException (org.apache.ignite.IgniteException)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)1 IgniteSpiOperationTimeoutException (org.apache.ignite.spi.IgniteSpiOperationTimeoutException)1