hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From haiboc...@apache.org
Subject hadoop git commit: YARN-8107. Give an informative message when incorrect format is used in ATSv2 filter attributes. (Rohith Sharma K S via Haibo Chen)
Date Fri, 06 Apr 2018 16:50:29 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 b412958f7 -> b19267259


YARN-8107. Give an informative message when incorrect format is used in ATSv2 filter attributes.
(Rohith Sharma K S via Haibo Chen)

(cherry picked from commit 024d7c08704e6a5fcc1f53a8f56a44c84c8d5fa0)
(cherry picked from commit b232dcab33c4f3e131b9699119167af8916879c4)
(cherry picked from commit ca105d1c8eb7563fcf7465ed48b8e7ec89eeee59)


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

Branch: refs/heads/branch-2
Commit: b19267259bdc22e65efcb1170cc042d2fc66c2e7
Parents: b412958
Author: Haibo Chen <haibochen@apache.org>
Authored: Fri Apr 6 09:37:21 2018 -0700
Committer: Haibo Chen <haibochen@apache.org>
Committed: Fri Apr 6 09:47:25 2018 -0700

----------------------------------------------------------------------
 .../reader/TimelineParserForCompareExpr.java    |  7 +++++-
 .../reader/TimelineParserForEqualityExpr.java   |  7 +++++-
 .../TestTimelineReaderWebServicesUtils.java     | 25 ++++++++++++++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b1926725/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForCompareExpr.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForCompareExpr.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForCompareExpr.java
index 1b020d9..a582956 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForCompareExpr.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForCompareExpr.java
@@ -282,7 +282,12 @@ abstract class TimelineParserForCompareExpr implements TimelineParser
{
           parseValue(expr.substring(kvStartOffset, offset)));
     }
     if (filterList == null || filterList.getFilterList().isEmpty()) {
-      filterList = new TimelineFilterList(currentFilter);
+      if (currentFilter == null) {
+        throw new TimelineParseException(
+            "Invalid expression provided for " + exprName);
+      } else {
+        filterList = new TimelineFilterList(currentFilter);
+      }
     } else if (currentFilter != null) {
       filterList.addFilter(currentFilter);
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b1926725/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForEqualityExpr.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForEqualityExpr.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForEqualityExpr.java
index 7451713..2bdce38 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForEqualityExpr.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineParserForEqualityExpr.java
@@ -325,7 +325,12 @@ abstract class TimelineParserForEqualityExpr implements TimelineParser
{
       }
     }
     if (filterList == null || filterList.getFilterList().isEmpty()) {
-      filterList = new TimelineFilterList(currentFilter);
+      if (currentFilter == null) {
+        throw new TimelineParseException(
+            "Invalid expression provided for " + exprName);
+      } else {
+        filterList = new TimelineFilterList(currentFilter);
+      }
     } else if (currentFilter != null) {
       filterList.addFilter(currentFilter);
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b1926725/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesUtils.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesUtils.java
index 13e129e..190e90d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesUtils.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilte
 import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineKeyValueFilter;
 import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineKeyValuesFilter;
 import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelinePrefixFilter;
+import org.junit.Assert;
 import org.junit.Test;
 
 import com.google.common.collect.Sets;
@@ -523,6 +524,30 @@ public class TestTimelineReaderWebServicesUtils {
     );
     verifyFilterList(expr, TimelineReaderWebServicesUtils.
         parseKVFilters(expr, false), expectedList);
+
+    expr = "abdeq";
+    try {
+      TimelineReaderWebServicesUtils.parseKVFilters(expr, false);
+      Assert.fail("Expression valuation should throw exception.");
+    } catch (TimelineParseException e) {
+      // expected: do nothing
+    }
+
+    expr = "abc gt 234 AND defeq";
+    try {
+      TimelineReaderWebServicesUtils.parseKVFilters(expr, false);
+      Assert.fail("Expression valuation should throw exception.");
+    } catch (TimelineParseException e) {
+      // expected: do nothing
+    }
+
+    expr = "((key11 ne 234 AND key12 eq val12) AND (key13eq OR key14 eq va14))";
+    try {
+      TimelineReaderWebServicesUtils.parseKVFilters(expr, false);
+      Assert.fail("Expression valuation should throw exception.");
+    } catch (TimelineParseException e) {
+      // expected: do nothing
+    }
   }
 
   @Test


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