hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jia...@apache.org
Subject hadoop git commit: YARN-6804. [yarn-native-services changes] Allow custom hostname for docker containers in native services. Contributed by Billie Rinaldi
Date Fri, 21 Jul 2017 21:50:17 GMT
Repository: hadoop
Updated Branches:
  refs/heads/yarn-native-services 48b880c74 -> e79f4f5a9


YARN-6804. [yarn-native-services changes] Allow custom hostname for docker containers in native
services. Contributed by Billie Rinaldi


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/e79f4f5a
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/e79f4f5a
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/e79f4f5a

Branch: refs/heads/yarn-native-services
Commit: e79f4f5a9da1da70e5a3a478581294fcd3479acc
Parents: 48b880c
Author: Jian He <jianhe@apache.org>
Authored: Fri Jul 21 14:49:42 2017 -0700
Committer: Jian He <jianhe@apache.org>
Committed: Fri Jul 21 14:49:46 2017 -0700

----------------------------------------------------------------------
 .../slider/core/launch/AbstractLauncher.java    |  7 ++++
 .../providers/AbstractProviderService.java      |  7 ++--
 .../providers/DefaultProviderService.java       |  9 +++--
 .../apache/slider/providers/ProviderUtils.java  |  3 +-
 .../providers/docker/DockerProviderService.java | 23 ++++++++++-
 .../tarball/TarballProviderService.java         | 10 +++--
 .../server/appmaster/state/RoleInstance.java    |  1 +
 .../server/dns/BaseServiceRecordProcessor.java  |  1 -
 .../dns/ContainerServiceRecordProcessor.java    |  9 ++++-
 .../registry/server/dns/TestRegistryDNS.java    | 40 ++++++++++----------
 .../runtime/DockerLinuxContainerRuntime.java    |  6 +++
 11 files changed, 79 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java
index 965ea35..8f61bf4 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java
@@ -81,6 +81,7 @@ public abstract class AbstractLauncher extends Configured {
   protected boolean yarnDockerMode = false;
   protected String dockerImage;
   protected String dockerNetwork = DEFAULT_DOCKER_NETWORK;
+  protected String dockerHostname;
   protected String yarnContainerMountPoints;
   protected String runPrivilegedContainer;
 
@@ -236,6 +237,8 @@ public abstract class AbstractLauncher extends Configured {
       env.put("YARN_CONTAINER_RUNTIME_TYPE", "docker");
       env.put("YARN_CONTAINER_RUNTIME_DOCKER_IMAGE", dockerImage);
       env.put("YARN_CONTAINER_RUNTIME_DOCKER_CONTAINER_NETWORK", dockerNetwork);
+      env.put("YARN_CONTAINER_RUNTIME_DOCKER_CONTAINER_HOSTNAME",
+          dockerHostname);
       env.put("YARN_CONTAINER_RUNTIME_DOCKER_RUN_PRIVILEGED_CONTAINER", runPrivilegedContainer);
       StringBuilder sb = new StringBuilder();
       for (Entry<String,String> mount : mountPaths.entrySet()) {
@@ -469,6 +472,10 @@ public abstract class AbstractLauncher extends Configured {
     this.dockerNetwork = dockerNetwork;
   }
 
+  public void setDockerHostname(String dockerHostname) {
+    this.dockerHostname = dockerHostname;
+  }
+
   public void setYarnContainerMountPoints(String yarnContainerMountPoints) {
     this.yarnContainerMountPoints = yarnContainerMountPoints;
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java
index b7fa802..e0d9402 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java
@@ -60,8 +60,9 @@ public abstract class AbstractProviderService extends AbstractService
     super(name);
   }
 
-  public abstract void processArtifact(ContainerLauncher launcher, Component
-      component, SliderFileSystem fileSystem) throws IOException;
+  public abstract void processArtifact(ContainerLauncher launcher,
+      Application application, RoleInstance roleInstance,
+      SliderFileSystem fileSystem) throws IOException;
 
   @Override
   public void setAMState(StateAccessForProviders stateAccessor) {
@@ -78,7 +79,7 @@ public abstract class AbstractProviderService extends AbstractService
       SliderFileSystem fileSystem, RoleInstance roleInstance)
       throws IOException, SliderException {
     Component component = providerRole.component;
-    processArtifact(launcher, component, fileSystem);
+    processArtifact(launcher, application, roleInstance, fileSystem);
 
     // Generate tokens (key-value pair) for config substitution.
     // Get pre-defined tokens

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/DefaultProviderService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/DefaultProviderService.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/DefaultProviderService.java
index 7f7d209..8d2725c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/DefaultProviderService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/DefaultProviderService.java
@@ -17,10 +17,10 @@
  */
 package org.apache.slider.providers;
 
-import org.apache.slider.api.resource.Component;
+import org.apache.slider.api.resource.Application;
 import org.apache.slider.common.tools.SliderFileSystem;
 import org.apache.slider.core.launch.ContainerLauncher;
-import org.apache.slider.providers.AbstractProviderService;
+import org.apache.slider.server.appmaster.state.RoleInstance;
 
 import java.io.IOException;
 
@@ -31,7 +31,8 @@ public class DefaultProviderService extends AbstractProviderService {
   }
 
   @Override
-  public void processArtifact(ContainerLauncher launcher, Component
-      component, SliderFileSystem fileSystem) throws IOException {
+  public void processArtifact(ContainerLauncher launcher, Application
+      application, RoleInstance roleInstance, SliderFileSystem fileSystem)
+      throws IOException {
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/ProviderUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/ProviderUtils.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/ProviderUtils.java
index 0da535e..ecc521f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/ProviderUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/ProviderUtils.java
@@ -504,8 +504,7 @@ public class ProviderUtils implements RoleKeys, SliderKeys {
         // create and publish updated service record (including hostname & ip)
         ServiceRecord record = new ServiceRecord();
         record.set(YarnRegistryAttributes.YARN_ID, containerId);
-        String componentInstanceName = role.getCompInstanceName();
-        record.description = componentInstanceName.replaceAll("_", "-");
+        record.description = role.getCompInstanceName();
         record.set(YarnRegistryAttributes.YARN_PERSISTENCE,
             PersistencePolicies.CONTAINER);
         // TODO: use constants from YarnRegistryAttributes

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/docker/DockerProviderService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/docker/DockerProviderService.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/docker/DockerProviderService.java
index f35d4d1..73783af 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/docker/DockerProviderService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/docker/DockerProviderService.java
@@ -17,14 +17,19 @@
  */
 package org.apache.slider.providers.docker;
 
+import org.apache.hadoop.registry.client.api.RegistryConstants;
+import org.apache.hadoop.registry.client.binding.RegistryUtils;
+import org.apache.slider.api.resource.Application;
 import org.apache.slider.api.resource.Component;
 import org.apache.slider.common.tools.SliderFileSystem;
 import org.apache.slider.core.launch.ContainerLauncher;
 import org.apache.slider.providers.AbstractProviderService;
+import org.apache.slider.server.appmaster.state.RoleInstance;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
+import java.text.MessageFormat;
 
 public class DockerProviderService extends AbstractProviderService
     implements DockerKeys {
@@ -36,12 +41,26 @@ public class DockerProviderService extends AbstractProviderService
     super(DockerProviderService.class.getSimpleName());
   }
 
-  public void processArtifact(ContainerLauncher launcher, Component
-      component, SliderFileSystem fileSystem) throws IOException {
+  public void processArtifact(ContainerLauncher launcher, Application
+      application, RoleInstance roleInstance, SliderFileSystem fileSystem)
+      throws IOException {
+    Component component = roleInstance.providerRole.component;
     launcher.setYarnDockerMode(true);
     launcher.setDockerImage(component.getArtifact().getId());
     launcher.setDockerNetwork(component.getConfiguration()
         .getProperty(DOCKER_NETWORK, DEFAULT_DOCKER_NETWORK));
+    String domain = getConfig().get(RegistryConstants.KEY_DNS_DOMAIN);
+    String hostname;
+    if (domain == null || domain.isEmpty()) {
+      hostname = MessageFormat.format("{0}.{1}.{2}", roleInstance
+          .getCompInstanceName(), application.getName(), RegistryUtils
+          .currentUser());
+    } else {
+      hostname = MessageFormat.format("{0}.{1}.{2}.{3}", roleInstance
+          .getCompInstanceName(), application.getName(), RegistryUtils
+          .currentUser(), domain);
+    }
+    launcher.setDockerHostname(hostname);
     launcher.setRunPrivilegedContainer(component.getRunPrivilegedContainer());
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/tarball/TarballProviderService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/tarball/TarballProviderService.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/tarball/TarballProviderService.java
index 9dd3499..8be63fd 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/tarball/TarballProviderService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/providers/tarball/TarballProviderService.java
@@ -20,10 +20,12 @@ package org.apache.slider.providers.tarball;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.yarn.api.records.LocalResource;
 import org.apache.hadoop.yarn.api.records.LocalResourceType;
+import org.apache.slider.api.resource.Application;
 import org.apache.slider.api.resource.Component;
 import org.apache.slider.common.tools.SliderFileSystem;
 import org.apache.slider.core.launch.ContainerLauncher;
 import org.apache.slider.providers.AbstractProviderService;
+import org.apache.slider.server.appmaster.state.RoleInstance;
 
 import java.io.IOException;
 
@@ -34,9 +36,11 @@ public class TarballProviderService extends AbstractProviderService {
   }
 
   @Override
-  public void processArtifact(ContainerLauncher launcher, Component
-      component, SliderFileSystem fileSystem) throws IOException {
-    Path artifact =  new Path(component.getArtifact().getId());
+  public void processArtifact(ContainerLauncher launcher, Application
+      application, RoleInstance roleInstance, SliderFileSystem fileSystem)
+      throws IOException {
+    Path artifact = new Path(roleInstance.providerRole.component
+        .getArtifact().getId());
     if (!fileSystem.isFile(artifact)) {
       throw new IOException("Package doesn't exist as a resource: " +
           artifact.toString());

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java
index 9ac26b5..5619492 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java
@@ -125,6 +125,7 @@ public final class RoleInstance implements Cloneable {
     } else {
       compInstanceName = role.name;
     }
+    compInstanceName = compInstanceName.toLowerCase().replaceAll("_", "-");
     this.providerRole = role;
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/BaseServiceRecordProcessor.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/BaseServiceRecordProcessor.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/BaseServiceRecordProcessor.java
index 1289fb3..2fe3a6c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/BaseServiceRecordProcessor.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/BaseServiceRecordProcessor.java
@@ -285,7 +285,6 @@ public abstract class BaseServiceRecordProcessor
      */
     protected Name getContainerIDName() throws TextParseException {
       String containerID = RegistryPathUtils.lastPathEntry(getPath());
-      containerID = containerID.replace("container", "ctr");
       return Name.fromString(String.format("%s.%s", containerID, domain));
     }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/ContainerServiceRecordProcessor.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/ContainerServiceRecordProcessor.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/ContainerServiceRecordProcessor.java
index 75873d7..2e95f54 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/ContainerServiceRecordProcessor.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/ContainerServiceRecordProcessor.java
@@ -16,6 +16,7 @@
  */
 package org.apache.hadoop.registry.server.dns;
 
+import org.apache.hadoop.fs.PathNotFoundException;
 import org.apache.hadoop.registry.client.types.ServiceRecord;
 import org.apache.hadoop.registry.client.types.yarn.YarnRegistryAttributes;
 import org.xbill.DNS.Name;
@@ -156,9 +157,11 @@ public class ContainerServiceRecordProcessor extends
      */
     @Override protected void init(ServiceRecord serviceRecord) {
       try {
-        this.setNames(new Name[] {getContainerIDName()});
+        this.setNames(new Name[] {getContainerName()});
       } catch (TextParseException e) {
         // log
+      } catch (PathNotFoundException e) {
+        // log
       }
       List<String> txts = new ArrayList<>();
       txts.add("id=" + serviceRecord.get(YarnRegistryAttributes.YARN_ID));
@@ -200,9 +203,11 @@ public class ContainerServiceRecordProcessor extends
       }
       this.setNames(new Name[] {reverseLookupName});
       try {
-        this.setTarget(getContainerIDName());
+        this.setTarget(getContainerName());
       } catch (TextParseException e) {
         //LOG
+      } catch (PathNotFoundException e) {
+        //LOG
       }
     }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/server/dns/TestRegistryDNS.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/server/dns/TestRegistryDNS.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/server/dns/TestRegistryDNS.java
index fcb602c..cc839cc 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/server/dns/TestRegistryDNS.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/server/dns/TestRegistryDNS.java
@@ -111,7 +111,7 @@ public class TestRegistryDNS extends Assert {
       + "}\n";
   static final String CONTAINER_RECORD = "{\n"
       + "  \"type\" : \"JSONServiceRecord\",\n"
-      + "  \"description\" : \"YCLOUD\",\n"
+      + "  \"description\" : \"COMP-NAME\",\n"
       + "  \"external\" : [ ],\n"
       + "  \"internal\" : [ ],\n"
       + "  \"yarn:id\" : \"container_e50_1451931954322_0016_01_000002\",\n"
@@ -122,7 +122,7 @@ public class TestRegistryDNS extends Assert {
 
   private static final String CONTAINER_RECORD_NO_IP = "{\n"
       + "  \"type\" : \"JSONServiceRecord\",\n"
-      + "  \"description\" : \"YCLOUD\",\n"
+      + "  \"description\" : \"COMP-NAME\",\n"
       + "  \"external\" : [ ],\n"
       + "  \"internal\" : [ ],\n"
       + "  \"yarn:id\" : \"container_e50_1451931954322_0016_01_000002\",\n"
@@ -131,7 +131,7 @@ public class TestRegistryDNS extends Assert {
 
   private static final String CONTAINER_RECORD_YARN_PERSISTANCE_ABSENT = "{\n"
       + "  \"type\" : \"JSONServiceRecord\",\n"
-      + "  \"description\" : \"YCLOUD\",\n"
+      + "  \"description\" : \"COMP-NAME\",\n"
       + "  \"external\" : [ ],\n"
       + "  \"internal\" : [ ],\n"
       + "  \"yarn:id\" : \"container_e50_1451931954322_0016_01_000003\",\n"
@@ -216,7 +216,7 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD.getBytes());
     getRegistryDNS().register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000002",
+            + "ctr-e50-1451931954322-0016-01-000002",
         record);
 
     // start assessing whether correct records are available
@@ -225,7 +225,7 @@ public class TestRegistryDNS extends Assert {
     assertEquals("wrong result", "172.17.0.19",
         ((ARecord) recs[0]).getAddress().getHostAddress());
 
-    recs = assertDNSQuery("ycloud.test1.root.hwx.test.", 1);
+    recs = assertDNSQuery("comp-name.test1.root.hwx.test.", 1);
     assertTrue("not an ARecord", recs[0] instanceof ARecord);
   }
 
@@ -235,7 +235,7 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD_YARN_PERSISTANCE_ABSENT.getBytes());
     registryDNS.register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000003",
+            + "ctr-e50-1451931954322-0016-01-000003",
          record);
 
     Name name =
@@ -254,7 +254,7 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD.getBytes());
     getRegistryDNS().register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000002",
+            + "ctr-e50-1451931954322-0016-01-000002",
         record);
 
     // start assessing whether correct records are available
@@ -264,7 +264,7 @@ public class TestRegistryDNS extends Assert {
         ((ARecord) recs[0]).getAddress().getHostAddress());
     assertEquals("wrong ttl", 30L, recs[0].getTTL());
 
-    recs = assertDNSQuery("ycloud.test1.root.hwx.test.", 1);
+    recs = assertDNSQuery("comp-name.test1.root.hwx.test.", 1);
     assertTrue("not an ARecord", recs[0] instanceof ARecord);
 
     assertEquals("wrong ttl", 30L, recs[0].getTTL());
@@ -276,13 +276,13 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD.getBytes());
     getRegistryDNS().register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000002",
+            + "ctr-e50-1451931954322-0016-01-000002",
         record);
 
     // start assessing whether correct records are available
     Record[] recs = assertDNSQuery("19.0.17.172.in-addr.arpa.", Type.PTR, 1);
     assertEquals("wrong result",
-        "ctr-e50-1451931954322-0016-01-000002.hwx.test.",
+        "comp-name.test1.root.hwx.test.",
         ((PTRRecord) recs[0]).getTarget().toString());
   }
 
@@ -302,13 +302,13 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD.getBytes());
     getRegistryDNS().register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000002",
+            + "ctr-e50-1451931954322-0016-01-000002",
         record);
 
     // start assessing whether correct records are available
     Record[] recs = assertDNSQuery("19.0.17.172.in-addr.arpa.", Type.PTR, 1);
     assertEquals("wrong result",
-        "ctr-e50-1451931954322-0016-01-000002.hwx.test.",
+        "comp-name.test1.root.hwx.test.",
         ((PTRRecord) recs[0]).getTarget().toString());
   }
 
@@ -318,7 +318,7 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD.getBytes());
     getRegistryDNS().register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000002",
+            + "ctr-e50-1451931954322-0016-01-000002",
         record);
 
     // start assessing whether correct records are available
@@ -339,7 +339,7 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD_NO_IP.getBytes());
     getRegistryDNS().register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000002",
+            + "ctr-e50-1451931954322-0016-01-000002",
         record);
 
     // start assessing whether correct records are available
@@ -453,7 +453,7 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD.getBytes());
     getRegistryDNS().register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000002",
+            + "ctr-e50-1451931954322-0016-01-000002",
         record);
 
     // start assessing whether correct records are available
@@ -462,7 +462,7 @@ public class TestRegistryDNS extends Assert {
     assertEquals("wrong result", "172.17.0.19",
         ((AAAARecord) recs[0]).getAddress().getHostAddress());
 
-    recs = assertDNSQuery("ycloud.test1.root.hwx.test.", Type.AAAA, 1);
+    recs = assertDNSQuery("comp-name.test1.root.hwx.test.", Type.AAAA, 1);
     assertTrue("not an ARecord", recs[0] instanceof AAAARecord);
   }
 
@@ -472,7 +472,7 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD.getBytes());
     getRegistryDNS().register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000002",
+            + "ctr-e50-1451931954322-0016-01-000002",
         record);
 
     // start assessing whether correct records are available
@@ -528,7 +528,7 @@ public class TestRegistryDNS extends Assert {
         CONTAINER_RECORD.getBytes());
     getRegistryDNS().register(
         "/registry/users/root/services/org-apache-slider/test1/components/"
-            + "container-e50-1451931954322-0016-01-000002",
+            + "ctr-e50-1451931954322-0016-01-000002",
         record);
 
     // start assessing whether correct records are available
@@ -537,13 +537,13 @@ public class TestRegistryDNS extends Assert {
     assertEquals("wrong result", "172.17.0.19",
         ((ARecord) recs[0]).getAddress().getHostAddress());
 
-    recs = assertDNSQuery("ycloud.test1.root.hwx.test.", 1);
+    recs = assertDNSQuery("comp-name.test1.root.hwx.test.", 1);
     assertTrue("not an ARecord", recs[0] instanceof ARecord);
 
     // lookup dyanmic reverse records
     recs = assertDNSQuery("19.0.17.172.in-addr.arpa.", Type.PTR, 1);
     assertEquals("wrong result",
-        "ctr-e50-1451931954322-0016-01-000002.hwx.test.",
+        "comp-name.test1.root.hwx.test.",
         ((PTRRecord) recs[0]).getTarget().toString());
 
     // now lookup static reverse records

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e79f4f5a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/DockerLinuxContainerRuntime.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/DockerLinuxContainerRuntime.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/DockerLinuxContainerRuntime.java
index 57dadb2..df89d63 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/DockerLinuxContainerRuntime.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/DockerLinuxContainerRuntime.java
@@ -27,6 +27,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.registry.client.api.RegistryConstants;
 import org.apache.hadoop.registry.client.binding.RegistryPathUtils;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.authorize.AccessControlList;
@@ -295,6 +296,11 @@ public class DockerLinuxContainerRuntime implements LinuxContainerRuntime
{
       throws ContainerExecutionException {
     if (name == null || name.isEmpty()) {
       name = RegistryPathUtils.encodeYarnID(containerIdStr);
+
+      String domain = conf.get(RegistryConstants.KEY_DNS_DOMAIN);
+      if (domain != null) {
+        name += ("." + domain);
+      }
       validateHostname(name);
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message