Search in sources :

Example 1 with StopNodeOrHaltFailureHandler

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

the class CacheDataRegionConfigurationTest method testNoFailNodeIfUnknownDataRegion.

/**
 * Test checks that nodes will not fall if you receive a request
 * to create a cache with an unknown data region.
 *
 * @throws Exception If failed.
 */
@Test
public void testNoFailNodeIfUnknownDataRegion() throws Exception {
    failureHnd = new StopNodeOrHaltFailureHandler();
    ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true));
    LogListener logLsnr = matches("Possible failure suppressed accordingly to a configured handler").build();
    logger = new ListeningTestLogger(false, log, logLsnr);
    IgniteEx srvNode = startGrid(0);
    String dataRegionName = "region";
    IgniteConfiguration clientCfg = getConfiguration(getTestIgniteInstanceName(1)).setDataStorageConfiguration(new DataStorageConfiguration().setDataRegionConfigurations(new DataRegionConfiguration().setName(dataRegionName)).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
    IgniteEx clientNode = startClientGrid(optimize(clientCfg));
    srvNode.cluster().active(true);
    assertThrows(log, () -> {
        clientNode.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME + 1).setDataRegionName(dataRegionName));
        return null;
    }, CacheException.class, null);
    assertThrows(log, () -> {
        clientNode.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME + 1).setDataRegionName(UUID.randomUUID().toString()));
        return null;
    }, CacheException.class, null);
    IgniteCache<Object, Object> cacheSrv = srvNode.cache(DEFAULT_CACHE_NAME);
    IgniteCache<Object, Object> cacheClient = clientNode.cache(DEFAULT_CACHE_NAME);
    cacheSrv.put(1, 1);
    assertEquals(1, cacheSrv.get(1));
    cacheClient.put(2, 2);
    assertEquals(2, cacheClient.get(2));
    assertFalse(logLsnr.check());
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) LogListener(org.apache.ignite.testframework.LogListener) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) StopNodeOrHaltFailureHandler(org.apache.ignite.failure.StopNodeOrHaltFailureHandler) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with StopNodeOrHaltFailureHandler

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

the class ClientFastReplyCoordinatorFailureTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setFailureHandler(new StopNodeOrHaltFailureHandler());
    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
    TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
    // Block messages to old coordinator right before killing it.
    if (igniteInstanceName.contains("client")) {
        commSpi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {

            @Override
            public boolean apply(ClusterNode node, Message msg) {
                if (msg instanceof GridDhtPartitionsSingleMessage && (node.id().getLeastSignificantBits() & OLD_CRD_BITS) == 0) {
                    info("Going to block message [node=" + node + ", msg=" + msg + ']');
                    clientSingleMesssageLatch.countDown();
                    return true;
                }
                return false;
            }
        });
        if (delayNodeFailedMsg) {
            TcpDiscoverySpi spi = new TestDiscoverySpi();
            spi.setIpFinder(IP_FINDER);
            cfg.setDiscoverySpi(spi);
        }
    } else if (getTestIgniteInstanceName(3).equals(igniteInstanceName)) {
        commSpi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {

            @Override
            public boolean apply(ClusterNode node, Message msg) {
                if (msg instanceof GridDhtPartitionsSingleMessage && (node.id().getLeastSignificantBits() & OLD_CRD_BITS) == 0L) {
                    info("Going to block message [node=" + node + ", msg=" + msg + ']');
                    newSrvSingleMesssageLatch.countDown();
                    return true;
                }
                return false;
            }
        });
    } else if (delayNodeFailedMsg) {
        commSpi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {

            @Override
            public boolean apply(ClusterNode node, Message msg) {
                if (msg instanceof GridDhtPartitionsSingleRequest && node.isClient()) {
                    GridTestUtils.runAsync(() -> {
                        try {
                            Thread.sleep(1_000);
                        } catch (InterruptedException ignore) {
                        // No-op.
                        }
                        PART_SINGLE_REQ_MSG_LATCH.countDown();
                    });
                }
                return false;
            }
        });
    }
    cfg.setCommunicationSpi(commSpi);
    return cfg;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) TcpDiscoveryNodeFailedMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage) GridDhtPartitionsSingleMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage) TcpDiscoveryAbstractMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) TcpDiscoveryNodeLeftMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeLeftMessage) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) StopNodeOrHaltFailureHandler(org.apache.ignite.failure.StopNodeOrHaltFailureHandler) GridDhtPartitionsSingleMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridDhtPartitionsSingleRequest(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleRequest) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 3 with StopNodeOrHaltFailureHandler

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

the class ClusterReadOnlyModeAbstractTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setCacheConfiguration(ClusterReadOnlyModeTestUtils.cacheConfigurations());
    cfg.setFailureHandler(new StopNodeOrHaltFailureHandler());
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) StopNodeOrHaltFailureHandler(org.apache.ignite.failure.StopNodeOrHaltFailureHandler)

Example 4 with StopNodeOrHaltFailureHandler

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

the class IgniteCacheExpireWhileRebalanceTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    cfg.setFailureHandler(new StopNodeOrHaltFailureHandler());
    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    ccfg.setAtomicityMode(ATOMIC);
    ccfg.setCacheMode(PARTITIONED);
    ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));
    cfg.setCacheConfiguration(ccfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) StopNodeOrHaltFailureHandler(org.apache.ignite.failure.StopNodeOrHaltFailureHandler) Duration(javax.cache.expiry.Duration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 5 with StopNodeOrHaltFailureHandler

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

the class CacheScanQueryFailoverTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String name) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(name);
    cfg.setConsistentId(name);
    cfg.setFailureHandler(new StopNodeOrHaltFailureHandler());
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) StopNodeOrHaltFailureHandler(org.apache.ignite.failure.StopNodeOrHaltFailureHandler)

Aggregations

StopNodeOrHaltFailureHandler (org.apache.ignite.failure.StopNodeOrHaltFailureHandler)7 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)5 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)2 AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)2 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)2 ExecutorConfiguration (org.apache.ignite.configuration.ExecutorConfiguration)2 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)2 NoOpFailureHandler (org.apache.ignite.failure.NoOpFailureHandler)2 StopNodeFailureHandler (org.apache.ignite.failure.StopNodeFailureHandler)2 PlatformDotNetBinaryConfiguration (org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration)2 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 NoopEventStorageSpi (org.apache.ignite.spi.eventstorage.NoopEventStorageSpi)2 MemoryEventStorageSpi (org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi)2 Serializable (java.io.Serializable)1 Map (java.util.Map)1 Duration (javax.cache.expiry.Duration)1