use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException in project ignite by apache.
the class GridDhtPartitionDemander method createDemandMessage.
/**
* @param old Old message.
* @param parts Partitions to demand.
* @return New demand message.
*/
private GridDhtPartitionDemandMessage createDemandMessage(GridDhtPartitionDemandMessage old, Collection<Integer> parts) {
Map<Integer, Long> partCntrs = null;
for (Integer part : parts) {
try {
if (cctx.shared().database().persistenceEnabled()) {
if (partCntrs == null)
partCntrs = new HashMap<>(parts.size(), 1.0f);
GridDhtLocalPartition p = cctx.topology().localPartition(part, old.topologyVersion(), false);
partCntrs.put(part, p.initialUpdateCounter());
}
} catch (GridDhtInvalidPartitionException ignore) {
// Skip this partition.
}
}
return new GridDhtPartitionDemandMessage(old, parts, partCntrs);
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException in project ignite by apache.
the class GridDhtPartitionDemander method preloadEntry.
/**
* Adds {@code entry} to partition {@code p}.
*
* @param from Node which sent entry.
* @param p Partition id.
* @param entry Preloaded entry.
* @param topVer Topology version.
* @return {@code False} if partition has become invalid during preloading.
* @throws IgniteInterruptedCheckedException If interrupted.
*/
private boolean preloadEntry(ClusterNode from, int p, GridCacheEntryInfo entry, AffinityTopologyVersion topVer) throws IgniteCheckedException {
ctx.database().checkpointReadLock();
try {
GridCacheEntryEx cached = null;
try {
GridCacheContext cctx = grp.sharedGroup() ? ctx.cacheContext(entry.cacheId()) : grp.singleCacheContext();
cached = cctx.dhtCache().entryEx(entry.key());
if (log.isDebugEnabled())
log.debug("Rebalancing key [key=" + entry.key() + ", part=" + p + ", node=" + from.id() + ']');
cctx.shared().database().checkpointReadLock();
try {
if (preloadPred == null || preloadPred.apply(entry)) {
if (cached.initialValue(entry.value(), entry.version(), entry.ttl(), entry.expireTime(), true, topVer, cctx.isDrEnabled() ? DR_PRELOAD : DR_NONE, false)) {
// Start tracking.
cctx.evicts().touch(cached, topVer);
if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_OBJECT_LOADED) && !cached.isInternal())
cctx.events().addEvent(cached.partition(), cached.key(), cctx.localNodeId(), (IgniteUuid) null, null, EVT_CACHE_REBALANCE_OBJECT_LOADED, entry.value(), true, null, false, null, null, null, true);
} else {
// Start tracking.
cctx.evicts().touch(cached, topVer);
if (log.isDebugEnabled())
log.debug("Rebalancing entry is already in cache (will ignore) [key=" + cached.key() + ", part=" + p + ']');
}
} else if (log.isDebugEnabled())
log.debug("Rebalance predicate evaluated to false for entry (will ignore): " + entry);
} finally {
cctx.shared().database().checkpointReadUnlock();
}
} catch (GridCacheEntryRemovedException ignored) {
if (log.isDebugEnabled())
log.debug("Entry has been concurrently removed while rebalancing (will ignore) [key=" + cached.key() + ", part=" + p + ']');
} catch (GridDhtInvalidPartitionException ignored) {
if (log.isDebugEnabled())
log.debug("Partition became invalid during rebalancing (will ignore): " + p);
return false;
}
} catch (IgniteInterruptedCheckedException e) {
throw e;
} catch (IgniteCheckedException e) {
throw new IgniteCheckedException("Failed to cache rebalanced entry (will stop rebalancing) [local=" + ctx.localNode() + ", node=" + from.id() + ", key=" + entry.key() + ", part=" + p + ']', e);
} finally {
ctx.database().checkpointReadUnlock();
}
return true;
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException in project ignite by apache.
the class SchemaIndexCacheVisitorImpl method processKey.
/**
* Process single key.
*
* @param key Key.
* @param clo Closure.
* @throws IgniteCheckedException If failed.
*/
private void processKey(KeyCacheObject key, SchemaIndexCacheVisitorClosure clo) throws IgniteCheckedException {
while (true) {
try {
checkCancelled();
GridCacheEntryEx entry = cctx.cache().entryEx(key);
try {
entry.updateIndex(rowFilter, clo);
} finally {
cctx.evicts().touch(entry, AffinityTopologyVersion.NONE);
}
break;
} catch (GridDhtInvalidPartitionException ignore) {
break;
} catch (GridCacheEntryRemovedException ignored) {
// No-op.
}
}
}
Aggregations