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();
}
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);
}
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();
}
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();
}
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);
}
}
Aggregations