Repository: ambari Updated Branches: refs/heads/trunk d9af23b18 -> 255f9ceb5
Revert "AMBARI-9764. Remove duplicated TimelineMetric datastructures from ambari-server. (mpapyrkovskyy)" This reverts commit eac00e7b2c7d6efde278be1f8ae6f419c38166dd. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/255f9ceb Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/255f9ceb Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/255f9ceb Branch: refs/heads/trunk Commit: 255f9ceb5e133a51d9fe0b9a822b18ebbad9a23d Parents: d9af23b Author: Yusaku Sako <[email protected]> Authored: Tue Feb 24 17:41:30 2015 -0800 Committer: Yusaku Sako <[email protected]> Committed: Tue Feb 24 17:41:35 2015 -0800 ---------------------------------------------------------------------- ambari-metrics/ambari-metrics-assembly/pom.xml | 1 - ambari-metrics/ambari-metrics-common/pom.xml | 22 --- .../ambari-metrics-flume-sink/pom.xml | 1 - .../ambari-metrics-hadoop-sink/pom.xml | 1 - .../ambari-metrics-host-monitoring/pom.xml | 1 - .../ambari-metrics-kafka-sink/pom.xml | 1 - .../ambari-metrics-storm-sink/pom.xml | 1 - .../ambari-metrics-timelineservice/pom.xml | 2 +- ambari-metrics/pom.xml | 45 ----- .../src/main/package/deb/control/control | 21 --- .../src/main/package/deb/control/postinst | 15 -- .../src/main/package/deb/control/postrm | 15 -- .../src/main/package/deb/control/posttrm | 15 -- .../src/main/package/deb/control/preinst | 15 -- .../src/main/package/deb/control/prerm | 15 -- ambari-server/pom.xml | 5 - .../metrics2/sink/timeline/TimelineMetric.java | 184 +++++++++++++++++++ .../metrics2/sink/timeline/TimelineMetrics.java | 103 +++++++++++ pom.xml | 5 - 19 files changed, 288 insertions(+), 180 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/ambari-metrics-assembly/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-assembly/pom.xml b/ambari-metrics/ambari-metrics-assembly/pom.xml index e7054d6..de85973 100644 --- a/ambari-metrics/ambari-metrics-assembly/pom.xml +++ b/ambari-metrics/ambari-metrics-assembly/pom.xml @@ -27,7 +27,6 @@ </parent> <modelVersion>4.0.0</modelVersion> <artifactId>ambari-metrics-assembly</artifactId> - <name>Ambari Metrics Assembly</name> <packaging>pom</packaging> <version>2.0.0-SNAPSHOT</version> http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/ambari-metrics-common/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-common/pom.xml b/ambari-metrics/ambari-metrics-common/pom.xml index 8ebd2f0..4658cfe 100644 --- a/ambari-metrics/ambari-metrics-common/pom.xml +++ b/ambari-metrics/ambari-metrics-common/pom.xml @@ -25,34 +25,12 @@ </parent> <modelVersion>4.0.0</modelVersion> <artifactId>ambari-metrics-common</artifactId> - <name>Ambari Metrics Common</name> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> </plugin> - <plugin> - <groupId>org.vafer</groupId> - <artifactId>jdeb</artifactId> - <version>1.0.1</version> - <executions> - <execution> - <!--Stub execution on direct plugin call - workaround for ambari deb build process--> - <id>stub-execution</id> - <phase>none</phase> - <goals> - <goal>jdeb</goal> - </goals> - </execution> - </executions> - <configuration> - <skip>true</skip> - <attach>false</attach> - <submodules>false</submodules> - <controlDir>${project.basedir}/../src/main/package/deb/control</controlDir> - </configuration> - </plugin> </plugins> </build> http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/ambari-metrics-flume-sink/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-flume-sink/pom.xml b/ambari-metrics/ambari-metrics-flume-sink/pom.xml index c4d94ab..f11b8b2 100644 --- a/ambari-metrics/ambari-metrics-flume-sink/pom.xml +++ b/ambari-metrics/ambari-metrics-flume-sink/pom.xml @@ -27,7 +27,6 @@ limitations under the License. <modelVersion>4.0.0</modelVersion> <artifactId>ambari-metrics-flume-sink</artifactId> <version>2.0.0-SNAPSHOT</version> - <name>Ambari Metrics Flume Sink</name> <packaging>jar</packaging> <build> <plugins> http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/ambari-metrics-hadoop-sink/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-hadoop-sink/pom.xml b/ambari-metrics/ambari-metrics-hadoop-sink/pom.xml index d3f4888..848a8f2 100644 --- a/ambari-metrics/ambari-metrics-hadoop-sink/pom.xml +++ b/ambari-metrics/ambari-metrics-hadoop-sink/pom.xml @@ -27,7 +27,6 @@ limitations under the License. <modelVersion>4.0.0</modelVersion> <artifactId>ambari-metrics-hadoop-sink</artifactId> <version>2.0.0-SNAPSHOT</version> - <name>Ambari Metrics Hadoop Sink</name> <packaging>jar</packaging> <properties> <sinkJarName>${project.artifactId}-with-common-${project.version}.jar</sinkJarName> http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/ambari-metrics-host-monitoring/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-host-monitoring/pom.xml b/ambari-metrics/ambari-metrics-host-monitoring/pom.xml index 746949b..7461bd6 100644 --- a/ambari-metrics/ambari-metrics-host-monitoring/pom.xml +++ b/ambari-metrics/ambari-metrics-host-monitoring/pom.xml @@ -28,7 +28,6 @@ <packaging>pom</packaging> <version>2.0.0-SNAPSHOT</version> <artifactId>ambari-metrics-host-monitoring</artifactId> - <name>Ambari Metrics Monitor</name> <properties> <resmonitor.install.dir> /usr/lib/python2.6/site-packages/resource_monitoring http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/ambari-metrics-kafka-sink/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-kafka-sink/pom.xml b/ambari-metrics/ambari-metrics-kafka-sink/pom.xml index b4a783d..e385935 100644 --- a/ambari-metrics/ambari-metrics-kafka-sink/pom.xml +++ b/ambari-metrics/ambari-metrics-kafka-sink/pom.xml @@ -27,7 +27,6 @@ limitations under the License. <modelVersion>4.0.0</modelVersion> <artifactId>ambari-metrics-kafka-sink</artifactId> <version>2.0.0-SNAPSHOT</version> - <name>Ambari Metrics Kafka Sink</name> <packaging>jar</packaging> <build> <plugins> http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/ambari-metrics-storm-sink/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-storm-sink/pom.xml b/ambari-metrics/ambari-metrics-storm-sink/pom.xml index ff7cdff..d069622 100644 --- a/ambari-metrics/ambari-metrics-storm-sink/pom.xml +++ b/ambari-metrics/ambari-metrics-storm-sink/pom.xml @@ -27,7 +27,6 @@ limitations under the License. <modelVersion>4.0.0</modelVersion> <artifactId>ambari-metrics-storm-sink</artifactId> <version>2.0.0-SNAPSHOT</version> - <name>Ambari Metrics Storm Sink</name> <packaging>jar</packaging> <properties> http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/ambari-metrics-timelineservice/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/pom.xml b/ambari-metrics/ambari-metrics-timelineservice/pom.xml index 4ec730e..97cc6af 100644 --- a/ambari-metrics/ambari-metrics-timelineservice/pom.xml +++ b/ambari-metrics/ambari-metrics-timelineservice/pom.xml @@ -27,7 +27,7 @@ <modelVersion>4.0.0</modelVersion> <artifactId>ambari-metrics-timelineservice</artifactId> <version>2.0.0-SNAPSHOT</version> - <name>Ambari Metrics Collector</name> + <name>ambari-metrics-timelineservice</name> <packaging>jar</packaging> <properties> http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/pom.xml b/ambari-metrics/pom.xml index 6fc0155..41ba1fc 100644 --- a/ambari-metrics/pom.xml +++ b/ambari-metrics/pom.xml @@ -164,51 +164,6 @@ </execution> </executions> </plugin> - <plugin> - <!--Stub execution on direct plugin call - workaround for ambari rpm build process--> - <groupId>org.codehaus.mojo</groupId> - <artifactId>rpm-maven-plugin</artifactId> - <version>2.0.1</version> - <executions> - <execution> - <id>stub-execution</id> - <!-- unbinds rpm creation from maven lifecycle --> - <phase>none</phase> - <goals> - <goal>attached-rpm</goal> - </goals> - </execution> - </executions> - <configuration> - <copyright>2012, Apache Software Foundation</copyright> - <group>Development</group> - <description>Maven Recipe: RPM Package.</description> - <release>${package-release}</release> - <version>${package-version}</version> - <mappings/> - </configuration> - </plugin> - <plugin> - <groupId>org.vafer</groupId> - <artifactId>jdeb</artifactId> - <version>1.0.1</version> - <executions> - <execution> - <!--Stub execution on direct plugin call - workaround for ambari deb build process--> - <id>stub-execution</id> - <phase>none</phase> - <goals> - <goal>jdeb</goal> - </goals> - </execution> - </executions> - <configuration> - <skip>true</skip> - <attach>false</attach> - <submodules>true</submodules> - <controlDir>${project.basedir}/src/main/package/deb/control</controlDir> - </configuration> - </plugin> </plugins> </build> http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/src/main/package/deb/control/control ---------------------------------------------------------------------- diff --git a/ambari-metrics/src/main/package/deb/control/control b/ambari-metrics/src/main/package/deb/control/control deleted file mode 100644 index d00c2cd..0000000 --- a/ambari-metrics/src/main/package/deb/control/control +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License -Package: [[artifactId]] -Version: [[package-version]]-[[package-release]] -Section: [[deb.section]] -Priority: [[deb.priority]] -Architecture: [[deb.architecture]] -Description: [[description]] -Maintainer: [[deb.publisher]] http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/src/main/package/deb/control/postinst ---------------------------------------------------------------------- diff --git a/ambari-metrics/src/main/package/deb/control/postinst b/ambari-metrics/src/main/package/deb/control/postinst deleted file mode 100644 index 21a01fa..0000000 --- a/ambari-metrics/src/main/package/deb/control/postinst +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# 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 http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/src/main/package/deb/control/postrm ---------------------------------------------------------------------- diff --git a/ambari-metrics/src/main/package/deb/control/postrm b/ambari-metrics/src/main/package/deb/control/postrm deleted file mode 100644 index 21a01fa..0000000 --- a/ambari-metrics/src/main/package/deb/control/postrm +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# 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 http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/src/main/package/deb/control/posttrm ---------------------------------------------------------------------- diff --git a/ambari-metrics/src/main/package/deb/control/posttrm b/ambari-metrics/src/main/package/deb/control/posttrm deleted file mode 100644 index 21a01fa..0000000 --- a/ambari-metrics/src/main/package/deb/control/posttrm +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# 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 http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/src/main/package/deb/control/preinst ---------------------------------------------------------------------- diff --git a/ambari-metrics/src/main/package/deb/control/preinst b/ambari-metrics/src/main/package/deb/control/preinst deleted file mode 100644 index 21a01fa..0000000 --- a/ambari-metrics/src/main/package/deb/control/preinst +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# 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 http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-metrics/src/main/package/deb/control/prerm ---------------------------------------------------------------------- diff --git a/ambari-metrics/src/main/package/deb/control/prerm b/ambari-metrics/src/main/package/deb/control/prerm deleted file mode 100644 index 21a01fa..0000000 --- a/ambari-metrics/src/main/package/deb/control/prerm +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# 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 http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-server/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml index c60dd0d..e9d9fac 100644 --- a/ambari-server/pom.xml +++ b/ambari-server/pom.xml @@ -1761,11 +1761,6 @@ <artifactId>commons-io</artifactId> <version>1.3.2</version> </dependency> - <dependency> - <groupId>org.apache.ambari</groupId> - <artifactId>ambari-metrics-common</artifactId> - <version>${project.version}</version> - </dependency> </dependencies> <pluginRepositories> http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetric.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetric.java b/ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetric.java new file mode 100644 index 0000000..843aecd --- /dev/null +++ b/ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetric.java @@ -0,0 +1,184 @@ +/** + * 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.metrics2.sink.timeline; + +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.text.DecimalFormat; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + +@XmlRootElement(name = "metric") +@XmlAccessorType(XmlAccessType.NONE) +public class TimelineMetric implements Comparable<TimelineMetric> { + + private String metricName; + private String appId; + private String instanceId; + private String hostName; + private long timestamp; + private long startTime; + private String type; + private Map<Long, Double> metricValues = new TreeMap<Long, Double>(); + + @XmlElement(name = "metricname") + public String getMetricName() { + return metricName; + } + + public void setMetricName(String metricName) { + this.metricName = metricName; + } + + @XmlElement(name = "appid") + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + @XmlElement(name = "instanceid") + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + @XmlElement(name = "hostname") + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + @XmlElement(name = "timestamp") + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + @XmlElement(name = "starttime") + public long getStartTime() { + return startTime; + } + + public void setStartTime(long startTime) { + this.startTime = startTime; + } + + @XmlElement(name = "type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @XmlElement(name = "metrics") + public Map<Long, Double> getMetricValues() { + return metricValues; + } + + public void setMetricValues(Map<Long, Double> metricValues) { + this.metricValues = metricValues; + } + + public void addMetricValues(Map<Long, Double> metricValues) { + this.metricValues.putAll(metricValues); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + TimelineMetric metric = (TimelineMetric) o; + + if (!metricName.equals(metric.metricName)) return false; + if (hostName != null ? !hostName.equals(metric.hostName) : metric.hostName != null) + return false; + if (!appId.equals(metric.appId)) return false; + if (instanceId != null ? !instanceId.equals(metric.instanceId) : metric.instanceId != null) + return false; + if (timestamp != metric.timestamp) return false; + if (startTime != metric.startTime) return false; + + return true; + } + + public boolean equalsExceptTime(TimelineMetric metric) { + if (!metricName.equals(metric.metricName)) return false; + if (hostName != null ? !hostName.equals(metric.hostName) : metric.hostName != null) + return false; + if (!appId.equals(metric.appId)) return false; + if (instanceId != null ? !instanceId.equals(metric.instanceId) : metric.instanceId != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = metricName.hashCode(); + result = 31 * result + appId.hashCode(); + result = 31 * result + (instanceId != null ? instanceId.hashCode() : 0); + result = 31 * result + (hostName != null ? hostName.hashCode() : 0); + result = 31 * result + (int) (timestamp ^ (timestamp >>> 32)); + return result; + } + + @Override + public int compareTo(TimelineMetric other) { + if (timestamp > other.timestamp) { + return -1; + } else if (timestamp < other.timestamp) { + return 1; + } else { + return metricName.compareTo(other.metricName); + } + } + + @Override + public String toString() { + return "TimelineMetric{" + + "metricName='" + metricName + '\'' + + ", appId='" + appId + '\'' + + ", instanceId='" + instanceId + '\'' + + ", hostName='" + hostName + '\'' + + ", timestamp=" + timestamp + + ", startTime=" + startTime + + ", type='" + type + '\'' + + ", metricValues=" + metricValues + + '}'; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetrics.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetrics.java b/ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetrics.java new file mode 100644 index 0000000..0448fdb --- /dev/null +++ b/ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetrics.java @@ -0,0 +1,103 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.metrics2.sink.timeline; + +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; + +/** + * The class that hosts a list of timeline entities. + */ +@XmlRootElement(name = "metrics") +@XmlAccessorType(XmlAccessType.NONE) +public class TimelineMetrics { + + private List<TimelineMetric> allMetrics = new ArrayList<TimelineMetric>(); + + public TimelineMetrics() {} + + @XmlElement(name = "metrics") + public List<TimelineMetric> getMetrics() { + return allMetrics; + } + + public void setMetrics(List<TimelineMetric> allMetrics) { + this.allMetrics = allMetrics; + } + + private boolean isEqualTimelineMetrics(TimelineMetric metric1, + TimelineMetric metric2) { + + boolean isEqual = true; + + if (!metric1.getMetricName().equals(metric2.getMetricName())) { + return false; + } + + if (metric1.getHostName() != null) { + isEqual = metric1.getHostName().equals(metric2.getHostName()); + } + + if (metric1.getAppId() != null) { + isEqual = metric1.getAppId().equals(metric2.getAppId()); + } + + return isEqual; + } + + @Override + public String toString() { + return "TimelineMetrics{" + + "allMetrics=" + allMetrics + + '}'; + } + + /** + * Merge with existing TimelineMetric if everything except startTime is + * the same. + * @param metric {@link TimelineMetric} + */ + public void addOrMergeTimelineMetric(TimelineMetric metric) { + TimelineMetric metricToMerge = null; + + if (!allMetrics.isEmpty()) { + for (TimelineMetric timelineMetric : allMetrics) { + if (timelineMetric.equalsExceptTime(metric)) { + metricToMerge = timelineMetric; + break; + } + } + } + + if (metricToMerge != null) { + metricToMerge.addMetricValues(metric.getMetricValues()); + if (metricToMerge.getTimestamp() > metric.getTimestamp()) { + metricToMerge.setTimestamp(metric.getTimestamp()); + } + if (metricToMerge.getStartTime() > metric.getStartTime()) { + metricToMerge.setStartTime(metric.getStartTime()); + } + } else { + allMetrics.add(metric); + } + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/255f9ceb/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 9fc2c90..bafff2e 100644 --- a/pom.xml +++ b/pom.xml @@ -345,7 +345,6 @@ <!-- Metrics module --> <!-- psutil : external lib, Apache 2.0 license included as a source file --> - <exclude>ambari-metrics/target/**</exclude> <exclude>ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil/**</exclude> <exclude>ambari-metrics/target/rpm/ambari-metrics/SPECS/ambari-metrics.spec</exclude> <exclude>ambari-metrics/ambari-metrics-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/4.2.0/phoenix-core-tests-4.2.0.pom</exclude> @@ -418,7 +417,6 @@ <module>ambari-agent</module> <module>ambari-client</module> <module>ambari-shell</module> - <module>ambari-metrics/ambari-metrics-common</module> </modules> </profile> <profile> @@ -431,7 +429,6 @@ <module>ambari-agent</module> <module>ambari-client</module> <module>ambari-shell</module> - <module>ambari-metrics/ambari-metrics-common</module> </modules> </profile> <profile> @@ -450,7 +447,6 @@ <module>ambari-agent</module> <module>ambari-client</module> <module>ambari-shell</module> - <module>ambari-metrics/ambari-metrics-common</module> </modules> </profile> <profile> @@ -476,7 +472,6 @@ <module>ambari-agent</module> <module>ambari-client</module> <module>ambari-shell</module> - <module>ambari-metrics/ambari-metrics-common</module> </modules> </profile> <profile>
