Java Code Examples for org.apache.ignite.configuration.CacheConfiguration#IgniteAllNodesPredicate

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#IgniteAllNodesPredicate . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PartitionExtractor.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Prepare affinity identifier for cache.
 *
 * @param ccfg Cache configuration.
 * @return Affinity identifier.
 */
private static PartitionTableAffinityDescriptor affinityForCache(CacheConfiguration ccfg) {
    // Partition could be extracted only from PARTITIONED caches.
    if (ccfg.getCacheMode() != CacheMode.PARTITIONED)
        return null;

    PartitionAffinityFunctionType aff = ccfg.getAffinity().getClass().equals(RendezvousAffinityFunction.class) ?
        PartitionAffinityFunctionType.RENDEZVOUS : PartitionAffinityFunctionType.CUSTOM;

    boolean hasNodeFilter = ccfg.getNodeFilter() != null &&
        !(ccfg.getNodeFilter() instanceof CacheConfiguration.IgniteAllNodesPredicate);

    return new PartitionTableAffinityDescriptor(
        aff,
        ccfg.getAffinity().partitions(),
        hasNodeFilter,
        ccfg.getDataRegionName()
    );
}
 
Example 2
Source File: ClientCachePartitionsRequest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param ccfg Cache configuration.
 * @return True if cache is applicable for partition awareness optimisation.
 */
private static boolean isApplicable(CacheConfiguration ccfg) {
    // Partition could be extracted only from PARTITIONED caches.
    if (ccfg.getCacheMode() != CacheMode.PARTITIONED)
        return false;

    // Only caches with no custom affinity key mapper is supported.
    AffinityKeyMapper keyMapper = ccfg.getAffinityMapper();
    if (!(keyMapper instanceof CacheDefaultBinaryAffinityKeyMapper))
        return false;

    // Only RendezvousAffinityFunction is supported for now.
    if (!ccfg.getAffinity().getClass().equals(RendezvousAffinityFunction.class))
        return false;

    IgnitePredicate filter = ccfg.getNodeFilter();
    boolean hasNodeFilter = filter != null && !(filter instanceof CacheConfiguration.IgniteAllNodesPredicate);

    // We cannot be sure that two caches are co-located if custom node filter is present.
    // Note that technically we may try to compare two filters. However, this adds unnecessary complexity
    // and potential deserialization issues.
    return !hasNodeFilter;
}