You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yarn-commits@hadoop.apache.org by vi...@apache.org on 2014/02/22 21:55:07 UTC
svn commit: r1570922 [1/3] - in /hadoop/common/trunk/hadoop-yarn-project: ./
hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/
hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline...
Author: vinodkv
Date: Sat Feb 22 20:55:06 2014
New Revision: 1570922
URL: http://svn.apache.org/r1570922
Log:
YARN-1687. Renamed user-facing records for the timeline-service to be simply named after 'timeline' instead of 'apptimeline'. Contributed by Zhijie Shen.
Added:
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntities.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntity.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvent.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvents.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelinePutResponse.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/package-info.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/TimelineUtils.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/package-info.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timeline/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timeline/TestTimelineRecords.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/EntityIdentifier.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/GenericObjectMapper.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/LeveldbTimelineStore.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/MemoryTimelineStore.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/NameValuePair.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/TimelineReader.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/TimelineStore.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/TimelineWriter.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/package-info.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TimelineWebServices.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/TestGenericObjectMapper.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/TestLeveldbTimelineStore.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/TestMemoryTimelineStore.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/TimelineStoreTestUtils.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestTimelineWebServices.java
Removed:
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/apptimeline/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/TimelineUtils.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/apptimeline/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/apptimeline/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/ATSWebServices.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/apptimeline/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestATSWebServices.java
Modified:
hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/TimelineClient.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineClientImpl.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebApp.java
Modified: hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt?rev=1570922&r1=1570921&r2=1570922&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt Sat Feb 22 20:55:06 2014
@@ -221,6 +221,9 @@ Release 2.4.0 - UNRELEASED
YARN-1732. Changed types of related-entities and primary-filters in the
timeline-service to be sets instead of maps. (Billie Rinaldi via vinodkv)
+ YARN-1687. Renamed user-facing records for the timeline-service to be simply
+ named after 'timeline' instead of 'apptimeline'. (Zhijie Shen via vinodkv)
+
OPTIMIZATIONS
BUG FIXES
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntities.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntities.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntities.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntities.java Sat Feb 22 20:55:06 2014
@@ -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.timeline;
+
+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 timeline entities.
+ */
+@XmlRootElement(name = "entities")
+@XmlAccessorType(XmlAccessType.NONE)
+@Public
+@Unstable
+public class TimelineEntities {
+
+ private List<TimelineEntity> entities =
+ new ArrayList<TimelineEntity>();
+
+ public TimelineEntities() {
+
+ }
+
+ /**
+ * Get a list of entities
+ *
+ * @return a list of entities
+ */
+ @XmlElement(name = "entities")
+ public List<TimelineEntity> getEntities() {
+ return entities;
+ }
+
+ /**
+ * Add a single entity into the existing entity list
+ *
+ * @param entity
+ * a single entity
+ */
+ public void addEntity(TimelineEntity entity) {
+ entities.add(entity);
+ }
+
+ /**
+ * All a list of entities into the existing entity list
+ *
+ * @param entities
+ * a list of entities
+ */
+ public void addEntities(List<TimelineEntity> 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<TimelineEntity> entities) {
+ this.entities = entities;
+ }
+
+}
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntity.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntity.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntity.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEntity.java Sat Feb 22 20:55:06 2014
@@ -0,0 +1,416 @@
+/**
+ * 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.timeline;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+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;
+
+/**
+ * <p>
+ * The class that contains the the meta information of some conceptual entity
+ * and its related events. The entity can be an application, an application
+ * attempt, a container or whatever the user-defined object.
+ * </p>
+ *
+ * <p>
+ * Primary filters will be used to index the entities in
+ * <code>TimelineStore</code>, such that users should carefully choose the
+ * information they want to store as the primary filters. The remaining can be
+ * stored as other information.
+ * </p>
+ */
+@XmlRootElement(name = "entity")
+@XmlAccessorType(XmlAccessType.NONE)
+@Public
+@Unstable
+public class TimelineEntity implements Comparable<TimelineEntity> {
+
+ private String entityType;
+ private String entityId;
+ private Long startTime;
+ private List<TimelineEvent> events = new ArrayList<TimelineEvent>();
+ private Map<String, Set<String>> relatedEntities =
+ new HashMap<String, Set<String>>();
+ private Map<String, Set<Object>> primaryFilters =
+ new HashMap<String, Set<Object>>();
+ private Map<String, Object> otherInfo =
+ new HashMap<String, Object>();
+
+ public TimelineEntity() {
+
+ }
+
+ /**
+ * 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<TimelineEvent> 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(TimelineEvent 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<TimelineEvent> 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<TimelineEvent> events) {
+ this.events = events;
+ }
+
+ /**
+ * Get the related entities
+ *
+ * @return the related entities
+ */
+ @XmlElement(name = "relatedentities")
+ public Map<String, Set<String>> getRelatedEntities() {
+ return relatedEntities;
+ }
+
+ /**
+ * Add an entity to the existing related entity map
+ *
+ * @param entityType
+ * the entity type
+ * @param entityId
+ * the entity Id
+ */
+ public void addRelatedEntity(String entityType, String entityId) {
+ Set<String> thisRelatedEntity = relatedEntities.get(entityType);
+ if (thisRelatedEntity == null) {
+ thisRelatedEntity = new HashSet<String>();
+ relatedEntities.put(entityType, thisRelatedEntity);
+ }
+ thisRelatedEntity.add(entityId);
+ }
+
+ /**
+ * Add a map of related entities to the existing related entity map
+ *
+ * @param relatedEntities
+ * a map of related entities
+ */
+ public void addRelatedEntities(Map<String, Set<String>> relatedEntities) {
+ for (Entry<String, Set<String>> relatedEntity : relatedEntities.entrySet()) {
+ Set<String> 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<String, Set<String>> relatedEntities) {
+ this.relatedEntities = relatedEntities;
+ }
+
+ /**
+ * Get the primary filters
+ *
+ * @return the primary filters
+ */
+ @XmlElement(name = "primaryfilters")
+ public Map<String, Set<Object>> 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) {
+ Set<Object> thisPrimaryFilter = primaryFilters.get(key);
+ if (thisPrimaryFilter == null) {
+ thisPrimaryFilter = new HashSet<Object>();
+ primaryFilters.put(key, thisPrimaryFilter);
+ }
+ thisPrimaryFilter.add(value);
+ }
+
+ /**
+ * Add a map of primary filters to the existing primary filter map
+ *
+ * @param primaryFilters
+ * a map of primary filters
+ */
+ public void addPrimaryFilters(Map<String, Set<Object>> primaryFilters) {
+ for (Entry<String, Set<Object>> primaryFilter : primaryFilters.entrySet()) {
+ Set<Object> thisPrimaryFilter =
+ this.primaryFilters.get(primaryFilter.getKey());
+ if (thisPrimaryFilter == null) {
+ this.primaryFilters.put(
+ primaryFilter.getKey(), primaryFilter.getValue());
+ } else {
+ thisPrimaryFilter.addAll(primaryFilter.getValue());
+ }
+ }
+ }
+
+ /**
+ * Set the primary filter map to the given map of primary filters
+ *
+ * @param primaryFilters
+ * a map of primary filters
+ */
+ public void setPrimaryFilters(Map<String, Set<Object>> primaryFilters) {
+ this.primaryFilters = primaryFilters;
+ }
+
+ /**
+ * Get the other information of the entity
+ *
+ * @return the other information of the entity
+ */
+ @XmlElement(name = "otherinfo")
+ public Map<String, Object> 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<String, Object> 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<String, Object> otherInfo) {
+ this.otherInfo = otherInfo;
+ }
+
+ @Override
+ public int hashCode() {
+ // generated by eclipse
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((entityId == null) ? 0 : entityId.hashCode());
+ result =
+ prime * result + ((entityType == null) ? 0 : entityType.hashCode());
+ result = prime * result + ((events == null) ? 0 : events.hashCode());
+ result = prime * result + ((otherInfo == null) ? 0 : otherInfo.hashCode());
+ result =
+ prime * result
+ + ((primaryFilters == null) ? 0 : primaryFilters.hashCode());
+ result =
+ prime * result
+ + ((relatedEntities == null) ? 0 : relatedEntities.hashCode());
+ result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ // generated by eclipse
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TimelineEntity other = (TimelineEntity) obj;
+ if (entityId == null) {
+ if (other.entityId != null)
+ return false;
+ } else if (!entityId.equals(other.entityId))
+ return false;
+ if (entityType == null) {
+ if (other.entityType != null)
+ return false;
+ } else if (!entityType.equals(other.entityType))
+ return false;
+ if (events == null) {
+ if (other.events != null)
+ return false;
+ } else if (!events.equals(other.events))
+ return false;
+ if (otherInfo == null) {
+ if (other.otherInfo != null)
+ return false;
+ } else if (!otherInfo.equals(other.otherInfo))
+ return false;
+ if (primaryFilters == null) {
+ if (other.primaryFilters != null)
+ return false;
+ } else if (!primaryFilters.equals(other.primaryFilters))
+ return false;
+ if (relatedEntities == null) {
+ if (other.relatedEntities != null)
+ return false;
+ } else if (!relatedEntities.equals(other.relatedEntities))
+ return false;
+ if (startTime == null) {
+ if (other.startTime != null)
+ return false;
+ } else if (!startTime.equals(other.startTime))
+ return false;
+ return true;
+ }
+
+ @Override
+ public int compareTo(TimelineEntity other) {
+ int comparison = entityType.compareTo(other.entityType);
+ if (comparison == 0) {
+ long thisStartTime =
+ startTime == null ? Long.MIN_VALUE : startTime;
+ long otherStartTime =
+ other.startTime == null ? Long.MIN_VALUE : other.startTime;
+ if (thisStartTime > otherStartTime) {
+ return -1;
+ } else if (thisStartTime < otherStartTime) {
+ return 1;
+ } else {
+ return entityId.compareTo(other.entityId);
+ }
+ } else {
+ return comparison;
+ }
+ }
+
+}
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvent.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvent.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvent.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvent.java Sat Feb 22 20:55:06 2014
@@ -0,0 +1,172 @@
+/**
+ * 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.timeline;
+
+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 TimelineEvent implements Comparable<TimelineEvent> {
+
+ private long timestamp;
+ private String eventType;
+ private Map<String, Object> eventInfo = new HashMap<String, Object>();
+
+ public TimelineEvent() {
+ }
+
+ /**
+ * 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<String, Object> 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<String, Object> 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<String, Object> eventInfo) {
+ this.eventInfo = eventInfo;
+ }
+
+ @Override
+ public int compareTo(TimelineEvent other) {
+ if (timestamp > other.timestamp) {
+ return -1;
+ } else if (timestamp < other.timestamp) {
+ return 1;
+ } else {
+ return eventType.compareTo(other.eventType);
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ TimelineEvent event = (TimelineEvent) o;
+
+ if (timestamp != event.timestamp)
+ return false;
+ if (!eventType.equals(event.eventType))
+ return false;
+ if (eventInfo != null ? !eventInfo.equals(event.eventInfo) :
+ event.eventInfo != null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (int) (timestamp ^ (timestamp >>> 32));
+ result = 31 * result + eventType.hashCode();
+ result = 31 * result + (eventInfo != null ? eventInfo.hashCode() : 0);
+ return result;
+ }
+}
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvents.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvents.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvents.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelineEvents.java Sat Feb 22 20:55:06 2014
@@ -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.timeline;
+
+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 TimelineEvents {
+
+ private List<EventsOfOneEntity> allEvents =
+ new ArrayList<EventsOfOneEntity>();
+
+ public TimelineEvents() {
+
+ }
+
+ /**
+ * Get a list of {@link EventsOfOneEntity} instances
+ *
+ * @return a list of {@link EventsOfOneEntity} instances
+ */
+ @XmlElement(name = "events")
+ public List<EventsOfOneEntity> 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<EventsOfOneEntity> 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<EventsOfOneEntity> 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<TimelineEvent> events = new ArrayList<TimelineEvent>();
+
+ 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<TimelineEvent> getEvents() {
+ return events;
+ }
+
+ /**
+ * Add a single event to the existing event list
+ *
+ * @param event
+ * a single event
+ */
+ public void addEvent(TimelineEvent event) {
+ events.add(event);
+ }
+
+ /**
+ * Add a list of event to the existing event list
+ *
+ * @param events
+ * a list of events
+ */
+ public void addEvents(List<TimelineEvent> 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<TimelineEvent> events) {
+ this.events = events;
+ }
+
+ }
+
+}
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelinePutResponse.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelinePutResponse.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelinePutResponse.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/TimelinePutResponse.java Sat Feb 22 20:55:06 2014
@@ -0,0 +1,176 @@
+/**
+ * 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.timeline;
+
+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 TimelineEntity} 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 TimelinePutResponse {
+
+ private List<TimelinePutError> errors = new ArrayList<TimelinePutError>();
+
+ public TimelinePutResponse() {
+
+ }
+
+ /**
+ * Get a list of {@link TimelinePutError} instances
+ *
+ * @return a list of {@link TimelinePutError} instances
+ */
+ @XmlElement(name = "errors")
+ public List<TimelinePutError> getErrors() {
+ return errors;
+ }
+
+ /**
+ * Add a single {@link TimelinePutError} instance into the existing list
+ *
+ * @param error
+ * a single {@link TimelinePutError} instance
+ */
+ public void addError(TimelinePutError error) {
+ errors.add(error);
+ }
+
+ /**
+ * Add a list of {@link TimelinePutError} instances into the existing list
+ *
+ * @param errors
+ * a list of {@link TimelinePutError} instances
+ */
+ public void addErrors(List<TimelinePutError> errors) {
+ this.errors.addAll(errors);
+ }
+
+ /**
+ * Set the list to the given list of {@link TimelinePutError} instances
+ *
+ * @param errors
+ * a list of {@link TimelinePutError} instances
+ */
+ public void setErrors(List<TimelinePutError> 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 TimelinePutError {
+
+ /**
+ * 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;
+ }
+
+ }
+
+}
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/package-info.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/package-info.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/package-info.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timeline/package-info.java Sat Feb 22 20:55:06 2014
@@ -0,0 +1,21 @@
+/**
+ * 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.
+ */
+@InterfaceAudience.Public
+package org.apache.hadoop.yarn.api.records.timeline;
+import org.apache.hadoop.classification.InterfaceAudience;
+
Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java?rev=1570922&r1=1570921&r2=1570922&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java Sat Feb 22 20:55:06 2014
@@ -1051,17 +1051,19 @@ public class YarnConfiguration extends C
AHS_PREFIX + "webapp.spnego-keytab-file";
////////////////////////////////
- // ATS Configs
+ // Timeline Service Configs
////////////////////////////////
- public static final String ATS_PREFIX = YARN_PREFIX + "ats.";
+ public static final String TIMELINE_SERVICE_PREFIX =
+ YARN_PREFIX + "timeline-service.";
- /** ATS store class */
- public static final String ATS_STORE = ATS_PREFIX + "store.class";
-
- /** ATS leveldb path */
- public static final String ATS_LEVELDB_PATH_PROPERTY =
- ATS_PREFIX + "leveldb-apptimeline-store.path";
+ /** Timeline service store class */
+ public static final String TIMELINE_SERVICE_STORE =
+ TIMELINE_SERVICE_PREFIX + "store-class";
+
+ /** Timeline service leveldb path */
+ public static final String TIMELINE_SERVICE_LEVELDB_PATH =
+ TIMELINE_SERVICE_PREFIX + "leveldb-timeline-store.path";
////////////////////////////////
// Other Configs
Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/TimelineClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/TimelineClient.java?rev=1570922&r1=1570921&r2=1570922&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/TimelineClient.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/TimelineClient.java Sat Feb 22 20:55:06 2014
@@ -24,8 +24,8 @@ import org.apache.hadoop.classification.
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.ATSEntity;
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSPutErrors;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
+import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
import org.apache.hadoop.yarn.client.api.impl.TimelineClientImpl;
import org.apache.hadoop.yarn.exceptions.YarnException;
@@ -33,7 +33,7 @@ import org.apache.hadoop.yarn.exceptions
* A client library that can be used to post some information in terms of a
* number of conceptual entities.
*
- * @See ATSEntity
+ * @See Entity
*/
@Public
@Unstable
@@ -52,19 +52,19 @@ public abstract class TimelineClient ext
/**
* <p>
- * Post the information of a number of conceptual entities of an application
- * to the timeline server. It is a blocking API. The method will not return
- * until it gets the response from the timeline server.
+ * Send the information of a number of conceptual entities to the timeline
+ * server. It is a blocking API. The method will not return until it gets the
+ * response from the timeline server.
* </p>
*
* @param entities
- * the collection of {@link ATSEntity}
- * @return the error information if the post entities are not correctly stored
+ * the collection of {@link TimelineEntity}
+ * @return the error information if the sent entities are not correctly stored
* @throws IOException
* @throws YarnException
*/
@Public
- public abstract ATSPutErrors postEntities(
- ATSEntity... entities) throws IOException, YarnException;
+ public abstract TimelinePutResponse putEntities(
+ TimelineEntity... entities) throws IOException, YarnException;
}
Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineClientImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineClientImpl.java?rev=1570922&r1=1570921&r2=1570922&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineClientImpl.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineClientImpl.java Sat Feb 22 20:55:06 2014
@@ -29,9 +29,9 @@ import org.apache.commons.logging.LogFac
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSEntities;
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSEntity;
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSPutErrors;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
+import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
import org.apache.hadoop.yarn.client.api.TimelineClient;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
@@ -50,7 +50,7 @@ import com.sun.jersey.api.client.config.
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 String RESOURCE_URI_STR = "/ws/v1/timeline/";
private static final Joiner JOINER = Joiner.on("");
private Client client;
@@ -79,9 +79,9 @@ public class TimelineClientImpl extends
}
@Override
- public ATSPutErrors postEntities(
- ATSEntity... entities) throws IOException, YarnException {
- ATSEntities entitiesContainer = new ATSEntities();
+ public TimelinePutResponse putEntities(
+ TimelineEntity... entities) throws IOException, YarnException {
+ TimelineEntities entitiesContainer = new TimelineEntities();
entitiesContainer.addEntities(Arrays.asList(entities));
ClientResponse resp = doPostingEntities(entitiesContainer);
if (resp.getClientResponseStatus() != ClientResponse.Status.OK) {
@@ -95,12 +95,12 @@ public class TimelineClientImpl extends
}
throw new YarnException(msg);
}
- return resp.getEntity(ATSPutErrors.class);
+ return resp.getEntity(TimelinePutResponse.class);
}
@Private
@VisibleForTesting
- public ClientResponse doPostingEntities(ATSEntities entities) {
+ public ClientResponse doPostingEntities(TimelineEntities entities) {
WebResource webResource = client.resource(resURI);
return webResource.accept(MediaType.APPLICATION_JSON)
.type(MediaType.APPLICATION_JSON)
Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java?rev=1570922&r1=1570921&r2=1570922&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java Sat Feb 22 20:55:06 2014
@@ -25,10 +25,10 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import junit.framework.Assert;
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSEntities;
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSEntity;
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSEvent;
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSPutErrors;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEvent;
+import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
import org.apache.hadoop.yarn.client.api.TimelineClient;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
@@ -58,8 +58,8 @@ public class TestTimelineClient {
public void testPostEntities() throws Exception {
mockClientResponse(ClientResponse.Status.OK, false);
try {
- ATSPutErrors errors = client.postEntities(generateATSEntity());
- Assert.assertEquals(0, errors.getErrors().size());
+ TimelinePutResponse response = client.putEntities(generateEntity());
+ Assert.assertEquals(0, response.getErrors().size());
} catch (YarnException e) {
Assert.fail("Exception is not expected");
}
@@ -69,14 +69,14 @@ public class TestTimelineClient {
public void testPostEntitiesWithError() throws Exception {
mockClientResponse(ClientResponse.Status.OK, true);
try {
- ATSPutErrors errors = client.postEntities(generateATSEntity());
- Assert.assertEquals(1, errors.getErrors().size());
- Assert.assertEquals("test entity id", errors.getErrors().get(0)
+ TimelinePutResponse response = client.putEntities(generateEntity());
+ Assert.assertEquals(1, response.getErrors().size());
+ Assert.assertEquals("test entity id", response.getErrors().get(0)
.getEntityId());
- Assert.assertEquals("test entity type", errors.getErrors().get(0)
+ Assert.assertEquals("test entity type", response.getErrors().get(0)
.getEntityType());
- Assert.assertEquals(ATSPutErrors.ATSPutError.IO_EXCEPTION,
- errors.getErrors().get(0).getErrorCode());
+ Assert.assertEquals(TimelinePutResponse.TimelinePutError.IO_EXCEPTION,
+ response.getErrors().get(0).getErrorCode());
} catch (YarnException e) {
Assert.fail("Exception is not expected");
}
@@ -86,7 +86,7 @@ public class TestTimelineClient {
public void testPostEntitiesNoResponse() throws Exception {
mockClientResponse(ClientResponse.Status.INTERNAL_SERVER_ERROR, false);
try {
- client.postEntities(generateATSEntity());
+ client.putEntities(generateEntity());
Assert.fail("Exception is expected");
} catch (YarnException e) {
Assert.assertTrue(e.getMessage().contains(
@@ -98,27 +98,28 @@ public class TestTimelineClient {
boolean hasError) {
ClientResponse response = mock(ClientResponse.class);
doReturn(response).when(client)
- .doPostingEntities(any(ATSEntities.class));
+ .doPostingEntities(any(TimelineEntities.class));
when(response.getClientResponseStatus()).thenReturn(status);
- ATSPutErrors.ATSPutError error = new ATSPutErrors.ATSPutError();
+ TimelinePutResponse.TimelinePutError error =
+ new TimelinePutResponse.TimelinePutError();
error.setEntityId("test entity id");
error.setEntityType("test entity type");
- error.setErrorCode(ATSPutErrors.ATSPutError.IO_EXCEPTION);
- ATSPutErrors errors = new ATSPutErrors();
+ error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION);
+ TimelinePutResponse putResponse = new TimelinePutResponse();
if (hasError) {
- errors.addError(error);
+ putResponse.addError(error);
}
- when(response.getEntity(ATSPutErrors.class)).thenReturn(errors);
+ when(response.getEntity(TimelinePutResponse.class)).thenReturn(putResponse);
return response;
}
- private static ATSEntity generateATSEntity() {
- ATSEntity entity = new ATSEntity();
+ private static TimelineEntity generateEntity() {
+ TimelineEntity entity = new TimelineEntity();
entity.setEntityId("entity id");
entity.setEntityType("entity type");
entity.setStartTime(System.currentTimeMillis());
for (int i = 0; i < 2; ++i) {
- ATSEvent event = new ATSEvent();
+ TimelineEvent event = new TimelineEvent();
event.setTimestamp(System.currentTimeMillis());
event.setEventType("test event type " + i);
event.addEventInfo("key1", "val1");
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/TimelineUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/TimelineUtils.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/TimelineUtils.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/TimelineUtils.java Sat Feb 22 20:55:06 2014
@@ -0,0 +1,86 @@
+/**
+ * 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.util.timeline;
+
+import java.io.IOException;
+
+import org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Evolving;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.AnnotationIntrospector;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
+
+/**
+ * The helper class for the timeline module.
+ *
+ */
+@Public
+@Evolving
+public class TimelineUtils {
+
+ private static ObjectMapper mapper;
+
+ static {
+ mapper = new ObjectMapper();
+ AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
+ mapper.setAnnotationIntrospector(introspector);
+ mapper.getSerializationConfig()
+ .setSerializationInclusion(Inclusion.NON_NULL);
+ }
+
+ /**
+ * Serialize a POJO object into a JSON string not in a pretty format
+ *
+ * @param o
+ * an object to serialize
+ * @return a JSON string
+ * @throws IOException
+ * @throws JsonMappingException
+ * @throws JsonGenerationException
+ */
+ public static String dumpTimelineRecordtoJSON(Object o)
+ throws JsonGenerationException, JsonMappingException, IOException {
+ return dumpTimelineRecordtoJSON(o, false);
+ }
+
+ /**
+ * Serialize a POJO object into a JSON string
+ *
+ * @param o
+ * an object to serialize
+ * @param pretty
+ * whether in a pretty format or not
+ * @return a JSON string
+ * @throws IOException
+ * @throws JsonMappingException
+ * @throws JsonGenerationException
+ */
+ public static String dumpTimelineRecordtoJSON(Object o, boolean pretty)
+ throws JsonGenerationException, JsonMappingException, IOException {
+ if (pretty) {
+ return mapper.defaultPrettyPrintingWriter().writeValueAsString(o);
+ } else {
+ return mapper.writeValueAsString(o);
+ }
+ }
+
+}
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/package-info.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/package-info.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/package-info.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/timeline/package-info.java Sat Feb 22 20:55:06 2014
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+@InterfaceAudience.Public
+package org.apache.hadoop.yarn.util.timeline;
+import org.apache.hadoop.classification.InterfaceAudience;
+
Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml?rev=1570922&r1=1570921&r2=1570922&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml Sat Feb 22 20:55:06 2014
@@ -1140,18 +1140,18 @@
<value>org.apache.hadoop.yarn.server.applicationhistoryservice.FileSystemApplicationHistoryStore</value>
</property>
- <!-- Application Timeline Service's Configuration-->
+ <!-- Timeline Service's Configuration-->
<property>
- <description>Store class name for application timeline store</description>
- <name>yarn.ats.store.class</name>
- <value>org.apache.hadoop.yarn.server.applicationhistoryservice.apptimeline.LeveldbApplicationTimelineStore</value>
+ <description>Store class name for timeline store</description>
+ <name>yarn.timeline-service.store-class</name>
+ <value>org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.LeveldbTimelineStore</value>
</property>
<property>
- <description>Store file name for leveldb application timeline store</description>
- <name>yarn.ats.leveldb-apptimeline-store.path</name>
- <value>${yarn.log.dir}/ats</value>
+ <description>Store file name for leveldb timeline store</description>
+ <name>yarn.timeline-service.leveldb-timeline-store.path</name>
+ <value>${yarn.log.dir}/timeline</value>
</property>
<!-- Other configuration -->
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timeline/TestTimelineRecords.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timeline/TestTimelineRecords.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timeline/TestTimelineRecords.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timeline/TestTimelineRecords.java Sat Feb 22 20:55:06 2014
@@ -0,0 +1,164 @@
+/**
+ * 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.timeline;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEvent;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents;
+import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
+import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse.TimelinePutError;
+import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
+import org.junit.Test;
+
+public class TestTimelineRecords {
+
+ private static final Log LOG =
+ LogFactory.getLog(TestTimelineRecords.class);
+
+ @Test
+ public void testEntities() throws Exception {
+ TimelineEntities entities = new TimelineEntities();
+ for (int j = 0; j < 2; ++j) {
+ TimelineEntity entity = new TimelineEntity();
+ entity.setEntityId("entity id " + j);
+ entity.setEntityType("entity type " + j);
+ entity.setStartTime(System.currentTimeMillis());
+ for (int i = 0; i < 2; ++i) {
+ TimelineEvent event = new TimelineEvent();
+ event.setTimestamp(System.currentTimeMillis());
+ event.setEventType("event type " + i);
+ event.addEventInfo("key1", "val1");
+ event.addEventInfo("key2", "val2");
+ entity.addEvent(event);
+ }
+ entity.addRelatedEntity("test ref type 1", "test ref id 1");
+ entity.addRelatedEntity("test ref type 2", "test ref id 2");
+ entity.addPrimaryFilter("pkey1", "pval1");
+ entity.addPrimaryFilter("pkey2", "pval2");
+ entity.addOtherInfo("okey1", "oval1");
+ entity.addOtherInfo("okey2", "oval2");
+ entities.addEntity(entity);
+ }
+ LOG.info("Entities in JSON:");
+ LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(entities, true));
+
+ Assert.assertEquals(2, entities.getEntities().size());
+ TimelineEntity 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());
+ TimelineEntity 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());
+ Assert.assertEquals(2, entity2.getEvents().size());
+ Assert.assertEquals(2, entity2.getPrimaryFilters().size());
+ Assert.assertEquals(2, entity2.getOtherInfo().size());
+ }
+
+ @Test
+ public void testEvents() throws Exception {
+ TimelineEvents events = new TimelineEvents();
+ for (int j = 0; j < 2; ++j) {
+ TimelineEvents.EventsOfOneEntity partEvents =
+ new TimelineEvents.EventsOfOneEntity();
+ partEvents.setEntityId("entity id " + j);
+ partEvents.setEntityType("entity type " + j);
+ for (int i = 0; i < 2; ++i) {
+ TimelineEvent event = new TimelineEvent();
+ event.setTimestamp(System.currentTimeMillis());
+ event.setEventType("event type " + i);
+ event.addEventInfo("key1", "val1");
+ event.addEventInfo("key2", "val2");
+ partEvents.addEvent(event);
+ }
+ events.addEvent(partEvents);
+ }
+ LOG.info("Events in JSON:");
+ LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(events, true));
+
+ Assert.assertEquals(2, events.getAllEvents().size());
+ TimelineEvents.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());
+ TimelineEvent event11 = partEvents1.getEvents().get(0);
+ Assert.assertEquals("event type 0", event11.getEventType());
+ Assert.assertEquals(2, event11.getEventInfo().size());
+ TimelineEvent event12 = partEvents1.getEvents().get(1);
+ Assert.assertEquals("event type 1", event12.getEventType());
+ Assert.assertEquals(2, event12.getEventInfo().size());
+ TimelineEvents.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());
+ TimelineEvent event21 = partEvents2.getEvents().get(0);
+ Assert.assertEquals("event type 0", event21.getEventType());
+ Assert.assertEquals(2, event21.getEventInfo().size());
+ TimelineEvent event22 = partEvents2.getEvents().get(1);
+ Assert.assertEquals("event type 1", event22.getEventType());
+ Assert.assertEquals(2, event22.getEventInfo().size());
+ }
+
+ @Test
+ public void testTimelinePutErrors() throws Exception {
+ TimelinePutResponse TimelinePutErrors = new TimelinePutResponse();
+ TimelinePutError error1 = new TimelinePutError();
+ error1.setEntityId("entity id 1");
+ error1.setEntityId("entity type 1");
+ error1.setErrorCode(TimelinePutError.NO_START_TIME);
+ TimelinePutErrors.addError(error1);
+ List<TimelinePutError> response = new ArrayList<TimelinePutError>();
+ response.add(error1);
+ TimelinePutError error2 = new TimelinePutError();
+ error2.setEntityId("entity id 2");
+ error2.setEntityId("entity type 2");
+ error2.setErrorCode(TimelinePutError.IO_EXCEPTION);
+ response.add(error2);
+ TimelinePutErrors.addErrors(response);
+ LOG.info("Errors in JSON:");
+ LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(TimelinePutErrors, true));
+
+ Assert.assertEquals(3, TimelinePutErrors.getErrors().size());
+ TimelinePutError e = TimelinePutErrors.getErrors().get(0);
+ Assert.assertEquals(error1.getEntityId(), e.getEntityId());
+ Assert.assertEquals(error1.getEntityType(), e.getEntityType());
+ Assert.assertEquals(error1.getErrorCode(), e.getErrorCode());
+ e = TimelinePutErrors.getErrors().get(1);
+ Assert.assertEquals(error1.getEntityId(), e.getEntityId());
+ Assert.assertEquals(error1.getEntityType(), e.getEntityType());
+ Assert.assertEquals(error1.getErrorCode(), e.getErrorCode());
+ e = TimelinePutErrors.getErrors().get(2);
+ Assert.assertEquals(error2.getEntityId(), e.getEntityId());
+ Assert.assertEquals(error2.getEntityType(), e.getEntityType());
+ Assert.assertEquals(error2.getErrorCode(), e.getErrorCode());
+ }
+
+}
Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java?rev=1570922&r1=1570921&r2=1570922&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java Sat Feb 22 20:55:06 2014
@@ -33,8 +33,8 @@ import org.apache.hadoop.util.StringUtil
import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.apache.hadoop.yarn.server.applicationhistoryservice.apptimeline.ApplicationTimelineStore;
-import org.apache.hadoop.yarn.server.applicationhistoryservice.apptimeline.LeveldbApplicationTimelineStore;
+import org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.TimelineStore;
+import org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.LeveldbTimelineStore;
import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.AHSWebApp;
import org.apache.hadoop.yarn.webapp.WebApp;
import org.apache.hadoop.yarn.webapp.WebApps;
@@ -54,7 +54,7 @@ public class ApplicationHistoryServer ex
ApplicationHistoryClientService ahsClientService;
ApplicationHistoryManager historyManager;
- ApplicationTimelineStore timelineStore;
+ TimelineStore timelineStore;
private WebApp webApp;
public ApplicationHistoryServer() {
@@ -67,7 +67,7 @@ public class ApplicationHistoryServer ex
ahsClientService = createApplicationHistoryClientService(historyManager);
addService(ahsClientService);
addService((Service) historyManager);
- timelineStore = createApplicationTimelineStore(conf);
+ timelineStore = createTimelineStore(conf);
addIfService(timelineStore);
super.serviceInit(conf);
}
@@ -141,11 +141,11 @@ public class ApplicationHistoryServer ex
return new ApplicationHistoryManagerImpl();
}
- protected ApplicationTimelineStore createApplicationTimelineStore(
+ protected TimelineStore createTimelineStore(
Configuration conf) {
return ReflectionUtils.newInstance(conf.getClass(
- YarnConfiguration.ATS_STORE, LeveldbApplicationTimelineStore.class,
- ApplicationTimelineStore.class), conf);
+ YarnConfiguration.TIMELINE_SERVICE_STORE, LeveldbTimelineStore.class,
+ TimelineStore.class), conf);
}
protected void startWebApp() {
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/EntityIdentifier.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/EntityIdentifier.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/EntityIdentifier.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/EntityIdentifier.java Sat Feb 22 20:55:06 2014
@@ -0,0 +1,100 @@
+/**
+ * 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.applicationhistoryservice.timeline;
+
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+
+/**
+ * The unique identifier for an entity
+ */
+@Private
+@Unstable
+public class EntityIdentifier implements Comparable<EntityIdentifier> {
+
+ private String id;
+ private String type;
+
+ public EntityIdentifier(String id, String type) {
+ this.id = id;
+ this.type = type;
+ }
+
+ /**
+ * Get the entity Id.
+ * @return The entity Id.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Get the entity type.
+ * @return The entity type.
+ */
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public int compareTo(EntityIdentifier other) {
+ int c = type.compareTo(other.type);
+ if (c != 0) return c;
+ return id.compareTo(other.id);
+ }
+
+ @Override
+ public int hashCode() {
+ // generated by eclipse
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ // generated by eclipse
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ EntityIdentifier other = (EntityIdentifier) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "{ id: " + id + ", type: "+ type + " }";
+ }
+
+}
Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/GenericObjectMapper.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/GenericObjectMapper.java?rev=1570922&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/GenericObjectMapper.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/timeline/GenericObjectMapper.java Sat Feb 22 20:55:06 2014
@@ -0,0 +1,222 @@
+/**
+ * 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.applicationhistoryservice.timeline;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.io.WritableUtils;
+import org.codehaus.jackson.map.ObjectMapper;
+
+/**
+ * A utility class providing methods for serializing and deserializing
+ * objects. The {@link #write(Object)}, {@link #read(byte[])} and {@link
+ * #write(java.io.DataOutputStream, Object)}, {@link
+ * #read(java.io.DataInputStream)} methods are used by the
+ * {@link LeveldbTimelineStore} to store and retrieve arbitrary
+ * JSON, while the {@link #writeReverseOrderedLong} and {@link
+ * #readReverseOrderedLong} methods are used to sort entities in descending
+ * start time order.
+ */
+@InterfaceAudience.Private
+@InterfaceStability.Unstable
+public class GenericObjectMapper {
+ private static final byte[] EMPTY_BYTES = new byte[0];
+
+ private static final byte LONG = 0x1;
+ private static final byte INTEGER = 0x2;
+ private static final byte DOUBLE = 0x3;
+ private static final byte STRING = 0x4;
+ private static final byte BOOLEAN = 0x5;
+ private static final byte LIST = 0x6;
+ private static final byte MAP = 0x7;
+
+ /**
+ * Serializes an Object into a byte array. Along with {@link #read(byte[]) },
+ * can be used to serialize an Object and deserialize it into an Object of
+ * the same type without needing to specify the Object's type,
+ * as long as it is one of the JSON-compatible objects Long, Integer,
+ * Double, String, Boolean, List, or Map. The current implementation uses
+ * ObjectMapper to serialize complex objects (List and Map) while using
+ * Writable to serialize simpler objects, to produce fewer bytes.
+ *
+ * @param o An Object
+ * @return A byte array representation of the Object
+ * @throws IOException
+ */
+ public static byte[] write(Object o) throws IOException {
+ if (o == null)
+ return EMPTY_BYTES;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ write(new DataOutputStream(baos), o);
+ return baos.toByteArray();
+ }
+
+ /**
+ * Serializes an Object and writes it to a DataOutputStream. Along with
+ * {@link #read(java.io.DataInputStream)}, can be used to serialize an Object
+ * and deserialize it into an Object of the same type without needing to
+ * specify the Object's type, as long as it is one of the JSON-compatible
+ * objects Long, Integer, Double, String, Boolean, List, or Map. The current
+ * implementation uses ObjectMapper to serialize complex objects (List and
+ * Map) while using Writable to serialize simpler objects, to produce fewer
+ * bytes.
+ *
+ * @param dos A DataOutputStream
+ * @param o An Object
+ * @throws IOException
+ */
+ public static void write(DataOutputStream dos, Object o)
+ throws IOException {
+ if (o == null)
+ return;
+ if (o instanceof Long) {
+ dos.write(LONG);
+ WritableUtils.writeVLong(dos, (Long) o);
+ } else if(o instanceof Integer) {
+ dos.write(INTEGER);
+ WritableUtils.writeVInt(dos, (Integer) o);
+ } else if(o instanceof Double) {
+ dos.write(DOUBLE);
+ dos.writeDouble((Double) o);
+ } else if (o instanceof String) {
+ dos.write(STRING);
+ WritableUtils.writeString(dos, (String) o);
+ } else if (o instanceof Boolean) {
+ dos.write(BOOLEAN);
+ dos.writeBoolean((Boolean) o);
+ } else if (o instanceof List) {
+ dos.write(LIST);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.writeValue(dos, o);
+ } else if (o instanceof Map) {
+ dos.write(MAP);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.writeValue(dos, o);
+ } else {
+ throw new IOException("Couldn't serialize object");
+ }
+ }
+
+ /**
+ * Deserializes an Object from a byte array created with
+ * {@link #write(Object)}.
+ *
+ * @param b A byte array
+ * @return An Object
+ * @throws IOException
+ */
+ public static Object read(byte[] b) throws IOException {
+ return read(b, 0);
+ }
+
+ /**
+ * Deserializes an Object from a byte array at a specified offset, assuming
+ * the bytes were created with {@link #write(Object)}.
+ *
+ * @param b A byte array
+ * @param offset Offset into the array
+ * @return An Object
+ * @throws IOException
+ */
+ public static Object read(byte[] b, int offset) throws IOException {
+ if (b == null || b.length == 0) {
+ return null;
+ }
+ ByteArrayInputStream bais = new ByteArrayInputStream(b, offset,
+ b.length - offset);
+ return read(new DataInputStream(bais));
+ }
+
+ /**
+ * Reads an Object from a DataInputStream whose data has been written with
+ * {@link #write(java.io.DataOutputStream, Object)}.
+ *
+ * @param dis A DataInputStream
+ * @return An Object, null if an unrecognized type
+ * @throws IOException
+ */
+ public static Object read(DataInputStream dis) throws IOException {
+ byte code = (byte)dis.read();
+ ObjectMapper mapper;
+ switch (code) {
+ case LONG:
+ return WritableUtils.readVLong(dis);
+ case INTEGER:
+ return WritableUtils.readVInt(dis);
+ case DOUBLE:
+ return dis.readDouble();
+ case STRING:
+ return WritableUtils.readString(dis);
+ case BOOLEAN:
+ return dis.readBoolean();
+ case LIST:
+ mapper = new ObjectMapper();
+ return mapper.readValue(dis, ArrayList.class);
+ case MAP:
+ mapper = new ObjectMapper();
+ return mapper.readValue(dis, HashMap.class);
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Converts a long to a 8-byte array so that lexicographic ordering of the
+ * produced byte arrays sort the longs in descending order.
+ *
+ * @param l A long
+ * @return A byte array
+ */
+ public static byte[] writeReverseOrderedLong(long l) {
+ byte[] b = new byte[8];
+ b[0] = (byte)(0x7f ^ ((l >> 56) & 0xff));
+ for (int i = 1; i < 7; i++)
+ b[i] = (byte)(0xff ^ ((l >> 8*(7-i)) & 0xff));
+ b[7] = (byte)(0xff ^ (l & 0xff));
+ return b;
+ }
+
+ /**
+ * Reads 8 bytes from an array starting at the specified offset and
+ * converts them to a long. The bytes are assumed to have been created
+ * with {@link #writeReverseOrderedLong}.
+ *
+ * @param b A byte array
+ * @param offset An offset into the byte array
+ * @return A long
+ */
+ public static long readReverseOrderedLong(byte[] b, int offset) {
+ long l = b[offset] & 0xff;
+ for (int i = 1; i < 8; i++) {
+ l = l << 8;
+ l = l | (b[offset+i]&0xff);
+ }
+ return l ^ 0x7fffffffffffffffl;
+ }
+
+}