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());
}
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;
}
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;
}
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;
}
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;
}
Aggregations