Repository: ambari Updated Branches: refs/heads/branch-2.2 dc9ebb728 -> f173878ac
AMBARI-15708 "Wrong metrics path " exceptions for JMX metrics (dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f173878a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f173878a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f173878a Branch: refs/heads/branch-2.2 Commit: f173878ac2cdb6ada8ca9fb3823f63b4028c7515 Parents: dc9ebb7 Author: Dmytro Sen <[email protected]> Authored: Tue Apr 5 18:12:21 2016 +0300 Committer: Dmytro Sen <[email protected]> Committed: Tue Apr 5 18:29:09 2016 +0300 ---------------------------------------------------------------------- .../server/api/services/AmbariMetaInfo.java | 27 +++++++++----------- .../state/alert/AggregateDefinitionMapping.java | 2 +- .../ambari/server/topology/PersistedState.java | 2 +- .../server/api/services/AmbariMetaInfoTest.java | 17 +++++++++++- .../StackDefinedPropertyProviderTest.java | 4 --- 5 files changed, 30 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f173878a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java index 2889f74..ecd9d70 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java @@ -913,24 +913,21 @@ public class AmbariMetaInfo { while (iterator.hasNext()) { Map.Entry<String, Metric> metricEntry = iterator.next(); // Process Namenode rpc metrics - Map<String, Metric> replacementMetrics = PropertyHelper.processRpcMetricDefinition(metricDefinition.getType(), + Map<String, Metric> processedMetrics = PropertyHelper.processRpcMetricDefinition(metricDefinition.getType(), componentName, metricEntry.getKey(), metricEntry.getValue()); - if (replacementMetrics != null) { + if (processedMetrics != null) { iterator.remove(); // Remove current metric entry - newMetricsToAdd.putAll(replacementMetrics); - // Add aggregate functions for replacement metrics - if (metricDefEntry.getKey().equals(Component.name())) { - for (Map.Entry<String, Metric> replacementMetric : replacementMetrics.entrySet()) { - newMetricsToAdd.putAll(getAggregateFunctionMetrics(replacementMetric.getKey(), - replacementMetric.getValue())); - } - } + newMetricsToAdd.putAll(processedMetrics); } else { - // NOTE: Only Component aggregates supported for now. - if (metricDefEntry.getKey().equals(Component.name())) { - Map<String, Metric> aggregateFunctionMetrics = - getAggregateFunctionMetrics(metricEntry.getKey(), metricEntry.getValue()); - newMetricsToAdd.putAll(aggregateFunctionMetrics); + processedMetrics = Collections.singletonMap(metricEntry.getKey(), metricEntry.getValue()); + } + + // NOTE: Only Component aggregates for AMS supported for now. + if (metricDefinition.getType().equals("ganglia") && + metricDefEntry.getKey().equals(Component.name())) { + for (Map.Entry<String, Metric> processedMetric : processedMetrics.entrySet()) { + newMetricsToAdd.putAll(getAggregateFunctionMetrics(processedMetric.getKey(), + processedMetric.getValue())); } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/f173878a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AggregateDefinitionMapping.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AggregateDefinitionMapping.java b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AggregateDefinitionMapping.java index 21ad99b..100537c 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AggregateDefinitionMapping.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AggregateDefinitionMapping.java @@ -96,7 +96,7 @@ public class AggregateDefinitionMapping { * * @param clusterId * the ID of the cluster that the definition is bound to. - * @param name + * @param aggregatedDefinitonName * the unique name of the definition for which aggregates should be * unassociated (not {@code null}). */ http://git-wip-us.apache.org/repos/asf/ambari/blob/f173878a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedState.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedState.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedState.java index 1ccd527..77419d8 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedState.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedState.java @@ -30,7 +30,7 @@ public interface PersistedState { /** * Persist a topology request. * - * @param topologyRequest topologyh request to persist + * @param topologyRequest topology request to persist * * @return a persisted topology request which is a wrapper around a TopologyRequest which * adds an id that can be used to refer to the persisted entity http://git-wip-us.apache.org/repos/asf/ambari/blob/f173878a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java index 3c8c5a3..9b08a8a 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java @@ -623,7 +623,7 @@ public class AmbariMetaInfoTest { @Test public void testGetStacks() { - Collection<StackInfo> stacks = metaInfo.getStacks(); + //Collection<StackInfo> stacks = metaInfo.getStacks(); //todo: complete test } @@ -873,6 +873,7 @@ public class AmbariMetaInfoTest { List<MetricDefinition> list = metaInfo.getMetrics(STACK_NAME_HDP, "2.0.5", "HDFS", SERVICE_COMPONENT_NAME, Resource.Type.Component.name()); Assert.assertNotNull(list); + checkNoAggregatedFunctionsForJmx(list); list = metaInfo.getMetrics(STACK_NAME_HDP, "2.0.5", "HDFS", "DATANODE", Resource.Type.Component.name()); Assert.assertNull(list); @@ -932,6 +933,8 @@ public class AmbariMetaInfoTest { if (list == null) { LOG.info("No metrics found for " + currentComponentInfo); continue; + } else { + checkNoAggregatedFunctionsForJmx(list); } LOG.info("Cross-checking JMX-to-Ganglia metrics for " + currentComponentInfo); @@ -1993,6 +1996,18 @@ public class AmbariMetaInfoTest { return metaInfo; } + private static void checkNoAggregatedFunctionsForJmx(List<MetricDefinition> metricDefinitions) { + for (MetricDefinition metricDefinition: metricDefinitions) { + if ("jmx".equals(metricDefinition.getType())) { + for (String metric: metricDefinition.getMetrics().keySet()) { + if (metric.endsWith("._sum")) { + Assert.fail("Aggregated functions aren't supported for JMX metrics. " + metric); + } + } + } + } + } + private static void waitForAllReposToBeResolved(AmbariMetaInfo metaInfo) throws Exception { int maxWait = 45000; int waitTime = 0; http://git-wip-us.apache.org/repos/asf/ambari/blob/f173878a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java index 9a4bf26..d55e023 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java @@ -878,10 +878,6 @@ public class StackDefinedPropertyProviderTest { Assert.assertEquals(1, propertyProvider.populateResources(Collections.singleton(resource), request, null).size()); - List<String> metricsRegexes = new ArrayList<String>(); - - metricsRegexes.add("metrics/yarn/Queue/$1.replaceAll(\"([.])\",\"/\")/"); - Assert.assertTrue(PropertyHelper.getProperties(resource).size() > 2); Assert.assertNotNull(resource.getPropertyValue(RM_AVAILABLE_MEMORY_PROPERTY)); }
