@Override public Future<BKLogWriteHandler> apply(ZKLogMetadataForWriter logMetadata) { Promise<BKLogWriteHandler> createPromise = new Promise<BKLogWriteHandler>(); createWriteHandler(logMetadata, lockHandler, createPromise); return createPromise; } });
PendingLogRecord(LogRecord record, boolean flush) { this.record = record; this.promise = new Promise<DLSN>(); this.flush = flush; }
BKTransmitPacket(EntryBuffer recordSet) { this.recordSet = recordSet; this.transmitTime = System.nanoTime(); this.transmitComplete = new Promise<Integer>(); }
void startQueueingRequests() { assert(null == pendingRequests && null == rollingFuture); pendingRequests = new LinkedList<PendingLogRecord>(); rollingFuture = new Promise<BKLogSegmentWriter>(); }
public ZKTransaction(ZooKeeperClient zkc) { this.zkc = zkc; this.ops = Lists.newArrayList(); this.zkOps = Lists.newArrayList(); this.result = new Promise<Void>(); }
private Future<Void> closeInternal(boolean abort) { Promise<Void> closePromise; synchronized (this) { if (null != closeFuture) { return closeFuture; } closePromise = closeFuture = new Promise<Void>(); } AtomicReference<Throwable> throwExc = new AtomicReference<Throwable>(null); closeInternal(abort, throwExc, closePromise); return closePromise; }
private Future<String> checkLockOwnerAndWaitIfPossible(final LockWatcher lockWatcher, final boolean wait) { final Promise<String> promise = new Promise<String>(); checkLockOwnerAndWaitIfPossible(lockWatcher, wait, promise); return promise; }
ListFutureProcessor(List<T> items, Function<T, Future<R>> processFunc, ExecutorService callbackExecutor) { this.itemsIter = items.iterator(); this.processFunc = processFunc; this.promise = new Promise<List<R>>(); this.promise.setInterruptHandler(this); this.results = new ArrayList<R>(); this.callbackExecutor = callbackExecutor; }
private Future<Void> reinitStream(int idx) { Promise<Void> promise = new Promise<Void>(); reinitStream(idx, promise); return promise; }
private Future<Void> fetchAccessControlEntries() { final Promise<Void> promise = new Promise<Void>(); fetchAccessControlEntries(promise); return promise; }
private Future<ZKAccessControl> fetchDefaultAccessControlEntry() { final Promise<ZKAccessControl> promise = new Promise<ZKAccessControl>(); fetchDefaultAccessControlEntry(promise); return promise; }
BulkWriteOp(final String name, final List<ByteBuffer> data) { super(name, clientStats.getOpStats("bulk_write")); this.data = data; // This could take a while (relatively speaking) for very large inputs. We probably don't want // to go so large for other reasons though. this.results = new ArrayList<Promise<DLSN>>(data.size()); for (int i = 0; i < data.size(); i++) { this.results.add(new Promise<DLSN>()); } }
Future<Void> scheduleReinitStream(int idx) { Promise<Void> promise = new Promise<Void>(); scheduleReinitStream(idx, promise); return promise; }
@Override void process(int rc) { if (!running) { setReadAheadStopped(); return; } if (null == stopPromise) { stopPromise = new Promise<Void>(); } // proceed the readahead request next.process(BKException.Code.OK); } }
@Override public Future<URI> createLog(final String logName) { if (duplicatedLogFound.get()) { return duplicatedLogException(duplicatedLogName.get()); } Promise<URI> createPromise = new Promise<URI>(); doCreateLog(logName, createPromise); return postStateCheck(createPromise); }
@Override public Future<Void> asyncClose() { Promise<Void> closePromise; synchronized (sharedLock) { if (null != closeFuture) { return closeFuture; } closeFuture = closePromise = new Promise<Void>(); } reader.asyncClose().proxyTo(closePromise); return closePromise; }
@Override public Object answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); String stream = (String) arguments[0]; if (stream.equals(secondStream)) { return Future.value(dlsn); } else { return new Promise<DLSN>(); } } }).when(client).writeRecordSet((String) any(), (LogRecordSetBuffer) any());
protected Future<BKLogSegmentWriter> asyncStartLogSegment(long txId, boolean bestEffort, boolean allowMaxTxID) { Promise<BKLogSegmentWriter> promise = new Promise<BKLogSegmentWriter>(); try { lock.checkOwnershipAndReacquire(); } catch (LockingException e) { FutureUtils.setException(promise, e); return promise; } doStartLogSegment(txId, bestEffort, allowMaxTxID, promise); return promise; }
Future<List<String>> getLogSegmentNames(String logSegmentsPath, Watcher watcher) { Promise<List<String>> result = new Promise<List<String>>(); try { zkc.get().getChildren(logSegmentsPath, watcher, this, result); } catch (ZooKeeperClient.ZooKeeperConnectionException e) { result.setException(FutureUtils.zkException(e, logSegmentsPath)); } catch (InterruptedException e) { result.setException(FutureUtils.zkException(e, logSegmentsPath)); } return result; }
private Future<Void> asyncCloseAndComplete(boolean shouldThrow) { BKLogSegmentWriter segmentWriter = getCachedLogWriter(); BKLogWriteHandler writeHandler = getCachedWriteHandler(); if (null != segmentWriter && null != writeHandler) { cancelTruncation(); Promise<Void> completePromise = new Promise<Void>(); asyncCloseAndComplete(segmentWriter, writeHandler, completePromise, shouldThrow); return completePromise; } else { return closeNoThrow(); } }