ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpapirkovs...@apache.org
Subject [6/6] ambari git commit: AMBARI-9769. Exception when Ambari Metrics service is not installed. (mpapyrkovskyy)
Date Tue, 24 Feb 2015 13:46:15 GMT
AMBARI-9769. Exception when Ambari Metrics service is not installed. (mpapyrkovskyy)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ab0ab610
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ab0ab610
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ab0ab610

Branch: refs/heads/trunk
Commit: ab0ab610c1aef1c78b9aef5d8180fcbec76ee75c
Parents: d7b816f
Author: Myroslav Papirkovskyy <mpapyrkovskyy@hortonworks.com>
Authored: Tue Feb 24 14:23:57 2015 +0200
Committer: Myroslav Papirkovskyy <mpapyrkovskyy@hortonworks.com>
Committed: Tue Feb 24 15:45:58 2015 +0200

----------------------------------------------------------------------
 .../internal/AbstractProviderModule.java        | 65 ---------------
 .../internal/MetricsServiceProviderTest.java    | 83 --------------------
 2 files changed, 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ab0ab610/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
index 058dd1e..2d015c0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
@@ -248,9 +248,6 @@ public abstract class AbstractProviderModule implements ProviderModule,
     } catch (SystemException e) {
       LOG.error("Exception during checkInit.", e);
     }
-    if (clusterGangliaCollectorMap.isEmpty() && clusterMetricCollectorMap.isEmpty())
{
-      resetMetricProviderMap();
-    }
 
     if (!clusterMetricCollectorMap.isEmpty()) {
       return TIMELINE_METRICS;
@@ -260,68 +257,6 @@ public abstract class AbstractProviderModule implements ProviderModule,
     return null;
   }
 
-  private void resetMetricProviderMap() {
-    LOG.info("Resetting metric property provider.");
-    ResourceProvider provider = getResourceProvider(Resource.Type.Cluster);
-
-    Set<String> propertyIds = new HashSet<String>();
-    propertyIds.add(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID);
-
-    Map<String, String> requestInfoProperties = new HashMap<String, String>();
-    requestInfoProperties.put(ClusterResourceProvider.GET_IGNORE_PERMISSIONS_PROPERTY_ID,
"true");
-
-    Request request = PropertyHelper.getReadRequest(propertyIds,
-      requestInfoProperties, null, null, null);
-
-    try {
-      Set<Resource> clusters = provider.getResources(request, null);
-
-      if (clusters != null && !clusters.isEmpty()) {
-        for (Resource cluster : clusters) {
-          String clusterName = (String) cluster.getPropertyValue(CLUSTER_NAME_PROPERTY_ID);
-
-          request = PropertyHelper.getReadRequest(HOST_COMPONENT_HOST_NAME_PROPERTY_ID,
-            HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID);
-
-          Predicate predicate =
-            new PredicateBuilder().property(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID)
-              .equals(clusterName).and().property(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)
-              .equals(GANGLIA_SERVER).toPredicate();
-
-          provider = getResourceProvider(Resource.Type.HostComponent);
-          Set<Resource> hostComponents = provider.getResources(request, predicate);
-
-          if (hostComponents != null && !hostComponents.isEmpty()) {
-            Resource hostComponent = hostComponents.iterator().next();
-            String hostName = (String) hostComponent.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID);
-            clusterGangliaCollectorMap.put(clusterName, hostName);
-          }
-
-          predicate = new PredicateBuilder().property(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID)
-            .equals(clusterName).and().property(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)
-            .equals(METRIC_SERVER).toPredicate();
-
-          hostComponents = provider.getResources(request, predicate);
-          if (hostComponents != null && !hostComponents.isEmpty()) {
-            Resource hostComponent = hostComponents.iterator().next();
-            String hostName = (String) hostComponent.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID);
-            clusterMetricCollectorMap.put(clusterName, hostName);
-          }
-        }
-      }
-
-    } catch (SystemException e) {
-      LOG.warn("Error finding metrics provider.", e);
-    } catch (UnsupportedPropertyException e) {
-      LOG.warn("Error finding metrics provider.", e);
-    } catch (NoSuchResourceException e) {
-      LOG.warn("Error finding metrics provider.", e);
-    } catch (NoSuchParentResourceException e) {
-      LOG.warn("Error finding metrics provider.", e);
-    }
-
-  }
-
   // ----- MetricsHostProvider ------------------------------------------------
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/ab0ab610/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MetricsServiceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MetricsServiceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MetricsServiceProviderTest.java
index b15201b..869cdc8 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MetricsServiceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MetricsServiceProviderTest.java
@@ -27,16 +27,6 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.apache.ambari.server.controller.internal.ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID;
-import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID;
-import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID;
-import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_HOST_NAME_PROPERTY_ID;
-import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
@@ -45,79 +35,6 @@ import static org.mockito.Mockito.when;
 
 public class MetricsServiceProviderTest {
 
-  @SuppressWarnings("unchecked")
-  @Test
-  public void testResetMetricProviderMap() throws Exception {
-    TestMetricProviderModule providerModule = new TestMetricProviderModule();
-
-    ResourceProvider clusterResourceProvider = providerModule.getResourceProvider(Resource.Type.Cluster);
-
-    final Resource cluster = mock(Resource.class);
-    final Set<Resource> resources = new HashSet<Resource>() {{ add(cluster);
}};
-    when(clusterResourceProvider.getResources((Request) any(),
-      (Predicate) any())).thenReturn(resources);
-    when(cluster.getPropertyValue(CLUSTER_NAME_PROPERTY_ID)).thenReturn("c1");
-
-    // Assert requests and predicates used
-    ResourceProvider hostComponentResourceProvider = providerModule
-      .getResourceProvider(Resource.Type.HostComponent);
-
-    Set<String> propertyIds = new HashSet<String>();
-    propertyIds.add(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID);
-    propertyIds.add(HOST_COMPONENT_HOST_NAME_PROPERTY_ID);
-
-    Request expectedRequest = PropertyHelper.getReadRequest(propertyIds);
-
-    Predicate expectedPredicate1 =
-      new PredicateBuilder().property(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID)
-        .equals("c1").and().property(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)
-        .equals("GANGLIA_SERVER").toPredicate();
-
-    Predicate expectedPredicate2 =
-      new PredicateBuilder().property(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID)
-        .equals("c1").and().property(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)
-        .equals("METRICS_COLLECTOR").toPredicate();
-
-    ArgumentCaptor<Request> requestCapture = ArgumentCaptor.forClass(Request.class);
-    ArgumentCaptor<Predicate> predicateCapture = ArgumentCaptor.forClass(Predicate.class);
-
-    when(hostComponentResourceProvider.getResources(any(Request.class),
-      any(Predicate.class))).thenReturn(Collections.<Resource>emptySet());
-
-    // Assert default null
-    MetricsService service = providerModule.getMetricsServiceType();
-    verify(hostComponentResourceProvider, times(3)).getResources(requestCapture
-      .capture(), predicateCapture.capture());
-
-    List<Request> requests = requestCapture.getAllValues();
-    Request request1 = requests.get(requests.size() - 2); // GANGLIA check
-    Request request2 = requests.get(requests.size() - 1); // COLLECTOR check
-
-    List<Predicate> predicates = predicateCapture.getAllValues();
-    Predicate predicate1 = predicates.get(predicates.size() - 2);
-    Predicate predicate2 = predicates.get(predicates.size() - 1);
-
-    Assert.assertEquals(expectedRequest, request1);
-    Assert.assertEquals(expectedRequest, request2);
-    Assert.assertEquals(expectedPredicate1, predicate1);
-    Assert.assertEquals(expectedPredicate2, predicate2);
-
-    Assert.assertEquals(null, service);
-
-    // Assert change to actual service
-
-    final Resource hostComponent = mock(Resource.class);
-    Set<Resource> hostComponents = new HashSet<Resource>() {{ add(hostComponent);
}};
-    when(hostComponentResourceProvider.getResources(any(Request.class),
-      any(Predicate.class))).thenReturn(hostComponents);
-    when(hostComponent.getPropertyValue
-      (HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)).thenReturn("METRICS_COLLECTOR");
-    when(hostComponent.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID)).thenReturn("h1");
-
-    service = providerModule.getMetricsServiceType();
-    Assert.assertEquals(MetricsService.TIMELINE_METRICS, service);
-  }
-
   private static class TestMetricProviderModule extends AbstractProviderModule {
     ResourceProvider clusterResourceProvider = mock(ClusterResourceProvider.class);
 


Mime
View raw message