Search in sources :

Example 11 with PackagedProgram

use of org.apache.flink.client.program.PackagedProgram in project flink by apache.

the class ApplicationDispatcherBootstrapTest method runApplication.

private CompletableFuture<Void> runApplication(TestingDispatcherGateway.Builder dispatcherBuilder, Configuration configuration, int noOfJobs) throws FlinkException {
    final PackagedProgram program = getProgram(noOfJobs);
    final ApplicationDispatcherBootstrap bootstrap = new ApplicationDispatcherBootstrap(program, Collections.emptyList(), configuration, dispatcherBuilder.build(), scheduledExecutor, exception -> {
    });
    return bootstrap.getApplicationCompletionFuture();
}
Also used : PackagedProgram(org.apache.flink.client.program.PackagedProgram)

Example 12 with PackagedProgram

use of org.apache.flink.client.program.PackagedProgram in project flink by apache.

the class YarnApplicationClusterEntryPoint method main.

public static void main(final String[] args) {
    // startup checks and logging
    EnvironmentInformation.logEnvironmentInfo(LOG, YarnApplicationClusterEntryPoint.class.getSimpleName(), args);
    SignalHandler.register(LOG);
    JvmShutdownSafeguard.installAsShutdownHook(LOG);
    Map<String, String> env = System.getenv();
    final String workingDirectory = env.get(ApplicationConstants.Environment.PWD.key());
    Preconditions.checkArgument(workingDirectory != null, "Working directory variable (%s) not set", ApplicationConstants.Environment.PWD.key());
    try {
        YarnEntrypointUtils.logYarnEnvironmentInformation(env, LOG);
    } catch (IOException e) {
        LOG.warn("Could not log YARN environment information.", e);
    }
    final Configuration dynamicParameters = ClusterEntrypointUtils.parseParametersOrExit(args, new DynamicParametersConfigurationParserFactory(), YarnApplicationClusterEntryPoint.class);
    final Configuration configuration = YarnEntrypointUtils.loadConfiguration(workingDirectory, dynamicParameters, env);
    PackagedProgram program = null;
    try {
        program = getPackagedProgram(configuration);
    } catch (Exception e) {
        LOG.error("Could not create application program.", e);
        System.exit(1);
    }
    try {
        configureExecution(configuration, program);
    } catch (Exception e) {
        LOG.error("Could not apply application configuration.", e);
        System.exit(1);
    }
    YarnApplicationClusterEntryPoint yarnApplicationClusterEntrypoint = new YarnApplicationClusterEntryPoint(configuration, program);
    ClusterEntrypoint.runClusterEntrypoint(yarnApplicationClusterEntrypoint);
}
Also used : DynamicParametersConfigurationParserFactory(org.apache.flink.runtime.entrypoint.DynamicParametersConfigurationParserFactory) PackagedProgram(org.apache.flink.client.program.PackagedProgram) ApplicationConfiguration(org.apache.flink.client.deployment.application.ApplicationConfiguration) Configuration(org.apache.flink.configuration.Configuration) IOException(java.io.IOException) FlinkException(org.apache.flink.util.FlinkException) IOException(java.io.IOException)

Example 13 with PackagedProgram

use of org.apache.flink.client.program.PackagedProgram in project flink by apache.

the class ClassLoaderITCase method testUserCodeTypeJobWithCustomClassLoader.

@Test
public void testUserCodeTypeJobWithCustomClassLoader() throws ProgramInvocationException {
    PackagedProgram userCodeTypeProg = PackagedProgram.newBuilder().setJarFile(new File(USERCODETYPE_JAR_PATH)).build();
    TestEnvironment.setAsContext(miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(USERCODETYPE_JAR_PATH)), Collections.emptyList());
    userCodeTypeProg.invokeInteractiveModeForExecution();
}
Also used : Path(org.apache.flink.core.fs.Path) PackagedProgram(org.apache.flink.client.program.PackagedProgram) File(java.io.File) Test(org.junit.Test)

Example 14 with PackagedProgram

use of org.apache.flink.client.program.PackagedProgram in project flink by apache.

the class ClassLoaderITCase method testStreamingCustomSplitJobWithCustomClassLoader.

@Test
public void testStreamingCustomSplitJobWithCustomClassLoader() throws ProgramInvocationException {
    PackagedProgram streamingInputSplitTestProg = PackagedProgram.newBuilder().setJarFile(new File(STREAMING_INPUT_SPLITS_PROG_JAR_FILE)).build();
    TestStreamEnvironment.setAsContext(miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(STREAMING_INPUT_SPLITS_PROG_JAR_FILE)), Collections.emptyList());
    streamingInputSplitTestProg.invokeInteractiveModeForExecution();
}
Also used : Path(org.apache.flink.core.fs.Path) PackagedProgram(org.apache.flink.client.program.PackagedProgram) File(java.io.File) Test(org.junit.Test)

Example 15 with PackagedProgram

use of org.apache.flink.client.program.PackagedProgram in project flink by apache.

the class ClassLoaderITCase method testProgramWithParentFirstClassLoader.

@Test
public void testProgramWithParentFirstClassLoader() throws IOException, ProgramInvocationException {
    // We have two files named test-resource in src/resource (parent classloader classpath) and
    // tmp folders (child classloader classpath) respectively.
    String childResourceDirName = "child1";
    String testResourceName = "test-resource";
    File childResourceDir = FOLDER.newFolder(childResourceDirName);
    File childResource = new File(childResourceDir, testResourceName);
    assertTrue(childResource.createNewFile());
    TestStreamEnvironment.setAsContext(miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(CLASSLOADING_POLICY_JAR_PATH)), Collections.emptyList());
    // parent-first classloading
    Configuration parentFirstConf = new Configuration();
    parentFirstConf.setString("classloader.resolve-order", "parent-first");
    final PackagedProgram parentFirstProgram = PackagedProgram.newBuilder().setJarFile(new File(CLASSLOADING_POLICY_JAR_PATH)).setUserClassPaths(Collections.singletonList(childResourceDir.toURI().toURL())).setConfiguration(parentFirstConf).setArguments(testResourceName, "test-classes").build();
    final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(parentFirstProgram.getUserCodeClassLoader());
    try {
        parentFirstProgram.invokeInteractiveModeForExecution();
    } finally {
        Thread.currentThread().setContextClassLoader(contextClassLoader);
    }
}
Also used : Path(org.apache.flink.core.fs.Path) PackagedProgram(org.apache.flink.client.program.PackagedProgram) MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) Configuration(org.apache.flink.configuration.Configuration) File(java.io.File) Test(org.junit.Test)

Aggregations

PackagedProgram (org.apache.flink.client.program.PackagedProgram)42 Test (org.junit.Test)25 File (java.io.File)20 Configuration (org.apache.flink.configuration.Configuration)19 URL (java.net.URL)13 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)12 Path (org.apache.flink.core.fs.Path)12 FileNotFoundException (java.io.FileNotFoundException)7 IOException (java.io.IOException)7 CommandLine (org.apache.commons.cli.CommandLine)6 RunOptions (org.apache.flink.client.cli.RunOptions)5 CompilerException (org.apache.flink.optimizer.CompilerException)5 FlinkException (org.apache.flink.util.FlinkException)5 Pipeline (org.apache.flink.api.dag.Pipeline)4 DataStatistics (org.apache.flink.optimizer.DataStatistics)4 Optimizer (org.apache.flink.optimizer.Optimizer)4 DefaultCostEstimator (org.apache.flink.optimizer.costs.DefaultCostEstimator)4 JobID (org.apache.flink.api.common.JobID)3 ApplicationConfiguration (org.apache.flink.client.deployment.application.ApplicationConfiguration)3 MiniClusterResourceConfiguration (org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration)3