本文整理汇总了Java中org.apache.ignite.cache.CacheAtomicityMode类的典型用法代码示例。如果您正苦于以下问题:Java CacheAtomicityMode类的具体用法?Java CacheAtomicityMode怎么用?Java CacheAtomicityMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CacheAtomicityMode类属于org.apache.ignite.cache包,在下文中一共展示了CacheAtomicityMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* @param config the akka configuration object
* @param actorSystem the akk actor system
* @return the created snapshot ignite cache
*/
@Override
public IgniteCache<Long, SnapshotItem> apply(Config config, ActorSystem actorSystem) {
final IgniteExtension extension = IgniteExtensionProvider.EXTENSION.get(actorSystem);
final String cachePrefix = config.getString(CACHE_PREFIX_PROPERTY);
final int cacheBackups = config.getInt(CACHE_BACKUPS);
final CacheConfiguration<Long, SnapshotItem> eventStore = new CacheConfiguration();
eventStore.setCopyOnRead(false);
if (cacheBackups > 0) {
eventStore.setBackups(cacheBackups);
} else {
eventStore.setBackups(1);
}
eventStore.setAtomicityMode(CacheAtomicityMode.ATOMIC);
eventStore.setName(cachePrefix + "_SNAPSHOT");
eventStore.setCacheMode(CacheMode.PARTITIONED);
eventStore.setReadFromBackup(true);
eventStore.setIndexedTypes(Long.class, SnapshotItem.class);
eventStore.setIndexedTypes(String.class, SnapshotItem.class);
return extension.getIgnite().getOrCreateCache(eventStore);
}
示例2: createCache
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* Creates cache with full configuration. Active store is used.
*
* @param cacheName name of cache.
* @param atomicityMode atomicity.
* @param cacheMode mode.
* @param writeBehindEnabled should write behind be used for active store.
* @param flushFreq flush frequency for write behind.
* @param base configuration to copy settings from.
* @param <K> type of key.
* @param <V> type of value
* @return cache instance.
*/
@SuppressWarnings("unchecked")
public <K, V> IgniteCache<K, V> createCache(String cacheName, CacheAtomicityMode atomicityMode, CacheMode cacheMode,
boolean writeBehindEnabled, int flushFreq,
CacheConfiguration<K, V> base) {
CacheConfiguration<K, V> realConfiguration = base == null
? new CacheConfiguration<K, V>()
: new CacheConfiguration<K, V>(base);
realConfiguration.setName(cacheName);
realConfiguration.setAtomicityMode(atomicityMode);
realConfiguration.setCacheMode(cacheMode);
realConfiguration.setBackups(2);
realConfiguration.setWriteThrough(true);
realConfiguration.setReadThrough(true);
realConfiguration.setWriteBehindEnabled(writeBehindEnabled);
realConfiguration.setWriteBehindFlushFrequency(flushFreq);
realConfiguration.setCacheStoreFactory(activeStoreConfiguration.activeCacheStoreFactory());
return ignite().createCache(realConfiguration);
}
示例3: createEntityCacheConfiguration
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
private CacheConfiguration<?,?> createEntityCacheConfiguration(EntityKeyMetadata entityKeyMetadata, SchemaDefinitionContext context) {
CacheConfiguration<?,?> cacheConfiguration = new CacheConfiguration<>();
cacheConfiguration.setStoreKeepBinary( true );
cacheConfiguration.setSqlSchema( QueryUtils.DFLT_SCHEMA );
cacheConfiguration.setBackups( 1 );
cacheConfiguration.setName( StringHelper.stringBeforePoint( entityKeyMetadata.getTable() ) );
cacheConfiguration.setAtomicityMode( CacheAtomicityMode.TRANSACTIONAL );
QueryEntity queryEntity = new QueryEntity();
queryEntity.setTableName( entityKeyMetadata.getTable() );
queryEntity.setKeyType( getEntityIdClassName( entityKeyMetadata.getTable(), context ).getSimpleName() );
queryEntity.setValueType( StringHelper.stringAfterPoint( entityKeyMetadata.getTable() ) );
addTableInfo( queryEntity, context, entityKeyMetadata.getTable() );
for ( AssociationKeyMetadata associationKeyMetadata : context.getAllAssociationKeyMetadata() ) {
if ( associationKeyMetadata.getAssociationKind() != AssociationKind.EMBEDDED_COLLECTION
&& associationKeyMetadata.getTable().equals( entityKeyMetadata.getTable() )
&& !IgniteAssociationSnapshot.isThirdTableAssociation( associationKeyMetadata ) ) {
appendIndex( queryEntity, associationKeyMetadata, context );
}
}
log.debugf( "queryEntity: %s", queryEntity );
cacheConfiguration.setQueryEntities( Arrays.asList( queryEntity ) );
return cacheConfiguration;
}
示例4: newCache
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<MatrixBlockKey, MatrixBlockEntry> newCache() {
CacheConfiguration<MatrixBlockKey, MatrixBlockEntry> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例5: newCache
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<VectorBlockKey, VectorBlockEntry> newCache() {
CacheConfiguration<VectorBlockKey, VectorBlockEntry> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例6: newCache
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<RowColMatrixKey, Double> newCache() {
CacheConfiguration<RowColMatrixKey, Double> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例7: testAdd
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
@Test
public void testAdd() throws Exception {
L2CacheConfig base = new L2CacheConfig();
base.setCacheMode(CacheMode.LOCAL);
base.setNearSize(42);
assertNull(base.getAtomicityMode());
L2CacheConfig apply = new L2CacheConfig();
apply.setNearSize(56);
apply.setAtomicityMode(CacheAtomicityMode.ATOMIC);
L2CacheConfig add = AddL2CacheConfig.add(base, apply);
assertEquals(add.getNearSize(), Integer.valueOf(56));
assertEquals(add.getAtomicityMode(), CacheAtomicityMode.ATOMIC);
assertEquals(add.getCacheMode(), CacheMode.LOCAL);
assertNull(add.getBackups());
}
示例8: getConfiguration
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
if (cnt.getAndIncrement() == 0)
cfg.setClientMode(true);
else {
cfg.setIndexingSpi(new MyBrokenIndexingSpi());
CacheConfiguration ccfg = cacheConfiguration(igniteInstanceName);
ccfg.setName("test-cache");
ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
ccfg.setIndexedTypes(Integer.class, Integer.class);
cfg.setCacheConfiguration(ccfg);
}
return cfg;
}
示例9: checkAddColumnNotNullCheckDmlInsertValues
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/** */
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());
}
示例10: cacheConfiguration
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* @param cacheMode Cache mode.
* @param atomicityMode Cache atomicity mode.
* @param backups Number of backups.
* @param nearEnabled {@code True} if near cache should be enabled.
* @return Cache configuration.
*/
private CacheConfiguration<Object, Object> cacheConfiguration(CacheMode cacheMode,
CacheAtomicityMode atomicityMode,
int backups,
boolean nearEnabled) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(cacheMode);
ccfg.setAtomicityMode(atomicityMode);
if (cacheMode != REPLICATED) {
ccfg.setBackups(backups);
if (nearEnabled)
ccfg.setNearConfiguration(new NearCacheConfiguration<>());
}
return ccfg;
}
示例11: cacheConfiguration
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* @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;
}
示例12: cacheConfigurations
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* @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;
}
示例13: getConfiguration
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setCommunicationSpi(new TestCommunicationSpi());
cfg.setDiscoverySpi(new TestDiscoverySpi());
CacheConfiguration ccfg = defaultCacheConfiguration();
ccfg.setName(CACHE_NAME);
ccfg.setNearConfiguration(null);
ccfg.setCacheMode(CacheMode.PARTITIONED);
ccfg.setBackups(1);
ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
ccfg.setCacheStoreFactory(new TestCacheStoreFactory());
ccfg.setReadThrough(true);
ccfg.setWriteThrough(true);
ccfg.setWriteBehindEnabled(false);
cfg.setCacheConfiguration(ccfg);
return cfg;
}
示例14: cacheConfiguration
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* @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;
}
示例15: testTransactionalCache
import org.apache.ignite.cache.CacheAtomicityMode; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testTransactionalCache() throws Exception {
CacheConfiguration<Integer, Integer> cfg = cacheConfiguration(DEFAULT_CACHE_NAME, CacheAtomicityMode.TRANSACTIONAL);
IgniteCache<Integer, Integer> cache = ignite(0).createCache(cfg);
try {
cache.loadCache(null);
cache.get(1);
cache.put(1, 1);
cache.remove(1);
}
finally {
cache.destroy();
}
assertEquals(3, loadCacheCnt.get());
assertEquals(1, loadCnt.get());
assertEquals(1, writeCnt.get());
assertEquals(1, deleteCnt.get());
assertEquals(0, reuseCnt.get());
}