Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D8C5A10372 for ; Wed, 25 Feb 2015 02:07:08 +0000 (UTC) Received: (qmail 72609 invoked by uid 500); 25 Feb 2015 02:07:08 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 72584 invoked by uid 500); 25 Feb 2015 02:07:08 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 72575 invoked by uid 99); 25 Feb 2015 02:07:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Feb 2015 02:07:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9E4FAE03E8; Wed, 25 Feb 2015 02:07:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yusaku@apache.org To: commits@ambari.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: Revert "AMBARI-9764. Remove duplicated TimelineMetric datastructures from ambari-server. (mpapyrkovskyy)" Date: Wed, 25 Feb 2015 02:07:08 +0000 (UTC) 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 Authored: Tue Feb 24 17:41:30 2015 -0800 Committer: Yusaku Sako 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 @@ 4.0.0 ambari-metrics-assembly - Ambari Metrics Assembly pom 2.0.0-SNAPSHOT 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 @@ 4.0.0 ambari-metrics-common - Ambari Metrics Common maven-compiler-plugin 3.0 - - org.vafer - jdeb - 1.0.1 - - - - stub-execution - none - - jdeb - - - - - true - false - false - ${project.basedir}/../src/main/package/deb/control - - 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. 4.0.0 ambari-metrics-flume-sink 2.0.0-SNAPSHOT - Ambari Metrics Flume Sink jar 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. 4.0.0 ambari-metrics-hadoop-sink 2.0.0-SNAPSHOT - Ambari Metrics Hadoop Sink jar ${project.artifactId}-with-common-${project.version}.jar 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 @@ pom 2.0.0-SNAPSHOT ambari-metrics-host-monitoring - Ambari Metrics Monitor /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. 4.0.0 ambari-metrics-kafka-sink 2.0.0-SNAPSHOT - Ambari Metrics Kafka Sink jar 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. 4.0.0 ambari-metrics-storm-sink 2.0.0-SNAPSHOT - Ambari Metrics Storm Sink jar 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 @@ 4.0.0 ambari-metrics-timelineservice 2.0.0-SNAPSHOT - Ambari Metrics Collector + ambari-metrics-timelineservice jar 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 @@ - - - org.codehaus.mojo - rpm-maven-plugin - 2.0.1 - - - stub-execution - - none - - attached-rpm - - - - - 2012, Apache Software Foundation - Development - Maven Recipe: RPM Package. - ${package-release} - ${package-version} - - - - - org.vafer - jdeb - 1.0.1 - - - - stub-execution - none - - jdeb - - - - - true - false - true - ${project.basedir}/src/main/package/deb/control - - 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 @@ commons-io 1.3.2 - - org.apache.ambari - ambari-metrics-common - ${project.version} - 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 { + + private String metricName; + private String appId; + private String instanceId; + private String hostName; + private long timestamp; + private long startTime; + private String type; + private Map metricValues = new TreeMap(); + + @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 getMetricValues() { + return metricValues; + } + + public void setMetricValues(Map metricValues) { + this.metricValues = metricValues; + } + + public void addMetricValues(Map 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 allMetrics = new ArrayList(); + + public TimelineMetrics() {} + + @XmlElement(name = "metrics") + public List getMetrics() { + return allMetrics; + } + + public void setMetrics(List 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 @@ - ambari-metrics/target/** ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil/** ambari-metrics/target/rpm/ambari-metrics/SPECS/ambari-metrics.spec 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 @@ -418,7 +417,6 @@ ambari-agent ambari-client ambari-shell - ambari-metrics/ambari-metrics-common @@ -431,7 +429,6 @@ ambari-agent ambari-client ambari-shell - ambari-metrics/ambari-metrics-common @@ -450,7 +447,6 @@ ambari-agent ambari-client ambari-shell - ambari-metrics/ambari-metrics-common @@ -476,7 +472,6 @@ ambari-agent ambari-client ambari-shell - ambari-metrics/ambari-metrics-common