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


Java CacheConfiguration.getAffinity方法代码示例

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


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

示例1: lifecycleAwares

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param grp Cache group.
 * @param ccfg Cache configuration.
 * @param objs Extra components.
 * @return Components provided in cache configuration which can implement {@link LifecycleAware} interface.
 */
private Iterable<Object> lifecycleAwares(CacheGroupContext grp, CacheConfiguration ccfg, Object... objs) {
    Collection<Object> ret = new ArrayList<>(7 + objs.length);

    if (grp.affinityFunction() != ccfg.getAffinity())
        ret.add(ccfg.getAffinity());

    ret.add(ccfg.getAffinityMapper());
    ret.add(ccfg.getEvictionFilter());
    ret.add(ccfg.getEvictionPolicyFactory());
    ret.add(ccfg.getEvictionPolicy());
    ret.add(ccfg.getInterceptor());

    NearCacheConfiguration nearCfg = ccfg.getNearConfiguration();

    if (nearCfg != null) {
        ret.add(nearCfg.getNearEvictionPolicyFactory());
        ret.add(nearCfg.getNearEvictionPolicy());
    }

    Collections.addAll(ret, objs);

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

示例2: VisorCacheAffinityConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Create data transfer object for affinity configuration properties.
 *
 * @param ccfg Cache configuration.
 */
public VisorCacheAffinityConfiguration(CacheConfiguration ccfg) {
    AffinityFunction aff = ccfg.getAffinity();

    function = compactClass(aff);
    mapper = compactClass(ccfg.getAffinityMapper());
    partitions = aff.partitions();
    partitionedBackups = ccfg.getBackups();

    Method mthd = findNonPublicMethod(aff.getClass(), "isExcludeNeighbors");

    if (mthd != null) {
        try {
            exclNeighbors = (Boolean)mthd.invoke(aff);
        }
        catch (InvocationTargetException | IllegalAccessException ignored) {
            //  No-op.
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:VisorCacheAffinityConfiguration.java

示例3: configure

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void configure(IgniteConfiguration cfg) {
    super.configure(cfg);

    for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) {
        AffinityFunction aff = ccfg.getAffinity();

        int parts = aff != null ? aff.partitions() : RendezvousAffinityFunction.DFLT_PARTITION_COUNT;

        ccfg.setGroupName("testGroup-parts" + parts);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java

示例4: affinityFunctions

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Find .NET affinity functions in configuration.
 *
 * @param cfg Configuration.
 * @return affinity functions.
 */
private static List<PlatformDotNetAffinityFunction> affinityFunctions(IgniteConfiguration cfg) {
    List<PlatformDotNetAffinityFunction> res = new ArrayList<>();

    CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration();

    if (cacheCfg != null) {
        for (CacheConfiguration ccfg : cacheCfg) {
            if (ccfg.getAffinity() instanceof PlatformDotNetAffinityFunction)
                res.add((PlatformDotNetAffinityFunction)ccfg.getAffinity());
        }
    }

    return res;
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:PlatformDotNetConfigurationClosure.java

示例5: 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

示例6: validateHashIdResolvers

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param node Joining node.
 * @return Validation result or {@code null} in case of success.
 */
@Nullable private IgniteNodeValidationResult validateHashIdResolvers(ClusterNode node) {
    if (!node.isClient()) {
        for (DynamicCacheDescriptor desc : cacheDescriptors().values()) {
            CacheConfiguration cfg = desc.cacheConfiguration();

            if (cfg.getAffinity() instanceof RendezvousAffinityFunction) {
                RendezvousAffinityFunction aff = (RendezvousAffinityFunction)cfg.getAffinity();

                Object nodeHashObj = aff.resolveNodeHash(node);

                for (ClusterNode topNode : ctx.discovery().allNodes()) {
                    Object topNodeHashObj = aff.resolveNodeHash(topNode);

                    if (nodeHashObj.hashCode() == topNodeHashObj.hashCode()) {
                        String errMsg = "Failed to add node to topology because it has the same hash code for " +
                            "partitioned affinity as one of existing nodes [cacheName=" +
                            cfg.getName() + ", existingNodeId=" + topNode.id() + ']';

                        String sndMsg = "Failed to add node to topology because it has the same hash code for " +
                            "partitioned affinity as one of existing nodes [cacheName=" +
                            cfg.getName() + ", existingNodeId=" + topNode.id() + ']';

                        return new IgniteNodeValidationResult(topNode.id(), errMsg, sndMsg);
                    }
                }
            }
        }
    }

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


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