@Override public Object call() throws Exception { QueryEntity e = new QueryEntity(); e.setTableName("City"); e.setKeyFields(Collections.singleton("name")); e.setFields(new LinkedHashMap<>(Collections.singletonMap("name", String.class.getName()))); e.setIndexes(Collections.singleton(new QueryIndex("name").setName("idx"))); e.setKeyType("CityKey"); e.setValueType("City"); queryProcessor(client()).dynamicTableCreate("PUBLIC", e, CacheMode.PARTITIONED.name(), null, null, null, null, CacheAtomicityMode.ATOMIC, null, 10, false, false); return null; } }, SchemaOperationException.class, "Index already exists: idx");
/** * Creates cache bean. * * @param ccfg Cache configuration. * @return Cache bean. */ public GridClientCacheBean createCacheBean(CacheConfiguration ccfg) { GridClientCacheBean cacheBean = new GridClientCacheBean(); cacheBean.setName(ccfg.getName()); cacheBean.setMode(GridClientCacheMode.valueOf(ccfg.getCacheMode().toString())); cacheBean.setSqlSchema(ccfg.getSqlSchema()); return cacheBean; }
/** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { seqReserveSize = in.readInt(); cacheMode = CacheMode.fromOrdinal(in.readByte()); backups = in.readInt(); }
itemWriter.accept(CfgItem.CACHE_MODE, w -> w.writeInt(cfg.getCacheMode().ordinal())); itemWriter.accept(CfgItem.ATOMICITY_MODE, w -> w.writeInt(cfg.getAtomicityMode().ordinal())); itemWriter.accept(CfgItem.BACKUPS, w -> w.writeInt(cfg.getBackups()));
CacheMode cacheMode = CacheMode.valueOf(cache.get("mode").asText());
/** * @throws Exception If failed. */ @Test public void testEnumVariations() throws Exception { ConfigParameter<CacheConfiguration>[] modes = Parameters.enumParameters("setCacheMode", CacheMode.class); assertEquals(CacheMode.values().length, modes.length); Set<CacheMode> res = new HashSet<>(); for (ConfigParameter<CacheConfiguration> modeApplier : modes) { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); modeApplier.apply(cfg); CacheMode mode = cfg.getCacheMode(); res.add(mode); System.out.println(">>> " + mode); } assertEquals(modes.length, res.size()); }
itemWriter.accept(CfgItem.CACHE_MODE, w -> w.writeInt(cfg.getCacheMode().ordinal())); itemWriter.accept(CfgItem.ATOMICITY_MODE, w -> w.writeInt(cfg.getAtomicityMode().ordinal())); itemWriter.accept(CfgItem.BACKUPS, w -> w.writeInt(cfg.getBackups()));
/** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { name = U.readString(in); dynamicDeploymentId = U.readGridUuid(in); mode = CacheMode.fromOrdinal(in.readByte()); memorySize = in.readLong(); indexesSize = in.readLong(); size = in.readLong(); nearSize = in.readInt(); primarySize = in.readLong(); backupSize = in.readLong(); partitions = in.readInt(); near = in.readBoolean(); metrics = (VisorCacheMetrics)in.readObject(); sys = protoVer > V1 ? in.readBoolean() : metrics != null && metrics.isSystem(); if (protoVer > V2) statisticsEnabled = in.readBoolean(); }
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\"");
getTypedValue("int", "888", PARTITIONED.toString());
/** * @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(); } }
mode = CacheMode.fromOrdinal(in.readByte()); sys = in.readBoolean(); metrics = U.readMap(in);
/** * Creates cache bean. * * @param ccfg Cache configuration. * @return Cache bean. */ public GridClientCacheBean createCacheBean(CacheConfiguration ccfg) { GridClientCacheBean cacheBean = new GridClientCacheBean(); cacheBean.setName(ccfg.getName()); cacheBean.setMode(GridClientCacheMode.valueOf(ccfg.getCacheMode().toString())); cacheBean.setSqlSchema(ccfg.getSqlSchema()); return cacheBean; }
/** */ 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); } } } } }
/** {@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; }
/** */ 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; }
mode = CacheMode.fromOrdinal(in.readByte()); sys = in.readBoolean(); size = in.readInt();
name = U.readString(in); grpName = U.readString(in); mode = CacheMode.fromOrdinal(in.readByte()); atomicityMode = CacheAtomicityMode.fromOrdinal(in.readByte()); eagerTtl = in.readBoolean();