ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject [2/2] ambari git commit: AMBARI-20309. HBase Master CPU Utilization Alert is in unknown state due to kinit error (rlevas)
Date Mon, 06 Mar 2017 17:30:35 GMT
AMBARI-20309. HBase Master CPU Utilization Alert is in unknown state due to kinit error (rlevas)


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

Branch: refs/heads/branch-2.5
Commit: e8956590389cf1c8e6a3942747710223ff3a5d34
Parents: 84e767b
Author: Robert Levas <rlevas@hortonworks.com>
Authored: Mon Mar 6 12:30:26 2017 -0500
Committer: Robert Levas <rlevas@hortonworks.com>
Committed: Mon Mar 6 12:30:26 2017 -0500

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog250.java       |   57 +
 .../HBASE/0.96.0.2.0/alerts.json                |    4 +-
 .../server/upgrade/UpgradeCatalog250Test.java   | 1014 ++++++++++--------
 3 files changed, 596 insertions(+), 479 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e8956590/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 c67e80d..0246229 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
@@ -19,6 +19,7 @@ package org.apache.ambari.server.upgrade;
 
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
 import com.google.inject.Inject;
 import com.google.inject.Injector;
 
@@ -66,6 +67,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicLong;
 
 /**
@@ -192,6 +194,61 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog {
     addManageServiceAutoStartPermissions();
     addManageAlertNotificationsPermissions();
     updateKerberosDescriptorArtifacts();
+    fixHBaseMasterCPUUtilizationAlertDefinition();
+  }
+
+  /**
+   * Fix the HBase Master CPU Utilization alert definition by swapping the values for <code>kerberos_keytab</code>
+   * and <code>kerberos_principal</code>.
+   */
+  protected void fixHBaseMasterCPUUtilizationAlertDefinition() {
+    AlertDefinitionDAO alertDefinitionDAO = injector.getInstance(AlertDefinitionDAO.class);
+    AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
+    Clusters clusters = ambariManagementController.getClusters();
+
+    Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters);
+    for (final Cluster cluster : clusterMap.values()) {
+      long clusterID = cluster.getClusterId();
+      AlertDefinitionEntity alertDefinition = alertDefinitionDAO.findByName(clusterID, "hbase_master_cpu");
+      if(alertDefinition != null) {
+        LOG.info("Updating alert definition {} in cluster {}", alertDefinition.getDefinitionName(),
clusterID);
+        String source = alertDefinition.getSource();
+
+        if(source != null) {
+          JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject();
+          LOG.debug("Source before update : {}", sourceJson);
+
+          JsonObject uriJson = sourceJson.get("uri").getAsJsonObject();
+          JsonPrimitive primitive;
+
+          // Replace
+          //  "kerberos_keytab": "{{hbase-site/hbase.security.authentication.spnego.kerberos.principal}}"
+          // With
+          //  "kerberos_keytab": "{{hbase-site/hbase.security.authentication.spnego.kerberos.keytab}}"
+          primitive = uriJson.getAsJsonPrimitive("kerberos_keytab");
+          if(primitive.isString() && "{{hbase-site/hbase.security.authentication.spnego.kerberos.principal}}".equals(primitive.getAsString()))
{
+            uriJson.remove("kerberos_keytab");
+            uriJson.addProperty("kerberos_keytab", "{{hbase-site/hbase.security.authentication.spnego.kerberos.keytab}}");
+          }
+
+          // Replace
+          //  "kerberos_principal": "{{hbase-site/hbase.security.authentication.spnego.kerberos.keytab}}"
+          // With
+          //  "kerberos_principal": "{{hbase-site/hbase.security.authentication.spnego.kerberos.principal}}"
+          primitive = uriJson.getAsJsonPrimitive("kerberos_principal");
+          if(primitive.isString() && "{{hbase-site/hbase.security.authentication.spnego.kerberos.keytab}}".equals(primitive.getAsString()))
{
+            uriJson.remove("kerberos_principal");
+            uriJson.addProperty("kerberos_principal", "{{hbase-site/hbase.security.authentication.spnego.kerberos.principal}}");
+          }
+
+          LOG.debug("Source after update : {}", sourceJson);
+          alertDefinition.setSource(sourceJson.toString());
+          alertDefinition.setHash(UUID.randomUUID().toString());
+
+          alertDefinitionDAO.merge(alertDefinition);
+        }
+      }
+    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/e8956590/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/alerts.json
b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/alerts.json
index 1b3ae25..6fcb4dc 100644
--- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/alerts.json
+++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/alerts.json
@@ -68,8 +68,8 @@
             "http": "{{hbase-site/hbase.master.info.port}}",
             "default_port": 60010,
             "connection_timeout": 5.0,
-            "kerberos_keytab": "{{hbase-site/hbase.security.authentication.spnego.kerberos.principal}}",
-            "kerberos_principal": "{{hbase-site/hbase.security.authentication.spnego.kerberos.keytab}}"
+            "kerberos_principal": "{{hbase-site/hbase.security.authentication.spnego.kerberos.principal}}",
+            "kerberos_keytab": "{{hbase-site/hbase.security.authentication.spnego.kerberos.keytab}}"
           },
           "reporting": {
             "ok": {


Mime
View raw message