Creates an OrFuture that is already completed with a {@link Bad}.

@param bad the failure value
@param <G> the success type
@return an instance of OrFuture
501464
public <G, B> OrFuture<G, B> badFuture(B bad) {
    return this.<G, B>promise().failure(bad).future();
  }
1108072
protected Response createBadRequest(String message) {
    ErrorResponse entity = new ErrorResponse();
    entity.setMessage(message);
    return Response
      .status(Response.Status.BAD_REQUEST)
      .entity(entity)
      .build();
  }
483394
final void orpush(CompletableFuture<?> b, BiCompletion<?,?,?> c) {
        if (c != null) {
            while ((b == null || b.result == null) && result == null) {
                if (tryPushStack(c)) {
                    if (b != null && b != this && b.result == null) {
                        Completion q = new CoCompletion(c);
                        while (result == null && b.result == null &&
                               !b.tryPushStack(q))
                            lazySetNext(q, null); // clear on failure
                    }
                    break;
                }
                lazySetNext(c, null); // clear on failure
            }
        }
    }
188424
public static <T> ValueSourceFuture<T> createValueSourceFuture(ApiFuture<T> apiFuture) {
        if (apiFuture instanceof ValueSourceFutureBackedApiFuture) {
            return ((ValueSourceFutureBackedApiFuture<T>) apiFuture).getWrappedFuture();
        } else {
            return new ApiFutureBackedValueSourceFuture<>(apiFuture);
        }
    }
785157
public static <F, S> Failure<F, S> failure(
    final F x)
  {
    return new Failure<F, S>(x);
  }
273607
@SuppressWarnings("static-method")
	protected Runnable createTask(Runnable runnable) {
		if (runnable instanceof JanusRunnable) {
			return runnable;
		}
		return new JanusRunnable(runnable);
	}
235753
@Override
	public <D, P> Promise<D, Throwable, P> when(DeferredFutureTask<D, P> task) {
		return new AndroidDeferredObject<D, Throwable, P>(super.when(task)).promise();
	}
872698
public static <F, S> TryType<F, S> failure(
    final F x)
  {
    return Failure.failure(x);
  }
385502
public static JobResult createFrom(AccessExecutionGraph accessExecutionGraph) {
		final JobID jobId = accessExecutionGraph.getJobID();
		final JobStatus jobStatus = accessExecutionGraph.getState();

		checkArgument(
			jobStatus.isGloballyTerminalState(),
			"The job " + accessExecutionGraph.getJobName() + '(' + jobId + ") is not in a globally " +
				"terminal state. It is in state " + jobStatus + '.');

		final JobResult.Builder builder = new JobResult.Builder();
		builder.jobId(jobId);

		builder.applicationStatus(ApplicationStatus.fromJobStatus(accessExecutionGraph.getState()));

		final long netRuntime = accessExecutionGraph.getStatusTimestamp(jobStatus) - accessExecutionGraph.getStatusTimestamp(JobStatus.CREATED);
		// guard against clock changes
		final long guardedNetRuntime = Math.max(netRuntime, 0L);
		builder.netRuntime(guardedNetRuntime);
		builder.accumulatorResults(accessExecutionGraph.getAccumulatorsSerialized());

		if (jobStatus != JobStatus.FINISHED) {
			final ErrorInfo errorInfo = accessExecutionGraph.getFailureInfo();

			if (errorInfo != null) {
				builder.serializedThrowable(errorInfo.getException());
			}
		}

		return builder.build();
	}
268301
public static <R> MethodResult<R> failure(Throwable failure) {
        return new MethodResult<>(null, failure, false);
    }
1115435
public static <T> ValueSourceFuture<T> createValueSourceFuture(ListenableFuture<T> listenableFuture) {
        if (listenableFuture instanceof ValueSourceFutureBackedListenableFuture) {
            return ((ValueSourceFutureBackedListenableFuture<T>) listenableFuture).getWrappedFuture();
        } else {
            return new ListenableFutureBackedValueSourceFuture<>(listenableFuture);
        }
    }
1272506
public static <T> AtomixFuture<T> wrap(CompletableFuture<T> future) {
    AtomixFuture<T> newFuture = new AtomixFuture<>();
    future.whenComplete((result, error) -> {
      if (error == null) {
        newFuture.complete(result);
      } else {
        newFuture.completeExceptionally(error);
      }
    });
    return newFuture;
  }
1279146
public static <T> ThriftCompletableFuture<T> failedCompletedFuture(Exception e) {
        final ThriftCompletableFuture<T> future = new ThriftCompletableFuture<>();
        future.onError(e);
        return future;
    }
7578
public CompletableFuture<CreateScopeStatus> createScope(final String scope) {
        Exceptions.checkNotNullOrEmpty(scope, "scope");
        try {
            NameUtils.validateScopeName(scope);
        } catch (IllegalArgumentException | NullPointerException e) {
            log.warn("Create scope failed due to invalid scope name {}", scope);
            return CompletableFuture.completedFuture(CreateScopeStatus.newBuilder().setStatus(
                    CreateScopeStatus.Status.INVALID_SCOPE_NAME).build());
        }
        return streamStore.createScope(scope);
    }
836140
@Override
	public EvolutionResult<G, C> apply(final EvolutionStart<G, C> start) {
		return evolve(start);
	}
896604
@Override
	public CompletableFuture<?> releaseSlot(@Nullable Throwable cause) {
		if (!isCanceled()) {
			final CompletableFuture<?> terminationFuture;

			if (payload != null) {
				// trigger the failure of the slot payload
				payload.fail(cause != null ? cause : new FlinkException("TaskManager was lost/killed: " + getTaskManagerLocation()));

				// wait for the termination of the payload before releasing the slot
				terminationFuture = payload.getTerminalStateFuture();
			} else {
				terminationFuture = CompletableFuture.completedFuture(null);
			}

			terminationFuture.whenComplete(
				(Object ignored, Throwable throwable) -> {
					// release directly (if we are directly allocated),
					// otherwise release through the parent shared slot
					if (getParent() == null) {
						// we have to give back the slot to the owning instance
						if (markCancelled()) {
							try {
								getOwner().returnLogicalSlot(this);
								releaseFuture.complete(null);
							} catch (Exception e) {
								releaseFuture.completeExceptionally(e);
							}
						}
					} else {
						// we have to ask our parent to dispose us
						getParent().releaseChild(this);

						releaseFuture.complete(null);
					}
				});
		}

		return releaseFuture;
	}
101156
private DevUtilsDemoObject create(final String name, ExecutionContext executionContext) {
        return executionContext.add(this, devUtilsDemoObjects.create(name));
    }