use of org.apache.ignite.internal.processors.cache.CacheGroupContext in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method resetLostPartitions.
/**
* @param cacheNames Cache names.
*/
private void resetLostPartitions(Collection<String> cacheNames) {
assert !exchCtx.mergeExchanges();
try {
doInParallelUninterruptibly(U.availableThreadCount(cctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2), cctx.kernalContext().pools().getSystemExecutorService(), cctx.affinity().caches().values(), desc -> {
if (desc.cacheConfiguration().getCacheMode() == CacheMode.LOCAL)
return null;
if (cacheNames.contains(desc.cacheName())) {
CacheGroupContext grp = cctx.cache().cacheGroup(desc.groupId());
GridDhtPartitionTopology top = grp != null ? grp.topology() : cctx.exchange().clientTopology(desc.groupId(), events().discoveryCache());
top.resetLostPartitions(initialVersion());
}
return null;
});
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.processors.cache.CacheGroupContext in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method initTopologies.
/**
* @throws IgniteCheckedException If failed.
*/
private void initTopologies() throws IgniteCheckedException {
cctx.database().checkpointReadLock();
try {
if (crd != null) {
for (CacheGroupContext grp : cctx.cache().cacheGroups()) {
if (grp.isLocal())
continue;
grp.topology().beforeExchange(this, !centralizedAff && !forceAffReassignment, false);
cctx.exchange().exchangerUpdateHeartbeat();
}
}
} finally {
cctx.database().checkpointReadUnlock();
}
}
use of org.apache.ignite.internal.processors.cache.CacheGroupContext in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method assignPartitionsStates.
/**
* @param cacheGroupsToResetOwners Set of cache groups which need to reset partitions state,
* null if reset partitions state for all cache groups needed
*/
private void assignPartitionsStates(Set<Integer> cacheGroupsToResetOwners) {
Map<String, List<SupplyPartitionInfo>> supplyInfoMap = log.isInfoEnabled() ? new ConcurrentHashMap<>() : null;
try {
U.doInParallel(cctx.kernalContext().pools().getSystemExecutorService(), nonLocalCacheGroupDescriptors(), grpDesc -> {
CacheGroupContext grpCtx = cctx.cache().cacheGroup(grpDesc.groupId());
GridDhtPartitionTopology top = grpCtx != null ? grpCtx.topology() : cctx.exchange().clientTopology(grpDesc.groupId(), events().discoveryCache());
if (CU.isPersistentCache(grpDesc.config(), cctx.gridConfig().getDataStorageConfiguration())) {
List<SupplyPartitionInfo> list;
if (cacheGroupsToResetOwners == null || cacheGroupsToResetOwners.contains(grpDesc.groupId()))
list = assignPartitionStates(top, true);
else
list = assignPartitionStates(top, false);
if (supplyInfoMap != null && !F.isEmpty(list))
supplyInfoMap.put(grpDesc.cacheOrGroupName(), list);
} else if (cacheGroupsToResetOwners == null)
assignPartitionSizes(top);
return null;
});
} catch (IgniteCheckedException e) {
throw new IgniteException("Failed to assign partition states", e);
}
if (!F.isEmpty(supplyInfoMap))
printPartitionRebalancingFully(supplyInfoMap);
timeBag.finishGlobalStage("Assign partitions states");
}
use of org.apache.ignite.internal.processors.cache.CacheGroupContext in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method finalizePartitionCounters.
/**
* Removes gaps in the local update counters. Gaps in update counters are possible on backup node when primary
* failed to send update counter deltas to backup.
*/
private void finalizePartitionCounters() {
// Reserve at least 2 threads for system operations.
int parallelismLvl = U.availableThreadCount(cctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2);
try {
U.<CacheGroupContext, Void>doInParallelUninterruptibly(parallelismLvl, cctx.kernalContext().pools().getSystemExecutorService(), nonLocalCacheGroups(), grp -> {
Set<Integer> parts;
if (exchCtx.exchangeFreeSwitch()) {
assert !isSnapshotOperation(firstDiscoEvt) : "Not allowed for taking snapshots: " + this;
// Previous topology to resolve failed primaries set.
AffinityTopologyVersion topVer = sharedContext().exchange().readyAffinityVersion();
// Failed node's primary partitions. Safe to use affinity since topology was fully rebalanced.
parts = grp.affinity().primaryPartitions(firstDiscoEvt.eventNode().id(), topVer);
} else
parts = grp.topology().localPartitionMap().keySet();
grp.topology().finalizeUpdateCounters(parts);
return null;
});
} catch (IgniteCheckedException e) {
throw new IgniteException("Failed to finalize partition counters", e);
}
timeBag.finishGlobalStage("Finalize update counters");
}
use of org.apache.ignite.internal.processors.cache.CacheGroupContext in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method processSingleMessageOnCrdFinish.
/**
* @param msg Single message to process.
* @param messageAccumulator Message to store message which need to be sent after.
*/
private void processSingleMessageOnCrdFinish(GridDhtPartitionsSingleMessage msg, Map<Integer, CacheGroupAffinityMessage> messageAccumulator) {
for (Map.Entry<Integer, GridDhtPartitionMap> e : msg.partitions().entrySet()) {
Integer grpId = e.getKey();
CacheGroupContext grp = cctx.cache().cacheGroup(grpId);
GridDhtPartitionTopology top = grp != null ? grp.topology() : cctx.exchange().clientTopology(grpId, events().discoveryCache());
CachePartitionPartialCountersMap cntrs = msg.partitionUpdateCounters(grpId, top.partitions());
if (cntrs != null)
top.collectUpdateCounters(cntrs);
}
Collection<Integer> affReq = msg.cacheGroupsAffinityRequest();
if (affReq != null)
CacheGroupAffinityMessage.createAffinityMessages(cctx, exchCtx.events().topologyVersion(), affReq, messageAccumulator);
}
Aggregations