| /** |
| * 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.ambari.metrics.core.timeline; |
| |
| import org.apache.ambari.metrics.core.timeline.availability.MetricCollectorHAController; |
| import org.apache.ambari.metrics.core.timeline.discovery.TimelineMetricMetadataManager; |
| import org.apache.commons.logging.Log; |
| import org.apache.commons.logging.LogFactory; |
| |
| 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.Date; |
| import java.util.HashMap; |
| import java.util.Map; |
| |
| @XmlRootElement(name = "summary") |
| @XmlAccessorType(XmlAccessType.NONE) |
| /** |
| * Class to provide basic summary of the state for AMS. |
| * Can be used to add AMS health metrics in the future without trying to reach HBase. |
| */ |
| public class TimelineMetricServiceSummary { |
| |
| private Date timestamp; |
| private Map<String, String> metadataSummary = new HashMap<>(); |
| private Map<String, String> aggregationSummary = new HashMap<>(); |
| static final Log LOG = LogFactory.getLog(TimelineMetricServiceSummary.class); |
| |
| TimelineMetricServiceSummary(TimelineMetricMetadataManager metricMetadataManager, |
| MetricCollectorHAController haController) { |
| timestamp = new Date(System.currentTimeMillis()); |
| try { |
| metadataSummary = metricMetadataManager.getMetadataSummary(); |
| } catch (Exception e) { |
| LOG.error("Error fetching metadata summary : " + e); |
| } |
| if (haController != null) { |
| aggregationSummary = haController.getAggregationSummary(); |
| } |
| } |
| |
| @XmlElement(name = "timestamp") |
| public Date getTimestamp() { |
| return timestamp; |
| } |
| |
| @XmlElement(name = "metadata") |
| public Map<String, String> getMetadataSummary() { |
| return metadataSummary; |
| } |
| |
| @XmlElement(name = "aggregation") |
| public Map<String, String> getAggregationSummary() { |
| return aggregationSummary; |
| } |
| } |