Repository: ambari Updated Branches: refs/heads/branch-2.5 e675c63bc -> 762b86ef4
AMBARI-19268 ulimit override missing from upgrade catalogs (dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/762b86ef Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/762b86ef Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/762b86ef Branch: refs/heads/branch-2.5 Commit: 762b86ef45461aecd7e730897a4e9dae01b50777 Parents: e675c63 Author: Dmytro Sen <d...@apache.org> Authored: Thu Dec 22 15:37:47 2016 +0200 Committer: Dmytro Sen <d...@apache.org> Committed: Thu Dec 22 15:55:36 2016 +0200 ---------------------------------------------------------------------- .../server/upgrade/UpgradeCatalog250.java | 41 ++++++++++++++++++++ .../server/upgrade/UpgradeCatalog250Test.java | 5 +++ 2 files changed, 46 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/762b86ef/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 944253f..59988ea 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 @@ -57,6 +57,7 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog { protected static final String GROUPS_TABLE = "groups"; protected static final String GROUP_TYPE_COL = "group_type"; private static final String AMS_ENV = "ams-env"; + private static final String HADOOP_ENV = "hadoop-env"; private static final String KAFKA_BROKER = "kafka-broker"; private static final String KAFKA_TIMELINE_METRICS_HOST = "kafka.timeline.metrics.host"; @@ -146,6 +147,7 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void executeDMLUpdates() throws AmbariException, SQLException { addNewConfigurationsFromXml(); updateAMSConfigs(); + updateHadoopEnvConfigs(); updateKafkaConfigs(); updateHIVEInteractiveConfigs(); updateTEZInteractiveConfigs(); @@ -275,6 +277,45 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog { } } + + protected void updateHadoopEnvConfigs() throws AmbariException { + AmbariManagementController ambariManagementController = injector.getInstance( + AmbariManagementController.class); + Clusters clusters = ambariManagementController.getClusters(); + + if (clusters != null) { + Map<String, Cluster> clusterMap = clusters.getClusters(); + Map<String, String> prop = new HashMap<String, String>(); + + if (clusterMap != null && !clusterMap.isEmpty()) { + for (final Cluster cluster : clusterMap.values()) { + /*** + * Append "ulimit -l" from hadoop-env.sh + */ + String content = null; + if (cluster.getDesiredConfigByType(HADOOP_ENV) != null) { + content = cluster.getDesiredConfigByType(HADOOP_ENV).getProperties().get("content"); + } + + if (content != null && !content.contains("ulimit")) { + content += "\n" + + "{% if is_datanode_max_locked_memory_set %}\n" + + "# Fix temporary bug, when ulimit from conf files is not picked up, without full relogin. \n" + + "# Makes sense to fix only when runing DN as root \n" + + "if [ \"$command\" == \"datanode\" ] && [ \"$EUID\" -eq 0 ] && [ -n \"$HADOOP_SECURE_DN_USER\" ]; then\n" + + " ulimit -l {{datanode_max_locked_memory}}\n" + + "fi\n" + + "{% endif %}"; + + prop.put("content", content); + updateConfigurationPropertiesForCluster(cluster, "hadoop-env", + prop, true, false); + } + } + } + } + } + /** * Creates the servicecomponent_version table * http://git-wip-us.apache.org/repos/asf/ambari/blob/762b86ef/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java index c57b018..bb46fa6 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java @@ -266,6 +266,7 @@ public class UpgradeCatalog250Test { @Test public void testExecuteDMLUpdates() throws Exception { Method updateAmsConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateAMSConfigs"); + Method updateHadoopEnvConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateHadoopEnvConfigs"); Method updateKafkaConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateKafkaConfigs"); Method updateHiveLlapConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateHiveLlapConfigs"); Method updateTablesForZeppelinViewRemoval = UpgradeCatalog250.class.getDeclaredMethod("updateTablesForZeppelinViewRemoval"); @@ -277,6 +278,7 @@ public class UpgradeCatalog250Test { UpgradeCatalog250 upgradeCatalog250 = createMockBuilder(UpgradeCatalog250.class) .addMockedMethod(updateAmsConfigs) + .addMockedMethod(updateHadoopEnvConfigs) .addMockedMethod(updateKafkaConfigs) .addMockedMethod(updateHIVEInteractiveConfigs) .addMockedMethod(updateTEZInteractiveConfigs) @@ -291,6 +293,9 @@ public class UpgradeCatalog250Test { upgradeCatalog250.updateAMSConfigs(); expectLastCall().once(); + upgradeCatalog250.updateHadoopEnvConfigs(); + expectLastCall().once(); + upgradeCatalog250.addNewConfigurationsFromXml(); expectLastCall().once();