Search in sources :

Example 1 with PartitionHandling

use of org.infinispan.partitionhandling.PartitionHandling in project infinispan by infinispan.

the class ClusterTopologyManagerImpl method initCacheStatusIfAbsent.

private ClusterCacheStatus initCacheStatusIfAbsent(String cacheName, CacheMode cacheMode) {
    return cacheStatusMap.computeIfAbsent(cacheName, (name) -> {
        // We assume that any cache with partition handling configured is already defined on all the nodes
        // (including the coordinator) before it starts on any node.
        LostDataCheck lostDataCheck;
        if (cacheMode.isScattered()) {
            lostDataCheck = ClusterTopologyManagerImpl::scatteredLostDataCheck;
        } else {
            lostDataCheck = ClusterTopologyManagerImpl::distLostDataCheck;
        }
        // TODO Partition handling config should be part of the join info
        AvailabilityStrategy availabilityStrategy;
        Configuration config = configurationManager.getConfiguration(cacheName, true);
        PartitionHandling partitionHandling = config != null ? config.clustering().partitionHandling().whenSplit() : null;
        boolean resolveConflictsOnMerge = resolveConflictsOnMerge(config, cacheMode);
        if (partitionHandling != null && partitionHandling != PartitionHandling.ALLOW_READ_WRITES) {
            availabilityStrategy = new PreferConsistencyStrategy(eventLogManager, persistentUUIDManager, lostDataCheck);
        } else {
            availabilityStrategy = new PreferAvailabilityStrategy(eventLogManager, persistentUUIDManager, lostDataCheck);
        }
        Optional<GlobalStateManager> globalStateManager = gcr.getOptionalComponent(GlobalStateManager.class);
        Optional<ScopedPersistentState> persistedState = globalStateManager.flatMap(gsm -> gsm.readScopedState(cacheName));
        return new ClusterCacheStatus(cacheManager, gcr, cacheName, availabilityStrategy, RebalanceType.from(cacheMode), this, transport, persistentUUIDManager, eventLogManager, persistedState, resolveConflictsOnMerge);
    });
}
Also used : PreferAvailabilityStrategy(org.infinispan.partitionhandling.impl.PreferAvailabilityStrategy) AvailabilityStrategy(org.infinispan.partitionhandling.impl.AvailabilityStrategy) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) PreferAvailabilityStrategy(org.infinispan.partitionhandling.impl.PreferAvailabilityStrategy) ScopedPersistentState(org.infinispan.globalstate.ScopedPersistentState) GlobalStateManager(org.infinispan.globalstate.GlobalStateManager) LostDataCheck(org.infinispan.partitionhandling.impl.LostDataCheck) PreferConsistencyStrategy(org.infinispan.partitionhandling.impl.PreferConsistencyStrategy) PartitionHandling(org.infinispan.partitionhandling.PartitionHandling)

Aggregations

Configuration (org.infinispan.configuration.cache.Configuration)1 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)1 GlobalStateManager (org.infinispan.globalstate.GlobalStateManager)1 ScopedPersistentState (org.infinispan.globalstate.ScopedPersistentState)1 PartitionHandling (org.infinispan.partitionhandling.PartitionHandling)1 AvailabilityStrategy (org.infinispan.partitionhandling.impl.AvailabilityStrategy)1 LostDataCheck (org.infinispan.partitionhandling.impl.LostDataCheck)1 PreferAvailabilityStrategy (org.infinispan.partitionhandling.impl.PreferAvailabilityStrategy)1 PreferConsistencyStrategy (org.infinispan.partitionhandling.impl.PreferConsistencyStrategy)1