Search in sources :

Example 6 with GridDhtInvalidPartitionException

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);
}
Also used : GridDhtInvalidPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException) HashMap(java.util.HashMap) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition)

Example 7 with GridDhtInvalidPartitionException

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;
}
Also used : GridDhtInvalidPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteUuid(org.apache.ignite.lang.IgniteUuid) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)

Example 8 with GridDhtInvalidPartitionException

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.
        }
    }
}
Also used : GridDhtInvalidPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)

Aggregations

GridDhtInvalidPartitionException (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)6 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)5 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)4 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)3 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)2 EntryGetResult (org.apache.ignite.internal.processors.cache.EntryGetResult)2 IgniteCacheExpiryPolicy (org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)2 GridDhtLocalPartition (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition)2 GridPartitionedGetFuture (org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture)2 CacheDataRow (org.apache.ignite.internal.processors.cache.persistence.CacheDataRow)2 GridFinishedFuture (org.apache.ignite.internal.util.future.GridFinishedFuture)2 HashMap (java.util.HashMap)1 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)1 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)1 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)1 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1