ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [04/11] ambari git commit: AMBARI-14801. Alerts: HBase Region servers alert should determine RegionServer liveliness differently.(vbrodetskyi)
Date Wed, 27 Jan 2016 15:33:23 GMT
AMBARI-14801. Alerts: HBase Region servers alert should determine RegionServer liveliness differently.(vbrodetskyi)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: d1e59133f7f867a16d6cb4c7e5cc8508893a29fe
Parents: c530e00
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Wed Jan 27 11:02:22 2016 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Wed Jan 27 11:02:22 2016 +0200

----------------------------------------------------------------------
 .../server/upgrade/SchemaUpgradeHelper.java     |   1 +
 .../server/upgrade/UpgradeCatalog222.java       | 125 +++++++++++++++++++
 .../server/upgrade/UpgradeCatalog240.java       |  26 ++--
 .../HBASE/0.96.0.2.0/alerts.json                |  37 ------
 .../server/upgrade/UpgradeCatalog222Test.java   | 104 +++++++++++++++
 5 files changed, 248 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d1e59133/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
index a07d42d..89e920d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
@@ -182,6 +182,7 @@ public class SchemaUpgradeHelper {
       catalogBinder.addBinding().to(UpgradeCatalog2121.class);
       catalogBinder.addBinding().to(UpgradeCatalog220.class);
       catalogBinder.addBinding().to(UpgradeCatalog221.class);
+      catalogBinder.addBinding().to(UpgradeCatalog222.class);
       catalogBinder.addBinding().to(UpgradeCatalog230.class);
       catalogBinder.addBinding().to(UpgradeCatalog240.class);
       catalogBinder.addBinding().to(FinalUpgradeCatalog.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d1e59133/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
new file mode 100644
index 0000000..bcbbf41
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.upgrade;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
+import org.apache.ambari.server.orm.dao.DaoUtils;
+import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.SQLException;
+import java.util.Map;
+
+/**
+ * Upgrade catalog for version 2.2.2.
+ */
+public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
+
+  @Inject
+  DaoUtils daoUtils;
+
+  /**
+   * Logger.
+   */
+  private static final Logger LOG = LoggerFactory.getLogger(UpgradeCatalog222.class);
+
+
+
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Don't forget to register new UpgradeCatalogs in {@link org.apache.ambari.server.upgrade.SchemaUpgradeHelper.UpgradeHelperModule#configure()}
+   *
+   * @param injector Guice injector to track dependencies and uses bindings to inject them.
+   */
+  @Inject
+  public UpgradeCatalog222(Injector injector) {
+    super(injector);
+    this.injector = injector;
+  }
+
+  // ----- UpgradeCatalog ----------------------------------------------------
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getTargetVersion() {
+    return "2.2.2";
+  }
+
+  // ----- AbstractUpgradeCatalog --------------------------------------------
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSourceVersion() {
+    return "2.2.1";
+  }
+
+
+  @Override
+  protected void executeDDLUpdates() throws AmbariException, SQLException {
+    //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  @Override
+  protected void executePreDMLUpdates() throws AmbariException, SQLException {
+    //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  @Override
+  protected void executeDMLUpdates() throws AmbariException, SQLException {
+    addNewConfigurationsFromXml();
+    updateAlerts();
+
+  }
+
+  protected void updateAlerts() {
+    LOG.info("Updating alert definitions.");
+    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();
+
+      final AlertDefinitionEntity regionserverHealthSummaryDefinitionEntity = alertDefinitionDAO.findByName(
+              clusterID, "regionservers_health_summary");
+
+      if (regionserverHealthSummaryDefinitionEntity != null) {
+        alertDefinitionDAO.remove(regionserverHealthSummaryDefinitionEntity);
+      }
+
+    }
+
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d1e59133/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index 1ccea5c..3414388 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@ -139,21 +139,21 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
               clusterID, "flume_agent_status");
 
       Map<AlertDefinitionEntity, List<String>> alertDefinitionParams = new HashMap<>();
-      alertDefinitionParams.put(namenodeLastCheckpointAlertDefinitionEntity,
+      checkedPutToMap(alertDefinitionParams, namenodeLastCheckpointAlertDefinitionEntity,
               new ArrayList<String>(Arrays.asList("connection.timeout", "checkpoint.time.warning.threshold",
"checkpoint.time.critical.threshold")));
-      alertDefinitionParams.put(namenodeHAHealthAlertDefinitionEntity,
+      checkedPutToMap(alertDefinitionParams, namenodeHAHealthAlertDefinitionEntity,
               new ArrayList<String>(Arrays.asList("connection.timeout")));
-      alertDefinitionParams.put(nodemanagerHealthAlertDefinitionEntity,
+      checkedPutToMap(alertDefinitionParams, nodemanagerHealthAlertDefinitionEntity,
               new ArrayList<String>(Arrays.asList("connection.timeout")));
-      alertDefinitionParams.put(nodemanagerHealthSummaryAlertDefinitionEntity,
+      checkedPutToMap(alertDefinitionParams, nodemanagerHealthSummaryAlertDefinitionEntity,
               new ArrayList<String>(Arrays.asList("connection.timeout")));
-      alertDefinitionParams.put(hiveMetastoreProcessAlertDefinitionEntity,
+      checkedPutToMap(alertDefinitionParams, hiveMetastoreProcessAlertDefinitionEntity,
               new ArrayList<String>(Arrays.asList("default.smoke.user", "default.smoke.principal",
"default.smoke.keytab")));
-      alertDefinitionParams.put(hiveServerProcessAlertDefinitionEntity,
+      checkedPutToMap(alertDefinitionParams, hiveServerProcessAlertDefinitionEntity,
               new ArrayList<String>(Arrays.asList("default.smoke.user", "default.smoke.principal",
"default.smoke.keytab")));
-      alertDefinitionParams.put(hiveWebhcatServerStatusAlertDefinitionEntity,
+      checkedPutToMap(alertDefinitionParams, hiveWebhcatServerStatusAlertDefinitionEntity,
               new ArrayList<String>(Arrays.asList("default.smoke.user", "connection.timeout")));
-      alertDefinitionParams.put(flumeAgentStatusAlertDefinitionEntity,
+      checkedPutToMap(alertDefinitionParams, flumeAgentStatusAlertDefinitionEntity,
               new ArrayList<String>(Arrays.asList("run.directory")));
 
       for(Map.Entry<AlertDefinitionEntity, List<String>> entry : alertDefinitionParams.entrySet()){
@@ -169,6 +169,16 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
     }
   }
 
+  /*
+  * Simple put method with check for key is not null
+  * */
+  private void checkedPutToMap(Map<AlertDefinitionEntity, List<String>> alertDefinitionParams,
AlertDefinitionEntity alertDefinitionEntity,
+                               List<String> params) {
+    if (alertDefinitionEntity != null) {
+      alertDefinitionParams.put(alertDefinitionEntity, params);
+    }
+  }
+
   protected String addParam(String source, List<String> params) {
     JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject();
     JsonArray parametersJson = sourceJson.getAsJsonArray("parameters");

http://git-wip-us.apache.org/repos/asf/ambari/blob/d1e59133/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 37e4792..e2dffe3 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
@@ -89,43 +89,6 @@
             "value": "{0} * 100"
           }
         }
-      },
-      {
-        "name": "regionservers_health_summary",
-        "label": "RegionServers Health Summary",
-        "description": "This service-level alert is triggered if there are unhealthy RegionServers",
-        "interval": 1,
-        "scope": "SERVICE",
-        "enabled": true,
-        "source": {
-          "type": "METRIC",
-          "uri": {
-            "http": "{{hbase-site/hbase.master.info.port}}",
-            "default_port": 60010,
-            "connection_timeout": 5.0
-          },
-          "reporting": {
-            "ok": {
-              "text": "All {1} RegionServer(s) are alive"
-            },
-            "warning": {
-              "text": "Dead RegionServer(s): {0} out of {1}",
-              "value": 1
-            },
-            "critical": {
-              "text": "Dead RegionServer(s): {0} out of {1}",
-              "value": 1
-            },
-            "units" : "RegionServer(s)"
-          },
-          "jmx": {
-            "property_list": [
-              "Hadoop:service=HBase,name=Master,sub=Server/numDeadRegionServers",
-              "Hadoop:service=HBase,name=Master,sub=Server/numRegionServers"
-            ],
-            "value": "{0}"
-          }
-        }
       }
     ],
     "HBASE_REGIONSERVER": [

http://git-wip-us.apache.org/repos/asf/ambari/blob/d1e59133/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
new file mode 100644
index 0000000..f33a31d
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.upgrade;
+
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+import com.google.inject.persist.PersistService;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.orm.GuiceJpaInitializer;
+import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.dao.StackDAO;
+import org.apache.ambari.server.orm.entities.StackEntity;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.persistence.EntityManager;
+import java.lang.reflect.Method;
+
+import static org.easymock.EasyMock.createMockBuilder;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
+
+public class UpgradeCatalog222Test {
+  private Injector injector;
+  private Provider<EntityManager> entityManagerProvider = createStrictMock(Provider.class);
+  private EntityManager entityManager = createNiceMock(EntityManager.class);
+  private UpgradeCatalogHelper upgradeCatalogHelper;
+  private StackEntity desiredStackEntity;
+
+
+
+  @Before
+  public void init() {
+    reset(entityManagerProvider);
+    expect(entityManagerProvider.get()).andReturn(entityManager).anyTimes();
+    replay(entityManagerProvider);
+    injector = Guice.createInjector(new InMemoryDefaultTestModule());
+    injector.getInstance(GuiceJpaInitializer.class);
+
+    upgradeCatalogHelper = injector.getInstance(UpgradeCatalogHelper.class);
+    // inject AmbariMetaInfo to ensure that stacks get populated in the DB
+    injector.getInstance(AmbariMetaInfo.class);
+    // load the stack entity
+    StackDAO stackDAO = injector.getInstance(StackDAO.class);
+    desiredStackEntity = stackDAO.find("HDP", "2.2.0");
+  }
+
+  @After
+  public void tearDown() {
+    injector.getInstance(PersistService.class).stop();
+  }
+
+  @Test
+  public void testExecuteDMLUpdates() throws Exception {
+    Method addNewConfigurationsFromXml = AbstractUpgradeCatalog.class.getDeclaredMethod("addNewConfigurationsFromXml");
+    Method updateAlerts = UpgradeCatalog222.class.getDeclaredMethod("updateAlerts");
+
+
+
+    UpgradeCatalog222 upgradeCatalog222 = createMockBuilder(UpgradeCatalog222.class)
+            .addMockedMethod(addNewConfigurationsFromXml)
+            .addMockedMethod(updateAlerts)
+            .createMock();
+
+    upgradeCatalog222.addNewConfigurationsFromXml();
+    expectLastCall().once();
+    upgradeCatalog222.updateAlerts();
+    expectLastCall().once();
+
+
+    replay(upgradeCatalog222);
+
+    upgradeCatalog222.executeDMLUpdates();
+
+    verify(upgradeCatalog222);
+  }
+
+
+
+}


Mime
View raw message