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