use of org.infinispan.partitionhandling.impl.LostDataCheck 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);
});
}
use of org.infinispan.partitionhandling.impl.LostDataCheck in project infinispan by infinispan.
the class BaseMergePolicyTest method getCacheFromPreferredPartition.
protected <K, V> AdvancedCache<K, V> getCacheFromPreferredPartition(AdvancedCache... caches) {
Map<Address, CacheStatusResponse> statusResponses = Arrays.stream(caches).collect(Collectors.toMap(this::address, this::getCacheStatus));
LostDataCheck lostDataCheck = cacheMode.isScattered() ? ClusterTopologyManagerImpl::scatteredLostDataCheck : ClusterTopologyManagerImpl::distLostDataCheck;
CacheTopology preferredTopology = new PreferAvailabilityStrategy(null, null, lostDataCheck).computePreferredTopology(statusResponses);
log.tracef("getCacheFromPreferredPartition: partition=%s", preferredTopology.getMembers());
return Arrays.stream(caches).filter(c -> address(c).equals(preferredTopology.getMembers().get(0))).findFirst().get();
}
Aggregations