Search in sources :

Example 1 with LostDataCheck

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

Example 2 with LostDataCheck

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();
}
Also used : LostDataCheck(org.infinispan.partitionhandling.impl.LostDataCheck) Address(org.infinispan.remoting.transport.Address) CacheTopology(org.infinispan.topology.CacheTopology) PreferAvailabilityStrategy(org.infinispan.partitionhandling.impl.PreferAvailabilityStrategy) ClusterTopologyManagerImpl(org.infinispan.topology.ClusterTopologyManagerImpl) CacheStatusResponse(org.infinispan.topology.CacheStatusResponse)

Aggregations

LostDataCheck (org.infinispan.partitionhandling.impl.LostDataCheck)2 PreferAvailabilityStrategy (org.infinispan.partitionhandling.impl.PreferAvailabilityStrategy)2 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 PreferConsistencyStrategy (org.infinispan.partitionhandling.impl.PreferConsistencyStrategy)1 Address (org.infinispan.remoting.transport.Address)1 CacheStatusResponse (org.infinispan.topology.CacheStatusResponse)1 CacheTopology (org.infinispan.topology.CacheTopology)1 ClusterTopologyManagerImpl (org.infinispan.topology.ClusterTopologyManagerImpl)1