use of org.apache.ignite.failure.FailureContext 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.FailureContext in project ignite by apache.
the class DistributedProcess method sendSingleMessage.
/**
* Sends single node message to coordinator.
*
* @param p Process.
*/
private void sendSingleMessage(Process p) {
assert p.resFut.isDone();
SingleNodeMessage<R> singleMsg = new SingleNodeMessage<>(p.id, type, p.resFut.result(), (Exception) p.resFut.error());
UUID crdId = p.crdId;
if (F.eq(ctx.localNodeId(), crdId))
onSingleNodeMessageReceived(singleMsg, crdId);
else {
try {
ctx.io().sendToGridTopic(crdId, GridTopic.TOPIC_DISTRIBUTED_PROCESS, singleMsg, SYSTEM_POOL);
} catch (ClusterTopologyCheckedException e) {
// The coordinator has failed. The single message will be sent when a new coordinator initialized.
if (log.isDebugEnabled()) {
log.debug("Failed to send a single message to coordinator: [crdId=" + crdId + ", processId=" + p.id + ", error=" + e.getMessage() + ']');
}
} catch (IgniteCheckedException e) {
log.error("Unable to send message to coordinator.", e);
ctx.failure().process(new FailureContext(CRITICAL_ERROR, new Exception("Unable to send message to coordinator.", e)));
}
}
}
use of org.apache.ignite.failure.FailureContext 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());
}
use of org.apache.ignite.failure.FailureContext in project ignite by apache.
the class IgnitePdsTaskCancelingTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setFailureHandler(new AbstractFailureHandler() {
@Override
protected boolean handle(Ignite ignite, FailureContext failureCtx) {
failure.set(true);
return true;
}
});
cfg.setCacheConfiguration(new CacheConfiguration().setName(DEFAULT_CACHE_NAME).setAffinity(new RendezvousAffinityFunction(false, NUM_TASKS / 2)));
cfg.setDataStorageConfiguration(getDataStorageConfiguration());
// Set the thread pool size according to the NUM_TASKS.
cfg.setPublicThreadPoolSize(16);
return cfg;
}
use of org.apache.ignite.failure.FailureContext in project ignite by apache.
the class FailureProcessorThreadDumpThrottlingTest method testThrottlingPerFailureType.
/**
* Tests that thread dumps will be throttled per failure type and will be generated again after timeout exceeded.
*/
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, value = "true")
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE_THROTTLING_TIMEOUT, value = "3000")
public void testThrottlingPerFailureType() throws Exception {
LogListener dumpLsnr = LogListener.matches(THREAD_DUMP_MSG).times(4).build();
LogListener throttledLsnr = LogListener.matches("Thread dump is hidden").times(4).build();
testLog.registerListener(dumpLsnr);
testLog.registerListener(throttledLsnr);
IgniteEx ignite = ignite(0);
FailureContext workerBlockedFailureCtx = new FailureContext(SYSTEM_WORKER_BLOCKED, new Throwable("Failure context error"));
FailureContext opTimeoutFailureCtx = new FailureContext(SYSTEM_CRITICAL_OPERATION_TIMEOUT, new Throwable("Failure context error"));
for (int i = 0; i < 2; i++) {
ignite.context().failure().process(workerBlockedFailureCtx);
ignite.context().failure().process(opTimeoutFailureCtx);
}
U.sleep(3000);
for (int i = 0; i < 2; i++) {
ignite.context().failure().process(workerBlockedFailureCtx);
ignite.context().failure().process(opTimeoutFailureCtx);
}
assertTrue(dumpLsnr.check());
assertTrue(throttledLsnr.check());
}
Aggregations