use of org.apache.flink.runtime.webmonitor.handlers.utils.JarHandlerUtils.JarHandlerContext in project flink by apache.
the class JarRunHandler method handleRequest.
@Override
@VisibleForTesting
public CompletableFuture<JarRunResponseBody> handleRequest(@Nonnull final HandlerRequest<JarRunRequestBody> request, @Nonnull final DispatcherGateway gateway) throws RestHandlerException {
final Configuration effectiveConfiguration = new Configuration(configuration);
effectiveConfiguration.set(DeploymentOptions.ATTACHED, false);
effectiveConfiguration.set(DeploymentOptions.TARGET, EmbeddedExecutor.NAME);
final JarHandlerContext context = JarHandlerContext.fromRequest(request, jarDir, log);
context.applyToConfiguration(effectiveConfiguration);
SavepointRestoreSettings.toConfiguration(getSavepointRestoreSettings(request), effectiveConfiguration);
final PackagedProgram program = context.toPackagedProgram(effectiveConfiguration);
return CompletableFuture.supplyAsync(() -> applicationRunner.run(gateway, program, effectiveConfiguration), executor).handle((jobIds, throwable) -> {
program.close();
if (throwable != null) {
throw new CompletionException(new RestHandlerException("Could not execute application.", HttpResponseStatus.BAD_REQUEST, throwable));
} else if (jobIds.isEmpty()) {
throw new CompletionException(new RestHandlerException("No jobs included in application.", HttpResponseStatus.BAD_REQUEST));
}
return new JarRunResponseBody(jobIds.get(0));
});
}
Aggregations