/** * Constructs a ClassLoader that load classes from the programClassLoader, then from the plugin lib ClassLoader, * followed by plugin Export-Package ClassLoader and with the system ClassLoader last. * This constructor should only be called from {@link MapReduceRuntimeService} only. */ MapReduceClassLoader(final Injector injector, CConfiguration cConf, Configuration hConf, ClassLoader programClassLoader, Map<String, Plugin> plugins, @Nullable PluginInstantiator pluginInstantiator) { this(new Parameters(cConf, hConf, programClassLoader, plugins, pluginInstantiator), new TaskContextProviderFactory() { @Override public MapReduceTaskContextProvider create(CConfiguration cConf, Configuration hConf, MapReduceClassLoader mapReduceClassLoader) { return new MapReduceTaskContextProvider(injector, mapReduceClassLoader); } }); }
/** * Creates the delegating list of ClassLoader. */ private static List<ClassLoader> createDelegates(Parameters parameters) { return ImmutableList.of( parameters.getProgramClassLoader(), parameters.getFilteredPluginsClassLoader(), MapReduceClassLoader.class.getClassLoader() ); }
/** * Returns the {@link PluginInstantiator} associated with this ClassLoader. */ @Nullable public PluginInstantiator getPluginInstantiator() { return parameters.getPluginInstantiator(); }
/** * Creates logging context for MapReduce program. If the program is started * by Workflow an instance of {@link WorkflowProgramLoggingContext} is returned, * otherwise an instance of {@link MapReduceLoggingContext} is returned. */ private LoggingContext createMapReduceLoggingContext() { MapReduceContextConfig contextConfig = new MapReduceContextConfig(parameters.getHConf()); ProgramId programId = contextConfig.getProgramId(); RunId runId = ProgramRunners.getRunId(contextConfig.getProgramOptions()); WorkflowProgramInfo workflowProgramInfo = contextConfig.getWorkflowProgramInfo(); if (workflowProgramInfo == null) { return new MapReduceLoggingContext(programId.getNamespace(), programId.getApplication(), programId.getProgram(), runId.getId()); } String workflowId = workflowProgramInfo.getName(); String workflowRunId = workflowProgramInfo.getRunId().getId(); return new WorkflowProgramLoggingContext(programId.getNamespace(), programId.getApplication(), workflowId, workflowRunId, ProgramType.MAPREDUCE, programId.getProgram(), runId.getId()); }
/** * Creates logging context for MapReduce program. If the program is started * by Workflow an instance of {@link WorkflowProgramLoggingContext} is returned, * otherwise an instance of {@link MapReduceLoggingContext} is returned. */ private LoggingContext createMapReduceLoggingContext() { MapReduceContextConfig contextConfig = new MapReduceContextConfig(parameters.getHConf()); ProgramId programId = contextConfig.getProgramId(); RunId runId = ProgramRunners.getRunId(contextConfig.getProgramOptions()); WorkflowProgramInfo workflowProgramInfo = contextConfig.getWorkflowProgramInfo(); if (workflowProgramInfo == null) { return new MapReduceLoggingContext(programId.getNamespace(), programId.getApplication(), programId.getProgram(), runId.getId()); } String workflowId = workflowProgramInfo.getName(); String workflowRunId = workflowProgramInfo.getRunId().getId(); return new WorkflowProgramLoggingContext(programId.getNamespace(), programId.getApplication(), workflowId, workflowRunId, ProgramType.MAPREDUCE, programId.getProgram(), runId.getId()); }
/** * Constructs a ClassLoader that load classes from the programClassLoader, then from the plugin lib ClassLoader, * followed by plugin Export-Package ClassLoader and with the system ClassLoader last. * This constructor should only be called from {@link MapReduceRuntimeService} only. */ MapReduceClassLoader(final Injector injector, CConfiguration cConf, Configuration hConf, ClassLoader programClassLoader, Map<String, Plugin> plugins, @Nullable PluginInstantiator pluginInstantiator) { this(new Parameters(cConf, hConf, programClassLoader, plugins, pluginInstantiator), new TaskContextProviderFactory() { @Override public MapReduceTaskContextProvider create(CConfiguration cConf, Configuration hConf, MapReduceClassLoader mapReduceClassLoader) { return new MapReduceTaskContextProvider(injector, mapReduceClassLoader); } }); }
/** * Constructor. It creates classloader for MapReduce from information * gathered through {@link MapReduceContextConfig}. This method is called by {@link MapReduceContainerLauncher}. */ @SuppressWarnings("unused") public MapReduceClassLoader() { this(new Parameters(), new TaskContextProviderFactory() { @Override public MapReduceTaskContextProvider create(CConfiguration cConf, Configuration hConf, MapReduceClassLoader mapReduceClassLoader) { Preconditions.checkState(!MapReduceTaskContextProvider.isLocal(hConf), "Expected to be in distributed mode."); return new DistributedMapReduceTaskContextProvider(cConf, hConf, mapReduceClassLoader); } }); }
/** * Constructor. It creates classloader for MapReduce from information * gathered through {@link MapReduceContextConfig}. This method is called by {@link MapReduceContainerLauncher}. */ @SuppressWarnings("unused") public MapReduceClassLoader() { this(new Parameters(), new TaskContextProviderFactory() { @Override public MapReduceTaskContextProvider create(CConfiguration cConf, Configuration hConf, MapReduceClassLoader mapReduceClassLoader) { Preconditions.checkState(!MapReduceTaskContextProvider.isLocal(hConf), "Expected to be in distributed mode."); return new DistributedMapReduceTaskContextProvider(cConf, hConf, mapReduceClassLoader); } }); }
Parameters(MapReduceContextConfig contextConfig) { this(contextConfig, createProgramClassLoader(contextConfig)); }
Parameters(MapReduceContextConfig contextConfig) { this(contextConfig, createProgramClassLoader(contextConfig)); }
Parameters(MapReduceContextConfig contextConfig, ClassLoader programClassLoader) { this(contextConfig.getCConf(), contextConfig.getHConf(), programClassLoader, contextConfig.getPlugins(), createPluginInstantiator(contextConfig, programClassLoader)); }
Parameters(MapReduceContextConfig contextConfig, ClassLoader programClassLoader) { this(contextConfig.getCConf(), contextConfig.getHConf(), programClassLoader, contextConfig.getPlugins(), createPluginInstantiator(contextConfig, programClassLoader)); }
/** * Returns the program {@link ProgramClassLoader} used to construct this ClassLoader. */ public ClassLoader getProgramClassLoader() { return parameters.getProgramClassLoader(); }
/** * Creates from the Job Configuration */ Parameters() { this(createContextConfig()); }
/** * Creates from the Job Configuration */ Parameters() { this(createContextConfig()); }
/** * Returns the program {@link ProgramClassLoader} used to construct this ClassLoader. */ public ClassLoader getProgramClassLoader() { return parameters.getProgramClassLoader(); }
/** * Returns the {@link PluginInstantiator} associated with this ClassLoader. */ @Nullable public PluginInstantiator getPluginInstantiator() { return parameters.getPluginInstantiator(); }
/** * Creates the delegating list of ClassLoader. */ private static List<ClassLoader> createDelegates(Parameters parameters) { return ImmutableList.of( parameters.getProgramClassLoader(), parameters.getFilteredPluginsClassLoader(), MapReduceClassLoader.class.getClassLoader() ); }