assert !m.empty(); MiniFuture fut = new MiniFuture(this, m, ++miniId); add((IgniteInternalFuture)new MiniFuture(this, m, ++miniId)); tx.removeMapping(fut.mapping().primary().id()); fut.onResult(new IgniteCheckedException("Failed to prepare transaction.", err));
/** * @param e Node failure. */ void onNodeLeft(ClusterTopologyCheckedException e) { if (isDone()) return; if (RCV_RES_UPD.compareAndSet(this, 0, 1)) { if (log.isDebugEnabled()) log.debug("Remote node left grid while sending or waiting for reply (will not retry): " + this); parent.onError(null, e); onDone(e); } }
Map<UUID, Collection<UUID>> txNodes, @Nullable MiniFuture locNearEntriesFut) { GridDistributedTxMapping m = fut.mapping(); IgniteCheckedException err = tx.timeoutException(); fut.onResult(err); fut.onResult(e); e.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion())); fut.onNodeLeft(e); fut.onResult(e);
assert !m.empty(); MiniFuture fut = new MiniFuture(this, m, ++miniId); add((IgniteInternalFuture)new MiniFuture(this, m, ++miniId)); tx.removeMapping(fut.mapping().primary().id()); fut.onResult(new IgniteCheckedException("Failed to prepare transaction.", err));
Map<UUID, Collection<UUID>> txNodes, @Nullable MiniFuture locNearEntriesFut) { GridDistributedTxMapping m = fut.mapping(); IgniteCheckedException err = tx.timeoutException(); fut.onResult(err); fut.onResult(e); e.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion())); fut.onNodeLeft(e); fut.onResult(e);
/** * Finds pending mini future by the given mini ID. * * @param miniId Mini ID to find. * @return Mini future. */ @SuppressWarnings("ForLoopReplaceableByForEach") private MiniFuture miniFuture(int miniId) { // We iterate directly over the futs collection here to avoid copy. synchronized (GridNearOptimisticSerializableTxPrepareFuture.this) { int size = futuresCountNoLock(); // Avoid iterator creation. for (int i = 0; i < size; i++) { IgniteInternalFuture 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; }
/** {@inheritDoc} */ @Override public boolean onNodeLeft(UUID nodeId) { boolean found = false; for (IgniteInternalFuture<?> fut : futures()) { if (isMini(fut)) { MiniFuture f = (MiniFuture) fut; if (f.primary().id().equals(nodeId)) { ClusterTopologyCheckedException e = new ClusterTopologyCheckedException("Remote node left grid: " + nodeId); e.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion())); f.onNodeLeft(e); found = true; } } } return found; }
/** * @param e Error. */ void onResult(Throwable e) { if (RCV_RES_UPD.compareAndSet(this, 0, 1)) { parent.onError(m, e); if (log.isDebugEnabled()) log.debug("Failed to get future result [fut=" + this + ", err=" + e + ']'); // Fail. onDone(e); } else U.warn(log, "Received error after another result has been processed [fut=" + parent + ", mini=" + this + ']', e); }
@Override public void run() { onDone(res); } });
/** * @param e Node failure. */ void onNodeLeft(ClusterTopologyCheckedException e) { if (isDone()) return; if (RCV_RES_UPD.compareAndSet(this, 0, 1)) { if (log.isDebugEnabled()) log.debug("Remote node left grid while sending or waiting for reply (will not retry): " + this); parent.onError(null, e); onDone(e); } }
/** {@inheritDoc} */ @Override public String toString() { return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error()); } }
/** {@inheritDoc} */ @Override public void onResult(UUID nodeId, GridNearTxPrepareResponse res) { if (!isDone()) { MiniFuture mini = miniFuture(res.miniId()); if (mini != null) mini.onResult(res, true); } }