hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oz...@apache.org
Subject hadoop git commit: YARN-3157. Refactor the exception handling in ConverterUtils#to*Id. Contributed by Bibin A Chundatt.
Date Thu, 12 Feb 2015 14:49:51 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 941a92351 -> dc14f2772


YARN-3157. Refactor the exception handling in ConverterUtils#to*Id. Contributed by Bibin A
Chundatt.

(cherry picked from commit 7bc492adab90c4533c20d48c004e92cb917cd199)


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

Branch: refs/heads/branch-2
Commit: dc14f2772f7d7ce842f5d6c53c35146b280c9a43
Parents: 941a923
Author: Tsuyoshi Ozawa <ozawa@apache.org>
Authored: Thu Feb 12 23:48:43 2015 +0900
Committer: Tsuyoshi Ozawa <ozawa@apache.org>
Committed: Thu Feb 12 23:49:27 2015 +0900

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                      |  3 +++
 .../apache/hadoop/yarn/api/records/ContainerId.java  |  5 +++++
 .../org/apache/hadoop/yarn/util/ConverterUtils.java  |  7 +++++++
 .../apache/hadoop/yarn/util/TestConverterUtils.java  | 15 +++++++++++++++
 4 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/dc14f277/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index d6f653b..eb13283 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -235,6 +235,9 @@ Release 2.7.0 - UNRELEASED
     YARN-1237. Description for yarn.nodemanager.aux-services in 
     yarn-default.xml is misleading. (Brahma Reddy Battula via ozawa)
 
+    YARN-3157. Refactor the exception handling in ConverterUtils#to*Id.
+    (Bibin A Chundatt via ozawa)
+
   OPTIMIZATIONS
 
     YARN-2990. FairScheduler's delay-scheduling always waits for node-local and 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/dc14f277/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java
index 5d0d65a..c9b9618 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java
@@ -22,6 +22,8 @@ import com.google.common.base.Splitter;
 
 import java.text.NumberFormat;
 import java.util.Iterator;
+import java.util.NoSuchElementException;
+
 import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
@@ -231,6 +233,9 @@ public abstract class ContainerId implements Comparable<ContainerId>{
     } catch (NumberFormatException n) {
       throw new IllegalArgumentException("Invalid ContainerId: "
           + containerIdStr, n);
+    } catch (NoSuchElementException e) {
+      throw new IllegalArgumentException("Invalid ContainerId: "
+          + containerIdStr, e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/dc14f277/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java
index 0aa68a2..e9674cf 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.NoSuchElementException;
 
 import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.fs.Path;
@@ -190,6 +191,9 @@ public class ConverterUtils {
     } catch (NumberFormatException n) {
       throw new IllegalArgumentException("Invalid AppAttemptId: "
           + applicationAttmeptIdStr, n);
+    } catch (NoSuchElementException e) {
+      throw new IllegalArgumentException("Invalid AppAttemptId: "
+          + applicationAttmeptIdStr, e);
     }
   }
   
@@ -206,6 +210,9 @@ public class ConverterUtils {
     } catch (NumberFormatException n) {
       throw new IllegalArgumentException("Invalid ApplicationId: "
           + appIdStr, n);
+    } catch (NoSuchElementException e) {
+      throw new IllegalArgumentException("Invalid ApplicationId: "
+          + appIdStr, e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/dc14f277/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestConverterUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestConverterUtils.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestConverterUtils.java
index 7d53785..3cec38b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestConverterUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestConverterUtils.java
@@ -99,4 +99,19 @@ public class TestConverterUtils {
     assertEquals(nid.getPort(), 0);
     assertEquals(nid.getHost(), "node");
   }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testInvalidContainerId() {
+    ConverterUtils.toContainerId("container_e20_1423221031460_0003_01");
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testInvalidAppattemptId() {
+    ConverterUtils.toApplicationAttemptId("appattempt_1423221031460");
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testApplicationId() {
+    ConverterUtils.toApplicationId("application_1423221031460");
+  }
 }


Mime
View raw message