Search in sources :

Example 6 with WorkersRegistry

use of org.apache.ignite.internal.worker.WorkersRegistry in project ignite by apache.

the class FailureHandlingConfigurationTest method testOverridingBySysProps.

/**
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT, value = "80000")
@WithSystemProperty(key = IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT, value = "90000")
public void testOverridingBySysProps() throws Exception {
    sysWorkerBlockedTimeout = 1L;
    checkpointReadLockTimeout = 2L;
    IgniteEx ignite = startGrid(0);
    ignite.cluster().active(true);
    WorkersRegistry reg = ignite.context().workersRegistry();
    IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
    FailureHandlingMxBean mBean = getMBean();
    assertEquals(sysWorkerBlockedTimeout, ignite.configuration().getSystemWorkerBlockedTimeout());
    assertEquals(checkpointReadLockTimeout, ignite.configuration().getDataStorageConfiguration().getCheckpointReadLockTimeout());
    long workerPropVal = Long.getLong(IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT);
    long checkpointPropVal = Long.getLong(IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT);
    assertEquals(workerPropVal, reg.getSystemWorkerBlockedTimeout());
    assertEquals(checkpointPropVal, dbMgr.checkpointReadLockTimeout());
    assertEquals(workerPropVal, mBean.getSystemWorkerBlockedTimeout());
    assertEquals(checkpointPropVal, mBean.getCheckpointReadLockTimeout());
}
Also used : WorkersRegistry(org.apache.ignite.internal.worker.WorkersRegistry) FailureHandlingMxBean(org.apache.ignite.mxbean.FailureHandlingMxBean) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 7 with WorkersRegistry

use of org.apache.ignite.internal.worker.WorkersRegistry in project ignite by apache.

the class FailureHandlingConfigurationTest method testNegativeParamValues.

/**
 * @throws Exception If failed.
 */
@Test
public void testNegativeParamValues() throws Exception {
    sysWorkerBlockedTimeout = -1L;
    checkpointReadLockTimeout = -85L;
    IgniteEx ignite = startGrid(0);
    ignite.cluster().active(true);
    WorkersRegistry reg = ignite.context().workersRegistry();
    IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
    FailureHandlingMxBean mBean = getMBean();
    assertEquals(0L, reg.getSystemWorkerBlockedTimeout());
    assertEquals(-85L, dbMgr.checkpointReadLockTimeout());
    assertEquals(0L, mBean.getSystemWorkerBlockedTimeout());
    assertEquals(-85L, mBean.getCheckpointReadLockTimeout());
}
Also used : WorkersRegistry(org.apache.ignite.internal.worker.WorkersRegistry) FailureHandlingMxBean(org.apache.ignite.mxbean.FailureHandlingMxBean) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 8 with WorkersRegistry

use of org.apache.ignite.internal.worker.WorkersRegistry in project ignite by apache.

the class SystemWorkersBlockingTest method testBlockingWorker.

/**
 * @throws Exception If failed.
 */
@Test
public void testBlockingWorker() throws Exception {
    IgniteEx ignite = startGrid(0);
    GridWorker worker = new LatchingGridWorker(ignite);
    runWorker(worker);
    ignite.context().workersRegistry().register(worker);
    assertTrue(hndLatch.await(ignite.configuration().getFailureDetectionTimeout() * 2, TimeUnit.MILLISECONDS));
    Throwable blockedExeption = failureError.get();
    assertNotNull(blockedExeption);
    assertTrue(Arrays.stream(blockedExeption.getStackTrace()).anyMatch(e -> CountDownLatch.class.getName().equals(e.getClassName())));
    assertTrue(Arrays.stream(blockedExeption.getStackTrace()).anyMatch(e -> LatchingGridWorker.class.getName().equals(e.getClassName())));
}
Also used : Arrays(java.util.Arrays) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Set(java.util.Set) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) AtomicReference(java.util.concurrent.atomic.AtomicReference) GridWorker(org.apache.ignite.internal.util.worker.GridWorker) Executors(java.util.concurrent.Executors) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) LockSupport(java.util.concurrent.locks.LockSupport) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) WorkersRegistry(org.apache.ignite.internal.worker.WorkersRegistry) ExecutorService(java.util.concurrent.ExecutorService) IgniteEx(org.apache.ignite.internal.IgniteEx) CountDownLatch(java.util.concurrent.CountDownLatch) GridWorker(org.apache.ignite.internal.util.worker.GridWorker) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 9 with WorkersRegistry

use of org.apache.ignite.internal.worker.WorkersRegistry in project ignite by apache.

the class SystemWorkersTerminationTest method testSyntheticWorkerTermination.

/**
 * @throws Exception If failed.
 */
@Test
public void testSyntheticWorkerTermination() throws Exception {
    IgniteEx ignite = grid(0);
    WorkersRegistry registry = ignite.context().workersRegistry();
    long fdTimeout = ignite.configuration().getFailureDetectionTimeout();
    GridWorker worker = new GridWorker(ignite.name(), "test-worker", log, registry) {

        @Override
        protected void body() throws InterruptedException {
            Thread.sleep(fdTimeout / 2);
        }
    };
    IgniteThread thread = new IgniteThread(worker);
    failureHndThreadName = null;
    thread.start();
    thread.join();
    assertTrue(GridTestUtils.waitForCondition(() -> thread.getName().equals(failureHndThreadName), fdTimeout * 2));
}
Also used : WorkersRegistry(org.apache.ignite.internal.worker.WorkersRegistry) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteThread(org.apache.ignite.thread.IgniteThread) GridWorker(org.apache.ignite.internal.util.worker.GridWorker) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

WorkersRegistry (org.apache.ignite.internal.worker.WorkersRegistry)9 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)7 Test (org.junit.Test)7 IgniteEx (org.apache.ignite.internal.IgniteEx)6 IgniteCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)4 FailureHandlingMxBean (org.apache.ignite.mxbean.FailureHandlingMxBean)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 GridWorker (org.apache.ignite.internal.util.worker.GridWorker)3 HashSet (java.util.HashSet)2 Set (java.util.Set)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 U (org.apache.ignite.internal.util.typedef.internal.U)2 IOException (java.io.IOException)1 UncaughtExceptionHandler (java.lang.Thread.UncaughtExceptionHandler)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ByteOrder (java.nio.ByteOrder)1