/** * @param cacheCtx Cache context. * @param it Entries iterator. * @param pageSize Page size. * @param timeout Timeout. * @param sequential Sequential locking flag. * @return Operation future. */ public IgniteInternalFuture<Long> updateAsync(GridCacheContext cacheCtx, UpdateSourceIterator<?> it, int pageSize, long timeout, boolean sequential) { try { beforePut(cacheCtx, false, true); return updateAsync(new GridNearTxQueryResultsEnlistFuture(cacheCtx, this, timeout, it, pageSize, sequential)); } catch (IgniteCheckedException e) { return new GridFinishedFuture(e); } catch (RuntimeException e) { onException(); throw e; } }
if (isDone() || SKIP_UPD.getAndIncrement(this) != 0) return null; while (hasNext0()) { checkCompleted(); Object cur = next0(); batch = batches.get(node.id()); else if (batch != null && !batch.node().equals(node)) res = markReady(res, batch); batch.add(op.isDeleteOrLock() ? key : cur, !node.isLocal() && isLocalBackup(op, key)); res = markReady(res, batch); onDone(this.res);
/** * @param nodeId Sender node id. * @param res Response. */ public void onResult(UUID nodeId, GridNearTxQueryResultsEnlistResponse res) { if (checkResponse(nodeId, res, res.error())) { Batch batch = batches.get(nodeId); if (batch != null && !F.isEmpty(batch.localBackupRows()) && res.dhtFutureId() != null) processBatchLocalBackupKeys(nodeId, batch.localBackupRows(), res.dhtVersion(), res.dhtFutureId()); else sendNextBatches(nodeId); } }
/** * * @param node Node. * @param batch Batch. * @param first First mapping flag. */ private void sendBatch(ClusterNode node, Batch batch, boolean first) throws IgniteCheckedException { updateMappings(node); boolean clientFirst = first && cctx.localNode().isClient() && !topLocked && !tx.hasRemoteLocks(); int batchId = batchCntr.incrementAndGet(); if (node.isLocal()) enlistLocal(batchId, node.id(), batch); else sendBatch(batchId, node.id(), batch, clientFirst); }
@Override public void apply(IgniteInternalFuture<Long> fut) { assert fut.error() != null || fut.result() != null : fut; try { clearLocalFuture((GridDhtTxAbstractEnlistFuture)fut); GridNearTxQueryResultsEnlistResponse res = fut.error() == null ? createResponse(fut) : null; if (checkResponse(nodeId, res, fut.error())) sendNextBatches(nodeId); } catch (IgniteCheckedException e) { checkResponse(nodeId, null, e); } finally { CU.unwindEvicts(cctx); } } });
/** * Continue iterating the data rows and form new batches. * * @param nodeId Node that is ready for a new batch. */ private void sendNextBatches(@Nullable UUID nodeId) { try { Collection<Batch> next = continueLoop(nodeId); if (next == null) return; boolean first = (nodeId != null); // Need to unlock topology to avoid deadlock with binary descriptors registration. if (!topLocked && cctx.topology().holdsLock()) cctx.topology().readUnlock(); for (Batch batch : next) { ClusterNode node = batch.node(); sendBatch(node, batch, first); if (!node.isLocal()) first = false; } } catch (Throwable e) { onDone(e); if (e instanceof Error) throw (Error)e; } }
/** */ private Object next0() { if (!hasNext0()) throw new NoSuchElementException(); Object cur; if ((cur = peek) != null) peek = null; else cur = it.next(); return cur; }
/** * * @param node Node. * @param batch Batch. * @param first First mapping flag. */ private void sendBatch(ClusterNode node, Batch batch, boolean first) throws IgniteCheckedException { updateMappings(node); boolean clientFirst = first && cctx.localNode().isClient() && !topLocked && !tx.hasRemoteLocks(); int batchId = batchCntr.incrementAndGet(); if (node.isLocal()) enlistLocal(batchId, node.id(), batch); else sendBatch(batchId, node.id(), batch, clientFirst); }
/** * Continue iterating the data rows and form new batches. * * @param nodeId Node that is ready for a new batch. */ private void sendNextBatches(@Nullable UUID nodeId) { try { Collection<Batch> next = continueLoop(nodeId); if (next == null) return; boolean first = (nodeId != null); // Need to unlock topology to avoid deadlock with binary descriptors registration. if(!topLocked && cctx.topology().holdsLock()) cctx.topology().readUnlock(); for (Batch batch : next) { ClusterNode node = batch.node(); sendBatch(node, batch, first); if (!node.isLocal()) first = false; } } catch (Throwable e) { onDone(e); if (e instanceof Error) throw (Error)e; } }
@Override public void apply(IgniteInternalFuture<Long> fut) { assert fut.error() != null || fut.result() != null : fut; try { clearLocalFuture((GridDhtTxAbstractEnlistFuture)fut); GridNearTxQueryResultsEnlistResponse res = fut.error() == null ? createResponse(fut) : null; if (checkResponse(nodeId, res, fut.error())) sendNextBatches(nodeId); } catch (IgniteCheckedException e) { checkResponse(nodeId, null, e); } finally { CU.unwindEvicts(cctx); } } });
/** */ private Object next0() { if (!hasNext0()) throw new NoSuchElementException(); Object cur; if ((cur = peek) != null) peek = null; else cur = it.next(); return cur; }
/** * @param nodeId Sender node id. * @param res Response. */ public void onResult(UUID nodeId, GridNearTxQueryResultsEnlistResponse res) { if (checkResponse(nodeId, res, res.error())) { Batch batch = batches.get(nodeId); if (batch != null && !F.isEmpty(batch.localBackupRows()) && res.dhtFutureId() != null) processBatchLocalBackupKeys(nodeId, batch.localBackupRows(), res.dhtVersion(), res.dhtFutureId()); else sendNextBatches(nodeId); } }
/** * @param cacheCtx Cache context. * @param it Entries iterator. * @param pageSize Page size. * @param timeout Timeout. * @param sequential Sequential locking flag. * @return Operation future. */ public IgniteInternalFuture<Long> updateAsync(GridCacheContext cacheCtx, UpdateSourceIterator<?> it, int pageSize, long timeout, boolean sequential) { try { beforePut(cacheCtx, false, true); return updateAsync(new GridNearTxQueryResultsEnlistFuture(cacheCtx, this, timeout, it, pageSize, sequential)); } catch (IgniteCheckedException e) { return new GridFinishedFuture(e); } catch (RuntimeException e) { onException(); throw e; } }