use of org.apache.ignite.failure.FailureContext in project ignite by apache.
the class FailureProcessorThreadDumpThrottlingTest method testNoThreadDumps.
/**
* Tests that thread dumps will not get if {@code IGNITE_DUMP_THREADS_ON_FAILURE == false}.
*/
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, value = "false")
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE_THROTTLING_TIMEOUT, value = "0")
public void testNoThreadDumps() throws Exception {
LogListener lsnr = LogListener.matches(THREAD_DUMP_MSG).times(0).build();
testLog.registerListener(lsnr);
IgniteEx ignite = ignite(0);
FailureContext failureCtx = new FailureContext(SYSTEM_WORKER_BLOCKED, new Throwable("Failure context error"));
for (int i = 0; i < 2; i++) ignite.context().failure().process(failureCtx);
assertTrue(lsnr.check());
}
use of org.apache.ignite.failure.FailureContext in project ignite by apache.
the class FailureProcessorLoggingTest method testFailureProcessorLoggedIgnoredFailureTest.
/**
* Tests log message for ignored failure types.
*/
@Test
public void testFailureProcessorLoggedIgnoredFailureTest() throws Exception {
IgniteEx ignite = grid(0);
testLog.expectedWarnMessage(IGNORED_FAILURE_LOG_MSG);
ignite.context().failure().process(new FailureContext(FailureType.SYSTEM_CRITICAL_OPERATION_TIMEOUT, new Throwable("Failure context error")));
assertTrue(testLog.warnFlag().get());
assertTrue(testLog.threadDumpWarnFlag().get());
}
use of org.apache.ignite.failure.FailureContext in project ignite by apache.
the class FailureProcessorLoggingTest method testFailureProcessorLoggedFailureTest.
/**
* Tests log message for not ingnored failure types.
*/
@Test
public void testFailureProcessorLoggedFailureTest() throws Exception {
IgniteEx ignite = grid(0);
testLog.expectedErrorMessage(FAILURE_LOG_MSG);
ignite.context().failure().process(new FailureContext(FailureType.SEGMENTATION, new Throwable("Failure context error")));
assertTrue(testLog.errorFlag().get());
assertTrue(testLog.threadDumpErrorFlag().get());
}
use of org.apache.ignite.failure.FailureContext in project ignite by apache.
the class CacheGetReadFromBackupFailoverTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setFailureHandler(new AbstractFailureHandler() {
@Override
protected boolean handle(Ignite ignite, FailureContext failureCtx) {
err.compareAndSet(null, failureCtx.error());
stop.set(true);
return false;
}
});
cfg.setConsistentId(igniteInstanceName);
CacheConfiguration<Long, Long> txCcfg = new CacheConfiguration<Long, Long>(TX_CACHE).setAtomicityMode(TRANSACTIONAL).setCacheMode(PARTITIONED).setBackups(1).setWriteSynchronizationMode(FULL_SYNC).setReadFromBackup(true);
CacheConfiguration<Long, Long> atomicCcfg = new CacheConfiguration<Long, Long>(ATOMIC_CACHE).setAtomicityMode(ATOMIC).setCacheMode(PARTITIONED).setBackups(1).setWriteSynchronizationMode(FULL_SYNC).setReadFromBackup(true);
cfg.setCacheConfiguration(txCcfg, atomicCcfg);
// Enforce different mac adresses to emulate distributed environment by default.
cfg.setUserAttributes(Collections.singletonMap(IgniteNodeAttributes.ATTR_MACS_OVERRIDE, UUID.randomUUID().toString()));
return cfg;
}
use of org.apache.ignite.failure.FailureContext in project ignite by apache.
the class CommunicationWorker method body.
/**
* Connection stat processing.
*/
@Override
protected void body() throws InterruptedException {
if (log.isDebugEnabled())
log.debug("Tcp communication worker has been started.");
Throwable err = null;
try {
while (!isCancelled()) {
DisconnectedSessionInfo disconnectData;
blockingSectionBegin();
try {
disconnectData = q.poll(cfg.idleConnectionTimeout(), TimeUnit.MILLISECONDS);
} finally {
blockingSectionEnd();
}
if (disconnectData != null)
processDisconnect(disconnectData);
else
processIdle();
onIdle();
}
} catch (Throwable t) {
if (!(t instanceof InterruptedException))
err = t;
throw t;
} finally {
FailureProcessor failureProcessor = failureProcessorSupplier.get();
if (failureProcessor != null) {
if (err == null && !stopping)
err = new IllegalStateException("Thread " + spiName + " is terminated unexpectedly.");
if (err instanceof OutOfMemoryError)
failureProcessor.process(new FailureContext(CRITICAL_ERROR, err));
else if (err != null)
failureProcessor.process(new FailureContext(SYSTEM_WORKER_TERMINATION, err));
}
}
}
Aggregations