Search in sources :

Example 21 with ACTIVE

use of org.apache.ignite.cluster.ClusterState.ACTIVE in project ignite by apache.

the class IgniteDataStorageMetricsSelfTest method testWalTotalSizeWithArchiveTurnedOff.

/**
 * Check whether Wal is reporting correct usage when WAL Archive is turned off.
 *
 * @throws Exception If failed.
 */
@Test
public void testWalTotalSizeWithArchiveTurnedOff() throws Exception {
    IgniteEx n = startGrid(0, (Consumer<IgniteConfiguration>) cfg -> cfg.getDataStorageConfiguration().setWalArchivePath(cfg.getDataStorageConfiguration().getWalPath()).setWalSegmentSize((int) (2 * U.MB)));
    n.cluster().state(ACTIVE);
    populateCache(n);
    disableWal(n, true);
    checkWalArchiveAndTotalSize(n, false);
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Arrays(java.util.Arrays) UnaryOperator(java.util.function.UnaryOperator) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) Matcher(java.util.regex.Matcher) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) DataStorageMetricsMXBean(org.apache.ignite.mxbean.DataStorageMetricsMXBean) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) WALMode(org.apache.ignite.configuration.WALMode) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) QuerySqlField(org.apache.ignite.cache.query.annotations.QuerySqlField) Collections.emptyList(java.util.Collections.emptyList) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) IgniteCache(org.apache.ignite.IgniteCache) Serializable(java.io.Serializable) Objects(java.util.Objects) DataRegionMetrics(org.apache.ignite.DataRegionMetrics) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Pattern(java.util.regex.Pattern) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) LongGauge(org.apache.ignite.internal.processors.metric.impl.LongGauge) WALDisableContext(org.apache.ignite.internal.processors.cache.WalStateManager.WALDisableContext) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) U(org.apache.ignite.internal.util.typedef.internal.U) HEADER_RECORD_SIZE(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.HEADER_RECORD_SIZE) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) PAX(org.apache.ignite.internal.util.typedef.PAX) S(org.apache.ignite.internal.util.typedef.internal.S) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) SegmentRouter(org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) DataStorageMetrics(org.apache.ignite.DataStorageMetrics) Test(org.junit.Test) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) File(java.io.File) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridTestUtils.setFieldValue(org.apache.ignite.testframework.GridTestUtils.setFieldValue) ATOMIC(org.apache.ignite.cache.CacheAtomicityMode.ATOMIC) DATASTORAGE_METRIC_PREFIX(org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl.DATASTORAGE_METRIC_PREFIX) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) CacheMode(org.apache.ignite.cache.CacheMode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 22 with ACTIVE

use of org.apache.ignite.cluster.ClusterState.ACTIVE in project ignite by apache.

the class IgniteDataStorageMetricsSelfTest method testWalWrittenBytes.

/**
 * Checking that the metrics of the total logged bytes are working correctly.
 *
 * @throws Exception If failed.
 */
@Test
public void testWalWrittenBytes() throws Exception {
    IgniteEx n = startGrid(0, (UnaryOperator<IgniteConfiguration>) cfg -> {
        cfg.getDataStorageConfiguration().setWalSegmentSize((int) (2 * U.MB));
        return cfg;
    });
    n.cluster().state(ACTIVE);
    awaitPartitionMapExchange();
    for (int i = 0; i < 10; i++) n.cache("cache").put(ThreadLocalRandom.current().nextLong(), new byte[(int) (32 * U.KB)]);
    WALDisableContext walDisableCtx = n.context().cache().context().walState().walDisableContext();
    assertNotNull(walDisableCtx);
    setFieldValue(walDisableCtx, "disableWal", true);
    assertTrue(walDisableCtx.check());
    assertNull(walMgr(n).log(new DataRecord(emptyList())));
    assertEquals(-1, walMgr(n).lastArchivedSegment());
    long exp = walMgr(n).lastWritePointer().fileOffset() - HEADER_RECORD_SIZE;
    assertEquals(exp, dbMgr(n).persistentStoreMetrics().getWalWrittenBytes());
    assertEquals(exp, dsMetricsMXBean(n).getWalWrittenBytes());
    assertEquals(exp, ((LongAdderMetric) dsMetricRegistry(n).findMetric("WalWrittenBytes")).value());
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Arrays(java.util.Arrays) UnaryOperator(java.util.function.UnaryOperator) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) Matcher(java.util.regex.Matcher) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) DataStorageMetricsMXBean(org.apache.ignite.mxbean.DataStorageMetricsMXBean) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) WALMode(org.apache.ignite.configuration.WALMode) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) QuerySqlField(org.apache.ignite.cache.query.annotations.QuerySqlField) Collections.emptyList(java.util.Collections.emptyList) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) IgniteCache(org.apache.ignite.IgniteCache) Serializable(java.io.Serializable) Objects(java.util.Objects) DataRegionMetrics(org.apache.ignite.DataRegionMetrics) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Pattern(java.util.regex.Pattern) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) LongGauge(org.apache.ignite.internal.processors.metric.impl.LongGauge) WALDisableContext(org.apache.ignite.internal.processors.cache.WalStateManager.WALDisableContext) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) U(org.apache.ignite.internal.util.typedef.internal.U) HEADER_RECORD_SIZE(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.HEADER_RECORD_SIZE) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) PAX(org.apache.ignite.internal.util.typedef.PAX) S(org.apache.ignite.internal.util.typedef.internal.S) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) SegmentRouter(org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) DataStorageMetrics(org.apache.ignite.DataStorageMetrics) Test(org.junit.Test) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) File(java.io.File) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridTestUtils.setFieldValue(org.apache.ignite.testframework.GridTestUtils.setFieldValue) ATOMIC(org.apache.ignite.cache.CacheAtomicityMode.ATOMIC) DATASTORAGE_METRIC_PREFIX(org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl.DATASTORAGE_METRIC_PREFIX) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) CacheMode(org.apache.ignite.cache.CacheMode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) WALDisableContext(org.apache.ignite.internal.processors.cache.WalStateManager.WALDisableContext) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 23 with ACTIVE

use of org.apache.ignite.cluster.ClusterState.ACTIVE in project ignite by apache.

the class IgniteDataStorageMetricsSelfTest method testWalCompressedBytes.

/**
 * Checking that the metrics of the total size compressed segment are working correctly.
 *
 * @throws Exception If failed.
 */
@Test
public void testWalCompressedBytes() throws Exception {
    IgniteEx n0 = startGrid(0, (UnaryOperator<IgniteConfiguration>) cfg -> {
        cfg.getDataStorageConfiguration().setWalCompactionEnabled(true).setWalSegmentSize((int) (2 * U.MB));
        return cfg;
    });
    n0.cluster().state(ACTIVE);
    awaitPartitionMapExchange();
    while (walMgr(n0).lastArchivedSegment() < 3) n0.cache("cache").put(ThreadLocalRandom.current().nextLong(), new byte[(int) (32 * U.KB)]);
    waitForCondition(() -> walMgr(n0).lastArchivedSegment() == walMgr(n0).lastCompactedSegment(), getTestTimeout());
    assertCorrectWalCompressedBytesMetrics(n0);
    stopAllGrids();
    IgniteEx n1 = startGrid(0, (UnaryOperator<IgniteConfiguration>) cfg -> {
        cfg.getDataStorageConfiguration().setWalCompactionEnabled(true);
        return cfg;
    });
    n1.cluster().state(ACTIVE);
    awaitPartitionMapExchange();
    assertCorrectWalCompressedBytesMetrics(n1);
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Arrays(java.util.Arrays) UnaryOperator(java.util.function.UnaryOperator) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) Matcher(java.util.regex.Matcher) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) DataStorageMetricsMXBean(org.apache.ignite.mxbean.DataStorageMetricsMXBean) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) WALMode(org.apache.ignite.configuration.WALMode) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) QuerySqlField(org.apache.ignite.cache.query.annotations.QuerySqlField) Collections.emptyList(java.util.Collections.emptyList) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) IgniteCache(org.apache.ignite.IgniteCache) Serializable(java.io.Serializable) Objects(java.util.Objects) DataRegionMetrics(org.apache.ignite.DataRegionMetrics) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Pattern(java.util.regex.Pattern) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) LongGauge(org.apache.ignite.internal.processors.metric.impl.LongGauge) WALDisableContext(org.apache.ignite.internal.processors.cache.WalStateManager.WALDisableContext) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) U(org.apache.ignite.internal.util.typedef.internal.U) HEADER_RECORD_SIZE(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.HEADER_RECORD_SIZE) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) PAX(org.apache.ignite.internal.util.typedef.PAX) S(org.apache.ignite.internal.util.typedef.internal.S) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) SegmentRouter(org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) DataStorageMetrics(org.apache.ignite.DataStorageMetrics) Test(org.junit.Test) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) File(java.io.File) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridTestUtils.setFieldValue(org.apache.ignite.testframework.GridTestUtils.setFieldValue) ATOMIC(org.apache.ignite.cache.CacheAtomicityMode.ATOMIC) DATASTORAGE_METRIC_PREFIX(org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl.DATASTORAGE_METRIC_PREFIX) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) CacheMode(org.apache.ignite.cache.CacheMode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 24 with ACTIVE

use of org.apache.ignite.cluster.ClusterState.ACTIVE in project ignite by apache.

the class DurableBackgroundTasksProcessorSelfTest method testDontDeleteTaskIfItsRestart.

/**
 * Check that the task will not be deleted from the MetaStorage if it was restarted.
 *
 * @throws Exception If failed.
 */
@Test
public void testDontDeleteTaskIfItsRestart() throws Exception {
    IgniteEx n = startGrid(0);
    ObservingCheckpointListener observingCpLsnr = new ObservingCheckpointListener();
    dbMgr(n).addCheckpointListener(observingCpLsnr);
    n.cluster().state(ACTIVE);
    CheckpointWorkflow cpWorkflow = checkpointWorkflow(n);
    List<CheckpointListener> cpLs = cpWorkflow.getRelevantCheckpointListeners(dbMgr(n).checkpointedDataRegions());
    assertTrue(cpLs.contains(observingCpLsnr));
    assertTrue(cpLs.contains(durableBackgroundTask(n)));
    assertTrue(cpLs.indexOf(observingCpLsnr) < cpLs.indexOf(durableBackgroundTask(n)));
    SimpleTask simpleTask0 = new SimpleTask("t");
    IgniteInternalFuture<Void> taskFut = durableBackgroundTask(n).executeAsync(simpleTask0, true);
    simpleTask0.onExecFut.get(getTestTimeout());
    forceCheckpoint();
    dbMgr(n).enableCheckpoints(false).get(getTestTimeout());
    simpleTask0.taskFut.onDone(DurableBackgroundTaskResult.complete(null));
    taskFut.get(getTestTimeout());
    SimpleTask simpleTask1 = new SimpleTask("t");
    AtomicReference<IgniteInternalFuture<Void>> taskFutRef = new AtomicReference<>();
    observingCpLsnr.afterCheckpointEndConsumer = ctx -> taskFutRef.set(durableBackgroundTask(n).executeAsync(simpleTask1, true));
    dbMgr(n).enableCheckpoints(true).get(getTestTimeout());
    forceCheckpoint();
    assertNotNull(metaStorageOperation(n, ms -> ms.read(metaStorageKey(simpleTask0))));
    simpleTask1.onExecFut.get(getTestTimeout());
    simpleTask1.taskFut.onDone(DurableBackgroundTaskResult.complete(null));
    taskFutRef.get().get(getTestTimeout());
    forceCheckpoint();
    assertNull(metaStorageOperation(n, ms -> ms.read(metaStorageKey(simpleTask1))));
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) DurableBackgroundTaskResult.restart(org.apache.ignite.internal.processors.cache.persistence.metastorage.pendingtask.DurableBackgroundTaskResult.restart) GridTestUtils.assertThrows(org.apache.ignite.testframework.GridTestUtils.assertThrows) IgniteEx(org.apache.ignite.internal.IgniteEx) AtomicReference(java.util.concurrent.atomic.AtomicReference) DurableBackgroundTasksProcessor.metaStorageKey(org.apache.ignite.internal.processors.localtask.DurableBackgroundTasksProcessor.metaStorageKey) CheckpointWorkflow(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointWorkflow) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) DurableBackgroundTaskResult.complete(org.apache.ignite.internal.processors.cache.persistence.metastorage.pendingtask.DurableBackgroundTaskResult.complete) Map(java.util.Map) DurableBackgroundTask(org.apache.ignite.internal.processors.cache.persistence.metastorage.pendingtask.DurableBackgroundTask) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) CheckpointListener(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener) COMPLETED(org.apache.ignite.internal.processors.localtask.DurableBackgroundTaskState.State.COMPLETED) STARTED(org.apache.ignite.internal.processors.localtask.DurableBackgroundTaskState.State.STARTED) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) INIT(org.apache.ignite.internal.processors.localtask.DurableBackgroundTaskState.State.INIT) State(org.apache.ignite.internal.processors.localtask.DurableBackgroundTaskState.State) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) Test(org.junit.Test) StopNodeFailureHandler(org.apache.ignite.failure.StopNodeFailureHandler) DurableBackgroundTaskResult(org.apache.ignite.internal.processors.cache.persistence.metastorage.pendingtask.DurableBackgroundTaskResult) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridTestUtils.getFieldValue(org.apache.ignite.testframework.GridTestUtils.getFieldValue) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) CheckpointListener(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener) IgniteEx(org.apache.ignite.internal.IgniteEx) AtomicReference(java.util.concurrent.atomic.AtomicReference) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) CheckpointWorkflow(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointWorkflow) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 25 with ACTIVE

use of org.apache.ignite.cluster.ClusterState.ACTIVE in project ignite by apache.

the class ClusterReadOnlyModeSelfTest method testEnableReadOnlyModeInsideTransaction.

/**
 */
@Test
public void testEnableReadOnlyModeInsideTransaction() throws Exception {
    IgniteEx grid = startGrids(SERVER_NODES_COUNT);
    grid.cluster().state(ACTIVE);
    CacheConfiguration cfg = Stream.of(grid.configuration().getCacheConfiguration()).filter(c -> c.getAtomicityMode() == CacheAtomicityMode.TRANSACTIONAL).filter(c -> !CU.isSystemCache(c.getName())).findAny().get();
    final int key = 1;
    IgniteCache<Integer, Integer> cache = grid.cache(cfg.getName());
    cache.put(key, 0);
    CountDownLatch startTxLatch = new CountDownLatch(1);
    CountDownLatch clusterReadOnlyLatch = new CountDownLatch(1);
    Thread t = new Thread(() -> {
        try {
            startTxLatch.await();
            grid(1).cluster().state(ACTIVE_READ_ONLY);
            assertEquals(ACTIVE_READ_ONLY, grid(1).cluster().state());
            clusterReadOnlyLatch.countDown();
        } catch (InterruptedException e) {
            log.error("Thread interrupted", e);
            fail("Thread interrupted");
        }
    });
    t.start();
    Transaction tx = grid(0).transactions().txStart();
    try {
        cache.put(key, 1);
        startTxLatch.countDown();
        tx.commit();
    } catch (Exception e) {
        log.error("TX Failed", e);
        tx.rollback();
    }
    assertEquals(1, (int) cache.get(key));
    t.join();
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) ClusterReadOnlyModeTestUtils.cacheNames(org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTestUtils.cacheNames) Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCacheUtilityKey(org.apache.ignite.internal.processors.cache.GridCacheUtilityKey) HashSet(java.util.HashSet) ACTIVE_READ_ONLY(org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) CacheException(javax.cache.CacheException) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) ClusterReadOnlyModeTestUtils.assertDataStreamerReadOnlyMode(org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTestUtils.assertDataStreamerReadOnlyMode) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) ClusterReadOnlyModeTestUtils.assertCachesReadOnlyMode(org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTestUtils.assertCachesReadOnlyMode) MetaStorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage) Test(org.junit.Test) IgniteCache(org.apache.ignite.IgniteCache) StopNodeFailureHandler(org.apache.ignite.failure.StopNodeFailureHandler) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteClusterReadOnlyException(org.apache.ignite.internal.processors.cache.distributed.dht.IgniteClusterReadOnlyException) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CU(org.apache.ignite.internal.util.typedef.internal.CU) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) ClusterReadOnlyModeTestUtils.cacheConfigurations(org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTestUtils.cacheConfigurations) Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) CountDownLatch(java.util.concurrent.CountDownLatch) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CacheException(javax.cache.CacheException) IgniteClusterReadOnlyException(org.apache.ignite.internal.processors.cache.distributed.dht.IgniteClusterReadOnlyException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

ACTIVE (org.apache.ignite.cluster.ClusterState.ACTIVE)33 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)33 IgniteEx (org.apache.ignite.internal.IgniteEx)31 Test (org.junit.Test)31 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)30 IgniteCache (org.apache.ignite.IgniteCache)27 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)27 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)27 U (org.apache.ignite.internal.util.typedef.internal.U)25 List (java.util.List)23 Serializable (java.io.Serializable)22 Map (java.util.Map)22 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)22 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)22 File (java.io.File)21 UUID (java.util.UUID)21 CountDownLatch (java.util.concurrent.CountDownLatch)21 Ignite (org.apache.ignite.Ignite)21 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)21 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)20