/** {@inheritDoc} */ @Override protected IgniteInternalFuture<Boolean> lockAllAsync( Collection<KeyCacheObject> keys, long timeout, IgniteTxLocalEx tx, boolean isInvalidate, boolean isRead, boolean retval, TransactionIsolation isolation, long createTtl, long accessTtl ) { CacheOperationContext opCtx = ctx.operationContextPerCall(); GridNearLockFuture fut = new GridNearLockFuture(ctx, keys, (GridNearTxLocal)tx, isRead, retval, timeout, createTtl, accessTtl, CU.empty0(), opCtx != null && opCtx.skipStore(), opCtx != null && opCtx.isKeepBinary(), opCtx != null && opCtx.recovery()); fut.map(); return fut; }
/** {@inheritDoc} */ @Override public boolean onDone(Boolean success, Throwable err) { if (log.isDebugEnabled()) log.debug("Received onDone(..) callback [success=" + success + ", err=" + err + ", fut=" + this + ']'); if (inTx() && cctx.tm().deadlockDetectionEnabled() && (this.err instanceof IgniteTxTimeoutCheckedException || timedOut)) return false; // If locks were not acquired yet, delay completion. if (isDone() || (err == null && success && !checkLocks())) return false; if (err != null && !(err instanceof GridCacheLockTimeoutException)) onError(err); if (err != null) success = false; return onComplete(success, true); }
/** * Finds pending mini future by the given mini ID. * * @param miniId Mini ID to find. * @return Mini future. */ @SuppressWarnings({"IfMayBeConditional"}) private MiniFuture miniFuture(int miniId) { // We iterate directly over the futs collection here to avoid copy. synchronized (this) { int size = futuresCountNoLock(); // Avoid iterator creation. for (int i = 0; i < size; i++) { IgniteInternalFuture<Boolean> fut = future(i); if (!isMini(fut)) continue; MiniFuture mini = (MiniFuture)fut; if (mini.futureId() == miniId) { if (!mini.isDone()) return mini; else return null; } } } return null; }
onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for near-only cache (all " + "partition nodes left the grid).")); GridNearLockMapping updated = map( key, map, if (isDone()) { if (log.isDebugEnabled()) log.debug("Abandoning (re)map because future is done: " + this); onComplete(false, false); GridCacheMvccCandidate cand = addEntry( topVer, entry, node.id()); if (isDone()) { if (log.isDebugEnabled()) log.debug("Abandoning (re)map because future is done after addEntry attempt " + GridDhtCacheEntry dhtEntry = dht().peekExx(key); assert !implicitTx() && !implicitSingleTx() : tx; futId, lockVer, inTx(),
/** * @param nodeId Left node ID * @return {@code True} if node was in the list. */ @Override public boolean onNodeLeft(UUID nodeId) { boolean found = false; for (IgniteInternalFuture<?> fut : futures()) { if (isMini(fut)) { MiniFuture f = (MiniFuture)fut; if (f.node().id().equals(nodeId)) { if (log.isDebugEnabled()) log.debug("Found mini-future for left node [nodeId=" + nodeId + ", mini=" + f + ", fut=" + this + ']'); f.onResult(newTopologyException(null, nodeId)); found = true; } } } if (!found) { if (log.isDebugEnabled()) log.debug("Near lock future does not have mapping for left node (ignoring) [nodeId=" + nodeId + ", fut=" + this + ']'); } return found; }
log.debug("Before locally locking near request: " + req); IgniteInternalFuture<GridNearLockResponse> fut = dht().lockAllAsync(cctx, cctx.localNode(), req, filter); add(new GridEmbeddedFuture<>( new C2<GridNearLockResponse, Exception, Boolean>() { @Override public Boolean apply(GridNearLockResponse res, Exception e) { add(fut); // Append new future. if (inTx()) txSync = cctx.tm().awaitFinishAckAsync(node.id(), tx.threadId());
/** * @return Keys for which locks requested from remote nodes but response isn't received. */ private Set<IgniteTxKey> requestedKeys0() { for (IgniteInternalFuture<Boolean> miniFut : futures()) { if (isMini(miniFut) && !miniFut.isDone()) { MiniFuture mini = (MiniFuture)miniFut; Set<IgniteTxKey> requestedKeys = U.newHashSet(mini.keys.size()); for (KeyCacheObject key : mini.keys) requestedKeys.add(new IgniteTxKey(key, cctx.cacheId())); return requestedKeys; } } return null; }
/** {@inheritDoc} */ @Override public String toString() { Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() { @Override public String apply(IgniteInternalFuture<?> f) { if (isMini(f)) { MiniFuture m = (MiniFuture)f; return "[node=" + m.node().id() + ", loc=" + m.node().isLocal() + ", done=" + f.isDone() + "]"; } else return "[loc=true, done=" + f.isDone() + "]"; } }); return S.toString(GridNearLockFuture.class, this, "innerFuts", futs, "inTx", inTx(), "super", super.toString()); }
/** * @param cached Entry. * @return {@code True} if locked. * @throws GridCacheEntryRemovedException If removed. */ private boolean locked(GridCacheEntryEx cached) throws GridCacheEntryRemovedException { // Reentry-aware check (If filter failed, lock is failed). return cached.lockedLocallyByIdOrThread(lockVer, threadId) && filter(cached); }
for (GridCacheEntryEx e : entriesCopy()) { try { e.removeLock(lockVer);
onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for near-only cache (all " + "partition nodes left the grid).")); GridNearLockMapping updated = map( key, map, if (isDone()) { if (log.isDebugEnabled()) log.debug("Abandoning (re)map because future is done: " + this); onComplete(false, false); GridCacheMvccCandidate cand = addEntry( topVer, entry, node.id()); if (isDone()) { if (log.isDebugEnabled()) log.debug("Abandoning (re)map because future is done after addEntry attempt " + GridDhtCacheEntry dhtEntry = dht().peekExx(key); assert !implicitTx() && !implicitSingleTx() : tx; futId, lockVer, inTx(),
/** * Finds pending mini future by the given mini ID. * * @param miniId Mini ID to find. * @return Mini future. */ @SuppressWarnings({"ForLoopReplaceableByForEach", "IfMayBeConditional"}) private MiniFuture miniFuture(int miniId) { // We iterate directly over the futs collection here to avoid copy. synchronized (this) { int size = futuresCountNoLock(); // Avoid iterator creation. for (int i = 0; i < size; i++) { IgniteInternalFuture<Boolean> fut = future(i); if (!isMini(fut)) continue; MiniFuture mini = (MiniFuture)fut; if (mini.futureId() == miniId) { if (!mini.isDone()) return mini; else return null; } } } return null; }
/** * @param nodeId Left node ID * @return {@code True} if node was in the list. */ @SuppressWarnings({"ThrowableInstanceNeverThrown"}) @Override public boolean onNodeLeft(UUID nodeId) { boolean found = false; for (IgniteInternalFuture<?> fut : futures()) { if (isMini(fut)) { MiniFuture f = (MiniFuture)fut; if (f.node().id().equals(nodeId)) { if (log.isDebugEnabled()) log.debug("Found mini-future for left node [nodeId=" + nodeId + ", mini=" + f + ", fut=" + this + ']'); f.onResult(newTopologyException(null, nodeId)); found = true; } } } if (!found) { if (log.isDebugEnabled()) log.debug("Near lock future does not have mapping for left node (ignoring) [nodeId=" + nodeId + ", fut=" + this + ']'); } return found; }
log.debug("Before locally locking near request: " + req); IgniteInternalFuture<GridNearLockResponse> fut = dht().lockAllAsync(cctx, cctx.localNode(), req, filter); add(new GridEmbeddedFuture<>( new C2<GridNearLockResponse, Exception, Boolean>() { @Override public Boolean apply(GridNearLockResponse res, Exception e) { add(fut); // Append new future. if (inTx()) txSync = cctx.tm().awaitFinishAckAsync(node.id(), tx.threadId());
/** * @return Keys for which locks requested from remote nodes but response isn't received. */ private Set<IgniteTxKey> requestedKeys0() { for (IgniteInternalFuture<Boolean> miniFut : futures()) { if (isMini(miniFut) && !miniFut.isDone()) { MiniFuture mini = (MiniFuture)miniFut; Set<IgniteTxKey> requestedKeys = U.newHashSet(mini.keys.size()); for (KeyCacheObject key : mini.keys) requestedKeys.add(new IgniteTxKey(key, cctx.cacheId())); return requestedKeys; } } return null; }
/** {@inheritDoc} */ @Override public String toString() { Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() { @Override public String apply(IgniteInternalFuture<?> f) { if (isMini(f)) { MiniFuture m = (MiniFuture)f; return "[node=" + m.node().id() + ", loc=" + m.node().isLocal() + ", done=" + f.isDone() + "]"; } else return "[loc=true, done=" + f.isDone() + "]"; } }); return S.toString(GridNearLockFuture.class, this, "innerFuts", futs, "inTx", inTx(), "super", super.toString()); }
/** * @param cached Entry. * @return {@code True} if locked. * @throws GridCacheEntryRemovedException If removed. */ private boolean locked(GridCacheEntryEx cached) throws GridCacheEntryRemovedException { // Reentry-aware check (If filter failed, lock is failed). return cached.lockedLocallyByIdOrThread(lockVer, threadId) && filter(cached); }
for (GridCacheEntryEx e : entriesCopy()) { try { e.removeLock(lockVer);
/** {@inheritDoc} */ @Override public boolean onDone(Boolean success, Throwable err) { if (log.isDebugEnabled()) log.debug("Received onDone(..) callback [success=" + success + ", err=" + err + ", fut=" + this + ']'); if (inTx() && cctx.tm().deadlockDetectionEnabled() && (this.err instanceof IgniteTxTimeoutCheckedException || timedOut)) return false; // If locks were not acquired yet, delay completion. if (isDone() || (err == null && success && !checkLocks())) return false; if (err != null && !(err instanceof GridCacheLockTimeoutException)) onError(err); if (err != null) success = false; return onComplete(success, true); }