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:27: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/6cfcc90a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6cfcc90a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6cfcc90a

Branch: refs/heads/trunk
Commit: 6cfcc90acfaced9cbcefe8abaa1a5d98a2db20ad
Parents: 801cd61
Author: Robert Levas <rlevas@hortonworks.com>
Authored: Mon Mar 6 12:27:23 2017 -0500
Committer: Robert Levas <rlevas@hortonworks.com>
Committed: Mon Mar 6 12:27:29 2017 -0500

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


http://git-wip-us.apache.org/repos/asf/ambari/blob/6cfcc90a/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 2a684dc..141e9cd 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
@@ -29,6 +29,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;
 
 import org.apache.ambari.server.AmbariException;
@@ -65,6 +66,7 @@ import org.springframework.jdbc.support.JdbcUtils;
 
 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;
 
@@ -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/6cfcc90a/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