Search in sources :

Example 1 with SecurityContext

use of org.apache.flink.runtime.security.contexts.SecurityContext in project flink by apache.

the class ClusterEntrypoint method startCluster.

public void startCluster() throws ClusterEntrypointException {
    LOG.info("Starting {}.", getClass().getSimpleName());
    try {
        FlinkSecurityManager.setFromConfiguration(configuration);
        PluginManager pluginManager = PluginUtils.createPluginManagerFromRootFolder(configuration);
        configureFileSystems(configuration, pluginManager);
        SecurityContext securityContext = installSecurityContext(configuration);
        ClusterEntrypointUtils.configureUncaughtExceptionHandler(configuration);
        securityContext.runSecured((Callable<Void>) () -> {
            runCluster(configuration, pluginManager);
            return null;
        });
    } catch (Throwable t) {
        final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class);
        try {
            // clean up any partial state
            shutDownAsync(ApplicationStatus.FAILED, ShutdownBehaviour.GRACEFUL_SHUTDOWN, ExceptionUtils.stringifyException(strippedThrowable), false).get(INITIALIZATION_SHUTDOWN_TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
        } catch (InterruptedException | ExecutionException | TimeoutException e) {
            strippedThrowable.addSuppressed(e);
        }
        throw new ClusterEntrypointException(String.format("Failed to initialize the cluster entrypoint %s.", getClass().getSimpleName()), strippedThrowable);
    }
}
Also used : PluginManager(org.apache.flink.core.plugin.PluginManager) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SecurityContext(org.apache.flink.runtime.security.contexts.SecurityContext)

Aggregations

UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 PluginManager (org.apache.flink.core.plugin.PluginManager)1 SecurityContext (org.apache.flink.runtime.security.contexts.SecurityContext)1