|
@@ -27,6 +27,7 @@ import org.apache.hadoop.fs.permission.FsPermission;
|
|
import org.apache.hadoop.yarn.api.records.Container;
|
|
import org.apache.hadoop.yarn.api.records.Container;
|
|
import org.apache.hadoop.yarn.api.records.LocalResource;
|
|
import org.apache.hadoop.yarn.api.records.LocalResource;
|
|
import org.apache.hadoop.yarn.api.records.LocalResourceType;
|
|
import org.apache.hadoop.yarn.api.records.LocalResourceType;
|
|
|
|
+import org.apache.hadoop.yarn.api.records.LocalResourceVisibility;
|
|
import org.apache.hadoop.yarn.service.ServiceContext;
|
|
import org.apache.hadoop.yarn.service.ServiceContext;
|
|
import org.apache.hadoop.yarn.service.api.records.ConfigFile;
|
|
import org.apache.hadoop.yarn.service.api.records.ConfigFile;
|
|
import org.apache.hadoop.yarn.service.api.records.ConfigFormat;
|
|
import org.apache.hadoop.yarn.service.api.records.ConfigFormat;
|
|
@@ -191,6 +192,17 @@ public class ProviderUtils implements YarnServiceConstants {
|
|
return compInstanceDir;
|
|
return compInstanceDir;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static Path initCompPublicResourceDir(SliderFileSystem fs,
|
|
|
|
+ ContainerLaunchService.ComponentLaunchContext compLaunchContext,
|
|
|
|
+ ComponentInstance instance) {
|
|
|
|
+ Path compDir = fs.getComponentPublicResourceDir(
|
|
|
|
+ compLaunchContext.getServiceVersion(), compLaunchContext.getName());
|
|
|
|
+ Path compPublicResourceDir = new Path(compDir,
|
|
|
|
+ instance.getCompInstanceName());
|
|
|
|
+ return compPublicResourceDir;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
// 1. Create all config files for a component on hdfs for localization
|
|
// 1. Create all config files for a component on hdfs for localization
|
|
// 2. Add the config file to localResource
|
|
// 2. Add the config file to localResource
|
|
public static synchronized void createConfigFileAndAddLocalResource(
|
|
public static synchronized void createConfigFileAndAddLocalResource(
|
|
@@ -212,6 +224,20 @@ public class ProviderUtils implements YarnServiceConstants {
|
|
log.info("Component instance conf dir already exists: " + compInstanceDir);
|
|
log.info("Component instance conf dir already exists: " + compInstanceDir);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Path compPublicResourceDir = initCompPublicResourceDir(fs,
|
|
|
|
+ compLaunchContext, instance);
|
|
|
|
+ if (!fs.getFileSystem().exists(compPublicResourceDir)) {
|
|
|
|
+ log.info("{} version {} : Creating Public Resource dir on hdfs: {}",
|
|
|
|
+ instance.getCompInstanceId(), compLaunchContext.getServiceVersion(),
|
|
|
|
+ compPublicResourceDir);
|
|
|
|
+ fs.getFileSystem().mkdirs(compPublicResourceDir,
|
|
|
|
+ new FsPermission(FsAction.ALL, FsAction.READ_EXECUTE,
|
|
|
|
+ FsAction.EXECUTE));
|
|
|
|
+ } else {
|
|
|
|
+ log.info("Component instance public resource dir already exists: "
|
|
|
|
+ + compPublicResourceDir);
|
|
|
|
+ }
|
|
|
|
+
|
|
log.debug("Tokens substitution for component instance: {}{}{}" + instance
|
|
log.debug("Tokens substitution for component instance: {}{}{}" + instance
|
|
.getCompInstanceName(), System.lineSeparator(), tokensForSubstitution);
|
|
.getCompInstanceName(), System.lineSeparator(), tokensForSubstitution);
|
|
|
|
|
|
@@ -236,7 +262,14 @@ public class ProviderUtils implements YarnServiceConstants {
|
|
* substitution and merges in new configs, and writes a new file to
|
|
* substitution and merges in new configs, and writes a new file to
|
|
* compInstanceDir/fileName.
|
|
* compInstanceDir/fileName.
|
|
*/
|
|
*/
|
|
- Path remoteFile = new Path(compInstanceDir, fileName);
|
|
|
|
|
|
+ Path remoteFile = null;
|
|
|
|
+ LocalResourceVisibility visibility = configFile.getVisibility();
|
|
|
|
+ if (visibility != null &&
|
|
|
|
+ visibility.equals(LocalResourceVisibility.PUBLIC)) {
|
|
|
|
+ remoteFile = new Path(compPublicResourceDir, fileName);
|
|
|
|
+ } else {
|
|
|
|
+ remoteFile = new Path(compInstanceDir, fileName);
|
|
|
|
+ }
|
|
|
|
|
|
if (!fs.getFileSystem().exists(remoteFile)) {
|
|
if (!fs.getFileSystem().exists(remoteFile)) {
|
|
log.info("Saving config file on hdfs for component " + instance
|
|
log.info("Saving config file on hdfs for component " + instance
|
|
@@ -268,7 +301,8 @@ public class ProviderUtils implements YarnServiceConstants {
|
|
|
|
|
|
// Add resource for localization
|
|
// Add resource for localization
|
|
LocalResource configResource =
|
|
LocalResource configResource =
|
|
- fs.createAmResource(remoteFile, LocalResourceType.FILE);
|
|
|
|
|
|
+ fs.createAmResource(remoteFile, LocalResourceType.FILE,
|
|
|
|
+ configFile.getVisibility());
|
|
Path destFile = new Path(configFile.getDestFile());
|
|
Path destFile = new Path(configFile.getDestFile());
|
|
String symlink = APP_CONF_DIR + "/" + fileName;
|
|
String symlink = APP_CONF_DIR + "/" + fileName;
|
|
addLocalResource(launcher, symlink, configResource, destFile,
|
|
addLocalResource(launcher, symlink, configResource, destFile,
|
|
@@ -311,7 +345,8 @@ public class ProviderUtils implements YarnServiceConstants {
|
|
LocalResource localResource = fs.createAmResource(sourceFile,
|
|
LocalResource localResource = fs.createAmResource(sourceFile,
|
|
(staticFile.getType() == ConfigFile.TypeEnum.ARCHIVE ?
|
|
(staticFile.getType() == ConfigFile.TypeEnum.ARCHIVE ?
|
|
LocalResourceType.ARCHIVE :
|
|
LocalResourceType.ARCHIVE :
|
|
- LocalResourceType.FILE));
|
|
|
|
|
|
+ LocalResourceType.FILE), staticFile.getVisibility());
|
|
|
|
+
|
|
Path destFile = new Path(sourceFile.getName());
|
|
Path destFile = new Path(sourceFile.getName());
|
|
if (staticFile.getDestFile() != null && !staticFile.getDestFile()
|
|
if (staticFile.getDestFile() != null && !staticFile.getDestFile()
|
|
.isEmpty()) {
|
|
.isEmpty()) {
|