@Override public boolean apply(GridFuture<?> f) { return f.isDone(); } };
/** {@inheritDoc} */ @Override public boolean isDone() { return fut.isDone(); }
@Override public boolean apply(GridFuture<?> f) { return !f.isDone(); } };
@Override public String apply(GridFuture<T> f) { return Boolean.toString(f.isDone()); } })
/** * Initializes data loader if it was not initialized yet and updates written space. * * @param len Data length to be written. */ private void preStoreDataBlocks(@Nullable DataInput in, int len) throws GridException, IOException { // Check if any exception happened while writing data. if (writeCompletionFut.isDone()) { assert ((GridFutureAdapter)writeCompletionFut).isFailed(); if (in != null) in.skipBytes(len); writeCompletionFut.get(); } bytes += len; space += len; }
/** * Add local cache future. * * @param idx Block index. * @param fut Future. */ private void addLocalCacheFuture(long idx, GridFuture<byte[]> fut) { assert Thread.holdsLock(this); if (!locCache.containsKey(idx)) { if (locCache.size() == maxLocCacheSize) { final GridFuture<byte[]> evictFut = locCache.remove(locCache.keySet().iterator().next()); if (!evictFut.isDone()) { pendingFuts.add(evictFut); evictFut.listenAsync(new GridInClosure<GridFuture<byte[]>>() { @Override public void apply(GridFuture<byte[]> t) { pendingFuts.remove(evictFut); pendingFutsLock.lock(); try { pendingFutsCond.signalAll(); } finally { pendingFutsLock.unlock(); } } }); } } locCache.put(idx, fut); } }
/** * Add local cache future. * * @param idx Block index. * @param fut Future. */ private void addLocalCacheFuture(long idx, GridFuture<byte[]> fut) { assert Thread.holdsLock(this); if (!locCache.containsKey(idx)) { if (locCache.size() == maxLocCacheSize) { final GridFuture<byte[]> evictFut = locCache.remove(locCache.keySet().iterator().next()); if (!evictFut.isDone()) { pendingFuts.add(evictFut); evictFut.listenAsync(new GridInClosure<GridFuture<byte[]>>() { @Override public void apply(GridFuture<byte[]> t) { pendingFuts.remove(evictFut); pendingFutsLock.lock(); try { pendingFutsCond.signalAll(); } finally { pendingFutsLock.unlock(); } } }); } } locCache.put(idx, fut); } }
/** * Initializes data loader if it was not initialized yet and updates written space. * * @param len Data length to be written. */ private void preStoreDataBlocks(@Nullable DataInput in, int len) throws GridException, IOException { // Check if any exception happened while writing data. if (writeCompletionFut.isDone()) { assert ((GridFutureAdapter)writeCompletionFut).isFailed(); if (in != null) in.skipBytes(len); writeCompletionFut.get(); } bytes += len; space += len; }
/** * @param <T> Type of command result. * @param fut Future to add. * @return Future for command. */ @SuppressWarnings("unchecked") private <T> Future<T> addFuture(GridFuture<T> fut) { synchronized (mux) { if (!fut.isDone()) { fut.listenAsync(lsnr); futs.add(fut); } return new TaskFutureWrapper<>(fut); } }
/** * */ void awaitInit() { if (!dataCacheStartFut.isDone()) { try { dataCacheStartFut.get(); } catch (GridException e) { throw new GridRuntimeException(e); } } }
/** * */ void awaitInit() { if (!metaCacheStartFut.isDone()) { try { metaCacheStartFut.get(); } catch (GridException e) { throw new GridRuntimeException(e); } } }
/** * Awaits for previous async operation to be completed. */ @SuppressWarnings("unchecked") private void awaitLastFut() { FutureHolder holder = lastFut.get(); GridFuture fut = holder.future(); if (fut != null && !fut.isDone()) { try { // Ignore any exception from previous async operation as it should be handled by user. fut.get(); } catch (GridException ignored) { // No-op. } } }
/** * Initializes this future. */ public void init() { assert cctx.preloader().startFuture().isDone(); map(keys, Collections.<GridNode>emptyList()); markInitialized(); }
/** * Executes local update. * * @param nodeId Node ID. * @param req Update request. * @param cached Cached entry if updating single local entry. * @param completionCb Completion callback. */ public void updateAllAsyncInternal( final UUID nodeId, final GridNearAtomicUpdateRequest<K, V> req, @Nullable final GridCacheEntryEx<K, V> cached, final CI2<GridNearAtomicUpdateRequest<K, V>, GridNearAtomicUpdateResponse<K, V>> completionCb ) { GridFuture<Object> forceFut = preldr.request(req.keys(), req.topologyVersion()); if (forceFut.isDone()) updateAllAsyncInternal0(nodeId, req, cached, completionCb); else { forceFut.listenAsync(new CI1<GridFuture<Object>>() { @Override public void apply(GridFuture<Object> t) { updateAllAsyncInternal0(nodeId, req, cached, completionCb); } }); } }
/** * @param node Node originated request. * @param msg Force keys message. */ private void processForceKeysRequest(final GridNode node, final GridDhtForceKeysRequest<K, V> msg) { GridFuture<?> fut = cctx.mvcc().finishKeys(msg.keys(), msg.topologyVersion()); if (fut.isDone()) processForceKeysRequest0(node, msg); else fut.listenAsync(new CI1<GridFuture<?>>() { @Override public void apply(GridFuture<?> t) { processForceKeysRequest0(node, msg); } }); }
GridFuture fut = holder.future(); if (fut != null && !fut.isDone()) { GridFuture<T> f = new GridEmbeddedFuture<>(fut, new C2<T, Exception, GridFuture<T>>() {
/** * @param nodeId Node ID. * @param req Request. */ protected final void processDhtLockRequest(final UUID nodeId, final GridDhtLockRequest<K, V> req) { GridFuture<Object> keyFut = F.isEmpty(req.keys()) ? null : ctx.dht().dhtPreloader().request(req.keys(), req.topologyVersion()); if (keyFut == null || keyFut.isDone()) processDhtLockRequest0(nodeId, req); else { keyFut.listenAsync(new CI1<GridFuture<Object>>() { @Override public void apply(GridFuture<Object> t) { processDhtLockRequest0(nodeId, req); } }); } }
GridFuture fut = holder.future(); if (fut != null && !fut.isDone()) { GridFuture f = new GridEmbeddedFuture(fut, new C2<Object, Exception, GridFuture>() {
GridFuture fut = holder.future(); if (fut != null && !fut.isDone()) { GridFuture<GridCacheTx> f = new GridEmbeddedFuture<>(fut, new C2<Object, Exception, GridFuture<GridCacheTx>>() {
if (!f.isDone()) f.get();