Search in sources :

Example 46 with FailureContext

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());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) FailureContext(org.apache.ignite.failure.FailureContext) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 47 with FailureContext

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());
}
Also used : FailureContext(org.apache.ignite.failure.FailureContext) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 48 with FailureContext

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());
}
Also used : FailureContext(org.apache.ignite.failure.FailureContext) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 49 with FailureContext

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FailureContext(org.apache.ignite.failure.FailureContext) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) Ignite(org.apache.ignite.Ignite)

Example 50 with FailureContext

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));
        }
    }
}
Also used : FailureContext(org.apache.ignite.failure.FailureContext) FailureProcessor(org.apache.ignite.internal.processors.failure.FailureProcessor)

Aggregations

FailureContext (org.apache.ignite.failure.FailureContext)54 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)20 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)13 Ignite (org.apache.ignite.Ignite)11 IOException (java.io.IOException)9 AbstractFailureHandler (org.apache.ignite.failure.AbstractFailureHandler)9 IgniteEx (org.apache.ignite.internal.IgniteEx)9 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)9 Test (org.junit.Test)9 IgniteException (org.apache.ignite.IgniteException)8 File (java.io.File)6 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)6 StorageException (org.apache.ignite.internal.processors.cache.persistence.StorageException)6 LogListener (org.apache.ignite.testframework.LogListener)5 WithSystemProperty (org.apache.ignite.testframework.junits.WithSystemProperty)4 ByteBuffer (java.nio.ByteBuffer)3 UUID (java.util.UUID)3 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)3 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)3 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)3