Search in sources :

Example 16 with TimelineFilterList

use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList in project hadoop by apache.

the class TimelineParserForEqualityExpr method handleDelimiter.

private void handleDelimiter() throws TimelineParseException {
    if (currentParseState == ParseState.PARSING_OP || currentParseState == ParseState.PARSING_VALUE) {
        if (currentParseState == ParseState.PARSING_VALUE) {
            createAndSetFilter(false);
        }
        if (filterList == null) {
            filterList = new TimelineFilterList();
        }
        // Add parsed filter into filterlist and make it null to move on to next
        // filter.
        filterList.addFilter(currentFilter);
        currentFilter = null;
        offset++;
        startOffset = offset;
        currentParseState = ParseState.PARSING_VALUE;
    } else {
        throw new TimelineParseException("Invalid " + exprName + "expression.");
    }
}
Also used : TimelineFilterList(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList)

Example 17 with TimelineFilterList

use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList in project hadoop by apache.

the class ApplicationEntityReader method createFilterListForColsOfInfoFamily.

/**
   * Creates a filter list which indicates that only some of the column
   * qualifiers in the info column family will be returned in result.
   *
   * @return filter list.
   * @throws IOException if any problem occurs while creating filter list.
   */
private FilterList createFilterListForColsOfInfoFamily() throws IOException {
    FilterList infoFamilyColsFilter = new FilterList(Operator.MUST_PASS_ONE);
    // Add filters for each column in entity table.
    updateFixedColumns(infoFamilyColsFilter);
    EnumSet<Field> fieldsToRetrieve = getDataToRetrieve().getFieldsToRetrieve();
    // with INFO column prefix.
    if (hasField(fieldsToRetrieve, Field.INFO)) {
        infoFamilyColsFilter.addFilter(TimelineFilterUtils.createHBaseQualifierFilter(CompareOp.EQUAL, ApplicationColumnPrefix.INFO));
    }
    TimelineFilterList relatesTo = getFilters().getRelatesTo();
    if (hasField(fieldsToRetrieve, Field.RELATES_TO)) {
        // If RELATES_TO field has to be retrieved, add a filter for fetching
        // columns with RELATES_TO column prefix.
        infoFamilyColsFilter.addFilter(TimelineFilterUtils.createHBaseQualifierFilter(CompareOp.EQUAL, ApplicationColumnPrefix.RELATES_TO));
    } else if (relatesTo != null && !relatesTo.getFilterList().isEmpty()) {
        // Even if fields to retrieve does not contain RELATES_TO, we still
        // need to have a filter to fetch some of the column qualifiers if
        // relatesTo filters are specified. relatesTo filters will then be
        // matched after fetching rows from HBase.
        Set<String> relatesToCols = TimelineFilterUtils.fetchColumnsFromFilterList(relatesTo);
        infoFamilyColsFilter.addFilter(createFiltersFromColumnQualifiers(ApplicationColumnPrefix.RELATES_TO, relatesToCols));
    }
    TimelineFilterList isRelatedTo = getFilters().getIsRelatedTo();
    if (hasField(fieldsToRetrieve, Field.IS_RELATED_TO)) {
        // If IS_RELATED_TO field has to be retrieved, add a filter for fetching
        // columns with IS_RELATED_TO column prefix.
        infoFamilyColsFilter.addFilter(TimelineFilterUtils.createHBaseQualifierFilter(CompareOp.EQUAL, ApplicationColumnPrefix.IS_RELATED_TO));
    } else if (isRelatedTo != null && !isRelatedTo.getFilterList().isEmpty()) {
        // Even if fields to retrieve does not contain IS_RELATED_TO, we still
        // need to have a filter to fetch some of the column qualifiers if
        // isRelatedTo filters are specified. isRelatedTo filters will then be
        // matched after fetching rows from HBase.
        Set<String> isRelatedToCols = TimelineFilterUtils.fetchColumnsFromFilterList(isRelatedTo);
        infoFamilyColsFilter.addFilter(createFiltersFromColumnQualifiers(ApplicationColumnPrefix.IS_RELATED_TO, isRelatedToCols));
    }
    TimelineFilterList eventFilters = getFilters().getEventFilters();
    if (hasField(fieldsToRetrieve, Field.EVENTS)) {
        // If EVENTS field has to be retrieved, add a filter for fetching columns
        // with EVENT column prefix.
        infoFamilyColsFilter.addFilter(TimelineFilterUtils.createHBaseQualifierFilter(CompareOp.EQUAL, ApplicationColumnPrefix.EVENT));
    } else if (eventFilters != null && !eventFilters.getFilterList().isEmpty()) {
        // Even if fields to retrieve does not contain EVENTS, we still need to
        // have a filter to fetch some of the column qualifiers on the basis of
        // event filters specified. Event filters will then be matched after
        // fetching rows from HBase.
        Set<String> eventCols = TimelineFilterUtils.fetchColumnsFromFilterList(eventFilters);
        infoFamilyColsFilter.addFilter(createFiltersFromColumnQualifiers(ApplicationColumnPrefix.EVENT, eventCols));
    }
    return infoFamilyColsFilter;
}
Also used : Field(org.apache.hadoop.yarn.server.timelineservice.storage.TimelineReader.Field) EnumSet(java.util.EnumSet) Set(java.util.Set) 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)

Example 18 with TimelineFilterList

use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList in project hadoop by apache.

the class ApplicationEntityReader method constructFilterListBasedOnFilters.

/**
   * This method is called only for multiple entity reads.
   */
@Override
protected FilterList constructFilterListBasedOnFilters() throws IOException {
    // Filters here cannot be null for multiple entity reads as they are set in
    // augmentParams if null.
    TimelineEntityFilters filters = getFilters();
    FilterList listBasedOnFilters = new FilterList();
    // Create filter list based on created time range and add it to
    // listBasedOnFilters.
    long createdTimeBegin = filters.getCreatedTimeBegin();
    long createdTimeEnd = filters.getCreatedTimeEnd();
    if (createdTimeBegin != 0 || createdTimeEnd != Long.MAX_VALUE) {
        listBasedOnFilters.addFilter(TimelineFilterUtils.createSingleColValueFiltersByRange(ApplicationColumn.CREATED_TIME, createdTimeBegin, createdTimeEnd));
    }
    // Create filter list based on metric filters and add it to
    // listBasedOnFilters.
    TimelineFilterList metricFilters = filters.getMetricFilters();
    if (metricFilters != null && !metricFilters.getFilterList().isEmpty()) {
        listBasedOnFilters.addFilter(TimelineFilterUtils.createHBaseFilterList(ApplicationColumnPrefix.METRIC, metricFilters));
    }
    // Create filter list based on config filters and add it to
    // listBasedOnFilters.
    TimelineFilterList configFilters = filters.getConfigFilters();
    if (configFilters != null && !configFilters.getFilterList().isEmpty()) {
        listBasedOnFilters.addFilter(TimelineFilterUtils.createHBaseFilterList(ApplicationColumnPrefix.CONFIG, configFilters));
    }
    // Create filter list based on info filters and add it to listBasedOnFilters
    TimelineFilterList infoFilters = filters.getInfoFilters();
    if (infoFilters != null && !infoFilters.getFilterList().isEmpty()) {
        listBasedOnFilters.addFilter(TimelineFilterUtils.createHBaseFilterList(ApplicationColumnPrefix.INFO, infoFilters));
    }
    return listBasedOnFilters;
}
Also used : TimelineEntityFilters(org.apache.hadoop.yarn.server.timelineservice.reader.TimelineEntityFilters) 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)

Example 19 with TimelineFilterList

use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList in project hadoop by apache.

the class FlowRunEntityReader method constructFilterListBasedOnFilters.

protected FilterList constructFilterListBasedOnFilters() throws IOException {
    FilterList listBasedOnFilters = new FilterList();
    // Filter based on created time range.
    Long createdTimeBegin = getFilters().getCreatedTimeBegin();
    Long createdTimeEnd = getFilters().getCreatedTimeEnd();
    if (createdTimeBegin != 0 || createdTimeEnd != Long.MAX_VALUE) {
        listBasedOnFilters.addFilter(TimelineFilterUtils.createSingleColValueFiltersByRange(FlowRunColumn.MIN_START_TIME, createdTimeBegin, createdTimeEnd));
    }
    // Filter based on metric filters.
    TimelineFilterList metricFilters = getFilters().getMetricFilters();
    if (metricFilters != null && !metricFilters.getFilterList().isEmpty()) {
        listBasedOnFilters.addFilter(TimelineFilterUtils.createHBaseFilterList(FlowRunColumnPrefix.METRIC, metricFilters));
    }
    return listBasedOnFilters;
}
Also used : 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)

Example 20 with TimelineFilterList

use of org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList in project hadoop by apache.

the class GenericEntityReader method createFilterListForColsOfInfoFamily.

/**
   * Creates a filter list which indicates that only some of the column
   * qualifiers in the info column family will be returned in result.
   *
   * @param isApplication If true, it means operations are to be performed for
   *          application table, otherwise for entity table.
   * @return filter list.
   * @throws IOException if any problem occurs while creating filter list.
   */
private FilterList createFilterListForColsOfInfoFamily() throws IOException {
    FilterList infoFamilyColsFilter = new FilterList(Operator.MUST_PASS_ONE);
    // Add filters for each column in entity table.
    updateFixedColumns(infoFamilyColsFilter);
    EnumSet<Field> fieldsToRetrieve = getDataToRetrieve().getFieldsToRetrieve();
    // with INFO column prefix.
    if (hasField(fieldsToRetrieve, Field.INFO)) {
        infoFamilyColsFilter.addFilter(TimelineFilterUtils.createHBaseQualifierFilter(CompareOp.EQUAL, EntityColumnPrefix.INFO));
    }
    TimelineFilterList relatesTo = getFilters().getRelatesTo();
    if (hasField(fieldsToRetrieve, Field.RELATES_TO)) {
        // If RELATES_TO field has to be retrieved, add a filter for fetching
        // columns with RELATES_TO column prefix.
        infoFamilyColsFilter.addFilter(TimelineFilterUtils.createHBaseQualifierFilter(CompareOp.EQUAL, EntityColumnPrefix.RELATES_TO));
    } else if (relatesTo != null && !relatesTo.getFilterList().isEmpty()) {
        // Even if fields to retrieve does not contain RELATES_TO, we still
        // need to have a filter to fetch some of the column qualifiers if
        // relatesTo filters are specified. relatesTo filters will then be
        // matched after fetching rows from HBase.
        Set<String> relatesToCols = TimelineFilterUtils.fetchColumnsFromFilterList(relatesTo);
        infoFamilyColsFilter.addFilter(createFiltersFromColumnQualifiers(EntityColumnPrefix.RELATES_TO, relatesToCols));
    }
    TimelineFilterList isRelatedTo = getFilters().getIsRelatedTo();
    if (hasField(fieldsToRetrieve, Field.IS_RELATED_TO)) {
        // If IS_RELATED_TO field has to be retrieved, add a filter for fetching
        // columns with IS_RELATED_TO column prefix.
        infoFamilyColsFilter.addFilter(TimelineFilterUtils.createHBaseQualifierFilter(CompareOp.EQUAL, EntityColumnPrefix.IS_RELATED_TO));
    } else if (isRelatedTo != null && !isRelatedTo.getFilterList().isEmpty()) {
        // Even if fields to retrieve does not contain IS_RELATED_TO, we still
        // need to have a filter to fetch some of the column qualifiers if
        // isRelatedTo filters are specified. isRelatedTo filters will then be
        // matched after fetching rows from HBase.
        Set<String> isRelatedToCols = TimelineFilterUtils.fetchColumnsFromFilterList(isRelatedTo);
        infoFamilyColsFilter.addFilter(createFiltersFromColumnQualifiers(EntityColumnPrefix.IS_RELATED_TO, isRelatedToCols));
    }
    TimelineFilterList eventFilters = getFilters().getEventFilters();
    if (hasField(fieldsToRetrieve, Field.EVENTS)) {
        // If EVENTS field has to be retrieved, add a filter for fetching columns
        // with EVENT column prefix.
        infoFamilyColsFilter.addFilter(TimelineFilterUtils.createHBaseQualifierFilter(CompareOp.EQUAL, EntityColumnPrefix.EVENT));
    } else if (eventFilters != null && !eventFilters.getFilterList().isEmpty()) {
        // Even if fields to retrieve does not contain EVENTS, we still need to
        // have a filter to fetch some of the column qualifiers on the basis of
        // event filters specified. Event filters will then be matched after
        // fetching rows from HBase.
        Set<String> eventCols = TimelineFilterUtils.fetchColumnsFromFilterList(eventFilters);
        infoFamilyColsFilter.addFilter(createFiltersFromColumnQualifiers(EntityColumnPrefix.EVENT, eventCols));
    }
    return infoFamilyColsFilter;
}
Also used : Field(org.apache.hadoop.yarn.server.timelineservice.storage.TimelineReader.Field) EnumSet(java.util.EnumSet) Set(java.util.Set) 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)

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