Search in sources :

Example 41 with TimelineFilterList

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;
}
Also used : TimelineFilterList(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList)

Example 42 with TimelineFilterList

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;
}
Also used : BinaryPrefixComparator(org.apache.hadoop.hbase.filter.BinaryPrefixComparator) TimelineFilterList(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList) FilterList(org.apache.hadoop.hbase.filter.FilterList) TimelineFilterList(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList) FamilyFilter(org.apache.hadoop.hbase.filter.FamilyFilter) TimelineDataToRetrieve(org.apache.hadoop.yarn.server.timelineservice.reader.TimelineDataToRetrieve) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter)

Example 43 with TimelineFilterList

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;
}
Also used : Operator(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList.Operator) TimelineFilterList(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList)

Example 44 with TimelineFilterList

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 + ".");
    }
}
Also used : TimelineFilterList(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList)

Example 45 with TimelineFilterList

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 + ".");
    }
}
Also used : TimelineFilterList(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList)

Aggregations

TimelineFilterList (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList)47 Test (org.junit.Test)32 TimelineEntityFilters (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineEntityFilters)28 TimelineDataToRetrieve (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineDataToRetrieve)27 TimelineEntity (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity)26 TimelineReaderContext (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext)26 TimelinePrefixFilter (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelinePrefixFilter)12 TimelineKeyValueFilter (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineKeyValueFilter)10 TimelineKeyValuesFilter (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineKeyValuesFilter)9 TimelineCompareFilter (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineCompareFilter)8 HashSet (java.util.HashSet)7 TimelineExistsFilter (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineExistsFilter)7 FilterList (org.apache.hadoop.hbase.filter.FilterList)6 TimelineMetric (org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric)5 Operator (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList.Operator)3 EnumSet (java.util.EnumSet)2 Set (java.util.Set)2 Configuration (org.apache.hadoop.conf.Configuration)2 TimelineEntities (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntities)2 HBaseTimelineReaderImpl (org.apache.hadoop.yarn.server.timelineservice.storage.HBaseTimelineReaderImpl)2