本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration.getAtomicityMode方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.getAtomicityMode方法的具体用法?Java CacheConfiguration.getAtomicityMode怎么用?Java CacheConfiguration.getAtomicityMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.configuration.CacheConfiguration
的用法示例。
在下文中一共展示了CacheConfiguration.getAtomicityMode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Init cache.
*/
@SuppressWarnings("unchecked")
void initCache() {
cache = webSesIgnite.cache(cacheName);
binaryCache = webSesIgnite.cache(cacheName);
if (cache == null)
throw new IgniteException("Cache for web sessions is not started (is it configured?): " + cacheName);
CacheConfiguration cacheCfg = cache.getConfiguration(CacheConfiguration.class);
if (cacheCfg.getWriteSynchronizationMode() == FULL_ASYNC)
throw new IgniteException("Cache for web sessions cannot be in FULL_ASYNC mode: " + cacheName);
if (!cacheCfg.isEagerTtl())
throw new IgniteException("Cache for web sessions cannot operate with lazy TTL. " +
"Consider setting eagerTtl to true for cache: " + cacheName);
if (cacheCfg.getCacheMode() == LOCAL)
U.quietAndWarn(webSesIgnite.log(), "Using LOCAL cache for web sessions caching " +
"(this is only OK in test mode): " + cacheName);
if (cacheCfg.getCacheMode() == PARTITIONED && cacheCfg.getAtomicityMode() != ATOMIC)
U.quietAndWarn(webSesIgnite.log(), "Using " + cacheCfg.getAtomicityMode() + " atomicity for web sessions " +
"caching (switch to ATOMIC mode for better performance)");
txEnabled = cacheCfg.getAtomicityMode() == TRANSACTIONAL;
}
示例2: executeWithAllTxCaches
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** */
private void executeWithAllTxCaches(final TestClosure clo) throws Exception {
for (CacheConfiguration ccfg : cacheConfigurations()) {
if (ccfg.getAtomicityMode() == CacheAtomicityMode.TRANSACTIONAL) {
for (TransactionConcurrency con : TransactionConcurrency.values()) {
for (TransactionIsolation iso : TransactionIsolation.values())
executeForCache(ccfg, clo, con, iso);
}
}
}
}
示例3: checkEntryProcessorCallCount
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param ccfg Cache configuration.
* @param expCallCnt Expected entry processor calls count.
* @throws Exception If failed.
*/
private void checkEntryProcessorCallCount(CacheConfiguration<Integer, TestValue> ccfg,
int expCallCnt) throws Exception {
Ignite client1 = ignite(SRV_CNT);
IgniteCache<Integer, TestValue> clientCache1 = client1.createCache(ccfg);
IgniteCache<Integer, TestValue> srvCache = ignite(0).cache(ccfg.getName());
awaitPartitionMapExchange();
int key = 0;
checkEntryProcessCall(key++, clientCache1, null, null, expCallCnt);
if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
checkEntryProcessCall(key++, clientCache1, OPTIMISTIC, REPEATABLE_READ, expCallCnt + 1);
checkEntryProcessCall(key++, clientCache1, PESSIMISTIC, REPEATABLE_READ, expCallCnt + 1);
checkEntryProcessCall(key++, clientCache1, OPTIMISTIC, SERIALIZABLE, expCallCnt + 1);
}
for (int i = 100; i < 110; i++) {
checkEntryProcessCall(key++, srvCache, null, null, expCallCnt);
if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
checkEntryProcessCall(key++, srvCache, OPTIMISTIC, REPEATABLE_READ, expCallCnt + 1);
checkEntryProcessCall(key++, srvCache, PESSIMISTIC, REPEATABLE_READ, expCallCnt + 1);
checkEntryProcessCall(key++, srvCache, OPTIMISTIC, SERIALIZABLE, expCallCnt + 1);
}
}
for (int i = 0; i < NODES; i++)
ignite(i).destroyCache(ccfg.getName());
}
示例4: test
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param cfg Cache configuration.
* @param oneEntry If {@code true} then single entry is tested.
* @throws Exception If failed.
*/
private void test(CacheConfiguration cfg, final boolean oneEntry) throws Exception {
final IgniteCache<Integer, TestValue> cache = grid(0).createCache(cfg);
try {
init(cache);
test(cache, null, null, null, oneEntry);
if (cfg.getAtomicityMode() == TRANSACTIONAL) {
TransactionConcurrency txConcurrency = concurrency();
TransactionIsolation txIsolation = isolation();
try (Transaction tx = grid(0).transactions().txStart(txConcurrency, txIsolation)) {
initTx(cache);
test(cache, txConcurrency, txIsolation, tx, oneEntry);
tx.commit();
}
testConcurrentTx(cache, OPTIMISTIC, REPEATABLE_READ, oneEntry);
testConcurrentTx(cache, OPTIMISTIC, READ_COMMITTED, oneEntry);
testConcurrentTx(cache, PESSIMISTIC, REPEATABLE_READ, oneEntry);
testConcurrentTx(cache, PESSIMISTIC, READ_COMMITTED, oneEntry);
testConcurrentOptimisticTxGet(cache, REPEATABLE_READ);
testConcurrentOptimisticTxGet(cache, READ_COMMITTED);
testConcurrentOptimisticTxGet(cache, SERIALIZABLE);
}
}
finally {
cache.destroy();
}
}
示例5: isLocalAtomic
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** */
protected boolean isLocalAtomic() {
CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);
return cfg.getCacheMode() == CacheMode.LOCAL && cfg.getAtomicityMode() == CacheAtomicityMode.ATOMIC;
}
示例6: validateLocalIgfsConfigurations
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Validates local IGFS configurations. Compares attributes only for IGFSes with same name.
*
* @param igniteCfg Ignite config.
* @throws IgniteCheckedException If any of IGFS configurations is invalid.
*/
private static void validateLocalIgfsConfigurations(IgniteConfiguration igniteCfg)
throws IgniteCheckedException {
if (igniteCfg.getFileSystemConfiguration() == null || igniteCfg.getFileSystemConfiguration().length == 0)
return;
Collection<String> cfgNames = new HashSet<>();
for (FileSystemConfiguration cfg : igniteCfg.getFileSystemConfiguration()) {
String name = cfg.getName();
if (name == null)
throw new IgniteCheckedException("IGFS name cannot be null");
if (cfgNames.contains(name))
throw new IgniteCheckedException("Duplicate IGFS name found (check configuration and " +
"assign unique name to each): " + name);
CacheConfiguration ccfgData = cfg.getDataCacheConfiguration();
CacheConfiguration ccfgMeta = cfg.getMetaCacheConfiguration();
if (QueryUtils.isEnabled(ccfgData))
throw new IgniteCheckedException("IGFS data cache cannot start with enabled query indexing.");
if (QueryUtils.isEnabled(ccfgMeta))
throw new IgniteCheckedException("IGFS metadata cache cannot start with enabled query indexing.");
if (ccfgMeta.getAtomicityMode() != TRANSACTIONAL)
throw new IgniteCheckedException("IGFS metadata cache should be transactional: " + cfg.getName());
if (!(ccfgData.getAffinityMapper() instanceof IgfsGroupDataBlocksKeyMapper))
throw new IgniteCheckedException(
"Invalid IGFS data cache configuration (key affinity mapper class should be " +
IgfsGroupDataBlocksKeyMapper.class.getSimpleName() + "): " + cfg);
IgfsIpcEndpointConfiguration ipcCfg = cfg.getIpcEndpointConfiguration();
if (ipcCfg != null) {
final int tcpPort = ipcCfg.getPort();
if (!(tcpPort >= MIN_TCP_PORT && tcpPort <= MAX_TCP_PORT))
throw new IgniteCheckedException("IGFS endpoint TCP port is out of range [" + MIN_TCP_PORT +
".." + MAX_TCP_PORT + "]: " + tcpPort);
if (ipcCfg.getThreadCount() <= 0)
throw new IgniteCheckedException("IGFS endpoint thread count must be positive: " +
ipcCfg.getThreadCount());
}
boolean secondary = cfg.getDefaultMode() == IgfsMode.PROXY;
if (cfg.getPathModes() != null) {
for (Map.Entry<String, IgfsMode> mode : cfg.getPathModes().entrySet()) {
if (mode.getValue() == IgfsMode.PROXY)
secondary = true;
}
}
if (secondary && cfg.getSecondaryFileSystem() == null) {
// When working in any mode except of primary, secondary FS config must be provided.
throw new IgniteCheckedException("Grid configuration parameter invalid: " +
"secondaryFileSystem cannot be null when mode is not " + IgfsMode.PRIMARY);
}
cfgNames.add(name);
}
}
示例7: VisorCacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Create data transfer object for cache configuration properties.
*
* @param ignite Grid.
* @param ccfg Cache configuration.
* @param dynamicDeploymentId Dynamic deployment ID.
*/
public VisorCacheConfiguration(IgniteEx ignite, CacheConfiguration ccfg, IgniteUuid dynamicDeploymentId) {
name = ccfg.getName();
grpName = ccfg.getGroupName();
this.dynamicDeploymentId = dynamicDeploymentId;
mode = ccfg.getCacheMode();
atomicityMode = ccfg.getAtomicityMode();
eagerTtl = ccfg.isEagerTtl();
writeSynchronizationMode = ccfg.getWriteSynchronizationMode();
invalidate = ccfg.isInvalidate();
maxConcurrentAsyncOps = ccfg.getMaxConcurrentAsyncOperations();
interceptor = compactClass(ccfg.getInterceptor());
dfltLockTimeout = ccfg.getDefaultLockTimeout();
qryEntities = VisorQueryEntity.list(ccfg.getQueryEntities());
jdbcTypes = VisorCacheJdbcType.list(ccfg.getCacheStoreFactory());
statisticsEnabled = ccfg.isStatisticsEnabled();
mgmtEnabled = ccfg.isManagementEnabled();
ldrFactory = compactClass(ccfg.getCacheLoaderFactory());
writerFactory = compactClass(ccfg.getCacheWriterFactory());
expiryPlcFactory = compactClass(ccfg.getExpiryPolicyFactory());
sys = ignite.context().cache().systemCache(ccfg.getName());
storeKeepBinary = ccfg.isStoreKeepBinary();
onheapCache = ccfg.isOnheapCacheEnabled();
partLossPlc = ccfg.getPartitionLossPolicy();
qryParallelism = ccfg.getQueryParallelism();
affinityCfg = new VisorCacheAffinityConfiguration(ccfg);
rebalanceCfg = new VisorCacheRebalanceConfiguration(ccfg);
evictCfg = new VisorCacheEvictionConfiguration(ccfg);
nearCfg = new VisorCacheNearConfiguration(ccfg);
storeCfg = new VisorCacheStoreConfiguration(ignite, ccfg);
qryCfg = new VisorQueryConfiguration(ccfg);
cpOnRead = ccfg.isCopyOnRead();
evictFilter = compactClass(ccfg.getEvictionFilter());
lsnrConfigurations = compactIterable(ccfg.getCacheEntryListenerConfigurations());
loadPrevVal = ccfg.isLoadPreviousValue();
dataRegName = ccfg.getDataRegionName();
sqlIdxMaxInlineSize = ccfg.getSqlIndexMaxInlineSize();
nodeFilter = compactClass(ccfg.getNodeFilter());
qryDetailMetricsSz = ccfg.getQueryDetailMetricsSize();
readFromBackup = ccfg.isReadFromBackup();
tmLookupClsName = ccfg.getTransactionManagerLookupClassName();
topValidator = compactClass(ccfg.getTopologyValidator());
}
示例8: testGetUpdateMultithreaded
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testGetUpdateMultithreaded(CacheConfiguration<Integer, Integer> ccfg) throws Exception {
final List<Ignite> putNodes = new ArrayList<>();
for (int i = 0; i < SRVS + CLIENTS - 1; i++)
putNodes.add(ignite(i));
final List<Ignite> getNodes = new ArrayList<>();
getNodes.add(ignite(SRVS + CLIENTS - 1));
getNodes.add(ignite(0));
logCacheInfo(ccfg);
getUpdateMultithreaded(ccfg, putNodes, getNodes, null, null);
if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
getUpdateMultithreaded(ccfg, putNodes, getNodes, PESSIMISTIC, REPEATABLE_READ);
getUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, REPEATABLE_READ);
getUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, SERIALIZABLE);
}
}