You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/11/04 14:37:01 UTC

[34/50] [abbrv] ambari git commit: AMBARI-13603. Alerts: Rename "Ambari Agent Disk Usage" alert (aonishuk)

AMBARI-13603. Alerts: Rename "Ambari Agent Disk Usage" alert (aonishuk)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: f24058f79e9b12e8c80aa4c03f6b82b0123ce7c3
Parents: 9ce6311
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Tue Nov 3 16:29:16 2015 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Tue Nov 3 16:29:16 2015 +0200

----------------------------------------------------------------------
 ambari-server/docs/api/v1/alerts.md             |  4 +-
 .../server/upgrade/UpgradeCatalog213.java       | 34 ++++++---
 ambari-server/src/main/resources/alerts.json    |  6 +-
 .../server/upgrade/UpgradeCatalog213Test.java   | 76 ++++++++++++++++----
 .../assets/data/alerts/alertDefinitions.json    |  4 +-
 .../app/assets/data/alerts/alert_instances.json |  2 +-
 .../app/assets/data/alerts/alert_summary.json   |  2 +-
 .../test/mappers/alert_instances_mapper_test.js |  2 +-
 8 files changed, 95 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f24058f7/ambari-server/docs/api/v1/alerts.md
----------------------------------------------------------------------
diff --git a/ambari-server/docs/api/v1/alerts.md b/ambari-server/docs/api/v1/alerts.md
index f2c50a8..1ee13c5 100644
--- a/ambari-server/docs/api/v1/alerts.md
+++ b/ambari-server/docs/api/v1/alerts.md
@@ -48,7 +48,7 @@ Current alerts can be exposed on the following resource endpoints:
             "host_name" : "<host>",
             "id" : 2,
             "instance" : null,
-            "label" : "Ambari Agent Disk Usage",
+            "label" : "Host Disk Usage",
             "latest_timestamp" : 1425704842163,
             "maintenance_state" : "OFF",
             "original_timestamp" : 1425600467615,
@@ -188,4 +188,4 @@ History can be exposed on the following resource endpoints:
 
 ##### All alerting events for HDFS and YARN
     GET api/v1/clusters/c1/alert_history?(AlertHistory/service_name.in(HDFS,YARN))
-        
\ No newline at end of file
+        

http://git-wip-us.apache.org/repos/asf/ambari/blob/f24058f7/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
index 34072dc..895d24b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
@@ -202,9 +202,9 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
 
   private void executeBlueprintDDLUpdates() throws AmbariException, SQLException {
     dbAccessor.addColumn(BLUEPRINT_TABLE, new DBAccessor.DBColumnInfo(SECURITY_TYPE_COLUMN,
-      String.class, 32, "NONE", false));
+        String.class, 32, "NONE", false));
     dbAccessor.addColumn(BLUEPRINT_TABLE, new DBAccessor.DBColumnInfo(SECURITY_DESCRIPTOR_REF_COLUMN,
-      String.class, null, null, true));
+        String.class, null, null, true));
   }
 
     /**
@@ -628,19 +628,33 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
 
     Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters);
     for (final Cluster cluster : clusterMap.values()) {
-      final AlertDefinitionEntity alertDefinitionEntity = alertDefinitionDAO.findByName(
-        cluster.getClusterId(), "journalnode_process");
+      long clusterID = cluster.getClusterId();
 
-      if (alertDefinitionEntity != null) {
-        String source = alertDefinitionEntity.getSource();
+      final AlertDefinitionEntity journalNodeProcessAlertDefinitionEntity = alertDefinitionDAO.findByName(
+          clusterID, "journalnode_process");
+      final AlertDefinitionEntity hostDiskUsageAlertDefinitionEntity = alertDefinitionDAO.findByName(
+          clusterID, "ambari_agent_disk_usage");
 
-        alertDefinitionEntity.setSource(modifyJournalnodeProcessAlertSource(source));
-        alertDefinitionEntity.setSourceType(SourceType.WEB);
-        alertDefinitionEntity.setHash(UUID.randomUUID().toString());
+      if (journalNodeProcessAlertDefinitionEntity != null) {
+        String source = journalNodeProcessAlertDefinitionEntity.getSource();
 
-        alertDefinitionDAO.merge(alertDefinitionEntity);
+        journalNodeProcessAlertDefinitionEntity.setSource(modifyJournalnodeProcessAlertSource(source));
+        journalNodeProcessAlertDefinitionEntity.setSourceType(SourceType.WEB);
+        journalNodeProcessAlertDefinitionEntity.setHash(UUID.randomUUID().toString());
+
+        alertDefinitionDAO.merge(journalNodeProcessAlertDefinitionEntity);
         LOG.info("journalnode_process alert definition was updated.");
       }
+
+      if (hostDiskUsageAlertDefinitionEntity != null) {
+        hostDiskUsageAlertDefinitionEntity.setDescription("This host-level alert is triggered if the amount of disk space " +
+            "used goes above specific thresholds. The default threshold values are 50% for WARNING and 80% for CRITICAL.");
+        hostDiskUsageAlertDefinitionEntity.setLabel("Host Disk Usage");
+
+        alertDefinitionDAO.merge(hostDiskUsageAlertDefinitionEntity);
+        LOG.info("ambari_agent_disk_usage alert definition was updated.");
+      }
+
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f24058f7/ambari-server/src/main/resources/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/alerts.json b/ambari-server/src/main/resources/alerts.json
index 6a50223..e584b2c 100644
--- a/ambari-server/src/main/resources/alerts.json
+++ b/ambari-server/src/main/resources/alerts.json
@@ -31,8 +31,8 @@
     "AMBARI_AGENT" : [
       {
         "name": "ambari_agent_disk_usage",
-        "label": "Ambari Agent Disk Usage",
-        "description": "This host-level alert is triggered if the amount of disk space used on a host goes above specific thresholds. The default values are 50% for WARNING and 80% for CRITICAL.",
+        "label": "Host Disk Usage",
+        "description": "This host-level alert is triggered if the amount of disk space used goes above specific thresholds. The default threshold values are 50% for WARNING and 80% for CRITICAL.",
         "interval": 1,
         "scope": "HOST",
         "enabled": true,
@@ -72,4 +72,4 @@
       }
     ]
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f24058f7/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
index 59d3f1a..fff720a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
@@ -33,12 +33,14 @@ import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.dao.ClusterDAO;
+import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
 import org.apache.ambari.server.orm.dao.DaoUtils;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.dao.StackDAO;
 import org.apache.ambari.server.orm.entities.ClusterEntity;
+import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
 import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.HostEntity;
 import org.apache.ambari.server.orm.entities.HostVersionEntity;
@@ -591,22 +593,66 @@ public class UpgradeCatalog213Test {
   }
 
   @Test
-  public void testModifyJournalnodeProcessAlertSource() throws Exception {
+  public void testUpdateAlertDefinitions() {
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
     UpgradeCatalog213 upgradeCatalog213 = new UpgradeCatalog213(injector);
-    String alertSource = "{\"uri\":\"{{hdfs-site/dfs.journalnode.http-address}}\",\"default_port\":8480," +
-      "\"type\":\"PORT\",\"reporting\":{\"ok\":{\"text\":\"TCP OK - {0:.3f}s response on port {1}\"}," +
-      "\"warning\":{\"text\":\"TCP OK - {0:.3f}s response on port {1}\",\"value\":1.5}," +
-      "\"critical\":{\"text\":\"Connection failed: {0} to {1}:{2}\",\"value\":5.0}}}";
-    String expected = "{\"reporting\":{\"ok\":{\"text\":\"HTTP {0} response in {2:.3f}s\"}," +
-      "\"warning\":{\"text\":\"HTTP {0} response from {1} in {2:.3f}s ({3})\"}," +
-      "\"critical\":{\"text\":\"Connection failed to {1} ({3})\"}},\"type\":\"WEB\"," +
-      "\"uri\":{\"http\":\"{{hdfs-site/dfs.journalnode.http-address}}\"," +
-      "\"https\":\"{{hdfs-site/dfs.journalnode.https-address}}\"," +
-      "\"kerberos_keytab\":\"{{hdfs-site/dfs.web.authentication.kerberos.keytab}}\"," +
-      "\"kerberos_principal\":\"{{hdfs-site/dfs.web.authentication.kerberos.principal}}\"," +
-      "\"https_property\":\"{{hdfs-site/dfs.http.policy}}\"," +
-      "\"https_property_value\":\"HTTPS_ONLY\",\"connection_timeout\":5.0}}";
-    Assert.assertEquals(expected, upgradeCatalog213.modifyJournalnodeProcessAlertSource(alertSource));
+    long clusterId = 1;
+
+    final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+    final AlertDefinitionDAO mockAlertDefinitionDAO = easyMockSupport.createNiceMock(AlertDefinitionDAO.class);
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+    final AlertDefinitionEntity mockJournalNodeProcessAlertDefinitionEntity = easyMockSupport.createNiceMock(AlertDefinitionEntity.class);
+    final AlertDefinitionEntity mockHostDiskUsageAlertDefinitionEntity = easyMockSupport.createNiceMock(AlertDefinitionEntity.class);
+
+    final String journalNodeProcessAlertSource = "{\"uri\":\"{{hdfs-site/dfs.journalnode.http-address}}\",\"default_port\":8480," +
+        "\"type\":\"PORT\",\"reporting\":{\"ok\":{\"text\":\"TCP OK - {0:.3f}s response on port {1}\"}," +
+        "\"warning\":{\"text\":\"TCP OK - {0:.3f}s response on port {1}\",\"value\":1.5}," +
+        "\"critical\":{\"text\":\"Connection failed: {0} to {1}:{2}\",\"value\":5.0}}}";
+    final String journalNodeProcessAlertSourceExpected = "{\"reporting\":{\"ok\":{\"text\":\"HTTP {0} response in {2:.3f}s\"}," +
+        "\"warning\":{\"text\":\"HTTP {0} response from {1} in {2:.3f}s ({3})\"}," +
+        "\"critical\":{\"text\":\"Connection failed to {1} ({3})\"}},\"type\":\"WEB\"," +
+        "\"uri\":{\"http\":\"{{hdfs-site/dfs.journalnode.http-address}}\"," +
+        "\"https\":\"{{hdfs-site/dfs.journalnode.https-address}}\"," +
+        "\"kerberos_keytab\":\"{{hdfs-site/dfs.web.authentication.kerberos.keytab}}\","+
+        "\"kerberos_principal\":\"{{hdfs-site/dfs.web.authentication.kerberos.principal}}\"," +
+        "\"https_property\":\"{{hdfs-site/dfs.http.policy}}\"," +
+        "\"https_property_value\":\"HTTPS_ONLY\",\"connection_timeout\":5.0}}";
+
+    final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+      @Override
+      protected void configure() {
+        bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+        bind(Clusters.class).toInstance(mockClusters);
+        bind(EntityManager.class).toInstance(entityManager);
+        bind(AlertDefinitionDAO.class).toInstance(mockAlertDefinitionDAO);
+        bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+        bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+      }
+    });
+
+    expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+    expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+      put("normal", mockClusterExpected);
+    }}).atLeastOnce();
+
+    expect(mockClusterExpected.getClusterId()).andReturn(clusterId).anyTimes();
+
+    expect(mockAlertDefinitionDAO.findByName(eq(clusterId), eq("journalnode_process"))).andReturn(mockJournalNodeProcessAlertDefinitionEntity).atLeastOnce();
+    expect(mockAlertDefinitionDAO.findByName(eq(clusterId), eq("ambari_agent_disk_usage"))).andReturn(mockHostDiskUsageAlertDefinitionEntity).atLeastOnce();
+
+    expect(mockJournalNodeProcessAlertDefinitionEntity.getSource()).andReturn(journalNodeProcessAlertSource).atLeastOnce();
+    Assert.assertEquals(journalNodeProcessAlertSourceExpected, upgradeCatalog213.modifyJournalnodeProcessAlertSource(journalNodeProcessAlertSource));
+
+    mockHostDiskUsageAlertDefinitionEntity.setDescription(eq("This host-level alert is triggered if the amount of disk space " +
+        "used goes above specific thresholds. The default threshold values are 50% for WARNING and 80% for CRITICAL."));
+    expectLastCall().atLeastOnce();
+    mockHostDiskUsageAlertDefinitionEntity.setLabel(eq("Host Disk Usage"));
+    expectLastCall().atLeastOnce();
+
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog213.class).updateAlertDefinitions();
+    easyMockSupport.verifyAll();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/f24058f7/ambari-web/app/assets/data/alerts/alertDefinitions.json
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/data/alerts/alertDefinitions.json b/ambari-web/app/assets/data/alerts/alertDefinitions.json
index 20d83bd..3d00708 100644
--- a/ambari-web/app/assets/data/alerts/alertDefinitions.json
+++ b/ambari-web/app/assets/data/alerts/alertDefinitions.json
@@ -1230,7 +1230,7 @@
         "id" : 37,
         "ignore_host" : false,
         "interval" : 1,
-        "label" : "Ambari Agent Disk Usage",
+        "label" : "Host Disk Usage",
         "name" : "ambari_agent_disk_usage",
         "scope" : "HOST",
         "service_name" : "AMBARI",
@@ -1241,4 +1241,4 @@
       }
     }
   ]
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f24058f7/ambari-web/app/assets/data/alerts/alert_instances.json
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/data/alerts/alert_instances.json b/ambari-web/app/assets/data/alerts/alert_instances.json
index 03ee7ce..4708978 100644
--- a/ambari-web/app/assets/data/alerts/alert_instances.json
+++ b/ambari-web/app/assets/data/alerts/alert_instances.json
@@ -9,7 +9,7 @@
         "host_name" : "c6401.ambari.apache.org",
         "id" : 18,
         "instance" : null,
-        "label" : "Ambari Agent Disk Usage",
+        "label" : "Host Disk Usage",
         "latest_timestamp" : 1415224354954,
         "maintenance_state" : "OFF",
         "name" : "ambari_agent_disk_usage",

http://git-wip-us.apache.org/repos/asf/ambari/blob/f24058f7/ambari-web/app/assets/data/alerts/alert_summary.json
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/data/alerts/alert_summary.json b/ambari-web/app/assets/data/alerts/alert_summary.json
index bbc8308..45c02df 100644
--- a/ambari-web/app/assets/data/alerts/alert_summary.json
+++ b/ambari-web/app/assets/data/alerts/alert_summary.json
@@ -1379,4 +1379,4 @@
       }
     }
   ]
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f24058f7/ambari-web/test/mappers/alert_instances_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/alert_instances_mapper_test.js b/ambari-web/test/mappers/alert_instances_mapper_test.js
index 2432749..6ea0086 100644
--- a/ambari-web/test/mappers/alert_instances_mapper_test.js
+++ b/ambari-web/test/mappers/alert_instances_mapper_test.js
@@ -35,7 +35,7 @@ describe('App.alertInstanceMapper', function () {
             "host_name": "c6401.ambari.apache.org",
             "id": 2,
             "instance": null,
-            "label": "Ambari Agent Disk Usage",
+            "label": "Host Disk Usage",
             "latest_timestamp": 1415224354954,
             "maintenance_state": "OFF",
             "name": "ambari_agent_disk_usage",