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);
});
}
Aggregations