hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gourks...@apache.org
Subject hadoop git commit: YARN-6544. Add Null check RegistryDNS service while parsing registry records. Contributed by Karam Singh
Date Fri, 12 May 2017 22:05:32 GMT
Repository: hadoop
Updated Branches:
  refs/heads/yarn-native-services ecc1ef988 -> 8c3234463


YARN-6544. Add Null check RegistryDNS service while parsing registry records. Contributed
by Karam Singh


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

Branch: refs/heads/yarn-native-services
Commit: 8c32344635ce9280945222dfe6bbabd938b59942
Parents: ecc1ef9
Author: Gour Saha <gourksaha@apache.org>
Authored: Fri May 12 15:04:17 2017 -0700
Committer: Gour Saha <gourksaha@apache.org>
Committed: Fri May 12 15:04:17 2017 -0700

----------------------------------------------------------------------
 .../hadoop/registry/server/dns/RegistryDNS.java | 31 +++++++++++++-------
 .../registry/server/dns/TestRegistryDNS.java    | 29 ++++++++++++++++++
 2 files changed, 49 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/8c323446/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/RegistryDNS.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/RegistryDNS.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/RegistryDNS.java
index 126795a..9ffc9db 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/RegistryDNS.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/RegistryDNS.java
@@ -1393,19 +1393,28 @@ public class RegistryDNS extends AbstractService implements DNSOperations,
       throws IOException {
     ServiceRecordProcessor processor;
     try {
-      if (record.get(YarnRegistryAttributes.YARN_PERSISTENCE)
-          .equals(CONTAINER)) {
-        // container registration.  the logic to identify and create the
-        // container entry needs to be enhanced/more accurate and associate to
-        // correct host
-        processor =
-            new ContainerServiceRecordProcessor(record, path, domainName, this);
+      String yarnPersistanceValue = record.get(
+                                    YarnRegistryAttributes.YARN_PERSISTENCE);
+      if (yarnPersistanceValue != null) {
+        if (yarnPersistanceValue.equals(CONTAINER)) {
+          // container registration.  the logic to identify and create the
+          // container entry needs to be enhanced/more accurate and associate
+          // to correct host
+          processor =
+               new ContainerServiceRecordProcessor(record, path, domainName,
+                   this);
+        } else {
+          LOG.debug("Creating ApplicationServiceRecordProcessor for {}",
+                    yarnPersistanceValue);
+          processor =
+               new ApplicationServiceRecordProcessor(record, path, domainName,
+                   this);
+        }
+        processor.manageDNSRecords(command);
       } else {
-        processor =
-            new ApplicationServiceRecordProcessor(record, path, domainName,
-                this);
+        LOG.warn("Yarn Resgistry record {} does not contain {} attribute ",
+                  record.toString(), YarnRegistryAttributes.YARN_PERSISTENCE);
       }
-      processor.manageDNSRecords(command);
     } catch (Exception e) {
       throw new IOException(e);
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/8c323446/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 d58b1c8..fcb602c 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
@@ -129,6 +129,16 @@ public class TestRegistryDNS extends Assert {
       + "  \"yarn:persistence\" : \"container\"\n"
       + "}\n";
 
+  private static final String CONTAINER_RECORD_YARN_PERSISTANCE_ABSENT = "{\n"
+      + "  \"type\" : \"JSONServiceRecord\",\n"
+      + "  \"description\" : \"YCLOUD\",\n"
+      + "  \"external\" : [ ],\n"
+      + "  \"internal\" : [ ],\n"
+      + "  \"yarn:id\" : \"container_e50_1451931954322_0016_01_000003\",\n"
+      + "  \"yarn:ip\" : \"172.17.0.19\",\n"
+      + "  \"yarn:hostname\" : \"0a134d6329bb\"\n"
+      + "}\n";
+
   @Before
   public void initialize() throws Exception {
     setRegistryDNS(new RegistryDNS("TestRegistry"));
@@ -220,6 +230,25 @@ public class TestRegistryDNS extends Assert {
   }
 
   @Test
+  public void testContainerRegistrationPersistanceAbsent() throws Exception {
+    ServiceRecord record = marshal.fromBytes("somepath",
+        CONTAINER_RECORD_YARN_PERSISTANCE_ABSENT.getBytes());
+    registryDNS.register(
+        "/registry/users/root/services/org-apache-slider/test1/components/"
+            + "container-e50-1451931954322-0016-01-000003",
+         record);
+
+    Name name =
+        Name.fromString("ctr-e50-1451931954322-0016-01-000002.hwx.test.");
+    Record question = Record.newRecord(name, Type.A, DClass.IN);
+    Message query = Message.newQuery(question);
+    byte[] responseBytes = registryDNS.generateReply(query, null);
+    Message response = new Message(responseBytes);
+    assertEquals("Excepting NXDOMAIN as Record must not have regsisterd wrong",
+        Rcode.NXDOMAIN, response.getRcode());
+  }
+
+  @Test
   public void testRecordTTL() throws Exception {
     ServiceRecord record = getMarshal().fromBytes("somepath",
         CONTAINER_RECORD.getBytes());


---------------------------------------------------------------------
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