ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [45/50] ambari git commit: AMBARI-20382. Appendum - Log Search: Web UI Alert tries to use http protocol even if ssl is enabled (oleewere)
Date Fri, 10 Mar 2017 20:47:13 GMT
AMBARI-20382. Appendum - Log Search: Web UI Alert tries to use http protocol even if ssl is
enabled (oleewere)


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

Branch: refs/heads/branch-dev-logsearch
Commit: e6fc6f47b9cf0eed4b7ac25b011a8aa7876cad7a
Parents: 971eaff
Author: oleewere <oleewere@gmail.com>
Authored: Fri Mar 10 21:09:46 2017 +0100
Committer: oleewere <oleewere@gmail.com>
Committed: Fri Mar 10 21:18:13 2017 +0100

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog250.java       | 33 +++++++++++++++++
 .../server/upgrade/UpgradeCatalog250Test.java   | 38 ++++++++++++++++++++
 2 files changed, 71 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e6fc6f47/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
index b217723..e5b091b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
@@ -180,6 +180,7 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog {
     addNewConfigurationsFromXml();
     updateAMSConfigs();
     updateStormAlerts();
+    updateLogSearchAlert();
     removeAlertDuplicates();
     updateHadoopEnvConfigs();
     updateKafkaConfigs();
@@ -337,6 +338,38 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog {
     }
   }
 
+  protected void updateLogSearchAlert() {
+    AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
+    AlertDefinitionDAO alertDefinitionDAO = injector.getInstance(AlertDefinitionDAO.class);
+    Clusters clusters = ambariManagementController.getClusters();
+
+    Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters);
+    for (final Cluster cluster : clusterMap.values()) {
+      long clusterID = cluster.getClusterId();
+      LOG.info("Updating Log Search web ui alert definitions on cluster : " + cluster.getClusterName());
+
+      final AlertDefinitionEntity logSearchWebAlert = alertDefinitionDAO.findByName(
+        clusterID, "logsearch_ui");
+
+      if (logSearchWebAlert != null) {
+        LOG.info("Updating alert definition : " + logSearchWebAlert.getDefinitionName());
+        String source = logSearchWebAlert.getSource();
+        JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject();
+        LOG.debug("Source before update : " + sourceJson);
+
+        JsonObject uriJson = sourceJson.get("uri").getAsJsonObject();
+        uriJson.remove("https_property");
+        uriJson.remove("https_property_value");
+        uriJson.addProperty("https_property", "{{logsearch-env/logsearch_ui_protocol}}");
+        uriJson.addProperty("https_property_value", "https");
+
+        LOG.debug("Source after update : " + sourceJson);
+        logSearchWebAlert.setSource(sourceJson.toString());
+        alertDefinitionDAO.merge(logSearchWebAlert);
+      }
+    }
+  }
+
   protected void updateHostVersionTable() throws SQLException {
     LOG.info("Updating the {} table", HOST_VERSION_TABLE);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e6fc6f47/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
index 97832d0..67806a0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
@@ -343,6 +343,39 @@ public class UpgradeCatalog250Test {
     easyMockSupport.verifyAll();
   }
 
+  @Test
+  public void testUpdateAlerts_LogSearchUIWebAlert() {
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+    final AlertDefinitionDAO mockAlertDefinitionDAO = easyMockSupport.createNiceMock(AlertDefinitionDAO.class);
+    final AlertDefinitionEntity logSearchWebUIAlertMock = easyMockSupport.createNiceMock(AlertDefinitionEntity.class);
+
+    final Injector mockInjector = createInjector(mockAmbariManagementController, mockClusters,
mockAlertDefinitionDAO);
+    long clusterId = 1;
+
+    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("logsearch_ui")))
+      .andReturn(logSearchWebUIAlertMock).atLeastOnce();
+    expect(logSearchWebUIAlertMock.getSource()).andReturn("{\"uri\": {\n" +
+      "            \"http\": \"{{logsearch-env/logsearch_ui_port}}\",\n" +
+      "            \"https\": \"{{logsearch-env/logsearch_ui_port}}\"\n" +
+      "          } }");
+
+    logSearchWebUIAlertMock.setSource("{\"uri\":{\"http\":\"{{logsearch-env/logsearch_ui_port}}\",\"https\":\"{{logsearch-env/logsearch_ui_port}}\",\"https_property\":\"{{logsearch-env/logsearch_ui_protocol}}\",\"https_property_value\":\"https\"}}");
+
+    expectLastCall().once();
+
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog250.class).updateLogSearchAlert();
+    easyMockSupport.verifyAll();
+  }
+
 
   @Test
   public void testExecuteDMLUpdates() throws Exception {
@@ -358,6 +391,7 @@ public class UpgradeCatalog250Test {
     Method updateZeppelinConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateZeppelinConfigs");
     Method updateAtlasConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateAtlasConfigs");
     Method updateLogSearchConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateLogSearchConfigs");
+    Method updateLogSearchAlert = UpgradeCatalog250.class.getDeclaredMethod("updateLogSearchAlert");
     Method updateAmbariInfraConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateAmbariInfraConfigs");
     Method updateRangerUrlConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateRangerUrlConfigs");
     Method updateYarnSite = UpgradeCatalog250.class.getDeclaredMethod("updateYarnSite");
@@ -383,6 +417,7 @@ public class UpgradeCatalog250Test {
         .addMockedMethod(updateRangerUrlConfigs)
         .addMockedMethod(updateYarnSite)
         .addMockedMethod(updateAlerts)
+        .addMockedMethod(updateLogSearchAlert)
         .addMockedMethod(removeAlertDuplicates)
         .addMockedMethod(updateKerberosDescriptorArtifacts)
         .addMockedMethod(fixHBaseMasterCPUUtilizationAlertDefinition)
@@ -436,6 +471,9 @@ public class UpgradeCatalog250Test {
     upgradeCatalog250.updateStormAlerts();
     expectLastCall().once();
 
+    upgradeCatalog250.updateLogSearchAlert();
+    expectLastCall().once();
+
     upgradeCatalog250.removeAlertDuplicates();
     expectLastCall().once();
 


Mime
View raw message