diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceApplication.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceApplication.java new file mode 100644 index 0000000..d2955be --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceApplication.java @@ -0,0 +1,115 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.api.records.timelineservice; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.timeline.TimelineEvent; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * + */ +@Public +@Unstable +public class TimelineServiceApplication extends TimelineServiceEntity { + + public static final String ENTITY_TYPE = "application"; + + private List events = new ArrayList(); + + public TimelineServiceApplication() { + setEntityType(ENTITY_TYPE); + } + + public String getFlowId() { + return getMetadata(FLOW_ID).toString(); + } + + public void setFlowId(String flowId) { + setMetadata(FLOW_ID, flowId); + } + + public String getFlowVersion() { + return getMetadata(FLOW_VERSION).toString(); + } + + public void setFlowVersion(String flowVersion) { + setMetadata(FLOW_VERSION, flowVersion); + } + + public String getFlowRunId() { + return getMetadata(FLOW_RUN_ID).toString(); + } + + public void setFlowRunId(String flowRunId) { + setMetadata(FLOW_RUN_ID, flowRunId); + } + + public String getPriority() { + return getMetadata(PRIORITY).toString(); + } + + public void setPriority(String priority) { + setMetadata(PRIORITY, priority); + } + + public String getClusterId() { + return getMetadata(CLUSTER_ID).toString(); + } + + public void setClusterId(String clusterId) { + setMetadata(CLUSTER_ID, clusterId); + } + + public String getUser() { + return getMetadata(USER).toString(); + } + + public void setUser(String user) { + setMetadata(USER, user); + } + + public String getQueue() { + return getMetadata(QUEUE).toString(); + } + + public void setQueue(String queue) { + setMetadata(QUEUE, queue); + } + + public List getEvents() { + return events; + } + + public void setEvents(List events) { + this.events = events; + } + + public void addEvent(TimelineEvent event) { + this.events.add(event); + } + + public void addEvents(List events) { + this.events.addAll(events); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceCluster.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceCluster.java new file mode 100644 index 0000000..376ad1d --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceCluster.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.api.records.timelineservice; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; + +import java.util.HashMap; + +/** + * + */ +@Public +@Unstable +public class TimelineServiceCluster extends TimelineServiceEntity { + + public static final String ENTITY_TYPE = "cluster"; + + public TimelineServiceCluster() { + setEntityType(ENTITY_TYPE); + } + + @Override + public HashMap getConfiguration() { + throw new UnsupportedOperationException(); + } + + @Override + public void setConfiguration(HashMap configuration) { + throw new UnsupportedOperationException(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceEntity.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceEntity.java new file mode 100644 index 0000000..db18961 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceEntity.java @@ -0,0 +1,148 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.api.records.timelineservice; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * + */ +@Public +@Unstable +public class TimelineServiceEntity { + + public static final String FLOW_ID = "flowid"; + public static final String FLOW_VERSION = "flowversion"; + public static final String FLOW_RUN_ID = "flowrunid"; + public static final String PRIORITY = "priority"; + public static final String CLUSTER_ID = "clusterid"; + public static final String USER = "user"; + public static final String QUEUE = "queue"; + + protected String entityType; + protected String entityId; + protected Long startTime; + protected HashMap configuration; + protected HashMap metrics = + new HashMap(); + protected TimelineServiceEntity parent; + protected HashMap metadata; + + public TimelineServiceEntity() { + } + + public String getEntityType() { + return entityType; + } + + protected void setEntityType(String entityType) { + this.entityType = entityType; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public HashMap getConfiguration() { + return configuration; + } + + public void setConfiguration(HashMap configuration) { + this.configuration = configuration; + } + + public TimelineServiceEntity getParent() { + return parent; + } + + public void setParent(TimelineServiceEntity parent) { + this.parent = parent; + } + + // TODO + public List getChildren() { + return null; + } + + public HashMap getMetrics() { + return metrics; + } + + public void setMetrics(HashMap metrics) { + this.metrics = metrics; + } + + // TODO + public Object getMetric(String name) { + return metrics.get(name); + } + + // TODO + public void addMetric(String name, Object metric) { + if (!metrics.containsKey(name)) { + setMetric(name, metric); + } + } + + // TODO + public void addMetrics(HashMap metrics) { + for (Map.Entry entry : metrics.entrySet()) { + addMetric(entry.getKey(), entry.getValue()); + } + } + + // TODO + public void setMetric(String name, Object metric) { + TimelineServiceMetric tsMetric = new TimelineServiceMetric(); + tsMetric.setEntityId(name); + tsMetric.setMetric(metric); + metrics.put(name, tsMetric); + } + + public Object getMetadata(String name) { + return metadata.get(name); + } + + public void setMetadata(String name, Object value) { + this.metadata.put(name, value); + } + + public void addMetadata(String name, Object value) { + if (!this.metadata.containsKey(name)) { + setMetadata(name, value); + } + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceFlow.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceFlow.java new file mode 100644 index 0000000..8669b32 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceFlow.java @@ -0,0 +1,56 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.api.records.timelineservice; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; + +import java.util.HashMap; + +/** + * + */ +@Public +@Unstable +public class TimelineServiceFlow extends TimelineServiceEntity { + + public static final String ENTITY_TYPE = "flow"; + + public TimelineServiceFlow() { + setEntityType(ENTITY_TYPE); + } + + public String getFlowVersion() { + return getMetadata(FLOW_VERSION).toString(); + } + + public void setFlowVersion(String flowVersion) { + setMetadata(FLOW_VERSION, flowVersion); + } + + @Override + public HashMap getConfiguration() { + throw new UnsupportedOperationException(); + } + + @Override + public void setConfiguration(HashMap configuration) { + throw new UnsupportedOperationException(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceFlowRun.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceFlowRun.java new file mode 100644 index 0000000..d05d129 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceFlowRun.java @@ -0,0 +1,64 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.api.records.timelineservice; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; + +import java.util.HashMap; + +/** + * + */ +@Public +@Unstable +public class TimelineServiceFlowRun extends TimelineServiceEntity { + + public static final String ENTITY_TYPE = "flowrun"; + + public TimelineServiceFlowRun() { + setEntityType(ENTITY_TYPE); + } + + public String getFlowId() { + return getMetadata(FLOW_ID).toString(); + } + + public void setFlowId(String flowId) { + setMetadata(FLOW_ID, flowId); + } + + public String getFlowVersion() { + return getMetadata(FLOW_VERSION).toString(); + } + + public void setFlowVersion(String flowVersion) { + setMetadata(FLOW_VERSION, flowVersion); + } + + @Override + public HashMap getConfiguration() { + throw new UnsupportedOperationException(); + } + + @Override + public void setConfiguration(HashMap configuration) { + throw new UnsupportedOperationException(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceMetric.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceMetric.java new file mode 100644 index 0000000..0050cd7 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceMetric.java @@ -0,0 +1,76 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.api.records.timelineservice; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; + +import java.util.HashMap; + +/** + * + */ +@Public +@Unstable +public class TimelineServiceMetric extends TimelineServiceEntity { + + public static final String ENTITY_TYPE = "metric"; + + protected boolean aggregate = false; + protected boolean critical = false; + protected Object metric; // TODO + + public TimelineServiceMetric() { + setEntityType(ENTITY_TYPE); + } + + public boolean isAggregate() { + return aggregate; + } + + public void setAggregate(boolean aggregate) { + this.aggregate = aggregate; + } + + public boolean isCritical() { + return critical; + } + + public void setCritical(boolean critical) { + this.critical = critical; + } + + public Object getMetric() { + return metric; + } + + public void setMetric(Object metric) { + this.metric = metric; + } + + @Override + public HashMap getConfiguration() { + throw new UnsupportedOperationException(); + } + + @Override + public void setConfiguration(HashMap configuration) { + throw new UnsupportedOperationException(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceUser.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceUser.java new file mode 100644 index 0000000..d112327 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/timelineservice/TimelineServiceUser.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.api.records.timelineservice; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; + +import java.util.HashMap; + +/** + * + */ +@Public +@Unstable +public class TimelineServiceUser extends TimelineServiceEntity { + + public static final String ENTITY_TYPE = "user"; + + public TimelineServiceUser() { + setEntityType(ENTITY_TYPE); + } + + @Override + public HashMap getConfiguration() { + throw new UnsupportedOperationException(); + } + + @Override + public void setConfiguration(HashMap configuration) { + throw new UnsupportedOperationException(); + } +}