You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by am...@apache.org on 2018/08/28 14:11:51 UTC
[ambari] branch trunk updated: AMBARI-24550. Yarn Timeline Service
V2 Reader goes down after Ambari Upgrade from 2.7.0.0 to 2.7.1.0 (amagyar)
(#2182)
This is an automated email from the ASF dual-hosted git repository.
amagyar pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 93e177c AMBARI-24550. Yarn Timeline Service V2 Reader goes down after Ambari Upgrade from 2.7.0.0 to 2.7.1.0 (amagyar) (#2182)
93e177c is described below
commit 93e177c81a1cc438b80d5eddbbb3afe0549a79ee
Author: Attila Magyar <m....@gmail.com>
AuthorDate: Tue Aug 28 16:10:49 2018 +0200
AMBARI-24550. Yarn Timeline Service V2 Reader goes down after Ambari Upgrade from 2.7.0.0 to 2.7.1.0 (amagyar) (#2182)
---
.../ambari/server/upgrade/UpgradeCatalog271.java | 49 ++++++++++++++++++++++
.../server/upgrade/UpgradeCatalog271Test.java | 5 +++
2 files changed, 54 insertions(+)
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog271.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog271.java
index eb609b1..c1e2544 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog271.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog271.java
@@ -19,11 +19,13 @@ package org.apache.ambari.server.upgrade;
import static org.apache.ambari.server.upgrade.UpgradeCatalog270.AMBARI_INFRA_NEW_NAME;
import static org.apache.ambari.server.upgrade.UpgradeCatalog270.AMBARI_INFRA_OLD_NAME;
+import static org.apache.ambari.server.upgrade.UpgradeCatalog270.YARN_SERVICE;
import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.regex.Matcher;
@@ -33,6 +35,8 @@ import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.ServiceComponentNotFoundException;
+import org.apache.ambari.server.ServiceNotFoundException;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.orm.DBAccessor;
import org.apache.ambari.server.orm.dao.DaoUtils;
@@ -42,6 +46,7 @@ import org.apache.ambari.server.state.BlueprintProvisioningState;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.ServiceComponent;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -176,6 +181,7 @@ public class UpgradeCatalog271 extends AbstractUpgradeCatalog {
renameAmbariInfraService();
removeLogSearchPatternConfigs();
updateSolrConfigurations();
+ updateTimelineReaderAddress();
}
/**
@@ -274,6 +280,49 @@ public class UpgradeCatalog271 extends AbstractUpgradeCatalog {
}
}
+ /**
+ * Replace placeholder values in timeline reader address.
+ * In Ambari 2.7 these properties are set to {{timeline_reader_address_http}} and {{timeline_reader_address_https}} and the stack code substitutes the proper host names.
+ * In Ambari 2.7.1 the stack code no longer does this but the stack advisor and a SingleHostTopologyUpdater is responsible for replacing the hosts.
+ */
+ protected void updateTimelineReaderAddress() throws AmbariException {
+ Clusters clusters = injector.getInstance(AmbariManagementController.class).getClusters();
+ if (clusters == null || clusters.getClusters() == null) {
+ return;
+ }
+ for (Cluster cluster : clusters.getClusters().values()) {
+ Set<String> installedServices = cluster.getServices().keySet();
+ if (installedServices.contains(YARN_SERVICE) && cluster.getService(YARN_SERVICE).getServiceComponents().keySet().contains("TIMELINE_READER")) {
+ String timelineReaderHost = hostNameOf(cluster, YARN_SERVICE, "TIMELINE_READER").orElse("localhost");
+ updateProperty(cluster, "yarn-site", "yarn.timeline-service.reader.webapp.address", timelineReaderHost + ":8198");
+ updateProperty(cluster, "yarn-site", "yarn.timeline-service.reader.webapp.https.address", timelineReaderHost + ":8199");
+ }
+ }
+ }
+
+ private void updateProperty(Cluster cluster, String configType, String propertyName, String newValue) throws AmbariException {
+ Config config = cluster.getDesiredConfigByType(configType);
+ if (config == null) {
+ return;
+ }
+ String oldValue = config.getProperties().get(propertyName);
+ if (oldValue != null) {
+ Map<String, String> newProperty = new HashMap<>();
+ newProperty.put(propertyName, newValue);
+ updateConfigurationPropertiesForCluster(cluster, configType, newProperty, true, false);
+ }
+ }
+
+ private Optional<String> hostNameOf(Cluster cluster, String serviceName, String componentName) throws AmbariException {
+ try {
+ ServiceComponent component = cluster.getService(serviceName).getServiceComponent(componentName);
+ Set<String> hosts = component.getServiceComponentHosts().keySet();
+ return hosts.isEmpty() ? Optional.empty() : Optional.of(hosts.iterator().next());
+ } catch (ServiceComponentNotFoundException | ServiceNotFoundException e) {
+ return Optional.empty();
+ }
+ }
+
protected void renameAmbariInfraService() {
LOG.info("Renaming service AMBARI_INFRA to AMBARI_INFRA_SOLR in config group records");
AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog271Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog271Test.java
index 63fe72a..22c0a7c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog271Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog271Test.java
@@ -95,6 +95,7 @@ public class UpgradeCatalog271Test {
Method renameAmbariInfraInConfigGroups = UpgradeCatalog271.class.getDeclaredMethod("renameAmbariInfraService");
Method removeLogSearchPatternConfigs = UpgradeCatalog271.class.getDeclaredMethod("removeLogSearchPatternConfigs");
Method updateSolrConfigurations = UpgradeCatalog271.class.getDeclaredMethod("updateSolrConfigurations");
+ Method updateTimelineReaderAddress = UpgradeCatalog271.class.getDeclaredMethod("updateTimelineReaderAddress");
UpgradeCatalog271 upgradeCatalog271 = createMockBuilder(UpgradeCatalog271.class)
.addMockedMethod(updateRangerKmsDbUrl)
@@ -103,6 +104,7 @@ public class UpgradeCatalog271Test {
.addMockedMethod(renameAmbariInfraInConfigGroups)
.addMockedMethod(removeLogSearchPatternConfigs)
.addMockedMethod(updateSolrConfigurations)
+ .addMockedMethod(updateTimelineReaderAddress)
.createMock();
upgradeCatalog271.addNewConfigurationsFromXml();
@@ -123,6 +125,9 @@ public class UpgradeCatalog271Test {
upgradeCatalog271.updateSolrConfigurations();
expectLastCall().once();
+ upgradeCatalog271.updateTimelineReaderAddress();
+ expectLastCall().once();
+
replay(upgradeCatalog271);
upgradeCatalog271.executeDMLUpdates();
verify(upgradeCatalog271);