Search in sources :

Example 1 with DefaultProgram

use of io.cdap.cdap.app.program.DefaultProgram in project cdap by caskdata.

the class MapReduceTaskContextProvider method createProgram.

/**
 * Creates a {@link Program} instance based on the information from the {@link MapReduceContextConfig}, using
 * the given program ClassLoader.
 */
private Program createProgram(MapReduceContextConfig contextConfig, ClassLoader programClassLoader) {
    Location programLocation;
    LocationFactory locationFactory = new LocalLocationFactory();
    // Use the program jar location regardless if local or distributed, since it is valid for both
    programLocation = locationFactory.create(new File(contextConfig.getProgramJarName()).getAbsoluteFile().toURI());
    return new DefaultProgram(new ProgramDescriptor(contextConfig.getProgramId(), contextConfig.getApplicationSpecification()), programLocation, programClassLoader);
}
Also used : DefaultProgram(io.cdap.cdap.app.program.DefaultProgram) ProgramDescriptor(io.cdap.cdap.app.program.ProgramDescriptor) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) File(java.io.File) Location(org.apache.twill.filesystem.Location) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory)

Example 2 with DefaultProgram

use of io.cdap.cdap.app.program.DefaultProgram in project cdap by caskdata.

the class SparkRuntimeContextProvider method createProgram.

private static Program createProgram(CConfiguration cConf, SparkRuntimeContextConfig contextConfig) throws IOException {
    File programJar = new File(PROGRAM_JAR_NAME);
    File programDir = new File(PROGRAM_JAR_EXPANDED_NAME);
    ClassLoader parentClassLoader = new FilterClassLoader(SparkRuntimeContextProvider.class.getClassLoader(), SparkResourceFilters.SPARK_PROGRAM_CLASS_LOADER_FILTER);
    ClassLoader classLoader = new ProgramClassLoader(cConf, programDir, parentClassLoader);
    return new DefaultProgram(new ProgramDescriptor(contextConfig.getProgramId(), contextConfig.getApplicationSpecification()), Locations.toLocation(programJar), classLoader);
}
Also used : FilterClassLoader(io.cdap.cdap.common.lang.FilterClassLoader) ProgramClassLoader(io.cdap.cdap.internal.app.runtime.ProgramClassLoader) ProgramClassLoader(io.cdap.cdap.internal.app.runtime.ProgramClassLoader) FilterClassLoader(io.cdap.cdap.common.lang.FilterClassLoader) DefaultProgram(io.cdap.cdap.app.program.DefaultProgram) ProgramDescriptor(io.cdap.cdap.app.program.ProgramDescriptor) File(java.io.File)

Aggregations

DefaultProgram (io.cdap.cdap.app.program.DefaultProgram)2 ProgramDescriptor (io.cdap.cdap.app.program.ProgramDescriptor)2 File (java.io.File)2 FilterClassLoader (io.cdap.cdap.common.lang.FilterClassLoader)1 ProgramClassLoader (io.cdap.cdap.internal.app.runtime.ProgramClassLoader)1 LocalLocationFactory (org.apache.twill.filesystem.LocalLocationFactory)1 Location (org.apache.twill.filesystem.Location)1 LocationFactory (org.apache.twill.filesystem.LocationFactory)1