ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-15301. Alert "Metadata Server Web UI" using hardcoded value for port.(vbrodetskyi)
Date Fri, 04 Mar 2016 18:43:46 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk e146400e6 -> 9a2a8b8a3


AMBARI-15301. Alert "Metadata Server Web UI" using hardcoded value for port.(vbrodetskyi)


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

Branch: refs/heads/trunk
Commit: 9a2a8b8a357e001a50a189dc2917959e89ae52a8
Parents: e146400
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Fri Mar 4 20:34:33 2016 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Fri Mar 4 20:34:33 2016 +0200

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog222.java       | 17 ++++++++
 .../common-services/ATLAS/0.1.0.2.3/alerts.json |  4 +-
 .../server/upgrade/UpgradeCatalog222Test.java   | 42 ++++++++++++++++++++
 3 files changed, 61 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9a2a8b8a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
index b8d47f9..8ea455d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
@@ -183,6 +183,23 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
         alertDefinitionDAO.merge(atsWebAlert);
       }
 
+      //update Atlas alert
+      final AlertDefinitionEntity atlasMetadataServerWebUI = alertDefinitionDAO.findByName(
+              clusterID, "metadata_server_webui");
+      if (atlasMetadataServerWebUI != null) {
+        String source = atlasMetadataServerWebUI.getSource();
+        JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject();
+
+        JsonObject uriJson = sourceJson.get("uri").getAsJsonObject();
+        uriJson.remove("http");
+        uriJson.remove("https");
+        uriJson.addProperty("http", "{{application-properties/atlas.server.http.port}}");
+        uriJson.addProperty("https", "{{application-properties/atlas.server.https.port}}");
+
+        atlasMetadataServerWebUI.setSource(sourceJson.toString());
+        alertDefinitionDAO.merge(atlasMetadataServerWebUI);
+      }
+
     }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a2a8b8a/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/alerts.json
b/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/alerts.json
index 5eaaace..186ccaf 100644
--- a/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/alerts.json
+++ b/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/alerts.json
@@ -37,8 +37,8 @@
         "source": {
           "type": "WEB",
           "uri": {
-            "http": "{{hostname}}:{{application-properties/atlas.server.http.port}}",
-            "https": "{{hostname}}:{{application-properties/atlas.server.https.port}}",
+            "http": "{{application-properties/atlas.server.http.port}}",
+            "https": "{{application-properties/atlas.server.https.port}}",
             "https_property": "{{application-properties/atlas.enableTLS}}",
             "https_property_value": "true",
             "default_port": 21000,

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a2a8b8a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
index 8a7a679..1d18206 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
@@ -357,4 +357,46 @@ public class UpgradeCatalog222Test {
     verify(dbAccessor);
   }
 
+  @Test
+  public void testUpdateAlerts_AtlasAlert() {
+    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 atlasMetadataServerWebUIMock = easyMockSupport.createNiceMock(AlertDefinitionEntity.class);
+
+    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));
+      }
+    });
+
+    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("metadata_server_webui")))
+            .andReturn(atlasMetadataServerWebUIMock).atLeastOnce();
+    expect(atlasMetadataServerWebUIMock.getSource()).andReturn("{\"uri\": {\n" +
+            "            \"http\": \"{{hostname}}:{{application-properties/atlas.server.http.port}}\",\n"
+
+            "            \"https\": \"{{hostname}}:{{application-properties/atlas.server.https.port}}\"
} }");
+
+    atlasMetadataServerWebUIMock.setSource("{\"uri\":{\"http\":\"{{application-properties/atlas.server.http.port}}\",\"https\":\"{{application-properties/atlas.server.https.port}}\"}}");
+    expectLastCall().once();
+
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog222.class).updateAlerts();
+    easyMockSupport.verifyAll();
+  }
+
 }


Mime
View raw message