incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject svn commit: r1490050 [3/3] - in /incubator/ambari/branches/branch-1.4.0/ambari-server/src: main/java/org/apache/ambari/server/controller/internal/ main/java/org/apache/ambari/server/controller/jmx/ main/java/org/apache/ambari/server/controller/utilitie...
Date Wed, 05 Jun 2013 22:22:35 GMT
Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProviderTest.java?rev=1490050&r1=1490049&r2=1490050&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProviderTest.java
(original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProviderTest.java
Wed Jun  5 22:22:35 2013
@@ -48,7 +48,7 @@ public class GangliaPropertyProviderTest
     TestGangliaHostProvider hostProvider = new TestGangliaHostProvider();
 
     GangliaPropertyProvider propertyProvider = new GangliaHostComponentPropertyProvider(
-        PropertyHelper.getGangliaPropertyIds(Resource.Type.HostComponent),
+        PropertyHelper.getGangliaPropertyIds(Resource.Type.HostComponent, PropertyHelper.MetricsVersion.HDP1),
         streamProvider,
         hostProvider,
         CLUSTER_NAME_PROPERTY_ID,
@@ -121,7 +121,7 @@ public class GangliaPropertyProviderTest
     TestGangliaHostProvider hostProvider = new TestGangliaHostProvider();
 
     GangliaPropertyProvider propertyProvider = new GangliaHostPropertyProvider(
-        PropertyHelper.getGangliaPropertyIds(Resource.Type.Host),
+        PropertyHelper.getGangliaPropertyIds(Resource.Type.Host, PropertyHelper.MetricsVersion.HDP1),
         streamProvider,
         hostProvider,
         CLUSTER_NAME_PROPERTY_ID,
@@ -164,7 +164,7 @@ public class GangliaPropertyProviderTest
     TestGangliaHostProvider hostProvider = new TestGangliaHostProvider();
 
     GangliaPropertyProvider propertyProvider = new GangliaHostPropertyProvider(
-        PropertyHelper.getGangliaPropertyIds(Resource.Type.Host),
+        PropertyHelper.getGangliaPropertyIds(Resource.Type.Host, PropertyHelper.MetricsVersion.HDP1),
         streamProvider,
         hostProvider,
         CLUSTER_NAME_PROPERTY_ID,

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/ganglia/GangliaReportPropertyProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/ganglia/GangliaReportPropertyProviderTest.java?rev=1490050&r1=1490049&r2=1490050&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/ganglia/GangliaReportPropertyProviderTest.java
(original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/ganglia/GangliaReportPropertyProviderTest.java
Wed Jun  5 22:22:35 2013
@@ -45,7 +45,7 @@ public class GangliaReportPropertyProvid
     TestGangliaHostProvider hostProvider = new TestGangliaHostProvider();
 
     GangliaReportPropertyProvider propertyProvider = new GangliaReportPropertyProvider(
-        PropertyHelper.getGangliaPropertyIds(Resource.Type.Cluster),
+        PropertyHelper.getGangliaPropertyIds(Resource.Type.Cluster, PropertyHelper.MetricsVersion.HDP1),
         streamProvider,
         hostProvider,
         CLUSTER_NAME_PROPERTY_ID);

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractPropertyProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractPropertyProviderTest.java?rev=1490050&r1=1490049&r2=1490050&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractPropertyProviderTest.java
(original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractPropertyProviderTest.java
Wed Jun  5 22:22:35 2013
@@ -37,14 +37,14 @@ public class AbstractPropertyProviderTes
 
   @Test
   public void testGetComponentMetrics() {
-    Map<String, Map<String, PropertyInfo>> componentMetrics = PropertyHelper.getGangliaPropertyIds(Resource.Type.HostComponent);
+    Map<String, Map<String, PropertyInfo>> componentMetrics = PropertyHelper.getGangliaPropertyIds(Resource.Type.HostComponent,
PropertyHelper.MetricsVersion.HDP1);
     AbstractPropertyProvider provider = new TestPropertyProvider(componentMetrics);
     Assert.assertEquals(componentMetrics, provider.getComponentMetrics());
   }
 
   @Test
   public void testGetPropertyInfoMap() {
-    AbstractPropertyProvider provider = new TestPropertyProvider(PropertyHelper.getGangliaPropertyIds(Resource.Type.HostComponent));
+    AbstractPropertyProvider provider = new TestPropertyProvider(PropertyHelper.getGangliaPropertyIds(Resource.Type.HostComponent,
PropertyHelper.MetricsVersion.HDP1));
 
     // specific property
     Map<String, PropertyInfo> propertyInfoMap = provider.getPropertyInfoMap("NAMENODE",
"metrics/cpu/cpu_aidle");

Added: incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersioningPropertyProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersioningPropertyProviderTest.java?rev=1490050&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersioningPropertyProviderTest.java
(added)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersioningPropertyProviderTest.java
Wed Jun  5 22:22:35 2013
@@ -0,0 +1,144 @@
+/**
+ * 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.server.controller.internal;
+
+import org.apache.ambari.server.controller.jmx.JMXPropertyProvider;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * VersioningPropertyProvider Tests
+ */
+public class VersioningPropertyProviderTest {
+  @Test
+  public void testPopulateResources() throws Exception {
+
+    Map<String, PropertyHelper.MetricsVersion> clusterVersionsMap =
+        new HashMap<String, PropertyHelper.MetricsVersion>();
+
+    clusterVersionsMap.put("c1", PropertyHelper.MetricsVersion.HDP1);
+    clusterVersionsMap.put("c2", PropertyHelper.MetricsVersion.HDP2);
+
+    Map<PropertyHelper.MetricsVersion, AbstractPropertyProvider> providers =
+        new HashMap<PropertyHelper.MetricsVersion, AbstractPropertyProvider>();
+
+    TestJMXPropertyProvider propertyProvider1 = new TestJMXPropertyProvider(
+        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.MetricsVersion.HDP1),
+        PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
+        PropertyHelper.getPropertyId("HostRoles", "host_name"),
+        PropertyHelper.getPropertyId("HostRoles", "component_name"),
+        PropertyHelper.getPropertyId("HostRoles", "state"),
+        Collections.singleton("STARTED"));
+    providers.put(PropertyHelper.MetricsVersion.HDP1, propertyProvider1);
+
+
+    TestJMXPropertyProvider propertyProvider2 = new TestJMXPropertyProvider(
+        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.MetricsVersion.HDP2),
+        PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
+        PropertyHelper.getPropertyId("HostRoles", "host_name"),
+        PropertyHelper.getPropertyId("HostRoles", "component_name"),
+        PropertyHelper.getPropertyId("HostRoles", "state"),
+        Collections.singleton("STARTED"));
+
+    providers.put(PropertyHelper.MetricsVersion.HDP2, propertyProvider2);
+
+
+    VersioningPropertyProvider provider = new VersioningPropertyProvider(clusterVersionsMap,
providers, PropertyHelper.getPropertyId("HostRoles", "cluster_name"));
+
+
+    Request request = PropertyHelper.getReadRequest();
+
+    Resource resource1 = new ResourceImpl(Resource.Type.HostComponent);
+    resource1.setProperty(PropertyHelper.getPropertyId("HostRoles", "cluster_name"), "c1");
+
+
+    provider.populateResources(Collections.singleton(resource1), request, null);
+
+    Assert.assertEquals(resource1, propertyProvider1.getResource());
+    Assert.assertNull(propertyProvider2.getResource());
+
+    propertyProvider1.setResource(null);
+    propertyProvider2.setResource(null);
+
+    Resource resource2 = new ResourceImpl(Resource.Type.HostComponent);
+    resource2.setProperty(PropertyHelper.getPropertyId("HostRoles", "cluster_name"), "c2");
+
+    provider.populateResources(Collections.singleton(resource2), request, null);
+
+    Assert.assertNull(propertyProvider1.getResource());
+    Assert.assertEquals(resource2, propertyProvider2.getResource());
+
+    propertyProvider1.setResource(null);
+    propertyProvider2.setResource(null);
+
+    Set<Resource> resources = new HashSet<Resource>();
+    resources.add(resource1);
+    resources.add(resource2);
+
+    provider.populateResources(resources, request, null);
+
+    Assert.assertEquals(resource1, propertyProvider1.getResource());
+    Assert.assertEquals(resource2, propertyProvider2.getResource());
+  }
+
+  private class TestJMXPropertyProvider extends JMXPropertyProvider {
+
+    private Resource resource = null;
+
+
+    public TestJMXPropertyProvider(Map<String, Map<String, PropertyInfo>> componentMetrics,
+                                   String clusterNamePropertyId,
+                                   String hostNamePropertyId,
+                                   String componentNamePropertyId,
+                                   String statePropertyId,
+                                   Set<String> healthyStates) {
+
+      super(componentMetrics, null, null, clusterNamePropertyId, hostNamePropertyId,
+          componentNamePropertyId, statePropertyId, healthyStates);
+    }
+
+    public Resource getResource() {
+      return resource;
+    }
+
+    public void setResource(Resource resource) {
+      this.resource = resource;
+    }
+
+    @Override
+    public Set<Resource> populateResources(Set<Resource> resources, Request request,
Predicate predicate) throws SystemException {
+
+      if (resources.size() == 1) {
+        resource = resources.iterator().next();
+      }
+      return resources;
+    }
+  }
+}

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java?rev=1490050&r1=1490049&r2=1490050&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
(original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
Wed Jun  5 22:22:35 2013
@@ -47,7 +47,7 @@ public class JMXPropertyProviderTest {
     TestJMXHostProvider hostProvider = new TestJMXHostProvider(false);
 
     JMXPropertyProvider propertyProvider = new JMXPropertyProvider(
-        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.JMXMetricsVersion.One),
+        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.MetricsVersion.HDP1),
         streamProvider,
         hostProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
@@ -234,7 +234,7 @@ public class JMXPropertyProviderTest {
     TestJMXHostProvider hostProvider = new TestJMXHostProvider(true);
 
     JMXPropertyProvider propertyProvider = new JMXPropertyProvider(
-        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.JMXMetricsVersion.One),
+        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.MetricsVersion.HDP1),
         streamProvider,
         hostProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
@@ -271,7 +271,7 @@ public class JMXPropertyProviderTest {
     TestJMXHostProvider hostProvider = new TestJMXHostProvider(true);
 
     JMXPropertyProvider propertyProvider = new JMXPropertyProvider(
-        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.JMXMetricsVersion.One),
+        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.MetricsVersion.HDP1),
         streamProvider,
         hostProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
@@ -304,7 +304,7 @@ public class JMXPropertyProviderTest {
     Set<Resource> resources = new HashSet<Resource>();
 
     JMXPropertyProvider propertyProvider = new JMXPropertyProvider(
-        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.JMXMetricsVersion.One),
+        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.MetricsVersion.HDP1),
         streamProvider,
         hostProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/PropertyHelperTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/PropertyHelperTest.java?rev=1490050&r1=1490049&r2=1490050&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/PropertyHelperTest.java
(original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/PropertyHelperTest.java
Wed Jun  5 22:22:35 2013
@@ -49,7 +49,7 @@ public class PropertyHelperTest {
   public void testGetJMXPropertyIds() {
 
     //version 1
-    Map<String, Map<String, PropertyInfo>> metrics = PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent,
PropertyHelper.JMXMetricsVersion.One);
+    Map<String, Map<String, PropertyInfo>> metrics = PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent,
PropertyHelper.MetricsVersion.HDP1);
     Map<String, PropertyInfo> componentMetrics = metrics.get("HISTORYSERVER");
     Assert.assertNull(componentMetrics);
     componentMetrics = metrics.get("NAMENODE");
@@ -59,7 +59,7 @@ public class PropertyHelperTest {
     Assert.assertEquals("Hadoop:service=NameNode,name=jvm.memHeapUsedM", info.getPropertyId());
 
     //version 2
-    metrics = PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.JMXMetricsVersion.Two);
+    metrics = PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent, PropertyHelper.MetricsVersion.HDP2);
     componentMetrics = metrics.get("HISTORYSERVER");
     Assert.assertNotNull(componentMetrics);
     componentMetrics = metrics.get("NAMENODE");



Mime
View raw message