List of usage examples for com.google.common.util.concurrent Futures immediateFailedFuture
@CheckReturnValue public static <V> ListenableFuture<V> immediateFailedFuture(Throwable throwable)
From source file:io.v.v23.V23TestUtil.java
public static VContext withDummyServer(VContext ctx) throws Exception { ctx = V.withListenSpec(ctx, V.getListenSpec(ctx).withAddress(new ListenSpec.Address("tcp", "localhost:0"))); return V.withNewServer(ctx, "", new ObjectServer() { @Override//from w w w .j a va 2 s. c om public ListenableFuture<Void> setPermissions(VContext ctx, ServerCall call, Permissions permissions, String version) { return Futures.immediateFailedFuture(new VException("Unimplemented!")); } @Override public ListenableFuture<ObjectServer.GetPermissionsOut> getPermissions(VContext ctx, ServerCall call) { return Futures.immediateFailedFuture(new VException("Unimplemented!")); } }, VSecurity.newAllowEveryoneAuthorizer()); }
From source file:org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader.java
public static ListenableFuture<CustomerId> findEntityIdAsync(TbContext ctx, EntityId original) { switch (original.getEntityType()) { case CUSTOMER: return Futures.immediateFuture((CustomerId) original); case USER:/*from w ww .j ava 2s . com*/ return getCustomerAsync(ctx.getUserService().findUserByIdAsync(ctx.getTenantId(), (UserId) original)); case ASSET: return getCustomerAsync( ctx.getAssetService().findAssetByIdAsync(ctx.getTenantId(), (AssetId) original)); case DEVICE: return getCustomerAsync( ctx.getDeviceService().findDeviceByIdAsync(ctx.getTenantId(), (DeviceId) original)); default: return Futures.immediateFailedFuture(new TbNodeException("Unexpected original EntityType " + original)); } }
From source file:org.esbtools.eventhandler.testing.FailingDocumentEvent.java
@Override public Future<?> lookupDocument() { return Futures.immediateFailedFuture(new RuntimeException("Oh no!")); }
From source file:org.esbtools.eventhandler.testing.FailingNotification.java
@Override public Future<Collection<DocumentEvent>> toDocumentEvents() { return Futures.immediateFailedFuture(new RuntimeException("Wooooooooopsie!")); }
From source file:com.facebook.buck.util.network.FakeFailingScribeLogger.java
@Override public ListenableFuture<Void> log(String category, Iterable<String> lines) { return failLogging.compareAndSet(false, true) ? Futures.immediateFuture(null) : Futures.immediateFailedFuture(new IOException()); }
From source file:com.android.tools.idea.run.EmulatorConnectionListener.java
public static ListenableFuture<IDevice> getDeviceForEmulator(@NotNull Project project, @NotNull String avdName, @Nullable ProcessHandler emulatorProcessHandler, long timeout, @NotNull TimeUnit units) { if (emulatorProcessHandler == null) { return Futures .immediateFailedFuture(new RuntimeException("Emulator process for AVD " + avdName + " died.")); }// w ww. ja v a 2s. c om final SettableFuture<IDevice> future = SettableFuture.create(); WaitForEmulatorTask task = new WaitForEmulatorTask(project, future, avdName, emulatorProcessHandler, timeout, units); ApplicationManager.getApplication().executeOnPooledThread(task); return future; }
From source file:org.thingsboard.rule.engine.util.EntitiesTenantIdAsyncLoader.java
public static ListenableFuture<TenantId> findEntityIdAsync(TbContext ctx, EntityId original) { switch (original.getEntityType()) { case TENANT:/*www. jav a 2 s .co m*/ return Futures.immediateFuture((TenantId) original); case CUSTOMER: return getTenantAsync( ctx.getCustomerService().findCustomerByIdAsync(ctx.getTenantId(), (CustomerId) original)); case USER: return getTenantAsync(ctx.getUserService().findUserByIdAsync(ctx.getTenantId(), (UserId) original)); case ASSET: return getTenantAsync(ctx.getAssetService().findAssetByIdAsync(ctx.getTenantId(), (AssetId) original)); case DEVICE: return getTenantAsync( ctx.getDeviceService().findDeviceByIdAsync(ctx.getTenantId(), (DeviceId) original)); case ALARM: return getTenantAsync(ctx.getAlarmService().findAlarmByIdAsync(ctx.getTenantId(), (AlarmId) original)); case RULE_CHAIN: return getTenantAsync( ctx.getRuleChainService().findRuleChainByIdAsync(ctx.getTenantId(), (RuleChainId) original)); default: return Futures.immediateFailedFuture(new TbNodeException("Unexpected original EntityType " + original)); } }
From source file:co.cask.cdap.common.conf.InMemoryPropertyStore.java
@Override public synchronized ListenableFuture<T> update(String name, PropertyUpdater<T> updater) { try {/* w w w . j a va2 s . c o m*/ T property = updater.apply(getCached(name)).get(); updateAndNotify(name, property); return Futures.immediateFuture(property); } catch (Exception e) { return Futures.immediateFailedFuture(e); } }
From source file:com.yahoo.yqlplus.engine.internal.java.runtime.TimeoutHandler.java
public <T> ListenableFuture<T> withTimeoutSync(final Callable<T> callable, final Timeout tracker, ListeningExecutorService executor) { try {/*from w ww. j av a 2 s .c o m*/ final long remaining = tracker.verify(); final TimeUnit units = tracker.getTickUnits(); final ListenableFuture<T> source = executor.submit(scoper.continueScope(callable)); return withTimeout(source, remaining, units); } catch (TimeoutException e) { return Futures.immediateFailedFuture(e); } }
From source file:net.sourceforge.fullsync.FullSync.java
public FullSync() { // deny everything by default questionHandler.push(question -> Futures .immediateFailedFuture(new ExecutionException("No Question handler present", null))); }