diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/TimelineReader.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/TimelineReader.java new file mode 100644 index 0000000..fa84c73 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/TimelineReader.java @@ -0,0 +1,124 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.timelineservice.storage; + +import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.classification.InterfaceStability; +import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity; + +import java.io.IOException; +import java.util.EnumSet; +import java.util.Set; + +/** + * This interface is for fetching timeline data from storage + */ +@InterfaceAudience.Private +@InterfaceStability.Unstable +public interface TimelineReader { + + public static enum Field { + ALL, + INFO, + CONFIGS, + EVENTS, + METRICS, + RELATES_TO, + IS_RELATED_TO, + } + + public static class KeyValuePair { + private String key; + private Object value; + public KeyValuePair(String key, Object value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + } + + /** + * + * @param clusterId context cluster Id + * @param appId context app Id + * @param entityType entity type + * @param entityId entity Id + * @param fieldsToRetrieve the fields to be be returned + * @return + * @throws IOException + */ + TimelineEntity getEntity( + String clusterId, String appId, String entityType, String entityId, + EnumSet fieldsToRetrieve) throws IOException; + + /** + * + * @param clusterId context cluster Id + * @param appId context app Id + * @param entityTypes the types of entities to fetch + * @param limit the number of entities to fetch at most + * @param createdTimeBegin + * the matched entities need to be created no early than this time + * @param createdTimeEnd + * the matched entities need to be created no later than this time + * @param modifiedTimeBegin + * the matched entities need to be modified no early than this time + * @param modifiedTimeEnd + * the matched entities need to be modified no later than this time + * @param relatesTo + * the matched entities need to relate to the given entities + * @param isRelatedTo + * the matched entities need to be related to the given entities + * @param info + * the matched entities need to contain the given info (key/value pairs) + * @param configs + * the matched entities need to contain the given configs (key/value pairs) + * @param events + * the matched entities need to contain the given events (Id) + * @param metrics + * the matched entities need to contain the given metrics (Id) + * TODO: We may want to support more sophasticated predicates for metrics, + * such as comparing against the aggregation value. + * @param fieldsToRetrieve the fields to be be returned + * @return + * @throws IOException + */ + Set getEntities( + String clusterId, String appId, Set entityTypes, Long limit, + Long createdTimeBegin, Long createdTimeEnd, Long modifiedTimeBegin, + Long modifiedTimeEnd, Set relatesTo, + Set isRelatedTo, Set info, + Set configs, Set events, Set metrics, + EnumSet fieldsToRetrieve) throws IOException; +}