Class ProviderUtils
java.lang.Object
org.apache.hadoop.yarn.service.provider.ProviderUtils
- All Implemented Interfaces:
YarnServiceConstants
This is a factoring out of methods handy for providers. It's bonded to a log
at construction time.
-
Field Summary
FieldsFields inherited from interface org.apache.hadoop.yarn.service.conf.YarnServiceConstants
APP_CONF_DIR, APP_LIB_DIR, APP_RESOURCES_DIR, APP_TYPE, CONTAINER_STATE_REPORT_AS_SERVICE_STATE, CONTENT, DEPENDENCY_DIR, DEPENDENCY_DIR_PERMISSIONS, DEPENDENCY_LOCALIZED_DIR_LINK, DEPENDENCY_TAR_GZ_FILE_EXT, DEPENDENCY_TAR_GZ_FILE_NAME, ERR_FILE, HADOOP_USER_NAME, KEYTAB_DIR, KEYTAB_LOCATION, OUT_FILE, PRINCIPAL, PROPERTY_LIB_DIR, RESOURCE_DIR, SERVICE_BASE_DIRECTORY, SERVICE_CORE_JAR, SERVICES_DIRECTORY, SERVICES_PUBLIC_DIRECTORY, STDERR_AM, STDOUT_AM, SUBMITTED_CONF_DIR, SYSPROP_LOG_DIR, SYSPROP_LOG4J_CONFIGURATION, TMP_DIR_PREFIX, UPGRADE_DIR, YARN_SERVICE_LOG4J_FILENAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddAllDependencyJars(Map<String, org.apache.hadoop.yarn.api.records.LocalResource> providerResources, SliderFileSystem sliderFileSystem, org.apache.hadoop.fs.Path tempPath, String libDir, String libLocalSrcDir) Loads all dependency jars from the default path.static booleanaddProviderJar(Map<String, org.apache.hadoop.yarn.api.records.LocalResource> providerResources, Class providerClass, String jarName, SliderFileSystem sliderFileSystem, org.apache.hadoop.fs.Path tempPath, String libdir, boolean miniClusterTestRun) Add oneself to the classpath.static voidcreateConfigFileAndAddLocalResource(AbstractLauncher launcher, SliderFileSystem fs, ContainerLaunchService.ComponentLaunchContext compLaunchContext, Map<String, String> tokensForSubstitution, ComponentInstance instance, org.apache.hadoop.yarn.service.ServiceContext context, ProviderService.ResolvedLaunchParams resolvedParams) static voidhandleStaticFilesForLocalization(AbstractLauncher launcher, SliderFileSystem fs, ContainerLaunchService.ComponentLaunchContext componentLaunchCtx, ProviderService.ResolvedLaunchParams resolvedParams) static org.apache.hadoop.fs.PathinitCompInstanceDir(SliderFileSystem fs, ContainerLaunchService.ComponentLaunchContext compLaunchContext, ComponentInstance instance) static org.apache.hadoop.fs.PathinitCompPublicResourceDir(SliderFileSystem fs, ContainerLaunchService.ComponentLaunchContext compLaunchContext, ComponentInstance instance) initCompTokensForSubstitute(ComponentInstance instance, org.apache.hadoop.yarn.api.records.Container container, ContainerLaunchService.ComponentLaunchContext componentLaunchContext) Get initial component token map to be substituted into config values.static StringreplaceSpacesWithDelimiter(String content, String delimiter) static voidstatic StringsubstituteStrWithTokens(String content, Map<String, String> tokensForSubstitution)
-
Field Details
-
log
protected static final org.slf4j.Logger log
-
-
Constructor Details
-
ProviderUtils
public ProviderUtils()
-
-
Method Details
-
addProviderJar
public static boolean addProviderJar(Map<String, org.apache.hadoop.yarn.api.records.LocalResource> providerResources, Class providerClass, String jarName, SliderFileSystem sliderFileSystem, org.apache.hadoop.fs.Path tempPath, String libdir, boolean miniClusterTestRun) throws IOException, SliderExceptionAdd oneself to the classpath. This does not work on minicluster test runs where the JAR is not built up.- Parameters:
providerResources- map of provider resources to add these entries toproviderClass- provider to addjarName- name of the jar to usesliderFileSystem- target filesystemtempPath- path in the cluster FS for temp fileslibdir- relative directory to place resourcesminiClusterTestRun- true if minicluster is being used- Returns:
- true if the class was found in a JAR
- Throws:
FileNotFoundException- if the JAR was not found and this is NOT a mini cluster test runIOException- IO problemsSliderException- any Slider problem
-
addAllDependencyJars
public static void addAllDependencyJars(Map<String, org.apache.hadoop.yarn.api.records.LocalResource> providerResources, SliderFileSystem sliderFileSystem, org.apache.hadoop.fs.Path tempPath, String libDir, String libLocalSrcDir) throws IOException, SliderExceptionLoads all dependency jars from the default path.- Parameters:
providerResources- map of provider resources to add these entries tosliderFileSystem- target filesystemtempPath- path in the cluster FS for temp fileslibDir- relative directory to place resourceslibLocalSrcDir- explicitly supplied local libs dir- Throws:
IOException- trouble copying to HDFSSliderException- trouble copying to HDFS
-
substituteStrWithTokens
-
replaceSpacesWithDelimiter
-
substituteMapWithTokens
-
initCompInstanceDir
public static org.apache.hadoop.fs.Path initCompInstanceDir(SliderFileSystem fs, ContainerLaunchService.ComponentLaunchContext compLaunchContext, ComponentInstance instance) -
initCompPublicResourceDir
public static org.apache.hadoop.fs.Path initCompPublicResourceDir(SliderFileSystem fs, ContainerLaunchService.ComponentLaunchContext compLaunchContext, ComponentInstance instance) -
createConfigFileAndAddLocalResource
public static void createConfigFileAndAddLocalResource(AbstractLauncher launcher, SliderFileSystem fs, ContainerLaunchService.ComponentLaunchContext compLaunchContext, Map<String, String> tokensForSubstitution, ComponentInstance instance, org.apache.hadoop.yarn.service.ServiceContext context, ProviderService.ResolvedLaunchParams resolvedParams) throws IOException- Throws:
IOException
-
handleStaticFilesForLocalization
public static void handleStaticFilesForLocalization(AbstractLauncher launcher, SliderFileSystem fs, ContainerLaunchService.ComponentLaunchContext componentLaunchCtx, ProviderService.ResolvedLaunchParams resolvedParams) throws IOException - Throws:
IOException
-
initCompTokensForSubstitute
public static Map<String,String> initCompTokensForSubstitute(ComponentInstance instance, org.apache.hadoop.yarn.api.records.Container container, ContainerLaunchService.ComponentLaunchContext componentLaunchContext) Get initial component token map to be substituted into config values.- Returns:
- tokens to replace
-