You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/07/31 14:10:38 UTC

[23/25] ambari git commit: AMBARI-21590. Connection refused to Spark Thrift Server alert after upgrade

AMBARI-21590. Connection refused to Spark Thrift Server alert after upgrade


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

Branch: refs/heads/branch-feature-AMBARI-21450
Commit: 63bdbcac5a28a5b9485cf8181123104823016ab0
Parents: 5aa398c
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Fri Jul 28 21:40:11 2017 +0200
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Mon Jul 31 09:22:23 2017 +0200

----------------------------------------------------------------------
 .../upgrades/RemoveObsoleteAlerts.java          | 75 ++++++++++++++++++++
 .../upgrades/nonrolling-upgrade-to-hdp-2.6.xml  |  6 ++
 2 files changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/63bdbcac/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/RemoveObsoleteAlerts.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/RemoveObsoleteAlerts.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/RemoveObsoleteAlerts.java
new file mode 100644
index 0000000..e6c5888
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/RemoveObsoleteAlerts.java
@@ -0,0 +1,75 @@
+/*
+ * 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.serveraction.upgrades;
+
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.inject.Inject;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.agent.CommandReport;
+import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
+import org.apache.ambari.server.orm.dao.AlertsDAO;
+import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
+import org.apache.ambari.server.serveraction.AbstractServerAction;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Removes alerts that are superseded in the target stack.
+ * Eg. SPARK2_THRIFTSERVER_PROCESS by spark2_thriftserver_status.
+ */
+public class RemoveObsoleteAlerts extends AbstractServerAction {
+
+  private static final Set<String> ALERTS_TO_BE_REMOVED = ImmutableSet.of("SPARK2_THRIFTSERVER_PROCESS");
+
+  @Inject
+  private Clusters clusters;
+
+  @Inject
+  private AlertsDAO alertsDAO;
+
+  @Inject
+  private AlertDefinitionDAO alertDefinitionDAO;
+
+  @Override
+  public CommandReport execute(ConcurrentMap<String, Object> requestSharedDataContext) throws AmbariException, InterruptedException {
+    String clusterName = getExecutionCommand().getClusterName();
+    Cluster cluster = clusters.getCluster(clusterName);
+
+    StringBuilder sb = new StringBuilder();
+    for (String alertName : ALERTS_TO_BE_REMOVED) {
+      String message;
+      AlertDefinitionEntity alert = alertDefinitionDAO.findByName(cluster.getClusterId(), alertName);
+      if (alert != null) {
+        alertsDAO.removeByDefinitionId(alert.getDefinitionId());
+        alertDefinitionDAO.remove(alert);
+        message = String.format("Removed alert id = %d, name = %s", alert.getDefinitionId(), alertName);
+      } else {
+        message = String.format("Alert with name %s not found", alertName);
+      }
+      sb.append(message);
+    }
+
+    return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", sb.toString(), "");
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/63bdbcac/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml b/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
index 00e8b22..93f88d9 100644
--- a/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
@@ -190,6 +190,12 @@
       </execute-stage>
     </group>
 
+    <group xsi:type="cluster" name="REMOVE_OBSOLETE_ALERTS" title="Remove obsolete alerts">
+      <execute-stage title="Remove obsolete alerts">
+        <task xsi:type="server_action" class="org.apache.ambari.server.serveraction.upgrades.RemoveObsoleteAlerts" />
+      </execute-stage>
+    </group>
+
     <group xsi:type="cluster" name="Upgrade service configs" title="Upgrade service configs">
       <direction>UPGRADE</direction>    <!--  prevent config changes on downgrade -->
       <skippable>true</skippable>       <!-- May fix configuration problems manually -->