Java Code Examples for com.twitter.util.Future#Void
The following examples show how to use
com.twitter.util.Future#Void .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DistributedLogServiceImpl.java From distributedlog with Apache License 2.0 | 6 votes |
@Override public Future<Void> setAcceptNewStream(boolean enabled) { closeLock.writeLock().lock(); try { logger.info("Set AcceptNewStream = {}", enabled); if (ServerStatus.DOWN != serverStatus) { if (enabled) { serverStatus = ServerStatus.WRITE_AND_ACCEPT; } else { serverStatus = ServerStatus.WRITE_ONLY; } } } finally { closeLock.writeLock().unlock(); } return Future.Void(); }
Example 2
Source File: DryrunLogSegmentMetadataStoreUpdater.java From distributedlog with Apache License 2.0 | 6 votes |
@Override public Transaction<Object> transaction() { return new Transaction<Object>() { @Override public void addOp(Op<Object> operation) { // no-op } @Override public Future<Void> execute() { return Future.Void(); } @Override public void abort(Throwable reason) { // no-op } }; }
Example 3
Source File: DistributedLogServiceImpl.java From distributedlog with Apache License 2.0 | 6 votes |
@Override public Future<Void> setAcceptNewStream(boolean enabled) { closeLock.writeLock().lock(); try { logger.info("Set AcceptNewStream = {}", enabled); if (ServerStatus.DOWN != serverStatus) { if (enabled) { serverStatus = ServerStatus.WRITE_AND_ACCEPT; } else { serverStatus = ServerStatus.WRITE_ONLY; } } } finally { closeLock.writeLock().unlock(); } return Future.Void(); }
Example 4
Source File: ScribeSender.java From zipkin-finagle with Apache License 2.0 | 5 votes |
@Override public Future<Void> apply(byte[] responseBytes) { TBinaryProtocol iprot = new TBinaryProtocol(new TMemoryInputTransport(responseBytes)); try { if (InternalScribeCodec.readLogResponse(0, iprot)) { return Future.Void(); } else { return Future.exception(new IllegalStateException("try later")); } } catch (Exception e) { return Future.exception(e); } }
Example 5
Source File: BKLogWriteHandler.java From distributedlog with Apache License 2.0 | 5 votes |
Future<Void> unlockHandler() { if (null != lockFuture) { return lock.asyncClose(); } else { return Future.Void(); } }
Example 6
Source File: ReadAheadWorker.java From distributedlog with Apache License 2.0 | 5 votes |
@Override public Future<Void> asyncClose() { LOG.info("Stopping Readahead worker for {}", fullyQualifiedName); running = false; this.zkc.getWatcherManager() .unregisterChildWatcher(this.logMetadata.getLogSegmentsPath(), this); // Aside from unfortunate naming of variables, this allows // the currently active long poll to be interrupted and completed AsyncNotification notification; synchronized (notificationLock) { notification = metadataNotification; metadataNotification = null; } if (null != notification) { notification.notifyOnOperationComplete(); } if (null == stopPromise) { return Future.Void(); } return FutureUtils.ignore(FutureUtils.within( stopPromise, 2 * conf.getReadAheadWaitTime(), TimeUnit.MILLISECONDS, new TimeoutException("Timeout on waiting for ReadAhead worker to stop " + fullyQualifiedName), scheduler, fullyQualifiedName)); }
Example 7
Source File: Utils.java From distributedlog with Apache License 2.0 | 5 votes |
public static Future<Void> asyncClose(@Nullable AsyncCloseable closeable, boolean swallowIOException) { if (null == closeable) { return Future.Void(); } else if (swallowIOException) { return FutureUtils.ignore(closeable.asyncClose()); } else { return closeable.asyncClose(); } }
Example 8
Source File: Abortables.java From distributedlog with Apache License 2.0 | 5 votes |
public static Future<Void> asyncAbort(@Nullable AsyncAbortable abortable, boolean swallowIOException) { if (null == abortable) { return Future.Void(); } else if (swallowIOException) { return FutureUtils.ignore(abortable.asyncAbort()); } else { return abortable.asyncAbort(); } }
Example 9
Source File: PinLaterBackendBase.java From pinlater with Apache License 2.0 | 5 votes |
public Future<PinLaterDequeueResponse> dequeueJobs(final String source, final PinLaterDequeueRequest request) { Future<PinLaterDequeueResponse> dequeueFuture; try { dequeueFuture = dequeueSemaphoreMap.get(request.getQueueName()).acquire().flatMap( new Function<Permit, Future<PinLaterDequeueResponse>>() { @Override public Future<PinLaterDequeueResponse> apply(final Permit permit) { return futurePool.apply(new ExceptionalFunction0<PinLaterDequeueResponse>() { @Override public PinLaterDequeueResponse applyE() throws Throwable { return dequeueJobsImpl(source, request, numAutoRetries); } }).respond(new Function<Try<PinLaterDequeueResponse>, BoxedUnit>() { @Override public BoxedUnit apply(Try<PinLaterDequeueResponse> responseTry) { permit.release(); return BoxedUnit.UNIT; } }); } }); } catch (ExecutionException e) { // The dequeueSemaphoreMap's get() can in theory throw an ExecutionException, but we // never expect it in practice since our load method is simply new'ing up an AsyncSemaphore. dequeueFuture = Future.exception(e); } // Dequeue requests can contain ack requests as payloads. If so, we execute both in parallel. Future<Void> ackFuture = request.isSetJobAckRequest() ? ackDequeuedJobsImpl(request.getJobAckRequest()) : Future.Void(); return dequeueFuture.join(ackFuture).map( new Function<Tuple2<PinLaterDequeueResponse, Void>, PinLaterDequeueResponse>() { @Override public PinLaterDequeueResponse apply(Tuple2<PinLaterDequeueResponse, Void> tuple) { return tuple._1(); } }); }
Example 10
Source File: NopDistributedLock.java From distributedlog with Apache License 2.0 | 4 votes |
@Override public Future<Void> asyncClose() { return Future.Void(); }
Example 11
Source File: BKLogHandler.java From distributedlog with Apache License 2.0 | 4 votes |
@Override public Future<Void> asyncClose() { // No-op this.zooKeeperClient.getWatcherManager().unregisterChildWatcher(logMetadata.getLogSegmentsPath(), this); return Future.Void(); }
Example 12
Source File: BKDistributedLogManager.java From distributedlog with Apache License 2.0 | 4 votes |
/** * Close the distributed log manager, freeing any resources it may hold. */ @Override public Future<Void> asyncClose() { Promise<Void> closeFuture; BKLogReadHandler readHandlerToClose; synchronized (this) { if (null != closePromise) { return closePromise; } closeFuture = closePromise = new Promise<Void>(); readHandlerToClose = readHandlerForListener; } // NOTE: the resources {scheduler, writerBKC, readerBKC} are mostly from namespace instance. // so they are not blocking call except tests. AsyncCloseable resourcesCloseable = new AsyncCloseable() { @Override public Future<Void> asyncClose() { int schedTimeout = conf.getSchedulerShutdownTimeoutMs(); // Clean up executor state. if (ownExecutor) { SchedulerUtils.shutdownScheduler(scheduler, schedTimeout, TimeUnit.MILLISECONDS); LOG.info("Stopped BKDL executor service for {}.", name); if (scheduler != readAheadScheduler) { SchedulerUtils.shutdownScheduler(readAheadScheduler, schedTimeout, TimeUnit.MILLISECONDS); LOG.info("Stopped BKDL ReadAhead Executor Service for {}.", name); } SchedulerUtils.shutdownScheduler(getLockStateExecutor(false), schedTimeout, TimeUnit.MILLISECONDS); LOG.info("Stopped BKDL Lock State Executor for {}.", name); } if (ownWriterBKC) { writerBKC.close(); } if (ownReaderBKC) { readerBKC.close(); } return Future.Void(); } }; Future<Void> closeResult = Utils.closeSequence(null, true, readHandlerToClose, pendingReaders, resourcesCloseable, new AsyncCloseable() { @Override public Future<Void> asyncClose() { return BKDistributedLogManager.super.asyncClose(); } }); closeResult.proxyTo(closeFuture); return closeFuture; }
Example 13
Source File: AsyncCloseable.java From distributedlog with Apache License 2.0 | 4 votes |
@Override public Future<Void> asyncClose() { return Future.Void(); }
Example 14
Source File: AsyncAbortable.java From distributedlog with Apache License 2.0 | 4 votes |
@Override public Future<Void> asyncAbort() { return Future.Void(); }