diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceWriteResponse.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceWriteResponse.java new file mode 100644 index 0000000..a99c50a --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceWriteResponse.java @@ -0,0 +1,177 @@ +/** + * 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.api.records.timelineservice; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +/** + * A class that holds a list of put errors. This is the response returned when a + * list of {@link TimelineServiceEntity} objects is added to the timeline. If there are errors + * in storing individual entity objects, they will be indicated in the list of + * errors. + */ +@XmlRootElement(name = "response") +@XmlAccessorType(XmlAccessType.NONE) +@Public +@Unstable +public class TimelineServiceWriteResponse { + + private List errors = new ArrayList(); + + public TimelineServiceWriteResponse() { + + } + + /** + * Get a list of {@link TimelineServiceWriteError} instances + * + * @return a list of {@link TimelineServiceWriteError} instances + */ + @XmlElement(name = "errors") + public List getErrors() { + return errors; + } + + /** + * Add a single {@link TimelineServiceWriteError} instance into the existing list + * + * @param error + * a single {@link TimelineServiceWriteError} instance + */ + public void addError(TimelineServiceWriteError error) { + errors.add(error); + } + + /** + * Add a list of {@link TimelineServiceWriteError} instances into the existing list + * + * @param errors + * a list of {@link TimelineServiceWriteError} instances + */ + public void addErrors(List errors) { + this.errors.addAll(errors); + } + + /** + * Set the list to the given list of {@link TimelineServiceWriteError} instances + * + * @param errors + * a list of {@link TimelineServiceWriteError} instances + */ + public void setErrors(List errors) { + this.errors.clear(); + this.errors.addAll(errors); + } + + /** + * A class that holds the error code for one entity. + */ + @XmlRootElement(name = "error") + @XmlAccessorType(XmlAccessType.NONE) + @Public + @Unstable + public static class TimelineServiceWriteError { + + /** + * Error code returned when no start time can be found when putting an + * entity. This occurs when the entity does not already exist in the store + * and it is put with no start time or events specified. + */ + public static final int NO_START_TIME = 1; + + /** + * Error code returned if an IOException is encountered when putting an + * entity. + */ + public static final int IO_EXCEPTION = 2; + + private String entityId; + private String entityType; + private int errorCode; + + /** + * Get the entity Id + * + * @return the entity Id + */ + @XmlElement(name = "entity") + public String getEntityId() { + return entityId; + } + + /** + * Set the entity Id + * + * @param entityId + * the entity Id + */ + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + /** + * Get the entity type + * + * @return the entity type + */ + @XmlElement(name = "entitytype") + public String getEntityType() { + return entityType; + } + + /** + * Set the entity type + * + * @param entityType + * the entity type + */ + public void setEntityType(String entityType) { + this.entityType = entityType; + } + + /** + * Get the error code + * + * @return an error code + */ + @XmlElement(name = "errorcode") + public int getErrorCode() { + return errorCode; + } + + /** + * Set the error code to the given error code + * + * @param errorCode + * an error code + */ + public void setErrorCode(int errorCode) { + this.errorCode = errorCode; + } + + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/AggregateUpTo.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/AggregateUpTo.java new file mode 100644 index 0000000..3657d29 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/AggregateUpTo.java @@ -0,0 +1,30 @@ +/** + * 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; + +/** + * specifies the tracks along which an entity info + * is to be aggregated on + * + */ +public enum AggregateUpTo { + FLOW, + USER, + QUEUE +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/TimelineServiceWriter.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/TimelineServiceWriter.java new file mode 100644 index 0000000..6682f4b --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/TimelineServiceWriter.java @@ -0,0 +1,99 @@ +/** + * 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; + +import java.io.IOException; + +import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.classification.InterfaceStability; +import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity; +import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity.Identifier; +import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent; +import org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric; +import org.apache.hadoop.yarn.api.records.timelineservice.TimelineServiceWriteResponse; + +/** + * This interface is for storing application timeline information. + */ +@InterfaceAudience.Private +@InterfaceStability.Unstable +public interface TimelineServiceWriter { + + /** + * Stores the entire information + * in {@link TimelineServiceEntity} + * to the timeline store. Any errors occurring for + * individual write request objects will be reported in the response. + * + * @param data + * a {@link TimelineEntity} object. + * @return a {@link TimelineServiceWriteResponse} object. + * @throws IOException + */ + TimelineServiceWriteResponse write(TimelineEntity data) throws IOException; + + /** + * Stores the metrics information for {@link Identifier} + * in the {@link TimelineMetric} object + * to the timeline store. Any errors occurring for + * individual write request objects will be reported in the response. + * + * @param data + * a {@link Identifier} object + * a {@link TimelineMetric} object. + * @return a {@link TimelineServiceWriteResponse} object. + * @throws IOException + */ + TimelineServiceWriteResponse updateMetrics(Identifier id, + TimelineMetric metric) throws IOException; + + /** + * Stores the event information for {@link Identifier} + * in {@link TimelineEvent} + * to the timeline store. Any errors occurring for + * individual write request objects will be reported in the response. + * + * @param data + * a {@link Identifier} object + * a {@link TimelineEvent} object. + * @return a {@link TimelineServiceWriteResponse} object. + * @throws IOException + */ + TimelineServiceWriteResponse addEvent(Identifier id, + TimelineEvent data) throws IOException; + + /** + * Aggregates the entity information to the timeline store + * based on which track this entity is to be rolled up to + * The tracks along which aggregations are to be done are given by + * {@link AggregateUpTo} + * + * Any errors occurring for individual write request objects + * will be reported in the response. + * + * @param data + * a {@link TimelineEntity} object. + * a {@link AggregateUpTo} enum value. + * @return a {@link TimelineServiceWriteResponse} object. + * @throws IOException + */ + TimelineServiceWriteResponse aggregate(TimelineEntity data, + AggregateUpTo aggregateUpTo) throws IOException; + +} \ No newline at end of file