当前位置: 首页>>代码示例>>Java>>正文


Java CacheConfiguration.getCacheMode方法代码示例

本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration.getCacheMode方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.getCacheMode方法的具体用法?Java CacheConfiguration.getCacheMode怎么用?Java CacheConfiguration.getCacheMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.configuration.CacheConfiguration的用法示例。


在下文中一共展示了CacheConfiguration.getCacheMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compareVersionWithPrimaryNode

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param e Entry.
 * @param cache Cache.
 * @throws Exception If failed.
 */
private void compareVersionWithPrimaryNode(CacheEntry<Integer, ?> e, IgniteCache<Integer, TestValue> cache)
    throws Exception {
    CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);

    if (cfg.getCacheMode() != LOCAL) {
        Ignite prim = primaryNode(e.getKey(), cache.getName());

        GridCacheAdapter<Object, Object> cacheAdapter = ((IgniteKernal)prim).internalCache(cache.getName());

        if (cfg.getNearConfiguration() != null)
            cacheAdapter = ((GridNearCacheAdapter)cacheAdapter).dht();

        IgniteCacheObjectProcessor cacheObjects = cacheAdapter.context().cacheObjects();

        CacheObjectContext cacheObjCtx = cacheAdapter.context().cacheObjectContext();

        GridCacheEntryEx mapEntry = cacheAdapter.entryEx(cacheObjects.toCacheKeyObject(
            cacheObjCtx, cacheAdapter.context(), e.getKey(), true));

        mapEntry.unswap();

        assertNotNull("No entry for key: " + e.getKey(), mapEntry);
        assertEquals(mapEntry.version(), e.version());
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:CacheGetEntryAbstractTest.java

示例2: validatePreloadOrder

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Checks that preload-order-dependant caches has SYNC or ASYNC preloading mode.
 *
 * @param cfgs Caches.
 * @return Maximum detected preload order.
 * @throws IgniteCheckedException If validation failed.
 */
private int validatePreloadOrder(CacheConfiguration[] cfgs) throws IgniteCheckedException {
    int maxOrder = 0;

    for (CacheConfiguration cfg : cfgs) {
        int rebalanceOrder = cfg.getRebalanceOrder();

        if (rebalanceOrder > 0) {
            if (cfg.getCacheMode() == LOCAL)
                throw new IgniteCheckedException("Rebalance order set for local cache (fix configuration and restart the " +
                    "node): " + U.maskName(cfg.getName()));

            if (cfg.getRebalanceMode() == CacheRebalanceMode.NONE)
                throw new IgniteCheckedException("Only caches with SYNC or ASYNC rebalance mode can be set as rebalance " +
                    "dependency for other caches [cacheName=" + U.maskName(cfg.getName()) +
                    ", rebalanceMode=" + cfg.getRebalanceMode() + ", rebalanceOrder=" + cfg.getRebalanceOrder() + ']');

            maxOrder = Math.max(maxOrder, rebalanceOrder);
        }
        else if (rebalanceOrder < 0)
            throw new IgniteCheckedException("Rebalance order cannot be negative for cache (fix configuration and restart " +
                "the node) [cacheName=" + cfg.getName() + ", rebalanceOrder=" + rebalanceOrder + ']');
    }

    return maxOrder;
}
 
开发者ID:apache,项目名称:ignite,代码行数:33,代码来源:GridCacheProcessor.java

示例3: testKeys

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param cache Cache.
 * @return Test keys.
 * @throws Exception If failed.
 */
private List<Integer> testKeys(IgniteCache<Integer, Integer> cache) throws Exception {
    CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class);

    List<Integer> keys = new ArrayList<>();

    if (!cache.unwrap(Ignite.class).configuration().isClientMode()) {
        if (ccfg.getCacheMode() == PARTITIONED)
            keys.add(nearKey(cache));

        keys.add(primaryKey(cache));

        if (ccfg.getBackups() != 0)
            keys.add(backupKey(cache));
    }
    else
        keys.add(nearKey(cache));

    return keys;
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:CacheSerializableTransactionsTest.java

示例4: testKeys

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param cache Cache.
 * @return Test keys.
 * @throws Exception If failed.
 */
private List<Integer> testKeys(IgniteCache<Integer, Integer> cache) throws Exception {
    CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class);

    List<Integer> keys = new ArrayList<>();

    if (!cache.unwrap(Ignite.class).configuration().isClientMode()) {
        if (ccfg.getCacheMode() == PARTITIONED && serversNumber() > 1)
            keys.add(nearKey(cache));

        keys.add(primaryKey(cache));

        if (ccfg.getBackups() != 0 && serversNumber() > 1)
            keys.add(backupKey(cache));
    }
    else
        keys.add(nearKey(cache));

    return keys;
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:CacheOptimisticTransactionsWithFilterTest.java

示例5: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName);

    cfg.setCacheStoreFactory(null);
    cfg.setReadThrough(false);
    cfg.setWriteThrough(false);
    cfg.setBackups(1);

    if (cfg.getCacheMode() == REPLICATED)
        cfg.setAffinity(null);
    else
        cfg.setAffinity(new RendezvousAffinityFunction(false, 32));

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:GridCacheClientModesAbstractSelfTest.java

示例6: getConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = loadConfiguration("modules/core/src/test/config/spring-multicache.xml");

    cfg.setIgniteInstanceName(igniteInstanceName);

    for (CacheConfiguration cCfg : cfg.getCacheConfiguration()) {
        if (cCfg.getCacheMode() == CacheMode.PARTITIONED) {
            cCfg.setAffinity(new RendezvousAffinityFunction(2048, null));
            cCfg.setBackups(1);
        }
    }

    ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:GridCacheDhtPreloadMultiThreadedSelfTest.java

示例7: 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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:WebSessionFilter.java

示例8: executeForNodeAndCache

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** */
private void executeForNodeAndCache(CacheConfiguration ccfg, Ignite ignite, TestClosure clo,
    TransactionConcurrency concurrency, TransactionIsolation isolation) throws Exception {
    String cacheName = ccfg.getName();

    IgniteCache cache;

    if (ignite.configuration().isClientMode() &&
        ccfg.getCacheMode() == CacheMode.PARTITIONED &&
        ccfg.getNearConfiguration() != null)
        cache = ignite.getOrCreateNearCache(ccfg.getName(), ccfg.getNearConfiguration());
    else
        cache = ignite.cache(ccfg.getName());

    cache.removeAll();

    assertEquals(0, cache.size());

    clo.configure(ignite, cache, concurrency, isolation);

    log.info("Running test with node " + ignite.name() + ", cache " + cacheName);

    clo.key1 = 1;
    clo.key2 = 4;

    clo.run();
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:IgniteSqlNotNullConstraintTest.java

示例9: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param cacheName Cache name.
 * @return Cache configuration.
 * @throws Exception In case of error.
 */
@SuppressWarnings("unchecked")
private  static CacheConfiguration cacheConfiguration(@NotNull final String cacheName) throws Exception {
    CacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setCacheMode(DEFAULT_CACHE_NAME.equals(cacheName) || CACHE_NAME.equals(cacheName) ? LOCAL : "replicated".equals(cacheName) ?
        REPLICATED : PARTITIONED);
    cfg.setName(cacheName);
    cfg.setWriteSynchronizationMode(FULL_SYNC);

    cfg.setCacheStoreFactory(new Factory<CacheStore>() {
        @Override public CacheStore create() {
            synchronized (cacheStores) {
                HashMapStore cacheStore = cacheStores.get(cacheName);

                if (cacheStore == null)
                    cacheStores.put(cacheName, cacheStore = new HashMapStore());

                return cacheStore;
            }
        }
    });

    cfg.setWriteThrough(true);
    cfg.setReadThrough(true);
    cfg.setLoadPreviousValue(true);

    if (cfg.getCacheMode() == PARTITIONED)
        cfg.setBackups(1);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:37,代码来源:ClientAbstractSelfTest.java

示例10: isNearEnabled

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Checks if near cache is enabled for cache configuration.
 *
 * @param cfg Cache configuration to check.
 * @return {@code True} if near cache is enabled, {@code false} otherwise.
 */
@SuppressWarnings("SimplifiableIfStatement")
public static boolean isNearEnabled(CacheConfiguration cfg) {
    if (cfg.getCacheMode() == LOCAL)
        return false;

    return cfg.getNearConfiguration() != null;
}
 
开发者ID:apache,项目名称:ignite,代码行数:14,代码来源:GridCacheUtils.java

示例11: suggestOptimizations

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param cfg Configuration to check for possible performance issues.
 * @param hasStore {@code True} if store is configured.
 */
private void suggestOptimizations(CacheConfiguration cfg, boolean hasStore) {
    GridPerformanceSuggestions perf = ctx.performance();

    String msg = "Disable eviction policy (remove from configuration)";

    if (cfg.getEvictionPolicyFactory() != null || cfg.getEvictionPolicy() != null)
        perf.add(msg, false);
    else
        perf.add(msg, true);

    if (cfg.getCacheMode() == PARTITIONED) {
        perf.add("Disable near cache (set 'nearConfiguration' to null)", cfg.getNearConfiguration() == null);

        if (cfg.getAffinity() != null)
            perf.add("Decrease number of backups (set 'backups' to 0)", cfg.getBackups() == 0);
    }

    // Suppress warning if at least one ATOMIC cache found.
    perf.add("Enable ATOMIC mode if not using transactions (set 'atomicityMode' to ATOMIC)",
        cfg.getAtomicityMode() == ATOMIC);

    // Suppress warning if at least one non-FULL_SYNC mode found.
    perf.add("Disable fully synchronous writes (set 'writeSynchronizationMode' to PRIMARY_SYNC or FULL_ASYNC)",
        cfg.getWriteSynchronizationMode() != FULL_SYNC);

    if (hasStore && cfg.isWriteThrough())
        perf.add("Enable write-behind to persistent store (set 'writeBehindEnabled' to true)",
            cfg.isWriteBehindEnabled());
}
 
开发者ID:apache,项目名称:ignite,代码行数:34,代码来源:GridCacheProcessor.java

示例12: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName);

    cfg.setRebalanceMode(SYNC);

    if (cfg.getCacheMode() == CacheMode.PARTITIONED)
        cfg.setBackups(TOP_CHANGE_THREAD_CNT);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:12,代码来源:GridCacheAbstractFailoverSelfTest.java

示例13: 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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:7,代码来源:IgniteSqlNotNullConstraintTest.java

示例14: validateCacheGroupConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param cfg Existing configuration.
 * @param startCfg Cache configuration to start.
 * @throws IgniteCheckedException If validation failed.
 */
private void validateCacheGroupConfiguration(CacheConfiguration cfg, CacheConfiguration startCfg)
    throws IgniteCheckedException {
    GridCacheAttributes attr1 = new GridCacheAttributes(cfg);
    GridCacheAttributes attr2 = new GridCacheAttributes(startCfg);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "cacheMode", "Cache mode",
        cfg.getCacheMode(), startCfg.getCacheMode(), true);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "affinity", "Affinity function",
        attr1.cacheAffinityClassName(), attr2.cacheAffinityClassName(), true);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "affinityPartitionsCount",
        "Affinity partitions count", attr1.affinityPartitionsCount(), attr2.affinityPartitionsCount(), true);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "nodeFilter", "Node filter",
        attr1.nodeFilterClassName(), attr2.nodeFilterClassName(), true);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "dataRegionName", "Data region",
        cfg.getDataRegionName(), startCfg.getDataRegionName(), true);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "topologyValidator", "Topology validator",
        attr1.topologyValidatorClassName(), attr2.topologyValidatorClassName(), true);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "partitionLossPolicy", "Partition Loss Policy",
        cfg.getPartitionLossPolicy(), startCfg.getPartitionLossPolicy(), true);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "rebalanceMode", "Rebalance mode",
        cfg.getRebalanceMode(), startCfg.getRebalanceMode(), true);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "rebalanceDelay", "Rebalance delay",
        cfg.getRebalanceDelay(), startCfg.getRebalanceDelay(), false);

    CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "rebalanceOrder", "Rebalance order",
        cfg.getRebalanceOrder(), startCfg.getRebalanceOrder(), false);

    if (cfg.getCacheMode() == PARTITIONED) {
        CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "backups", "Backups",
            cfg.getBackups(), startCfg.getBackups(), true);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:46,代码来源:ClusterCachesInfo.java

示例15: run

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected VisorCachePartitions run(VisorCachePartitionsTaskArg arg) throws IgniteException {
    String cacheName = arg.getCacheName();

    if (debug)
        log(ignite.log(), "Collecting partitions for cache: " + escapeName(cacheName));

    VisorCachePartitions parts = new VisorCachePartitions();

    GridCacheAdapter ca = ignite.context().cache().internalCache(cacheName);

    // Cache was not started.
    if (ca == null || !ca.context().started())
        return parts;

    CacheConfiguration cfg = ca.configuration();

    CacheMode mode = cfg.getCacheMode();

    boolean partitioned = (mode == CacheMode.PARTITIONED || mode == CacheMode.REPLICATED)
        && ca.context().affinityNode();

    if (partitioned) {
        GridDhtCacheAdapter dca = null;

        if (ca instanceof GridNearCacheAdapter)
            dca = ((GridNearCacheAdapter)ca).dht();
        else if (ca instanceof GridDhtCacheAdapter)
            dca = (GridDhtCacheAdapter)ca;

        if (dca != null) {
            GridDhtPartitionTopology top = dca.topology();

            List<GridDhtLocalPartition> locParts = top.localPartitions();

            for (GridDhtLocalPartition part : locParts) {
                int p = part.id();

                long sz = part.dataStore().cacheSize(ca.context().cacheId());

                // Pass NONE as topology version in order not to wait for topology version.
                if (part.primary(AffinityTopologyVersion.NONE))
                    parts.addPrimary(p, sz);
                else if (part.state() == GridDhtPartitionState.OWNING && part.backup(AffinityTopologyVersion.NONE))
                    parts.addBackup(p, sz);
            }
        }
    }

    return parts;
}
 
开发者ID:apache,项目名称:ignite,代码行数:52,代码来源:VisorCachePartitionsTask.java


注:本文中的org.apache.ignite.configuration.CacheConfiguration.getCacheMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。