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)
This commit is contained in:
parent
9638c3fe67
commit
ca105d1c8e
@ -282,7 +282,12 @@ public TimelineFilterList parse() throws TimelineParseException {
|
|||||||
parseValue(expr.substring(kvStartOffset, offset)));
|
parseValue(expr.substring(kvStartOffset, offset)));
|
||||||
}
|
}
|
||||||
if (filterList == null || filterList.getFilterList().isEmpty()) {
|
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) {
|
} else if (currentFilter != null) {
|
||||||
filterList.addFilter(currentFilter);
|
filterList.addFilter(currentFilter);
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,12 @@ public TimelineFilterList parse() throws TimelineParseException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (filterList == null || filterList.getFilterList().isEmpty()) {
|
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) {
|
} else if (currentFilter != null) {
|
||||||
filterList.addFilter(currentFilter);
|
filterList.addFilter(currentFilter);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineKeyValueFilter;
|
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.TimelineKeyValuesFilter;
|
||||||
import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelinePrefixFilter;
|
import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelinePrefixFilter;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
@ -520,6 +521,30 @@ public void testInfoFiltersParsing() throws Exception {
|
|||||||
);
|
);
|
||||||
verifyFilterList(expr, TimelineReaderWebServicesUtils.
|
verifyFilterList(expr, TimelineReaderWebServicesUtils.
|
||||||
parseKVFilters(expr, false), expectedList);
|
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
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user