001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.hadoop.yarn.api.records.timeline;
019
020 import org.apache.hadoop.classification.InterfaceAudience.Public;
021 import org.apache.hadoop.classification.InterfaceStability.Unstable;
022
023 import javax.xml.bind.annotation.XmlAccessType;
024 import javax.xml.bind.annotation.XmlAccessorType;
025 import javax.xml.bind.annotation.XmlElement;
026 import javax.xml.bind.annotation.XmlRootElement;
027 import java.util.ArrayList;
028 import java.util.List;
029
030 /**
031 * A class that holds a list of put errors. This is the response returned when a
032 * list of {@link TimelineEntity} objects is added to the timeline. If there are errors
033 * in storing individual entity objects, they will be indicated in the list of
034 * errors.
035 */
036 @XmlRootElement(name = "response")
037 @XmlAccessorType(XmlAccessType.NONE)
038 @Public
039 @Unstable
040 public class TimelinePutResponse {
041
042 private List<TimelinePutError> errors = new ArrayList<TimelinePutError>();
043
044 public TimelinePutResponse() {
045
046 }
047
048 /**
049 * Get a list of {@link TimelinePutError} instances
050 *
051 * @return a list of {@link TimelinePutError} instances
052 */
053 @XmlElement(name = "errors")
054 public List<TimelinePutError> getErrors() {
055 return errors;
056 }
057
058 /**
059 * Add a single {@link TimelinePutError} instance into the existing list
060 *
061 * @param error
062 * a single {@link TimelinePutError} instance
063 */
064 public void addError(TimelinePutError error) {
065 errors.add(error);
066 }
067
068 /**
069 * Add a list of {@link TimelinePutError} instances into the existing list
070 *
071 * @param errors
072 * a list of {@link TimelinePutError} instances
073 */
074 public void addErrors(List<TimelinePutError> errors) {
075 this.errors.addAll(errors);
076 }
077
078 /**
079 * Set the list to the given list of {@link TimelinePutError} instances
080 *
081 * @param errors
082 * a list of {@link TimelinePutError} instances
083 */
084 public void setErrors(List<TimelinePutError> errors) {
085 this.errors.clear();
086 this.errors.addAll(errors);
087 }
088
089 /**
090 * A class that holds the error code for one entity.
091 */
092 @XmlRootElement(name = "error")
093 @XmlAccessorType(XmlAccessType.NONE)
094 @Public
095 @Unstable
096 public static class TimelinePutError {
097
098 /**
099 * Error code returned when no start time can be found when putting an
100 * entity. This occurs when the entity does not already exist in the store
101 * and it is put with no start time or events specified.
102 */
103 public static final int NO_START_TIME = 1;
104 /**
105 * Error code returned if an IOException is encountered when putting an
106 * entity.
107 */
108 public static final int IO_EXCEPTION = 2;
109
110 /**
111 * Error code returned if the user specifies the timeline system reserved
112 * filter key
113 */
114 public static final int SYSTEM_FILTER_CONFLICT = 3;
115
116 /**
117 * Error code returned if the user is denied to access the timeline data
118 */
119 public static final int ACCESS_DENIED = 4;
120
121 private String entityId;
122 private String entityType;
123 private int errorCode;
124
125 /**
126 * Get the entity Id
127 *
128 * @return the entity Id
129 */
130 @XmlElement(name = "entity")
131 public String getEntityId() {
132 return entityId;
133 }
134
135 /**
136 * Set the entity Id
137 *
138 * @param entityId
139 * the entity Id
140 */
141 public void setEntityId(String entityId) {
142 this.entityId = entityId;
143 }
144
145 /**
146 * Get the entity type
147 *
148 * @return the entity type
149 */
150 @XmlElement(name = "entitytype")
151 public String getEntityType() {
152 return entityType;
153 }
154
155 /**
156 * Set the entity type
157 *
158 * @param entityType
159 * the entity type
160 */
161 public void setEntityType(String entityType) {
162 this.entityType = entityType;
163 }
164
165 /**
166 * Get the error code
167 *
168 * @return an error code
169 */
170 @XmlElement(name = "errorcode")
171 public int getErrorCode() {
172 return errorCode;
173 }
174
175 /**
176 * Set the error code to the given error code
177 *
178 * @param errorCode
179 * an error code
180 */
181 public void setErrorCode(int errorCode) {
182 this.errorCode = errorCode;
183 }
184
185 }
186
187 }