use of org.apache.ignite.internal.IgniteInternalFuture in project ignite by apache.
the class GridNearAtomicSingleUpdateFuture method waitAndRemap.
/**
* @param remapTopVer New topology version.
*/
private void waitAndRemap(AffinityTopologyVersion remapTopVer) {
if (topLocked) {
CachePartialUpdateCheckedException e = new CachePartialUpdateCheckedException("Failed to update keys (retry update if possible).");
ClusterTopologyCheckedException cause = new ClusterTopologyCheckedException("Failed to update keys, topology changed while execute atomic update inside transaction.");
cause.retryReadyFuture(cctx.affinity().affinityReadyFuture(remapTopVer));
e.add(Collections.singleton(cctx.toCacheKeyObject(key)), cause);
completeFuture(null, e, null);
return;
}
IgniteInternalFuture<AffinityTopologyVersion> fut = cctx.shared().exchange().affinityReadyFuture(remapTopVer);
if (fut == null)
fut = new GridFinishedFuture<>(remapTopVer);
fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
@Override
public void apply(final IgniteInternalFuture<AffinityTopologyVersion> fut) {
cctx.kernalContext().closure().runLocalSafe(new Runnable() {
@Override
public void run() {
mapOnTopology();
}
});
}
});
}
use of org.apache.ignite.internal.IgniteInternalFuture in project ignite by apache.
the class GridNearAtomicSingleUpdateFuture method mapOnTopology.
/** {@inheritDoc} */
@Override
protected void mapOnTopology() {
AffinityTopologyVersion topVer;
if (cache.topology().stopping()) {
completeFuture(null, new IgniteCheckedException("Failed to perform cache operation (cache is stopped): " + cache.name()), null);
return;
}
GridDhtTopologyFuture fut = cache.topology().topologyVersionFuture();
if (fut.isDone()) {
Throwable err = fut.validateCache(cctx, recovery, /*read*/
false, key, null);
if (err != null) {
completeFuture(null, err, null);
return;
}
topVer = fut.topologyVersion();
} else {
assert !topLocked : this;
fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
@Override
public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) {
cctx.kernalContext().closure().runLocalSafe(new Runnable() {
@Override
public void run() {
mapOnTopology();
}
});
}
});
return;
}
map(topVer);
}
use of org.apache.ignite.internal.IgniteInternalFuture in project ignite by apache.
the class GridDhtAtomicCache method removeAllAsync0.
/**
* Entry point for all public API remove methods.
*
* @param keys Keys to remove.
* @param conflictMap Conflict map.
* @param retval Return value required flag.
* @param rawRetval Return {@code GridCacheReturn} instance.
* @return Completion future.
*/
private IgniteInternalFuture removeAllAsync0(@Nullable Collection<? extends K> keys, @Nullable Map<KeyCacheObject, GridCacheVersion> conflictMap, final boolean retval, boolean rawRetval, boolean async) {
assert ctx.updatesAllowed();
assert keys != null || conflictMap != null;
if (keyCheck)
validateCacheKeys(keys);
ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);
final CacheOperationContext opCtx = ctx.operationContextPerCall();
UUID subjId = ctx.subjectIdPerCall(null, opCtx);
int taskNameHash = ctx.kernalContext().job().currentTaskNameHash();
Collection<GridCacheVersion> drVers = null;
if (opCtx != null && keys != null && opCtx.hasDataCenterId()) {
assert conflictMap == null : conflictMap;
drVers = F.transform(keys, new C1<K, GridCacheVersion>() {
@Override
public GridCacheVersion apply(K k) {
return ctx.versions().next(opCtx.dataCenterId());
}
});
}
final GridNearAtomicUpdateFuture updateFut = new GridNearAtomicUpdateFuture(ctx, this, ctx.config().getWriteSynchronizationMode(), DELETE, keys != null ? keys : conflictMap.keySet(), null, null, null, drVers != null ? drVers : (keys != null ? null : conflictMap.values()), retval, rawRetval, opCtx != null ? opCtx.expiry() : null, CU.filterArray(null), subjId, taskNameHash, opCtx != null && opCtx.skipStore(), opCtx != null && opCtx.isKeepBinary(), opCtx != null && opCtx.recovery(), opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES);
if (async) {
return asyncOp(new CO<IgniteInternalFuture<Object>>() {
@Override
public IgniteInternalFuture<Object> apply() {
updateFut.map();
return updateFut;
}
});
} else {
updateFut.map();
return updateFut;
}
}
use of org.apache.ignite.internal.IgniteInternalFuture in project ignite by apache.
the class GridDhtAtomicCache method invoke0.
/**
* @param async Async operation flag.
* @param key Key.
* @param entryProcessor Entry processor.
* @param args Entry processor arguments.
* @return Future.
*/
private <T> IgniteInternalFuture<EntryProcessorResult<T>> invoke0(boolean async, K key, EntryProcessor<K, V, T> entryProcessor, Object... args) {
A.notNull(key, "key", entryProcessor, "entryProcessor");
if (keyCheck)
validateCacheKey(key);
CacheOperationContext opCtx = ctx.operationContextPerCall();
final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
IgniteInternalFuture<Map<K, EntryProcessorResult<T>>> fut = update0(key, null, entryProcessor, args, false, null, async);
return fut.chain(new CX1<IgniteInternalFuture<Map<K, EntryProcessorResult<T>>>, EntryProcessorResult<T>>() {
@Override
public EntryProcessorResult<T> applyx(IgniteInternalFuture<Map<K, EntryProcessorResult<T>>> fut) throws IgniteCheckedException {
Map<K, EntryProcessorResult<T>> resMap = fut.get();
if (resMap != null) {
assert resMap.isEmpty() || resMap.size() == 1 : resMap.size();
EntryProcessorResult<T> res = resMap.isEmpty() ? null : resMap.values().iterator().next();
if (res instanceof CacheInvokeResult) {
CacheInvokeResult invokeRes = (CacheInvokeResult) res;
if (invokeRes.result() != null)
res = CacheInvokeResult.fromResult((T) ctx.unwrapBinaryIfNeeded(invokeRes.result(), keepBinary, false));
}
return res;
}
return null;
}
});
}
use of org.apache.ignite.internal.IgniteInternalFuture in project ignite by apache.
the class GridDhtAtomicCache method getAsync0.
/**
* Entry point to all public API single get methods.
*
* @param key Key.
* @param forcePrimary Force primary flag.
* @param subjId Subject ID.
* @param taskName Task name.
* @param deserializeBinary Deserialize binary flag.
* @param expiryPlc Expiry policy.
* @param skipVals Skip values flag.
* @param skipStore Skip store flag.
* @param canRemap Can remap flag.
* @param needVer Need version.
* @return Get future.
*/
private IgniteInternalFuture<V> getAsync0(KeyCacheObject key, boolean forcePrimary, UUID subjId, String taskName, boolean deserializeBinary, boolean recovery, @Nullable ExpiryPolicy expiryPlc, boolean skipVals, boolean skipStore, boolean canRemap, boolean needVer) {
AffinityTopologyVersion topVer = canRemap ? ctx.affinity().affinityTopologyVersion() : ctx.shared().exchange().readyAffinityVersion();
IgniteCacheExpiryPolicy expiry = skipVals ? null : expiryPolicy(expiryPlc);
GridPartitionedSingleGetFuture fut = new GridPartitionedSingleGetFuture(ctx, key, topVer, !skipStore, forcePrimary, subjId, taskName, deserializeBinary, expiry, skipVals, canRemap, needVer, false, recovery);
fut.init();
return (IgniteInternalFuture<V>) fut;
}
Aggregations