entities) {
- this.entities = entities;
- }
-
-}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/ATSEntity.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/ATSEntity.java
deleted file mode 100644
index 1884db7..0000000
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/ATSEntity.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/**
- * 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.apptimeline;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-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 org.apache.hadoop.classification.InterfaceAudience.Public;
-import org.apache.hadoop.classification.InterfaceStability.Unstable;
-
-/**
- *
- * The class that contains the the meta information of some conceptual entity of
- * an application and its related events. The entity can be an application, an
- * application attempt, a container or whatever the user-defined object.
- *
- *
- *
- * Primary filters will be used to index the entities in
- * ApplicationTimelineStore, such that users should carefully
- * choose the information they want to store as the primary filters. The
- * remaining can be stored as other information.
- *
- */
-@XmlRootElement(name = "entity")
-@XmlAccessorType(XmlAccessType.NONE)
-@Public
-@Unstable
-public class ATSEntity {
-
- private String entityType;
- private String entityId;
- private long startTime;
- private List events = new ArrayList();
- private Map> relatedEntities =
- new HashMap>();
- private Map primaryFilters =
- new HashMap();
- private Map otherInfo =
- new HashMap();
-
- public ATSEntity() {
-
- }
-
- /**
- * 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 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 start time of the entity
- *
- * @return the start time of the entity
- */
- @XmlElement(name = "starttime")
- public long getStartTime() {
- return startTime;
- }
-
- /**
- * Set the start time of the entity
- *
- * @param startTime
- * the start time of the entity
- */
- public void setStartTime(long startTime) {
- this.startTime = startTime;
- }
-
- /**
- * Get a list of events related to the entity
- *
- * @return a list of events related to the entity
- */
- @XmlElement(name = "events")
- public List getEvents() {
- return events;
- }
-
- /**
- * Add a single event related to the entity to the existing event list
- *
- * @param event
- * a single event related to the entity
- */
- public void addEvent(ATSEvent event) {
- events.add(event);
- }
-
- /**
- * Add a list of events related to the entity to the existing event list
- *
- * @param events
- * a list of events related to the entity
- */
- public void addEvents(List events) {
- this.events.addAll(events);
- }
-
- /**
- * Set the event list to the given list of events related to the entity
- *
- * @param events
- * events a list of events related to the entity
- */
- public void setEvents(List events) {
- this.events = events;
- }
-
- /**
- * Get the related entities
- *
- * @return the related entities
- */
- @XmlElement(name = "relatedentities")
- public Map> getRelatedEntities() {
- return relatedEntities;
- }
-
- /**
- * Add a list of entity of the same type to the existing related entity map
- *
- * @param entityType
- * the entity type
- * @param entityIds
- * a list of entity Ids
- */
- public void addRelatedEntity(String entityType, List entityIds) {
- List thisRelatedEntity = relatedEntities.get(entityType);
- relatedEntities.put(entityType, entityIds);
- if (thisRelatedEntity == null) {
- relatedEntities.put(entityType, entityIds);
- } else {
- thisRelatedEntity.addAll(entityIds);
- }
- }
-
- /**
- * Add a map of related entities to the existing related entity map
- *
- * @param relatedEntities
- * a map of related entities
- */
- public void addRelatedEntities(
- Map> relatedEntities) {
- for (Map.Entry> relatedEntity : relatedEntities
- .entrySet()) {
- List thisRelatedEntity =
- this.relatedEntities.get(relatedEntity.getKey());
- if (thisRelatedEntity == null) {
- this.relatedEntities.put(
- relatedEntity.getKey(), relatedEntity.getValue());
- } else {
- thisRelatedEntity.addAll(relatedEntity.getValue());
- }
- }
- }
-
- /**
- * Set the related entity map to the given map of related entities
- *
- * @param relatedEntities
- * a map of related entities
- */
- public void setRelatedEntities(
- Map> relatedEntities) {
- this.relatedEntities = relatedEntities;
- }
-
- /**
- * Get the primary filters
- *
- * @return the primary filters
- */
- @XmlElement(name = "primaryfilters")
- public Map getPrimaryFilters() {
- return primaryFilters;
- }
-
- /**
- * Add a single piece of primary filter to the existing primary filter map
- *
- * @param key
- * the primary filter key
- * @param value
- * the primary filter value
- */
- public void addPrimaryFilter(String key, Object value) {
- primaryFilters.put(key, value);
- }
-
- /**
- * Add a map of primary filters to the existing primary filter map
- *
- * @param primaryFilters
- * a map of primary filters
- */
- public void addPrimaryFilters(Map primaryFilters) {
- this.primaryFilters.putAll(primaryFilters);
- }
-
- /**
- * Set the primary filter map to the given map of primary filters
- *
- * @param primaryFilters
- * a map of primary filters
- */
- public void setPrimaryFilters(Map primaryFilters) {
- this.primaryFilters = primaryFilters;
- }
-
- /**
- * Get the other information of the entity
- *
- * @return the other information of the entity
- */
- @XmlElement(name = "otherinfo")
- public Map getOtherInfo() {
- return otherInfo;
- }
-
- /**
- * Add one piece of other information of the entity to the existing other info
- * map
- *
- * @param key
- * the other information key
- * @param value
- * the other information value
- */
- public void addOtherInfo(String key, Object value) {
- this.otherInfo.put(key, value);
- }
-
- /**
- * Add a map of other information of the entity to the existing other info map
- *
- * @param otherInfo
- * a map of other information
- */
- public void addOtherInfo(Map otherInfo) {
- this.otherInfo.putAll(otherInfo);
- }
-
- /**
- * Set the other info map to the given map of other information
- *
- * @param otherInfo
- * a map of other information
- */
- public void setOtherInfo(Map otherInfo) {
- this.otherInfo = otherInfo;
- }
-
-}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/ATSEvent.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/ATSEvent.java
deleted file mode 100644
index 6477a57..0000000
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/ATSEvent.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * 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.apptimeline;
-
-import java.util.HashMap;
-import java.util.Map;
-
-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 org.apache.hadoop.classification.InterfaceAudience.Public;
-import org.apache.hadoop.classification.InterfaceStability.Unstable;
-
-/**
- * The class that contains the information of an event that is related to some
- * conceptual entity of an application. Users are free to define what the event
- * means, such as starting an application, getting allocated a container and
- * etc.
- */
-@XmlRootElement(name = "event")
-@XmlAccessorType(XmlAccessType.NONE)
-@Public
-@Unstable
-public class ATSEvent {
-
- private long timestamp;
- private String eventType;
- private Map eventInfo = new HashMap();
-
- public ATSEvent() {
- }
-
- /**
- * Get the timestamp of the event
- *
- * @return the timestamp of the event
- */
- @XmlElement(name = "timestamp")
- public long getTimestamp() {
- return timestamp;
- }
-
- /**
- * Set the timestamp of the event
- *
- * @param timestamp
- * the timestamp of the event
- */
- public void setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- }
-
- /**
- * Get the event type
- *
- * @return the event type
- */
- @XmlElement(name = "eventtype")
- public String getEventType() {
- return eventType;
- }
-
- /**
- * Set the event type
- *
- * @param eventType
- * the event type
- */
- public void setEventType(String eventType) {
- this.eventType = eventType;
- }
-
- /**
- * Set the information of the event
- *
- * @return the information of the event
- */
- @XmlElement(name = "eventinfo")
- public Map getEventInfo() {
- return eventInfo;
- }
-
- /**
- * Add one piece of the information of the event to the existing information
- * map
- *
- * @param key
- * the information key
- * @param value
- * the information value
- */
- public void addEventInfo(String key, Object value) {
- this.eventInfo.put(key, value);
- }
-
- /**
- * Add a map of the information of the event to the existing information map
- *
- * @param eventInfo
- * a map of of the information of the event
- */
- public void addEventInfo(Map eventInfo) {
- this.eventInfo.putAll(eventInfo);
- }
-
- /**
- * Set the information map to the given map of the information of the event
- *
- * @param eventInfo
- * a map of of the information of the event
- */
- public void setEventInfo(Map eventInfo) {
- this.eventInfo = eventInfo;
- }
-
-}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/ATSEvents.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/ATSEvents.java
deleted file mode 100644
index da7fd28..0000000
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/ATSEvents.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- * 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.apptimeline;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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 org.apache.hadoop.classification.InterfaceAudience.Public;
-import org.apache.hadoop.classification.InterfaceStability.Unstable;
-
-/**
- * The class that hosts a list of events, which are categorized according to
- * their related entities.
- */
-@XmlRootElement(name = "events")
-@XmlAccessorType(XmlAccessType.NONE)
-@Public
-@Unstable
-public class ATSEvents {
-
- private List allEvents =
- new ArrayList();
-
- public ATSEvents() {
-
- }
-
- /**
- * Get a list of {@link ATSEventsOfOneEntity} instances
- *
- * @return a list of {@link ATSEventsOfOneEntity} instances
- */
- @XmlElement(name = "events")
- public List getAllEvents() {
- return allEvents;
- }
-
- /**
- * Add a single {@link ATSEventsOfOneEntity} instance into the existing list
- *
- * @param eventsOfOneEntity
- * a single {@link ATSEventsOfOneEntity} instance
- */
- public void addEvent(ATSEventsOfOneEntity eventsOfOneEntity) {
- allEvents.add(eventsOfOneEntity);
- }
-
- /**
- * Add a list of {@link ATSEventsOfOneEntity} instances into the existing list
- *
- * @param allEvents
- * a list of {@link ATSEventsOfOneEntity} instances
- */
- public void addEvents(List allEvents) {
- this.allEvents.addAll(allEvents);
- }
-
- /**
- * Set the list to the given list of {@link ATSEventsOfOneEntity} instances
- *
- * @param allEvents
- * a list of {@link ATSEventsOfOneEntity} instances
- */
- public void setEvents(List allEvents) {
- this.allEvents.clear();
- this.allEvents.addAll(allEvents);
- }
-
- /**
- * The class that hosts a list of events that are only related to one entity.
- */
- @XmlRootElement(name = "events")
- @XmlAccessorType(XmlAccessType.NONE)
- @Public
- @Unstable
- public static class ATSEventsOfOneEntity {
-
- private String entityId;
- private String entityType;
- private List events = new ArrayList();
-
- public ATSEventsOfOneEntity() {
-
- }
-
- /**
- * 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 a list of events
- *
- * @return a list of events
- */
- @XmlElement(name = "events")
- public List getEvents() {
- return events;
- }
-
- /**
- * Add a single event to the existing event list
- *
- * @param event
- * a single event
- */
- public void addEntity(ATSEvent event) {
- events.add(event);
- }
-
- /**
- * Add a list of event to the existing event list
- *
- * @param events
- * a list of events
- */
- public void addEvents(List events) {
- this.events.addAll(events);
- }
-
- /**
- * Set the event list to the given list of events
- *
- * @param events
- * a list of events
- */
- public void setEvents(List events) {
- this.events = events;
- }
-
- }
-
-}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Entities.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Entities.java
new file mode 100644
index 0000000..2b4c074
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Entities.java
@@ -0,0 +1,88 @@
+/**
+ * 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.apptimeline;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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 org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+
+/**
+ * The class that hosts a list of application timeline entities.
+ */
+@XmlRootElement(name = "entities")
+@XmlAccessorType(XmlAccessType.NONE)
+@Public
+@Unstable
+public class Entities {
+
+ private List entities =
+ new ArrayList();
+
+ public Entities() {
+
+ }
+
+ /**
+ * Get a list of entities
+ *
+ * @return a list of entities
+ */
+ @XmlElement(name = "entities")
+ public List getEntities() {
+ return entities;
+ }
+
+ /**
+ * Add a single entity into the existing entity list
+ *
+ * @param entity
+ * a single entity
+ */
+ public void addEntity(Entity entity) {
+ entities.add(entity);
+ }
+
+ /**
+ * All a list of entities into the existing entity list
+ *
+ * @param entities
+ * a list of entities
+ */
+ public void addEntities(List entities) {
+ this.entities.addAll(entities);
+ }
+
+ /**
+ * Set the entity list to the given list of entities
+ *
+ * @param entities
+ * a list of entities
+ */
+ public void setEntities(List entities) {
+ this.entities = entities;
+ }
+
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Entity.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Entity.java
new file mode 100644
index 0000000..c60b3ef
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Entity.java
@@ -0,0 +1,314 @@
+/**
+ * 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.apptimeline;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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 org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+
+/**
+ *
+ * The class that contains the the meta information of some conceptual entity of
+ * an application and its related events. The entity can be an application, an
+ * application attempt, a container or whatever the user-defined object.
+ *
+ *
+ *
+ * Primary filters will be used to index the entities in
+ * ApplicationTimelineStore, such that users should carefully
+ * choose the information they want to store as the primary filters. The
+ * remaining can be stored as other information.
+ *
+ */
+@XmlRootElement(name = "entity")
+@XmlAccessorType(XmlAccessType.NONE)
+@Public
+@Unstable
+public class Entity {
+
+ private String entityType;
+ private String entityId;
+ private long startTime;
+ private List events = new ArrayList();
+ private Map> relatedEntities =
+ new HashMap>();
+ private Map primaryFilters =
+ new HashMap();
+ private Map otherInfo =
+ new HashMap();
+
+ public Entity() {
+
+ }
+
+ /**
+ * 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 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 start time of the entity
+ *
+ * @return the start time of the entity
+ */
+ @XmlElement(name = "starttime")
+ public long getStartTime() {
+ return startTime;
+ }
+
+ /**
+ * Set the start time of the entity
+ *
+ * @param startTime
+ * the start time of the entity
+ */
+ public void setStartTime(long startTime) {
+ this.startTime = startTime;
+ }
+
+ /**
+ * Get a list of events related to the entity
+ *
+ * @return a list of events related to the entity
+ */
+ @XmlElement(name = "events")
+ public List getEvents() {
+ return events;
+ }
+
+ /**
+ * Add a single event related to the entity to the existing event list
+ *
+ * @param event
+ * a single event related to the entity
+ */
+ public void addEvent(Event event) {
+ events.add(event);
+ }
+
+ /**
+ * Add a list of events related to the entity to the existing event list
+ *
+ * @param events
+ * a list of events related to the entity
+ */
+ public void addEvents(List events) {
+ this.events.addAll(events);
+ }
+
+ /**
+ * Set the event list to the given list of events related to the entity
+ *
+ * @param events
+ * events a list of events related to the entity
+ */
+ public void setEvents(List events) {
+ this.events = events;
+ }
+
+ /**
+ * Get the related entities
+ *
+ * @return the related entities
+ */
+ @XmlElement(name = "relatedentities")
+ public Map> getRelatedEntities() {
+ return relatedEntities;
+ }
+
+ /**
+ * Add a list of entity of the same type to the existing related entity map
+ *
+ * @param entityType
+ * the entity type
+ * @param entityIds
+ * a list of entity Ids
+ */
+ public void addRelatedEntity(String entityType, List entityIds) {
+ List thisRelatedEntity = relatedEntities.get(entityType);
+ relatedEntities.put(entityType, entityIds);
+ if (thisRelatedEntity == null) {
+ relatedEntities.put(entityType, entityIds);
+ } else {
+ thisRelatedEntity.addAll(entityIds);
+ }
+ }
+
+ /**
+ * Add a map of related entities to the existing related entity map
+ *
+ * @param relatedEntities
+ * a map of related entities
+ */
+ public void addRelatedEntities(
+ Map> relatedEntities) {
+ for (Map.Entry> relatedEntity : relatedEntities
+ .entrySet()) {
+ List thisRelatedEntity =
+ this.relatedEntities.get(relatedEntity.getKey());
+ if (thisRelatedEntity == null) {
+ this.relatedEntities.put(
+ relatedEntity.getKey(), relatedEntity.getValue());
+ } else {
+ thisRelatedEntity.addAll(relatedEntity.getValue());
+ }
+ }
+ }
+
+ /**
+ * Set the related entity map to the given map of related entities
+ *
+ * @param relatedEntities
+ * a map of related entities
+ */
+ public void setRelatedEntities(
+ Map> relatedEntities) {
+ this.relatedEntities = relatedEntities;
+ }
+
+ /**
+ * Get the primary filters
+ *
+ * @return the primary filters
+ */
+ @XmlElement(name = "primaryfilters")
+ public Map getPrimaryFilters() {
+ return primaryFilters;
+ }
+
+ /**
+ * Add a single piece of primary filter to the existing primary filter map
+ *
+ * @param key
+ * the primary filter key
+ * @param value
+ * the primary filter value
+ */
+ public void addPrimaryFilter(String key, Object value) {
+ primaryFilters.put(key, value);
+ }
+
+ /**
+ * Add a map of primary filters to the existing primary filter map
+ *
+ * @param primaryFilters
+ * a map of primary filters
+ */
+ public void addPrimaryFilters(Map primaryFilters) {
+ this.primaryFilters.putAll(primaryFilters);
+ }
+
+ /**
+ * Set the primary filter map to the given map of primary filters
+ *
+ * @param primaryFilters
+ * a map of primary filters
+ */
+ public void setPrimaryFilters(Map primaryFilters) {
+ this.primaryFilters = primaryFilters;
+ }
+
+ /**
+ * Get the other information of the entity
+ *
+ * @return the other information of the entity
+ */
+ @XmlElement(name = "otherinfo")
+ public Map getOtherInfo() {
+ return otherInfo;
+ }
+
+ /**
+ * Add one piece of other information of the entity to the existing other info
+ * map
+ *
+ * @param key
+ * the other information key
+ * @param value
+ * the other information value
+ */
+ public void addOtherInfo(String key, Object value) {
+ this.otherInfo.put(key, value);
+ }
+
+ /**
+ * Add a map of other information of the entity to the existing other info map
+ *
+ * @param otherInfo
+ * a map of other information
+ */
+ public void addOtherInfo(Map otherInfo) {
+ this.otherInfo.putAll(otherInfo);
+ }
+
+ /**
+ * Set the other info map to the given map of other information
+ *
+ * @param otherInfo
+ * a map of other information
+ */
+ public void setOtherInfo(Map otherInfo) {
+ this.otherInfo = otherInfo;
+ }
+
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Event.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Event.java
new file mode 100644
index 0000000..24fab50
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Event.java
@@ -0,0 +1,134 @@
+/**
+ * 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.apptimeline;
+
+import java.util.HashMap;
+import java.util.Map;
+
+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 org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+
+/**
+ * The class that contains the information of an event that is related to some
+ * conceptual entity of an application. Users are free to define what the event
+ * means, such as starting an application, getting allocated a container and
+ * etc.
+ */
+@XmlRootElement(name = "event")
+@XmlAccessorType(XmlAccessType.NONE)
+@Public
+@Unstable
+public class Event {
+
+ private long timestamp;
+ private String eventType;
+ private Map eventInfo = new HashMap();
+
+ public Event() {
+ }
+
+ /**
+ * Get the timestamp of the event
+ *
+ * @return the timestamp of the event
+ */
+ @XmlElement(name = "timestamp")
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Set the timestamp of the event
+ *
+ * @param timestamp
+ * the timestamp of the event
+ */
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ /**
+ * Get the event type
+ *
+ * @return the event type
+ */
+ @XmlElement(name = "eventtype")
+ public String getEventType() {
+ return eventType;
+ }
+
+ /**
+ * Set the event type
+ *
+ * @param eventType
+ * the event type
+ */
+ public void setEventType(String eventType) {
+ this.eventType = eventType;
+ }
+
+ /**
+ * Set the information of the event
+ *
+ * @return the information of the event
+ */
+ @XmlElement(name = "eventinfo")
+ public Map getEventInfo() {
+ return eventInfo;
+ }
+
+ /**
+ * Add one piece of the information of the event to the existing information
+ * map
+ *
+ * @param key
+ * the information key
+ * @param value
+ * the information value
+ */
+ public void addEventInfo(String key, Object value) {
+ this.eventInfo.put(key, value);
+ }
+
+ /**
+ * Add a map of the information of the event to the existing information map
+ *
+ * @param eventInfo
+ * a map of of the information of the event
+ */
+ public void addEventInfo(Map eventInfo) {
+ this.eventInfo.putAll(eventInfo);
+ }
+
+ /**
+ * Set the information map to the given map of the information of the event
+ *
+ * @param eventInfo
+ * a map of of the information of the event
+ */
+ public void setEventInfo(Map eventInfo) {
+ this.eventInfo = eventInfo;
+ }
+
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Events.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Events.java
new file mode 100644
index 0000000..60644b1
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/Events.java
@@ -0,0 +1,189 @@
+/**
+ * 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.apptimeline;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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 org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+
+/**
+ * The class that hosts a list of events, which are categorized according to
+ * their related entities.
+ */
+@XmlRootElement(name = "events")
+@XmlAccessorType(XmlAccessType.NONE)
+@Public
+@Unstable
+public class Events {
+
+ private List allEvents =
+ new ArrayList();
+
+ public Events() {
+
+ }
+
+ /**
+ * Get a list of {@link EventsOfOneEntity} instances
+ *
+ * @return a list of {@link EventsOfOneEntity} instances
+ */
+ @XmlElement(name = "events")
+ public List getAllEvents() {
+ return allEvents;
+ }
+
+ /**
+ * Add a single {@link EventsOfOneEntity} instance into the existing list
+ *
+ * @param eventsOfOneEntity
+ * a single {@link EventsOfOneEntity} instance
+ */
+ public void addEvent(EventsOfOneEntity eventsOfOneEntity) {
+ allEvents.add(eventsOfOneEntity);
+ }
+
+ /**
+ * Add a list of {@link EventsOfOneEntity} instances into the existing list
+ *
+ * @param allEvents
+ * a list of {@link EventsOfOneEntity} instances
+ */
+ public void addEvents(List allEvents) {
+ this.allEvents.addAll(allEvents);
+ }
+
+ /**
+ * Set the list to the given list of {@link EventsOfOneEntity} instances
+ *
+ * @param allEvents
+ * a list of {@link EventsOfOneEntity} instances
+ */
+ public void setEvents(List allEvents) {
+ this.allEvents.clear();
+ this.allEvents.addAll(allEvents);
+ }
+
+ /**
+ * The class that hosts a list of events that are only related to one entity.
+ */
+ @XmlRootElement(name = "events")
+ @XmlAccessorType(XmlAccessType.NONE)
+ @Public
+ @Unstable
+ public static class EventsOfOneEntity {
+
+ private String entityId;
+ private String entityType;
+ private List events = new ArrayList();
+
+ public EventsOfOneEntity() {
+
+ }
+
+ /**
+ * 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 a list of events
+ *
+ * @return a list of events
+ */
+ @XmlElement(name = "events")
+ public List getEvents() {
+ return events;
+ }
+
+ /**
+ * Add a single event to the existing event list
+ *
+ * @param event
+ * a single event
+ */
+ public void addEntity(Event event) {
+ events.add(event);
+ }
+
+ /**
+ * Add a list of event to the existing event list
+ *
+ * @param events
+ * a list of events
+ */
+ public void addEvents(List events) {
+ this.events.addAll(events);
+ }
+
+ /**
+ * Set the event list to the given list of events
+ *
+ * @param events
+ * a list of events
+ */
+ public void setEvents(List events) {
+ this.events = events;
+ }
+
+ }
+
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
index 54da659..6091686 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
@@ -79,6 +79,10 @@
org.mortbay.jetty
jetty-util
+
+ com.sun.jersey
+ jersey-client
+
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/TimelineClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/TimelineClient.java
new file mode 100644
index 0000000..9b3f195
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/TimelineClient.java
@@ -0,0 +1,66 @@
+/**
+ * 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.client.api;
+
+import java.io.IOException;
+
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.service.AbstractService;
+import org.apache.hadoop.yarn.api.records.apptimeline.Entity;
+import org.apache.hadoop.yarn.client.api.impl.TimelineClientImpl;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
+/**
+ * The client library that can be used to post the information of a number of
+ * conceptual entities of an application.
+ */
+@Public
+@Unstable
+public abstract class TimelineClient extends AbstractService {
+
+ @Public
+ public static TimelineClient createTimelineClient() {
+ TimelineClient client = new TimelineClientImpl();
+ return client;
+ }
+
+ @Private
+ protected TimelineClient(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ * Post the information of a number of conceptual entities of an application
+ * to the application timeline server. It is a blocking API. The method will
+ * not return until it gets the response from the application timeline server.
+ *
+ *
+ * @param entities
+ * the collection of {@link Entity}
+ * @throws IOException
+ * @throws YarnException
+ */
+ @Public
+ public abstract void postEntities(
+ Entity... entities) throws IOException, YarnException;
+
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineClientImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineClientImpl.java
new file mode 100644
index 0000000..d9e8860
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineClientImpl.java
@@ -0,0 +1,103 @@
+/**
+ * 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.client.api.impl;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.http.HttpConfig;
+import org.apache.hadoop.yarn.api.records.apptimeline.Entities;
+import org.apache.hadoop.yarn.api.records.apptimeline.Entity;
+import org.apache.hadoop.yarn.client.api.TimelineClient;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+import org.apache.hadoop.yarn.webapp.YarnJacksonJaxbJsonProvider;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+
+@Private
+@Unstable
+public class TimelineClientImpl extends TimelineClient {
+
+ private static final Log LOG = LogFactory.getLog(TimelineClientImpl.class);
+ private static final String RESOURCE_URI_STR = "/ws/v1/apptimeline/";
+ private static final Joiner JOINER = Joiner.on("");
+
+ private Client client;
+ private URI resURI;
+
+ public TimelineClientImpl() {
+ super(TimelineClientImpl.class.getName());
+ ClientConfig cc = new DefaultClientConfig();
+ cc.getClasses().add(YarnJacksonJaxbJsonProvider.class);
+ client = Client.create(cc);
+ }
+
+ protected void serviceInit(Configuration conf) throws Exception {
+ resURI = new URI(JOINER.join(HttpConfig.getSchemePrefix(),
+ HttpConfig.isSecure() ? conf.get(
+ YarnConfiguration.AHS_WEBAPP_HTTPS_ADDRESS,
+ YarnConfiguration.DEFAULT_AHS_WEBAPP_HTTPS_ADDRESS) : conf.get(
+ YarnConfiguration.AHS_WEBAPP_ADDRESS,
+ YarnConfiguration.DEFAULT_AHS_WEBAPP_ADDRESS), RESOURCE_URI_STR));
+ super.serviceInit(conf);
+ }
+
+ @Override
+ public void postEntities(
+ Entity... entities) throws IOException, YarnException {
+ Entities entitiesContainer = new Entities();
+ entitiesContainer.addEntities(Arrays.asList(entities));
+ ClientResponse resp = doPostingEntities(entitiesContainer);
+ if (resp.getStatus() != ClientResponse.Status.OK.getStatusCode()) {
+ String msg = "Failed to post application timeline entities.";
+ LOG.error(msg);
+ if (LOG.isDebugEnabled()) {
+ String output = resp.getEntity(String.class);
+ LOG.debug("HTTP error code: " + resp.getStatus()
+ + " Server response : \n" + output);
+ }
+ throw new YarnException(msg);
+ }
+ }
+
+ @Private
+ @VisibleForTesting
+ public ClientResponse doPostingEntities(Entities entities) {
+ WebResource webResource = client.resource(resURI);
+ return webResource.accept(MediaType.APPLICATION_JSON)
+ .type(MediaType.APPLICATION_JSON)
+ .post(ClientResponse.class, entities);
+ }
+
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java
new file mode 100644
index 0000000..a15ecec
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java
@@ -0,0 +1,114 @@
+/**
+ * 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.client.api.impl;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+
+import junit.framework.Assert;
+
+import org.apache.hadoop.yarn.api.records.apptimeline.Entities;
+import org.apache.hadoop.yarn.api.records.apptimeline.Entity;
+import org.apache.hadoop.yarn.api.records.apptimeline.Event;
+import org.apache.hadoop.yarn.client.api.TimelineClient;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.sun.jersey.api.client.ClientResponse;
+
+public class TestTimelineClient {
+
+ private TimelineClientImpl client;
+
+ @Before
+ public void setup() {
+ client = spy((TimelineClientImpl) TimelineClient.createTimelineClient());
+ client.init(new YarnConfiguration());
+ client.start();
+ }
+
+ @After
+ public void tearDown() {
+ client.stop();
+ }
+
+ @Test
+ public void testPostEntities() throws Exception {
+ mockClientResponse(ClientResponse.Status.OK.getStatusCode());
+ try {
+ client.postEntities(generateEntity());
+ } catch (YarnException e) {
+ Assert.fail("Exception is not expected");
+ }
+ }
+
+ @Test
+ public void testPostEntitiesError() throws Exception {
+ mockClientResponse(ClientResponse.Status.INTERNAL_SERVER_ERROR
+ .getStatusCode());
+ try {
+ client.postEntities(generateEntity());
+ Assert.fail("Exception is expected");
+ } catch (YarnException e) {
+ Assert.assertTrue(e.getMessage().contains(
+ "Failed to post application timeline entities."));
+ }
+ }
+
+ private ClientResponse mockClientResponse(int statusCode) {
+ ClientResponse response = mock(ClientResponse.class);
+ doReturn(response).when(client)
+ .doPostingEntities(any(Entities.class));
+ when(response.getStatus()).thenReturn(statusCode);
+ return response;
+ }
+
+ private static Entity generateEntity() {
+ Entity entity = new Entity();
+ entity.setEntityId("entity id");
+ entity.setEntityType("entity type");
+ entity.setStartTime(System.currentTimeMillis());
+ for (int i = 0; i < 2; ++i) {
+ Event event = new Event();
+ event.setTimestamp(System.currentTimeMillis());
+ event.setEventType("test event type " + i);
+ event.addEventInfo("key1", "val1");
+ event.addEventInfo("key2", "val2");
+ entity.addEvent(event);
+ }
+ entity.addRelatedEntity(
+ "test ref type 1", Arrays.asList((Object) "test ref id 1"));
+ entity.addRelatedEntity(
+ "test ref type 2", Arrays.asList((Object) "test ref id 2"));
+ entity.addPrimaryFilter("pkey1", "pval1");
+ entity.addPrimaryFilter("pkey2", "pval2");
+ entity.addOtherInfo("okey1", "oval1");
+ entity.addOtherInfo("okey2", "oval2");
+ return entity;
+ }
+
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/YarnJacksonJaxbJsonProvider.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/YarnJacksonJaxbJsonProvider.java
new file mode 100644
index 0000000..67a48d8
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/YarnJacksonJaxbJsonProvider.java
@@ -0,0 +1,63 @@
+/**
+ * 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.webapp;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
+import org.codehaus.jackson.map.AnnotationIntrospector;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
+
+import com.google.inject.Singleton;
+
+/**
+ * YARN's implementation of JAX-RS abstractions based on
+ * {@link JacksonJaxbJsonProvider} needed for deserialize JSON content to or
+ * serialize it from POJO objects.
+ */
+@Singleton
+@Provider
+@Unstable
+@Private
+public class YarnJacksonJaxbJsonProvider extends JacksonJaxbJsonProvider {
+
+ public YarnJacksonJaxbJsonProvider() {
+ super();
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public ObjectMapper locateMapper(Class> type, MediaType mediaType) {
+ ObjectMapper mapper = super.locateMapper(type, mediaType);
+ mapper.configure(DeserializationConfig.Feature.WRAP_ROOT_VALUE, true);
+ AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
+ // TODO: change to use non-deprecated methods
+ mapper.getSerializationConfig().setAnnotationIntrospector(introspector);
+ mapper.getDeserializationConfig().setAnnotationIntrospector(introspector);
+ mapper.getSerializationConfig()
+ .setSerializationInclusion(Inclusion.NON_NULL);
+ return mapper;
+ }
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/apptimeline/TestApplicationTimelineRecords.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/apptimeline/TestApplicationTimelineRecords.java
index fe79e74..a2b45eb 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/apptimeline/TestApplicationTimelineRecords.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/apptimeline/TestApplicationTimelineRecords.java
@@ -27,15 +27,15 @@
public class TestApplicationTimelineRecords {
@Test
- public void testATSEntities() {
- ATSEntities entities = new ATSEntities();
+ public void testEntities() {
+ Entities entities = new Entities();
for (int j = 0; j < 2; ++j) {
- ATSEntity entity = new ATSEntity();
+ Entity entity = new Entity();
entity.setEntityId("entity id " + j);
entity.setEntityType("entity type " + j);
entity.setStartTime(System.currentTimeMillis());
for (int i = 0; i < 2; ++i) {
- ATSEvent event = new ATSEvent();
+ Event event = new Event();
event.setTimestamp(System.currentTimeMillis());
event.setEventType("event type " + i);
event.addEventInfo("key1", "val1");
@@ -53,14 +53,14 @@ public void testATSEntities() {
entities.addEntity(entity);
}
Assert.assertEquals(2, entities.getEntities().size());
- ATSEntity entity1 = entities.getEntities().get(0);
+ Entity entity1 = entities.getEntities().get(0);
Assert.assertEquals("entity id 0", entity1.getEntityId());
Assert.assertEquals("entity type 0", entity1.getEntityType());
Assert.assertEquals(2, entity1.getRelatedEntities().size());
Assert.assertEquals(2, entity1.getEvents().size());
Assert.assertEquals(2, entity1.getPrimaryFilters().size());
Assert.assertEquals(2, entity1.getOtherInfo().size());
- ATSEntity entity2 = entities.getEntities().get(1);
+ Entity entity2 = entities.getEntities().get(1);
Assert.assertEquals("entity id 1", entity2.getEntityId());
Assert.assertEquals("entity type 1", entity2.getEntityType());
Assert.assertEquals(2, entity2.getRelatedEntities().size());
@@ -70,15 +70,15 @@ public void testATSEntities() {
}
@Test
- public void testATSEvents() {
- ATSEvents events = new ATSEvents();
+ public void testEvents() {
+ Events events = new Events();
for (int j = 0; j < 2; ++j) {
- ATSEvents.ATSEventsOfOneEntity partEvents =
- new ATSEvents.ATSEventsOfOneEntity();
+ Events.EventsOfOneEntity partEvents =
+ new Events.EventsOfOneEntity();
partEvents.setEntityId("entity id " + j);
partEvents.setEntityType("entity type " + j);
for (int i = 0; i < 2; ++i) {
- ATSEvent event = new ATSEvent();
+ Event event = new Event();
event.setTimestamp(System.currentTimeMillis());
event.setEventType("event type " + i);
event.addEventInfo("key1", "val1");
@@ -88,24 +88,24 @@ public void testATSEvents() {
events.addEvent(partEvents);
}
Assert.assertEquals(2, events.getAllEvents().size());
- ATSEvents.ATSEventsOfOneEntity partEvents1 = events.getAllEvents().get(0);
+ Events.EventsOfOneEntity partEvents1 = events.getAllEvents().get(0);
Assert.assertEquals("entity id 0", partEvents1.getEntityId());
Assert.assertEquals("entity type 0", partEvents1.getEntityType());
Assert.assertEquals(2, partEvents1.getEvents().size());
- ATSEvent event11 = partEvents1.getEvents().get(0);
+ Event event11 = partEvents1.getEvents().get(0);
Assert.assertEquals("event type 0", event11.getEventType());
Assert.assertEquals(2, event11.getEventInfo().size());
- ATSEvent event12 = partEvents1.getEvents().get(1);
+ Event event12 = partEvents1.getEvents().get(1);
Assert.assertEquals("event type 1", event12.getEventType());
Assert.assertEquals(2, event12.getEventInfo().size());
- ATSEvents.ATSEventsOfOneEntity partEvents2 = events.getAllEvents().get(1);
+ Events.EventsOfOneEntity partEvents2 = events.getAllEvents().get(1);
Assert.assertEquals("entity id 1", partEvents2.getEntityId());
Assert.assertEquals("entity type 1", partEvents2.getEntityType());
Assert.assertEquals(2, partEvents2.getEvents().size());
- ATSEvent event21 = partEvents2.getEvents().get(0);
+ Event event21 = partEvents2.getEvents().get(0);
Assert.assertEquals("event type 0", event21.getEventType());
Assert.assertEquals(2, event21.getEventInfo().size());
- ATSEvent event22 = partEvents2.getEvents().get(1);
+ Event event22 = partEvents2.getEvents().get(1);
Assert.assertEquals("event type 1", event22.getEventType());
Assert.assertEquals(2, event22.getEventInfo().size());
}