Search in sources :

Example 1 with AbstractFailureHandler

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

the class IgniteExchangeLatchManagerDiscoHistoryTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoveryIpFinder ipFinder = ((TcpDiscoverySpi) cfg.getDiscoverySpi()).getIpFinder();
    int topHistSize = victim ? TOPOLOGY_HISTORY_SIZE : TcpDiscoverySpi.DFLT_TOP_HISTORY_SIZE;
    CustomTcpDiscoverySpi discoSpi = new CustomTcpDiscoverySpi(topHistSize, ipFinder);
    cfg.setDiscoverySpi(discoSpi);
    if (victim) {
        cfg.setFailureHandler(new AbstractFailureHandler() {

            /**
             * {@inheritDoc}
             */
            @Override
            protected boolean handle(Ignite ignite, FailureContext failureCtx) {
                cpFailureCtx.compareAndSet(null, failureCtx);
                // Invalidate kernel context.
                return true;
            }
        });
        cfg.setLifecycleBeans(lifecycleBean);
        disco = discoSpi;
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FailureContext(org.apache.ignite.failure.FailureContext) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) Ignite(org.apache.ignite.Ignite) TcpDiscoveryIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder) TestTcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 2 with AbstractFailureHandler

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

the class OutOfMemoryVolatileRegionTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    cfg.setDataStorageConfiguration(new DataStorageConfiguration().setPageSize(4096).setSystemDataRegionConfiguration(new SystemDataRegionConfiguration().setInitialSize(DATA_REGION_SIZE).setMaxSize(DATA_REGION_SIZE)).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true).setMetricsEnabled(true)));
    cfg.setFailureHandler(new AbstractFailureHandler() {

        /**
         * {@inheritDoc}
         */
        @Override
        protected boolean handle(Ignite ignite, FailureContext failureCtx) {
            failure = true;
            // Do not invalidate a node context.
            return false;
        }
    });
    cfg.setCacheConfiguration(cacheConfiguration(ATOMIC), cacheConfiguration(TRANSACTIONAL));
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) SystemDataRegionConfiguration(org.apache.ignite.configuration.SystemDataRegionConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) SystemDataRegionConfiguration(org.apache.ignite.configuration.SystemDataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FailureContext(org.apache.ignite.failure.FailureContext) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) Ignite(org.apache.ignite.Ignite)

Example 3 with AbstractFailureHandler

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

the class CacheNoAffinityExchangeTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
    cfg.setDiscoverySpi(new TestDiscoverySpi().setIpFinder(IP_FINDER));
    cfg.setClusterStateOnStart(INACTIVE);
    cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(200 * 1024 * 1024)));
    if (cfg.isClientMode()) {
        TestRecordingCommunicationSpi customSpi = clientCommSpi;
        if (customSpi != null)
            cfg.setCommunicationSpi(customSpi);
        // It is necessary to ensure that client always connects to grid(0).
        ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(CLIENT_IP_FINDER);
        if (startClientCaches) {
            CacheConfiguration<Integer, Integer> txCfg = new CacheConfiguration<Integer, Integer>().setName(PARTITIONED_TX_CLIENT_CACHE_NAME).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC).setAffinity(new RendezvousAffinityFunction(false, 32)).setBackups(2);
            cfg.setCacheConfiguration(txCfg);
        }
    }
    cfg.setFailureHandler(new AbstractFailureHandler() {

        /**
         * {@inheritDoc}
         */
        @Override
        protected boolean handle(Ignite ignite, FailureContext failureCtx) {
            errs.put(ignite.configuration().getIgniteInstanceName(), failureCtx.error());
            return false;
        }
    });
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FailureContext(org.apache.ignite.failure.FailureContext) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) Ignite(org.apache.ignite.Ignite) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 4 with AbstractFailureHandler

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

the class CacheIgniteOutOfMemoryExceptionTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(DATA_REGION_SIZE).setPageEvictionMode(DISABLED).setPersistenceEnabled(false)));
    cfg.setFailureHandler(new AbstractFailureHandler() {

        /**
         * {@inheritDoc}
         */
        @Override
        protected boolean handle(Ignite ignite, FailureContext failureCtx) {
            failure.set(true);
            // Do not invalidate a node context.
            return false;
        }
    });
    cfg.setCacheConfiguration(cacheConfiguration(ATOMIC), cacheConfiguration(TRANSACTIONAL));
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FailureContext(org.apache.ignite.failure.FailureContext) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) Ignite(org.apache.ignite.Ignite)

Example 5 with AbstractFailureHandler

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

the class IgniteClientRejoinTest method testClientsReconnect.

/**
 * @throws Exception If failed.
 */
@Test
public void testClientsReconnect() throws Exception {
    Ignite srv1 = startGrid("server1");
    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;
    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 nodeName = "client" + idx;
                IgniteConfiguration cfg = getConfiguration(nodeName).setFailureHandler(new AbstractFailureHandler() {

                    @Override
                    protected boolean handle(Ignite ignite, FailureContext failureCtx) {
                        // This should _not_ fire when exchange-worker terminates before reconnect.
                        Runtime.getRuntime().halt(Ignition.KILL_EXIT_CODE);
                        return false;
                    }
                });
                return startClientGrid(nodeName, optimize(cfg));
            }
        });
        futs.add(fut);
    }
    GridTestUtils.runAsync(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            latch.countDown();
            Random rnd = new Random();
            U.sleep((rnd.nextInt(15) + 15) * 1000);
            block = false;
            System.out.println(">>> ALLOW connection to coordinator.");
            return true;
        }
    });
    for (IgniteInternalFuture<Ignite> clientFut : futs) {
        Ignite client = clientFut.get();
        IgniteCache<Integer, Integer> cache = client.getOrCreateCache(client.name());
        for (int i = 0; i < 100; i++) cache.put(i, i);
        for (int i = 0; i < 100; i++) assert i == cache.get(i);
    }
    assertEquals(CLIENTS_NUM, srv1.cluster().forClients().nodes().size());
    assertEquals(CLIENTS_NUM, 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) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Random(java.util.Random) FailureContext(org.apache.ignite.failure.FailureContext) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

Ignite (org.apache.ignite.Ignite)9 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)9 AbstractFailureHandler (org.apache.ignite.failure.AbstractFailureHandler)9 FailureContext (org.apache.ignite.failure.FailureContext)9 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)3 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)3 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 IOException (java.io.IOException)1 SocketException (java.net.SocketException)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)1 IgniteException (org.apache.ignite.IgniteException)1 SystemDataRegionConfiguration (org.apache.ignite.configuration.SystemDataRegionConfiguration)1 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)1 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)1