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