use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList in project hadoop by apache.
the class TimelineParserForCompareExpr method parse.
@Override
public TimelineFilterList parse() throws TimelineParseException {
if (expr == null || exprLength == 0) {
return null;
}
boolean closingBracket = false;
while (offset < exprLength) {
char offsetChar = expr.charAt(offset);
switch(offsetChar) {
case TimelineParseConstants.SPACE_CHAR:
handleSpaceChar();
break;
case TimelineParseConstants.OPENING_BRACKET_CHAR:
handleOpeningBracketChar();
break;
case TimelineParseConstants.CLOSING_BRACKET_CHAR:
handleClosingBracketChar();
closingBracket = true;
break;
default:
// Parse based on state.
if (currentParseState == ParseState.PARSING_COMPAREOP) {
parseCompareOp();
} else if (currentParseState == ParseState.PARSING_OP) {
parseOp(closingBracket);
closingBracket = false;
} else {
// Might be a key or value. Move ahead.
offset++;
}
break;
}
}
if (!filterListStack.isEmpty()) {
filterListStack.clear();
throw new TimelineParseException("Encountered improper brackets while " + "parsing " + exprName + ".");
}
if (currentParseState == ParseState.PARSING_VALUE) {
setValueToCurrentFilter(parseValue(expr.substring(kvStartOffset, offset)));
}
if (filterList == null || filterList.getFilterList().isEmpty()) {
filterList = new TimelineFilterList(currentFilter);
} else if (currentFilter != null) {
filterList.addFilter(currentFilter);
}
return filterList;
}
use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList in project hadoop by apache.
the class FlowRunEntityReader method constructFilterListBasedOnFields.
@Override
protected FilterList constructFilterListBasedOnFields() throws IOException {
FilterList list = new FilterList(Operator.MUST_PASS_ONE);
// By default fetch everything in INFO column family.
FamilyFilter infoColumnFamily = new FamilyFilter(CompareOp.EQUAL, new BinaryComparator(FlowRunColumnFamily.INFO.getBytes()));
TimelineDataToRetrieve dataToRetrieve = getDataToRetrieve();
// Metrics are always returned if we are reading a single entity.
if (!isSingleEntityRead() && !hasField(dataToRetrieve.getFieldsToRetrieve(), Field.METRICS)) {
FilterList infoColFamilyList = new FilterList(Operator.MUST_PASS_ONE);
infoColFamilyList.addFilter(infoColumnFamily);
infoColFamilyList.addFilter(new QualifierFilter(CompareOp.NOT_EQUAL, new BinaryPrefixComparator(FlowRunColumnPrefix.METRIC.getColumnPrefixBytes(""))));
list.addFilter(infoColFamilyList);
} else {
// Check if metricsToRetrieve are specified and if they are, create a
// filter list for info column family by adding flow run tables columns
// and a list for metrics to retrieve. Pls note that fieldsToRetrieve
// will have METRICS added to it if metricsToRetrieve are specified
// (in augmentParams()).
TimelineFilterList metricsToRetrieve = dataToRetrieve.getMetricsToRetrieve();
if (metricsToRetrieve != null && !metricsToRetrieve.getFilterList().isEmpty()) {
FilterList infoColFamilyList = new FilterList();
infoColFamilyList.addFilter(infoColumnFamily);
FilterList columnsList = updateFixedColumns();
columnsList.addFilter(TimelineFilterUtils.createHBaseFilterList(FlowRunColumnPrefix.METRIC, metricsToRetrieve));
infoColFamilyList.addFilter(columnsList);
list.addFilter(infoColFamilyList);
}
}
return list;
}
use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList 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 in project hadoop by apache.
the class TimelineParserForCompareExpr method handleClosingBracketChar.
private void handleClosingBracketChar() throws TimelineParseException {
if (currentParseState != ParseState.PARSING_VALUE && currentParseState != ParseState.PARSING_OP) {
throw new TimelineParseException("Encountered unexpected closing " + "bracket while parsing " + exprName + ".");
}
if (!filterListStack.isEmpty()) {
if (currentParseState == ParseState.PARSING_VALUE) {
setValueToCurrentFilter(parseValue(expr.substring(kvStartOffset, offset)));
currentParseState = ParseState.PARSING_OP;
}
if (currentFilter != null) {
filterList.addFilter(currentFilter);
}
// As bracket is closing, pop the filter list from top of the stack and
// combine it with current filter list.
TimelineFilterList fList = filterListStack.pop();
if (fList != null) {
fList.addFilter(filterList);
filterList = fList;
}
currentFilter = null;
offset++;
kvStartOffset = offset;
} else {
throw new TimelineParseException("Encountered unexpected closing " + "bracket while parsing " + exprName + ".");
}
}
use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList in project hadoop by apache.
the class TimelineParserForEqualityExpr method handleClosingBracketChar.
private void handleClosingBracketChar() throws TimelineParseException {
if (currentParseState != ParseState.PARSING_VALUE && currentParseState != ParseState.PARSING_OP) {
throw new TimelineParseException("Encountered unexpected closing " + "bracket while parsing " + exprName + ".");
}
if (!filterListStack.isEmpty()) {
if (currentParseState == ParseState.PARSING_VALUE) {
if (startOffset != offset) {
createAndSetFilter(true);
currentParseState = ParseState.PARSING_OP;
}
}
if (filterList == null) {
filterList = new TimelineFilterList();
}
if (currentFilter != null) {
filterList.addFilter(currentFilter);
}
// As bracket is closing, pop the filter list from top of the stack and
// combine it with current filter list.
TimelineFilterList fList = filterListStack.pop();
if (fList != null) {
fList.addFilter(filterList);
filterList = fList;
}
currentFilter = null;
offset++;
startOffset = offset;
} else {
throw new TimelineParseException("Encountered unexpected closing " + "bracket while parsing " + exprName + ".");
}
}
Aggregations