use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList.Operator in project hadoop by apache.
the class TimelineParserForDataToRetrieve method parse.
@Override
public TimelineFilterList parse() throws TimelineParseException {
if (expr == null || exprLength == 0) {
return null;
}
TimelineCompareOp compareOp = null;
int openingBracketIndex = expr.indexOf(TimelineParseConstants.OPENING_BRACKET_CHAR);
if (expr.charAt(0) == TimelineParseConstants.NOT_CHAR) {
if (openingBracketIndex == -1) {
throw new TimelineParseException("Invalid config/metric to retrieve " + "expression");
}
if (openingBracketIndex != 1 && expr.substring(1, openingBracketIndex + 1).trim().length() != 1) {
throw new TimelineParseException("Invalid config/metric to retrieve " + "expression");
}
compareOp = TimelineCompareOp.NOT_EQUAL;
} else if (openingBracketIndex <= 0) {
compareOp = TimelineCompareOp.EQUAL;
}
char lastChar = expr.charAt(exprLength - 1);
if (compareOp == TimelineCompareOp.NOT_EQUAL && lastChar != TimelineParseConstants.CLOSING_BRACKET_CHAR) {
throw new TimelineParseException("Invalid config/metric to retrieve " + "expression");
}
if (openingBracketIndex != -1 && expr.charAt(exprLength - 1) == TimelineParseConstants.CLOSING_BRACKET_CHAR) {
expr = expr.substring(openingBracketIndex + 1, exprLength - 1).trim();
}
if (expr.isEmpty()) {
return null;
}
Operator op = (compareOp == TimelineCompareOp.NOT_EQUAL) ? Operator.AND : Operator.OR;
TimelineFilterList list = new TimelineFilterList(op);
String[] splits = expr.split(TimelineParseConstants.COMMA_DELIMITER);
for (String split : splits) {
list.addFilter(new TimelinePrefixFilter(compareOp, split.trim()));
}
return list;
}
use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList.Operator in project hadoop by apache.
the class TimelineParserForCompareExpr method parseOp.
private void parseOp(boolean closingBracket) throws TimelineParseException {
Operator operator = null;
if (exprInLowerCase.startsWith("or ", offset)) {
operator = Operator.OR;
offset = offset + 3;
} else if (exprInLowerCase.startsWith("and ", offset)) {
operator = Operator.AND;
offset = offset + 4;
}
if (operator == null) {
throw new TimelineParseException("Operator cannot be parsed for " + exprName + ".");
}
if (filterList == null) {
filterList = new TimelineFilterList(operator);
}
if (currentFilter != null) {
filterList.addFilter(currentFilter);
}
if (closingBracket || filterList.getOperator() != operator) {
filterList = new TimelineFilterList(operator, filterList);
}
currentFilter = null;
kvStartOffset = offset;
currentParseState = ParseState.PARSING_KEY;
}
use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList.Operator in project hadoop by apache.
the class TimelineParserForEqualityExpr method parseOp.
private void parseOp(boolean closingBracket) throws TimelineParseException {
Operator operator = null;
if (exprInLowerCase.startsWith("or ", offset)) {
operator = Operator.OR;
offset = offset + 3;
} else if (exprInLowerCase.startsWith("and ", offset)) {
operator = Operator.AND;
offset = offset + 4;
}
if (operator == null) {
throw new TimelineParseException("Operator cannot be parsed for " + exprName + ".");
}
if (filterList == null) {
filterList = new TimelineFilterList(operator);
}
if (currentFilter != null) {
filterList.addFilter(currentFilter);
}
if (closingBracket || filterList.getOperator() != operator) {
filterList = new TimelineFilterList(operator, filterList);
}
currentFilter = null;
startOffset = offset;
currentParseState = ParseState.PARSING_COMPAREOP;
}
Aggregations