Search in sources :

Example 56 with GridCacheContext

use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.

the class IgniteTxStateImpl method onTxEnd.

/**
 * {@inheritDoc}
 */
@Override
public void onTxEnd(GridCacheSharedContext cctx, IgniteInternalTx tx, boolean commit) {
    for (int i = 0; i < activeCacheIds.size(); i++) {
        int cacheId = activeCacheIds.get(i);
        GridCacheContext cacheCtx = cctx.cacheContext(cacheId);
        onTxEnd(cacheCtx, tx, commit);
    }
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext)

Example 57 with GridCacheContext

use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.

the class GridDhtAtomicSingleUpdateRequest method finishUnmarshal.

/**
 * {@inheritDoc}
 */
@Override
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
    super.finishUnmarshal(ctx, ldr);
    GridCacheContext cctx = ctx.cacheContext(cacheId);
    finishUnmarshalObject(key, cctx, ldr);
    finishUnmarshalObject(val, cctx, ldr);
    finishUnmarshalObject(prevVal, cctx, ldr);
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext)

Example 58 with GridCacheContext

use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.

the class GridNearAtomicFullUpdateRequest method prepareMarshal.

/**
 * {@inheritDoc}
 */
@Override
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
    super.prepareMarshal(ctx);
    GridCacheContext cctx = ctx.cacheContext(cacheId);
    if (expiryPlc != null && expiryPlcBytes == null)
        expiryPlcBytes = CU.marshal(cctx, new IgniteExternalizableExpiryPolicy(expiryPlc));
    prepareMarshalCacheObjects(keys, cctx);
    if (filter != null) {
        boolean hasFilter = false;
        for (CacheEntryPredicate p : filter) {
            if (p != null) {
                hasFilter = true;
                p.prepareMarshal(cctx);
            }
        }
        if (!hasFilter)
            filter = null;
    }
    if (op == TRANSFORM) {
        // force addition of deployment info for entry processors if P2P is enabled globally.
        if (!addDepInfo && ctx.deploymentEnabled())
            addDepInfo = true;
        if (entryProcessorsBytes == null)
            entryProcessorsBytes = marshalCollection(entryProcessors, cctx);
        if (invokeArgsBytes == null)
            invokeArgsBytes = marshalInvokeArguments(invokeArgs, cctx);
    } else
        prepareMarshalCacheObjects(vals, cctx);
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteExternalizableExpiryPolicy(org.apache.ignite.internal.processors.cache.distributed.IgniteExternalizableExpiryPolicy) CacheEntryPredicate(org.apache.ignite.internal.processors.cache.CacheEntryPredicate)

Example 59 with GridCacheContext

use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.

the class GridNearAtomicFullUpdateRequest method finishUnmarshal.

/**
 * {@inheritDoc}
 */
@Override
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
    super.finishUnmarshal(ctx, ldr);
    GridCacheContext cctx = ctx.cacheContext(cacheId);
    if (expiryPlcBytes != null && expiryPlc == null)
        expiryPlc = U.unmarshal(ctx, expiryPlcBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
    finishUnmarshalCacheObjects(keys, cctx, ldr);
    if (filter != null) {
        for (CacheEntryPredicate p : filter) {
            if (p != null)
                p.finishUnmarshal(cctx, ldr);
        }
    }
    if (op == TRANSFORM) {
        if (entryProcessors == null)
            entryProcessors = unmarshalCollection(entryProcessorsBytes, ctx, ldr);
        if (invokeArgs == null)
            invokeArgs = unmarshalInvokeArguments(invokeArgsBytes, ctx, ldr);
    } else
        finishUnmarshalCacheObjects(vals, cctx, ldr);
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) CacheEntryPredicate(org.apache.ignite.internal.processors.cache.CacheEntryPredicate)

Example 60 with GridCacheContext

use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.

the class GridDhtPartitionDemander method addAssignments.

/**
 * Initiates new rebalance process from given {@code assignments}.
 * If previous rebalance is not finished method cancels it.
 * In case of delayed rebalance method schedules new with configured delay.
 *
 * @param assignments Assignments.
 * @param force {@code True} if dummy reassign.
 * @param rebalanceId Rebalance id.
 * @param next Runnable responsible for cache rebalancing start.
 * @param forcedRebFut External future for forced rebalance.
 * @return Rebalancing runnable.
 */
Runnable addAssignments(final GridDhtPreloaderAssignments assignments, boolean force, long rebalanceId, final Runnable next, @Nullable final GridCompoundFuture<Boolean, Boolean> forcedRebFut) {
    if (log.isDebugEnabled())
        log.debug("Adding partition assignments: " + assignments);
    assert force == (forcedRebFut != null);
    long delay = grp.config().getRebalanceDelay();
    if ((delay == 0 || force) && assignments != null) {
        final RebalanceFuture oldFut = rebalanceFut;
        final RebalanceFuture fut = new RebalanceFuture(grp, assignments, log, rebalanceId);
        if (!oldFut.isInitial())
            oldFut.cancel();
        else
            fut.listen(f -> oldFut.onDone(f.result()));
        if (forcedRebFut != null)
            forcedRebFut.add(fut);
        rebalanceFut = fut;
        for (final GridCacheContext cctx : grp.caches()) {
            if (cctx.statisticsEnabled()) {
                final CacheMetricsImpl metrics = cctx.cache().metrics0();
                metrics.clearRebalanceCounters();
                metrics.startRebalance(0);
                rebalanceFut.listen(f -> metrics.clearRebalanceCounters());
            }
        }
        fut.sendRebalanceStartedEvent();
        if (assignments.cancelled()) {
            // Pending exchange.
            if (log.isDebugEnabled())
                log.debug("Rebalancing skipped due to cancelled assignments.");
            fut.onDone(false);
            fut.sendRebalanceFinishedEvent();
            return null;
        }
        if (assignments.isEmpty()) {
            // Nothing to rebalance.
            if (log.isDebugEnabled())
                log.debug("Rebalancing skipped due to empty assignments.");
            fut.onDone(true);
            ((GridFutureAdapter) grp.preloader().syncFuture()).onDone();
            fut.sendRebalanceFinishedEvent();
            return null;
        }
        return () -> {
            if (next != null)
                fut.listen(f -> {
                    try {
                        if (// Not cancelled.
                        f.get())
                            // Starts next cache rebalancing (according to the order).
                            next.run();
                    } catch (IgniteCheckedException e) {
                        if (log.isDebugEnabled())
                            log.debug(e.getMessage());
                    }
                });
            requestPartitions(fut, assignments);
        };
    } else if (delay > 0) {
        for (GridCacheContext cctx : grp.caches()) {
            if (cctx.statisticsEnabled()) {
                final CacheMetricsImpl metrics = cctx.cache().metrics0();
                metrics.startRebalance(delay);
            }
        }
        GridTimeoutObject obj = lastTimeoutObj.get();
        if (obj != null)
            ctx.time().removeTimeoutObject(obj);
        final GridDhtPartitionsExchangeFuture exchFut = lastExchangeFut;
        assert exchFut != null : "Delaying rebalance process without topology event.";
        obj = new GridTimeoutObjectAdapter(delay) {

            @Override
            public void onTimeout() {
                exchFut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {

                    @Override
                    public void apply(IgniteInternalFuture<AffinityTopologyVersion> f) {
                        ctx.exchange().forceRebalance(exchFut.exchangeId());
                    }
                });
            }
        };
        lastTimeoutObj.set(obj);
        ctx.time().addTimeoutObject(obj);
    }
    return null;
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition) CacheRebalanceMode(org.apache.ignite.cache.CacheRebalanceMode) EVT_CACHE_REBALANCE_STARTED(org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STARTED) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) EVT_CACHE_REBALANCE_STOPPED(org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STOPPED) EVT_CACHE_REBALANCE_PART_LOADED(org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_LOADED) GridCacheEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheEntryInfo) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) DR_PRELOAD(org.apache.ignite.internal.processors.dr.GridDrType.DR_PRELOAD) Set(java.util.Set) UUID(java.util.UUID) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) EVT_CACHE_REBALANCE_OBJECT_LOADED(org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_LOADED) GridCachePartitionExchangeManager(org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager) MOVING(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.MOVING) DR_NONE(org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) CacheEntryInfoCollection(org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) IgniteLogger(org.apache.ignite.IgniteLogger) AtomicReference(java.util.concurrent.atomic.AtomicReference) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext) LT(org.apache.ignite.internal.util.typedef.internal.LT) ArrayList(java.util.ArrayList) AffinityAssignment(org.apache.ignite.internal.processors.affinity.AffinityAssignment) GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology) HashSet(java.util.HashSet) ClusterNode(org.apache.ignite.cluster.ClusterNode) CI1(org.apache.ignite.internal.util.typedef.CI1) GridTimeoutObjectAdapter(org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) S(org.apache.ignite.internal.util.typedef.internal.S) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) Iterator(java.util.Iterator) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) T2(org.apache.ignite.internal.util.typedef.T2) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CacheMetricsImpl(org.apache.ignite.internal.processors.cache.CacheMetricsImpl) IgniteUuid(org.apache.ignite.lang.IgniteUuid) GridDhtInvalidPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) CacheMetricsImpl(org.apache.ignite.internal.processors.cache.CacheMetricsImpl) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridTimeoutObjectAdapter(org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter)

Aggregations

GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)147 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)37 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)22 HashMap (java.util.HashMap)21 ClusterNode (org.apache.ignite.cluster.ClusterNode)20 Map (java.util.Map)19 UUID (java.util.UUID)18 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)18 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)16 ArrayList (java.util.ArrayList)15 IgniteException (org.apache.ignite.IgniteException)14 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)14 List (java.util.List)13 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)13 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)13 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)11 ConcurrentMap (java.util.concurrent.ConcurrentMap)10 IgniteTxEntry (org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry)10 GridCacheEntryInfo (org.apache.ignite.internal.processors.cache.GridCacheEntryInfo)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8