ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From avija...@apache.org
Subject ambari git commit: AMBARI-15982 : AMS metrics gaps/inconsistencies in data (avijayan)
Date Tue, 19 Apr 2016 22:58:39 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 0a13257f8 -> 43567ff1d


AMBARI-15982 : AMS metrics gaps/inconsistencies in data (avijayan)


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

Branch: refs/heads/trunk
Commit: 43567ff1de4f5260679d70eb784d9955303fca26
Parents: 0a13257
Author: Aravindan Vijayan <avijayan@hortonworks.com>
Authored: Tue Apr 19 15:58:21 2016 -0700
Committer: Aravindan Vijayan <avijayan@hortonworks.com>
Committed: Tue Apr 19 15:58:28 2016 -0700

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog240.java       | 16 +++++-
 .../server/upgrade/UpgradeCatalog240Test.java   | 55 ++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/43567ff1/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index b621e86..d4d47bf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@ -103,6 +103,9 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
 
   private static final String OOZIE_ENV_CONFIG = "oozie-env";
   private static final String HIVE_ENV_CONFIG = "hive-env";
+  private static final String AMS_SITE = "ams-site";
+  public static final String TIMELINE_METRICS_SINK_COLLECTION_PERIOD = "timeline.metrics.sink.collection.period";
+
 
   @Inject
   PermissionDAO permissionDAO;
@@ -1282,7 +1285,7 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
             updateConfigurationPropertiesForCluster(cluster, "ams-hbase-env", newProperties,
true, true);
           }
 
-          Config amsSite = cluster.getDesiredConfigByType("ams-site");
+          Config amsSite = cluster.getDesiredConfigByType(AMS_SITE);
           if (amsSite != null) {
             String metadataFilters = amsSite.getProperties().get("timeline.metrics.service.metadata.filters");
             if (StringUtils.isEmpty(metadataFilters) ||
@@ -1290,6 +1293,17 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
               updateConfigurationProperties("ams-site",
                 Collections.singletonMap("timeline.metrics.service.metadata.filters", "ContainerResource"),
true, false);
             }
+
+            Map<String, String> amsSiteProperties = amsSite.getProperties();
+            Map<String, String> newProperties = new HashMap<>();
+
+            if (!amsSiteProperties.containsKey(TIMELINE_METRICS_SINK_COLLECTION_PERIOD) ||
+              "60".equals(amsSiteProperties.get(TIMELINE_METRICS_SINK_COLLECTION_PERIOD)))
{
+
+              newProperties.put(TIMELINE_METRICS_SINK_COLLECTION_PERIOD, "10");
+              LOG.info("Setting value of " + TIMELINE_METRICS_SINK_COLLECTION_PERIOD + "
: 10");
+            }
+            updateConfigurationPropertiesForCluster(cluster, AMS_SITE, newProperties, true,
true);
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/43567ff1/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
index 1b6b3aa..c091262 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
@@ -759,6 +759,61 @@ public class UpgradeCatalog240Test {
   }
 
   @Test
+  public void testAmsSiteUpdateConfigs() throws Exception{
+
+    Map<String, String> oldPropertiesAmsSite = new HashMap<String, String>()
{
+      {
+        put("timeline.metrics.sink.collection.period", "60");
+      }
+    };
+    Map<String, String> newPropertiesAmsSite = new HashMap<String, String>()
{
+      {
+        put("timeline.metrics.sink.collection.period", "10");
+      }
+    };
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+
+    Clusters clusters = easyMockSupport.createNiceMock(Clusters.class);
+    final Cluster cluster = easyMockSupport.createNiceMock(Cluster.class);
+    Config mockAmsSite = easyMockSupport.createNiceMock(Config.class);
+
+    expect(clusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+      put("normal", cluster);
+    }}).once();
+    expect(cluster.getDesiredConfigByType("ams-site")).andReturn(mockAmsSite).atLeastOnce();
+    expect(mockAmsSite.getProperties()).andReturn(oldPropertiesAmsSite).anyTimes();
+
+    Injector injector = easyMockSupport.createNiceMock(Injector.class);
+    expect(injector.getInstance(Gson.class)).andReturn(null).anyTimes();
+    expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null).anyTimes();
+    expect(injector.getInstance(KerberosHelper.class)).andReturn(createNiceMock(KerberosHelper.class)).anyTimes();
+
+    replay(injector, clusters, mockAmsSite, cluster);
+
+    AmbariManagementControllerImpl controller = createMockBuilder(AmbariManagementControllerImpl.class)
+      .addMockedMethod("createConfiguration")
+      .addMockedMethod("getClusters", new Class[] { })
+      .addMockedMethod("createConfig")
+      .withConstructor(createNiceMock(ActionManager.class), clusters, injector)
+      .createNiceMock();
+
+    Injector injector2 = easyMockSupport.createNiceMock(Injector.class);
+    Capture<Map> propertiesCapture = EasyMock.newCapture();
+
+    expect(injector2.getInstance(AmbariManagementController.class)).andReturn(controller).anyTimes();
+    expect(controller.getClusters()).andReturn(clusters).anyTimes();
+    expect(controller.createConfig(anyObject(Cluster.class), anyString(), capture(propertiesCapture),
anyString(),
+      anyObject(Map.class))).andReturn(createNiceMock(Config.class)).once();
+
+    replay(controller, injector2);
+    new UpgradeCatalog240(injector2).updateAMSConfigs();
+    easyMockSupport.verifyAll();
+
+    Map<String, String> updatedProperties = propertiesCapture.getValue();
+    assertTrue(Maps.difference(newPropertiesAmsSite, updatedProperties).areEqual());
+  }
+
+  @Test
   public void testUpdateKerberosConfiguration() throws Exception {
     final AmbariManagementController controller = createNiceMock(AmbariManagementController.class);
     final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);


Mime
View raw message