if (CacheAtomicityMode.TRANSACTIONAL.name().equalsIgnoreCase(val)) atomicityMode = CacheAtomicityMode.TRANSACTIONAL; else if (CacheAtomicityMode.ATOMIC.name().equalsIgnoreCase(val)) atomicityMode = CacheAtomicityMode.ATOMIC; else if (CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT.name().equalsIgnoreCase(val)) atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; else
/** * @param qryEntity Query entity. * @return Cache configuration. */ protected CacheConfiguration cacheConfiguration(QueryEntity qryEntity) { CacheConfiguration<?, ?> cache = defaultCacheConfiguration(); cache.setCacheMode(cacheMode()); cache.setAtomicityMode(atomicityMode()); cache.setBackups(1); cache.setWriteSynchronizationMode(FULL_SYNC); cache.setQueryEntities(Collections.singletonList(qryEntity)); if (TRANSACTIONAL_SNAPSHOT.equals(atomicityMode())) cache.setNearConfiguration(null); return cache; }
/** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { seqName = U.readString(in); seqVal = in.readLong(); cacheName = U.readString(in); cacheId = in.readInt(); grpName = U.readString(in); grpId = in.readInt(); partitions = in.readInt(); mapped = in.readInt(); topVer = (AffinityTopologyVersion)in.readObject(); mode = CacheMode.fromOrdinal(in.readByte()); backupsCnt = in.readInt(); affinityClsName = U.readString(in); cachesCnt = in.readInt(); atomicityMode = protoVer >= V2 ? CacheAtomicityMode.fromOrdinal(in.readByte()) : null; }
/** * @param grp Caches group name. * @throws Exception If failed. */ private void startMultipleClientCaches(@Nullable String grp) throws Exception { final int SRVS = 1; Ignite srv = startGrids(SRVS); client = true; Ignite client = startGrid(SRVS); for (CacheAtomicityMode atomicityMode : values()) { for (boolean batch : new boolean[]{false, true}) startCachesForGroup(srv, client, grp, atomicityMode, batch); } }
itemWriter.accept(CfgItem.ATOMICITY_MODE, w -> w.writeInt(cfg.getAtomicityMode().ordinal())); itemWriter.accept(CfgItem.BACKUPS, w -> w.writeInt(cfg.getBackups())); itemWriter.accept(CfgItem.WRITE_SYNC_MODE, w -> w.writeInt(cfg.getWriteSynchronizationMode().ordinal()));
/** * @throws Exception if failed. */ public void checkModes(int gridCnt) throws Exception { startGrids(gridCnt); try { for (CacheMode mode : CacheMode.values()) { for (CacheAtomicityMode atomMode : CacheAtomicityMode.values()) { if (mode == CacheMode.PARTITIONED) { // Near cache makes sense only for partitioned cache. checkTxCache(CacheMode.PARTITIONED, atomMode, true, false); } checkTxCache(mode, atomMode, false, true); checkTxCache(mode, atomMode, false, false); } } } finally { stopAllGrids(); } }
itemWriter.accept(CfgItem.ATOMICITY_MODE, w -> w.writeInt(cfg.getAtomicityMode().ordinal())); itemWriter.accept(CfgItem.BACKUPS, w -> w.writeInt(cfg.getBackups())); itemWriter.accept(CfgItem.WRITE_SYNC_MODE, w -> w.writeInt(cfg.getWriteSynchronizationMode().ordinal()));
/** */ private void checkNotNullCheckDmlInsertValues(CacheAtomicityMode atomicityMode) throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, name VARCHAR NOT NULL) WITH \"atomicity=" + atomicityMode.name() + "\""); GridTestUtils.assertThrows(log(), new Callable<Object>() { @Override public Object call() throws Exception { executeSql("INSERT INTO test(id, name) " + "VALUES (1, 'ok'), (2, NULLIF('a', 'a')), (3, 'ok')"); return null; } }, IgniteSQLException.class, ERR_MSG); List<List<?>> result = executeSql("SELECT id, name FROM test ORDER BY id"); assertEquals(0, result.size()); executeSql("INSERT INTO test(id, name) VALUES (1, 'ok'), (2, 'ok2'), (3, 'ok3')"); result = executeSql("SELECT id, name FROM test ORDER BY id"); assertEquals(3, result.size()); }
grpName = U.readString(in); mode = CacheMode.fromOrdinal(in.readByte()); atomicityMode = CacheAtomicityMode.fromOrdinal(in.readByte()); eagerTtl = in.readBoolean(); writeSynchronizationMode = CacheWriteSynchronizationMode.fromOrdinal(in.readByte());
/** */ private void testOOMPropagation(boolean useStreamer) throws Exception { for (CacheAtomicityMode atomicityMode : CacheAtomicityMode.values()) { for (CacheMode cacheMode : CacheMode.values()) { for (CacheWriteSynchronizationMode writeSyncMode : CacheWriteSynchronizationMode.values()) { for (int backupsCnt = 0; backupsCnt <= 1; backupsCnt++) { if (writeSyncMode == CacheWriteSynchronizationMode.FULL_ASYNC || cacheMode == CacheMode.REPLICATED) continue; if (atomicityMode == CacheAtomicityMode.TRANSACTIONAL && !useStreamer) { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { checkOOMPropagation( false, CacheAtomicityMode.TRANSACTIONAL, cacheMode, writeSyncMode, backupsCnt, concurrency, isolation); } } } checkOOMPropagation(useStreamer, atomicityMode, cacheMode, writeSyncMode, backupsCnt); } } } } }
/** */ 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"); GridTestUtils.assertThrows(log(), new Callable<Object>() { @Override public Object call() throws Exception { executeSql("INSERT INTO test(id, name, age) " + "VALUES (1, 'ok', 1), (2, NULLIF('a', 'a'), 2), (3, 'ok', 3)"); return null; } }, IgniteSQLException.class, ERR_MSG); List<List<?>> result = executeSql("SELECT id, name, age FROM test ORDER BY id"); assertEquals(0, result.size()); executeSql("INSERT INTO test(id, name) VALUES (1, 'ok'), (2, 'ok2'), (3, 'ok3')"); result = executeSql("SELECT id, name FROM test ORDER BY id"); assertEquals(3, result.size()); }
.setAtomicityMode(CacheAtomicityMode.fromOrdinal(reader.readInt())) .setBackups(reader.readInt()) .setCacheMode(CacheMode.fromOrdinal(reader.readInt()))
for (CacheAtomicityMode atomicityMode : CacheAtomicityMode.values()) { for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) { CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
public void testOperations() { executeSql("CREATE TABLE person (id int, name varchar, age int, company varchar, city varchar, " + "primary key (id, name, city)) WITH \"template=" + cacheMode.name() + ",atomicity=" + atomicityMode.name() + ",backups=" + backups + ",affinity_key=city\""); "\"template=" + cacheMode.name() + ",atomicity=" + atomicityMode.name() + ",backups=" + backups + ",affinity_key=name\"");
ccfg.setAtomicityMode(CacheAtomicityMode.fromOrdinal(in.readInt())); ccfg.setBackups(in.readInt()); ccfg.setCacheMode(CacheMode.fromOrdinal(in.readInt()));
cfg.setAtomicityMode(CacheAtomicityMode.fromOrdinal(reader.readInt())); break;
/** */ private CacheConfiguration buildCacheConfiguration(CacheMode mode, CacheAtomicityMode atomicityMode, boolean hasNear, boolean writeThrough, boolean notNullAnnotated) { CacheConfiguration cfg = new CacheConfiguration(CACHE_PREFIX + "-" + mode.name() + "-" + atomicityMode.name() + (hasNear ? "-near" : "") + (writeThrough ? "-writethrough" : "") + (notNullAnnotated ? "-annot" : "")); cfg.setCacheMode(mode); cfg.setAtomicityMode(atomicityMode); cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); QueryEntity qe = new QueryEntity(new QueryEntity(Integer.class, Person.class)); if (!notNullAnnotated) qe.setNotNullFields(Collections.singleton("name")); cfg.setQueryEntities(F.asList(qe)); if (hasNear) cfg.setNearConfiguration(new NearCacheConfiguration().setNearStartSize(100)); if (writeThrough) { cfg.setCacheStoreFactory(singletonFactory(new TestStore())); cfg.setWriteThrough(true); } return cfg; }
/** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { seqName = U.readString(in); seqVal = in.readLong(); cacheName = U.readString(in); cacheId = in.readInt(); grpName = U.readString(in); grpId = in.readInt(); partitions = in.readInt(); mapped = in.readInt(); topVer = (AffinityTopologyVersion)in.readObject(); mode = CacheMode.fromOrdinal(in.readByte()); backupsCnt = in.readInt(); affinityClsName = U.readString(in); cachesCnt = in.readInt(); atomicityMode = protoVer >= V2 ? CacheAtomicityMode.fromOrdinal(in.readByte()) : null; }
if (CacheAtomicityMode.TRANSACTIONAL.name().equalsIgnoreCase(val)) atomicityMode = CacheAtomicityMode.TRANSACTIONAL; else if (CacheAtomicityMode.ATOMIC.name().equalsIgnoreCase(val)) atomicityMode = CacheAtomicityMode.ATOMIC; else if (CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT.name().equalsIgnoreCase(val)) atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; else