org.apache.ignite.cache.CacheAtomicityMode Java Examples
The following examples show how to use
org.apache.ignite.cache.CacheAtomicityMode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CacheKeepBinaryIterationTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param cacheMode Cache mode. * @param backups Number of backups. * @param atomicityMode Cache atomicity mode. * @return Cache configuration. */ protected CacheConfiguration<Object, Object> cacheConfiguration( CacheMode cacheMode, int backups, CacheAtomicityMode atomicityMode) { CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setAtomicityMode(atomicityMode); ccfg.setCacheMode(cacheMode); ccfg.setWriteSynchronizationMode(FULL_SYNC); if (cacheMode == PARTITIONED) ccfg.setBackups(backups); return ccfg; }
Example #2
Source File: IgniteCacheSingleGetMessageTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param cacheMode Cache mode. * @param atomicityMode Cache atomicity mode. * @param syncMode Write synchronization mode. * @param backups Number of backups. * @return Cache configuration. */ private CacheConfiguration<Integer, Integer> cacheConfiguration( CacheMode cacheMode, CacheAtomicityMode atomicityMode, CacheWriteSynchronizationMode syncMode, int backups) { CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setCacheMode(cacheMode); ccfg.setAtomicityMode(atomicityMode); ccfg.setWriteSynchronizationMode(syncMode); if (cacheMode == PARTITIONED) ccfg.setBackups(backups); return ccfg; }
Example #3
Source File: IgnitePersistentStoreCacheGroupsTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param grpName Cache group name. * @param name Cache name. * @param cacheMode Cache mode. * @param atomicityMode Atomicity mode. * @param backups Backups number. * @return Cache configuration. */ private CacheConfiguration cacheConfiguration( String grpName, String name, CacheMode cacheMode, CacheAtomicityMode atomicityMode, int backups ) { CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setName(name); ccfg.setGroupName(grpName); ccfg.setAtomicityMode(atomicityMode); ccfg.setBackups(backups); ccfg.setCacheMode(cacheMode); ccfg.setWriteSynchronizationMode(FULL_SYNC); return ccfg; }
Example #4
Source File: GridCacheQuerySimpleBenchmark.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); CacheConfiguration<?,?> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setName("offheap-cache"); ccfg.setCacheMode(CacheMode.PARTITIONED); ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); ccfg.setIndexedTypes( Long.class, Person.class ); c.setCacheConfiguration(ccfg); return c; }
Example #5
Source File: IgniteDynamicClientCacheStartSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param grp Group name. * @param atomicityMode Atomicity mode. * @return Cache configurations. */ private List<CacheConfiguration> cacheConfigurations(@Nullable String grp, CacheAtomicityMode atomicityMode) { List<CacheConfiguration> ccfgs = new ArrayList<>(); for (int i = 0; i < 3; i++) { CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setGroupName(grp); ccfg.setName("cache-" + atomicityMode + "-" + i); ccfg.setWriteSynchronizationMode(FULL_SYNC); ccfgs.add(ccfg); } return ccfgs; }
Example #6
Source File: WalPreloadingConcurrentTest.java From ignite with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setConsistentId(gridName); CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME) .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setRebalanceMode(CacheRebalanceMode.ASYNC) .setCacheMode(CacheMode.REPLICATED); cfg.setCacheConfiguration(ccfg); DataStorageConfiguration dbCfg = new DataStorageConfiguration() .setWalMode(WALMode.LOG_ONLY) .setDefaultDataRegionConfiguration( new DataRegionConfiguration() .setPersistenceEnabled(true) ); cfg.setDataStorageConfiguration(dbCfg); return cfg; }
Example #7
Source File: IgniteCacheDistributedJoinTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration<Integer, A> ccfga = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfga.setName("a"); ccfga.setSqlSchema("A"); ccfga.setAtomicityMode(CacheAtomicityMode.ATOMIC); ccfga.setBackups(1); ccfga.setCacheMode(CacheMode.PARTITIONED); ccfga.setIndexedTypes(Integer.class, A.class); CacheConfiguration<Integer, B> ccfgb = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfgb.setName("b"); ccfgb.setSqlSchema("B"); ccfgb.setAtomicityMode(CacheAtomicityMode.ATOMIC); ccfgb.setBackups(1); ccfgb.setCacheMode(CacheMode.PARTITIONED); ccfgb.setIndexedTypes(Integer.class, B.class); CacheConfiguration<Integer, C> ccfgc = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfgc.setName("c"); ccfgc.setSqlSchema("C"); ccfgc.setAtomicityMode(CacheAtomicityMode.ATOMIC); ccfgc.setBackups(1); ccfgc.setCacheMode(CacheMode.PARTITIONED); ccfgc.setIndexedTypes(Integer.class, C.class); cfg.setCacheConfiguration(ccfga, ccfgb, ccfgc); return cfg; }
Example #8
Source File: CacheMvccVacuumTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Test public void testStartStopVacuumInMemory() throws Exception { Ignite node0 = startGrid(0); Ignite node1 = startGrid(1); node1.createCache(new CacheConfiguration<>("test1") .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); ensureNoVacuum(node0); ensureNoVacuum(node1); node1.createCache(new CacheConfiguration<>("test2") .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT)); ensureVacuum(node0); ensureVacuum(node1); stopGrid(0); ensureNoVacuum(node0); ensureVacuum(node1); stopGrid(1); ensureNoVacuum(node0); ensureNoVacuum(node1); }
Example #9
Source File: CacheGetInsideLockChangingTopologyTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param name Cache name. * @param atomicityMode Atomicity mode. * @return Cache configuration. */ private CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode atomicityMode) { CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setName(name); ccfg.setAtomicityMode(atomicityMode); ccfg.setWriteSynchronizationMode(FULL_SYNC); ccfg.setBackups(1); return ccfg; }
Example #10
Source File: IgnitePdsCheckpointSimulationWithRealCpDisabledTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME) .setRebalanceMode(CacheRebalanceMode.NONE); CacheConfiguration mvccCfg = new CacheConfiguration(MVCC_CACHE_NAME) .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) .setRebalanceDelay(Long.MAX_VALUE); cfg.setCacheConfiguration(ccfg, mvccCfg); cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setCheckpointFrequency(500) .setWalMode(WALMode.LOG_ONLY) .setAlwaysWriteFullPages(true) .setDefaultDataRegionConfiguration( new DataRegionConfiguration() .setPersistenceEnabled(true) .setMaxSize(DataStorageConfiguration.DFLT_DATA_REGION_INITIAL_SIZE) ) ); return cfg; }
Example #11
Source File: CacheConnectionLeakStoreTxTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Test public void testConnectionLeakOneBackupPessimisticReadCommittedLoadFromStore() throws Exception { isLoadFromStore = true; checkConnectionLeak(CacheAtomicityMode.TRANSACTIONAL, PESSIMISTIC, READ_COMMITTED); }
Example #12
Source File: NearCacheSyncUpdateTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param atomicityMode Atomicity mode. * @return Cache configuration. */ private CacheConfiguration<Integer, Integer> cacheConfiguration(CacheAtomicityMode atomicityMode) { CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setCacheMode(PARTITIONED); ccfg.setBackups(1); ccfg.setWriteSynchronizationMode(FULL_SYNC); ccfg.setAtomicityMode(atomicityMode); ccfg.setNearConfiguration(new NearCacheConfiguration<Integer, Integer>()); return ccfg; }
Example #13
Source File: CacheGroupsPreloadTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Test public void testCachePreload8() throws Exception { sameGrp = false; cacheMode = CacheMode.REPLICATED; atomicityMode = CacheAtomicityMode.TRANSACTIONAL; cachePreloadTest(); }
Example #14
Source File: TxWithKeyContentionSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** */ protected CacheConfiguration<?, ?> getCacheConfiguration(String name) { CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(name) .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) .setAffinity(new RendezvousAffinityFunction(false, 16)) .setBackups(2) .setStatisticsEnabled(true); if (nearCache) ccfg.setNearConfiguration(new NearCacheConfiguration<>()); return ccfg; }
Example #15
Source File: CacheBaselineTopologyTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception if failed. */ @Test public void testMetadataUpdate() throws Exception { startGrids(5); Ignite ignite3 = grid(3); ignite3.cluster().active(true); CacheConfiguration<Object, Object> repCacheCfg = new CacheConfiguration<>("replicated") .setCacheMode(CacheMode.REPLICATED) .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); IgniteCache<Object, Object> cache = ignite3.getOrCreateCache(repCacheCfg); stopGrid(0); stopGrid(1); stopGrid(2); stopGrid(4); for (int i = 0; i < 100; i++) cache.put(i, new TestValue(i)); stopAllGrids(); startGrids(5); GridTestUtils.waitForCondition(() -> grid(0).cluster().active(), getTestTimeout()); for (int g = 0; g < 5; g++) { for (int i = 0; i < 100; i++) assertEquals(new TestValue(i), grid(g).cache("replicated").get(i)); } }
Example #16
Source File: PageEvictionMultinodeAbstractTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Ignore("https://issues.apache.org/jira/browse/IGNITE-10738") @Test public void testPageEvictionMvcc() throws Exception { for (int i = 0; i < CACHE_MODES.length; i++) { CacheConfiguration<Object, Object> cfg = cacheConfig( "evict" + i, null, CACHE_MODES[i], CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheWriteSynchronizationMode.FULL_SYNC); createCacheAndTestEviction(cfg); } }
Example #17
Source File: DynamicIndexAbstractBasicSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Create cache with the given cache mode and atomicity mode. * * @param mode Mode. * @param atomicityMode Atomicity mode. * @param near Whether near cache should be initialized. * @return Cache configuration. */ private CacheConfiguration<KeyClass, ValueClass> cacheConfiguration(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) { CacheConfiguration<KeyClass, ValueClass> ccfg = cacheConfiguration(); ccfg.setCacheMode(mode); ccfg.setAtomicityMode(atomicityMode); if (near) ccfg.setNearConfiguration(new NearCacheConfiguration<KeyClass, ValueClass>()); return ccfg; }
Example #18
Source File: CachePartitionLossWithPersistenceTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); cfg.setConsistentId(igniteInstanceName); cfg.setClientMode(igniteInstanceName.startsWith("client")); cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setWalMode(WALMode.LOG_ONLY) .setWalSegmentSize(4 * 1024 * 1024) .setDefaultDataRegionConfiguration( new DataRegionConfiguration() .setPersistenceEnabled(true) .setMaxSize(100L * 1024 * 1024)) ); cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME). setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL). setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC). setPartitionLossPolicy(lossPlc). setBackups(1). setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT))); return cfg; }
Example #19
Source File: CacheStopAndDestroySelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @return near config */ private CacheConfiguration getNearConfig() { CacheConfiguration cfg = defaultCacheConfiguration(); cfg.setName(CACHE_NAME_NEAR); cfg.setCacheMode(PARTITIONED); cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); cfg.setNearConfiguration(new NearCacheConfiguration()); return cfg; }
Example #20
Source File: CacheStopAndDestroySelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @return client config */ private CacheConfiguration getClientConfig() { CacheConfiguration cfg = defaultCacheConfiguration(); cfg.setName(CACHE_NAME_CLIENT); cfg.setCacheMode(PARTITIONED); cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); cfg.setNearConfiguration(null); return cfg; }
Example #21
Source File: IgniteSqlNotNullConstraintTest.java From ignite with Apache License 2.0 | 5 votes |
/** */ private void checkAddColumnNotNullCheckDmlInsertValues(CacheAtomicityMode atomicityMode) throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, age INT) WITH \"atomicity=" + atomicityMode.name() + "\""); executeSql("ALTER TABLE test ADD COLUMN name VARCHAR NOT NULL"); checkNotNullInsertValues(); }
Example #22
Source File: IgniteDiagnosticMessagesTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Test public void testDiagnosticMessages2() throws Exception { connectionsPerNode = 5; checkBasicDiagnosticInfo(CacheAtomicityMode.TRANSACTIONAL); }
Example #23
Source File: CacheValidatorMetricsTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setActiveOnStart(false); CacheConfiguration cCfg1 = new CacheConfiguration() .setName(CACHE_NAME_1) .setCacheMode(CacheMode.PARTITIONED) .setBackups(0) .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setPartitionLossPolicy(PartitionLossPolicy.READ_ONLY_SAFE); CacheConfiguration cCfg2 = new CacheConfiguration() .setName(CACHE_NAME_2) .setCacheMode(CacheMode.REPLICATED) .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setTopologyValidator(new TopologyValidator() { @Override public boolean validate(Collection<ClusterNode> nodes) { return nodes.size() == 2; } }); cfg.setCacheConfiguration(cCfg1, cCfg2); return cfg; }
Example #24
Source File: CachePutEventListenerErrorSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param cacheMode Cache mode. * @param atomicityMode Atomicity mode. * @throws Exception If failed. */ private void doTest(CacheMode cacheMode, CacheAtomicityMode atomicityMode) throws Exception { Ignite ignite = grid("client"); try { CacheConfiguration<Integer, Integer> cfg = defaultCacheConfiguration(); cfg.setName("cache"); cfg.setCacheMode(cacheMode); cfg.setAtomicityMode(atomicityMode); IgniteCache<Integer, Integer> cache = ignite.createCache(cfg); IgniteFuture f = cache.putAsync(0, 0); try { f.get(2000); assert false : "Exception was not thrown"; } catch (CacheException e) { info("Caught expected exception: " + e); } } finally { ignite.destroyCache("cache"); } }
Example #25
Source File: IgniteCachelessQueriesSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param name Cache name. * @param mode Cache mode. * @param idxTypes Indexed types. * @return Cache configuration. */ protected <K, V> CacheConfiguration<K, V> cacheConfig(String name, TestCacheMode mode, Class<?>... idxTypes) { return new CacheConfiguration<K, V>() .setName(name) .setCacheMode(mode == TestCacheMode.REPLICATED ? CacheMode.REPLICATED : CacheMode.PARTITIONED) .setQueryParallelism(mode == TestCacheMode.SEGMENTED ? 5 : 1) .setAtomicityMode(CacheAtomicityMode.ATOMIC) .setIndexedTypes(idxTypes); }
Example #26
Source File: IgniteCacheTxNoLoadPreviousValueTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; }
Example #27
Source File: CacheGetRemoveSkipStoreTest.java From ignite with Apache License 2.0 | 4 votes |
/** */ @Test public void testRemoveIsAppliedAtomicNoBackups() { checkRemoveIsApplied(grid("client"), configuration(CacheAtomicityMode.ATOMIC, 0)); }
Example #28
Source File: CacheDeferredDeleteQueueTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @param atomicityMode Cache atomicity mode. * @param nearCache {@code True} if need create near cache. * * @throws Exception If failed. */ private void testQueue(CacheAtomicityMode atomicityMode, boolean nearCache) throws Exception { CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setCacheMode(PARTITIONED); ccfg.setAtomicityMode(atomicityMode); ccfg.setWriteSynchronizationMode(FULL_SYNC); ccfg.setBackups(1); if (nearCache) ccfg.setNearConfiguration(new NearCacheConfiguration<Integer, Integer>()); IgniteCache<Integer, Integer> cache = ignite(0).createCache(ccfg); try { final int KEYS = cache.getConfiguration(CacheConfiguration.class).getAffinity().partitions() * 3; for (int i = 0; i < KEYS; i++) cache.put(i, i); for (int i = 0; i < KEYS; i++) cache.remove(i); boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { for (int i = 0; i < NODES; i++) { final GridDhtPartitionTopology top = ((IgniteKernal)ignite(i)).context().cache().cache(DEFAULT_CACHE_NAME).context().topology(); for (GridDhtLocalPartition p : top.currentLocalPartitions()) { Collection<Object> rmvQueue = GridTestUtils.getFieldValue(p, "rmvQueue"); if (!rmvQueue.isEmpty() || p.dataStore().fullSize() != 0) return false; } } return true; } }, 5000); assertTrue("Failed to wait for rmvQueue cleanup.", wait); } finally { ignite(0).destroyCache(ccfg.getName()); } }
Example #29
Source File: DataStreamProcessorMvccSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode getCacheAtomicityMode() { return TRANSACTIONAL_SNAPSHOT; }
Example #30
Source File: IgniteCacheAtomicNoLoadPreviousValueTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return ATOMIC; }