Repository: ambari Updated Branches: refs/heads/trunk 43279cc7e -> 823527e3c
AMBARI-5900 Installation error on 2000 node cluster "ulimit" (dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/823527e3 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/823527e3 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/823527e3 Branch: refs/heads/trunk Commit: 823527e3cda7721b40c806c720047cba6d4de099 Parents: 43279cc Author: Dmitry Sen <[email protected]> Authored: Thu Jun 5 12:36:57 2014 +0300 Committer: Dmitry Sen <[email protected]> Committed: Thu Jun 5 12:36:57 2014 +0300 ---------------------------------------------------------------------- ambari-server/conf/unix/ambari.properties | 3 ++ ambari-server/src/main/python/ambari-server.py | 18 ++++++++++++ .../src/test/python/TestAmbariServer.py | 29 ++++++++++++++++++++ 3 files changed, 50 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/823527e3/ambari-server/conf/unix/ambari.properties ---------------------------------------------------------------------- diff --git a/ambari-server/conf/unix/ambari.properties b/ambari-server/conf/unix/ambari.properties index 764328e..b5816af 100644 --- a/ambari-server/conf/unix/ambari.properties +++ b/ambari-server/conf/unix/ambari.properties @@ -46,3 +46,6 @@ agent.task.timeout=600 # thread pool maximums client.threadpool.size.max=25 agent.threadpool.size.max=25 + +# linux open-file limit +ulimit.open.files=10000 http://git-wip-us.apache.org/repos/asf/ambari/blob/823527e3/ambari-server/src/main/python/ambari-server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py index 6ad94d5..d580634 100755 --- a/ambari-server/src/main/python/ambari-server.py +++ b/ambari-server/src/main/python/ambari-server.py @@ -401,6 +401,10 @@ DEFAULT_DB_NAME = "ambari" STACK_LOCATION_KEY = 'metadata.path' STACK_LOCATION_DEFAULT = '/var/lib/ambari-server/resources/stacks' +# linux open-file limit +ULIMIT_OPEN_FILES_KEY = 'ulimit.open.files' +ULIMIT_OPEN_FILES_DEFAULT = 10000 + #Apache License Header ASF_LICENSE_HEADER = ''' # Copyright 2011 The Apache Software Foundation @@ -2542,6 +2546,7 @@ def start(args): pidfile = PID_DIR + os.sep + PID_NAME command_base = SERVER_START_CMD_DEBUG if (SERVER_DEBUG_MODE or SERVER_START_DEBUG) else SERVER_START_CMD + command_base = "ulimit -n " + str(get_ulimit_open_files()) + "; " + command_base command = command_base.format(jdk_path, conf_dir, get_ambari_classpath(), pidfile) if not os.path.exists(PID_DIR): os.makedirs(PID_DIR, 0755) @@ -4021,6 +4026,19 @@ def get_fqdn(): return socket.getfqdn() +def get_ulimit_open_files(): + properties = get_ambari_properties() + if properties == -1: + print "Error reading ambari properties" + return None + + open_files = int(properties[ULIMIT_OPEN_FILES_KEY]) + if open_files > 0: + return open_files + else: + return ULIMIT_OPEN_FILES_DEFAULT + + def is_valid_filepath(filepath): if not filepath or not os.path.exists(filepath) or os.path.isdir(filepath): print 'Invalid path, please provide the absolute file path.' http://git-wip-us.apache.org/repos/asf/ambari/blob/823527e3/ambari-server/src/test/python/TestAmbariServer.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py index c2d868d..0ed238a 100644 --- a/ambari-server/src/test/python/TestAmbariServer.py +++ b/ambari-server/src/test/python/TestAmbariServer.py @@ -1683,6 +1683,35 @@ class TestAmbariServer(TestCase): self.assertEqual(fqdn, host) + @patch.object(ambari_server, "find_properties_file") + def test_get_ulimit_open_files(self, find_properties_file_mock): + + # 1 - No ambari.properties + find_properties_file_mock.return_value = None + open_files = ambari_server.get_fqdn() + self.assertEqual(open_files, None) + + # 2 - With ambari.properties - ok + tf1 = tempfile.NamedTemporaryFile() + prop_value = 65000 + with open(tf1.name, 'w') as fout: + fout.write(ambari_server.ULIMIT_OPEN_FILES_KEY + '=' + str(prop_value)) + fout.close() + find_properties_file_mock.return_value = tf1.name + open_files = ambari_server.get_ulimit_open_files() + self.assertEqual(open_files, 65000) + + # 2 - With ambari.properties - default + tf1 = tempfile.NamedTemporaryFile() + prop_value = 0 + with open(tf1.name, 'w') as fout: + fout.write(ambari_server.ULIMIT_OPEN_FILES_KEY + '=' + str(prop_value)) + fout.close() + find_properties_file_mock.return_value = tf1.name + open_files = ambari_server.get_ulimit_open_files() + self.assertEqual(open_files, ambari_server.ULIMIT_OPEN_FILES_DEFAULT) + + @patch.object(ambari_server, "run_os_command") def test_get_cert_info(self, run_os_command_mock): # Error running openssl command
