ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: AMBARI-12438 - MySQL Connection Pooling Defaults Should Be Correct And Present In ambari.properties (jonathanhurley)
Date Fri, 17 Jul 2015 03:40:04 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9d8ce4f06 -> a56a5912a


AMBARI-12438 - MySQL Connection Pooling Defaults Should Be Correct And Present In ambari.properties
(jonathanhurley)


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

Branch: refs/heads/trunk
Commit: a56a5912ac6947ba534a75e3b43e46ae35c0cbdb
Parents: 9d8ce4f
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Thu Jul 16 15:42:22 2015 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Thu Jul 16 23:39:56 2015 -0400

----------------------------------------------------------------------
 .../ambari_server/dbConfiguration_linux.py      | 30 +++++++++++++++++++-
 .../python/ambari_server/serverConfiguration.py |  9 ++++++
 .../src/test/python/TestAmbariServer.py         | 21 +++++++++++++-
 3 files changed, 58 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a56a5912/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
index 25958eb..b337014 100644
--- a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
+++ b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
@@ -42,7 +42,10 @@ from ambari_server.serverConfiguration import encrypt_password, store_password_f
     JDBC_DRIVER_PROPERTY, JDBC_URL_PROPERTY, \
     JDBC_RCA_USER_NAME_PROPERTY, JDBC_RCA_PASSWORD_ALIAS, JDBC_RCA_PASSWORD_FILE_PROPERTY,
\
     JDBC_RCA_DRIVER_PROPERTY, JDBC_RCA_URL_PROPERTY, \
-    PERSISTENCE_TYPE_PROPERTY
+    PERSISTENCE_TYPE_PROPERTY, JDBC_CONNECTION_POOL_TYPE, JDBC_CONNECTION_POOL_ACQUISITION_SIZE,
\
+    JDBC_CONNECTION_POOL_IDLE_TEST_INTERVAL, JDBC_CONNECTION_POOL_MAX_AGE, JDBC_CONNECTION_POOL_MAX_IDLE_TIME,
\
+    JDBC_CONNECTION_POOL_MAX_IDLE_TIME_EXCESS
+
 from ambari_server.userInput import get_YN_input, get_validated_string_input, read_password
 from ambari_server.utils import get_postgre_hba_dir, get_postgre_running_status
 
@@ -258,6 +261,7 @@ class LinuxDBMSConfig(DBMSConfig):
     properties.process_pair(JDBC_DATABASE_NAME_PROPERTY, self.database_name)
 
     properties.process_pair(JDBC_DRIVER_PROPERTY, self.driver_class_name)
+
     # fully qualify the hostname to make sure all the other hosts can connect
     # to the jdbc hostname since its passed onto the agents for RCA
     jdbc_hostname = self.database_host
@@ -282,6 +286,9 @@ class LinuxDBMSConfig(DBMSConfig):
 
     self._store_password_property(properties, JDBC_RCA_PASSWORD_FILE_PROPERTY)
 
+    # connection pooling (internal JPA by default)
+    properties.process_pair(JDBC_CONNECTION_POOL_TYPE, "internal")
+
 
 # PostgreSQL configuration and setup
 class PGConfig(LinuxDBMSConfig):
@@ -518,8 +525,12 @@ class PGConfig(LinuxDBMSConfig):
     properties.process_pair(JDBC_POSTGRES_SCHEMA_PROPERTY, self.postgres_schema)
     properties.process_pair(JDBC_USER_NAME_PROPERTY, self.database_username)
 
+    # connection pooling (internal JPA by default)
+    properties.process_pair(JDBC_CONNECTION_POOL_TYPE, "internal")
+
     self._store_password_property(properties, JDBC_PASSWORD_PROPERTY)
 
+
   @staticmethod
   def _get_postgre_status():
     retcode, out, err = run_os_command(PGConfig.PG_ST_CMD)
@@ -868,6 +879,23 @@ class MySQLConfig(LinuxDBMSConfig):
       scriptFile
     )
 
+  def _store_remote_properties(self, properties):
+    """
+    Override the remote properties written for MySQL, inheriting those from the parent first.
+    :param properties:  the properties object to set MySQL specific properties on
+    :return:
+    """
+    super(MySQLConfig, self)._store_remote_properties(properties)
+
+    # connection pooling (c3p0 used by MySQL by default)
+    properties.process_pair(JDBC_CONNECTION_POOL_TYPE, "c3p0")
+    properties.process_pair(JDBC_CONNECTION_POOL_ACQUISITION_SIZE, "5")
+    properties.process_pair(JDBC_CONNECTION_POOL_IDLE_TEST_INTERVAL, "7200")
+    properties.process_pair(JDBC_CONNECTION_POOL_MAX_IDLE_TIME, "14400")
+    properties.process_pair(JDBC_CONNECTION_POOL_MAX_IDLE_TIME_EXCESS, "0")
+    properties.process_pair(JDBC_CONNECTION_POOL_MAX_AGE, "0")
+
+
 def createMySQLConfig(options, properties, storage_type, dbId):
   return MySQLConfig(options, properties, storage_type)
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a56a5912/ambari-server/src/main/python/ambari_server/serverConfiguration.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverConfiguration.py b/ambari-server/src/main/python/ambari_server/serverConfiguration.py
index 1a56fa6..88683e4 100644
--- a/ambari-server/src/main/python/ambari_server/serverConfiguration.py
+++ b/ambari-server/src/main/python/ambari_server/serverConfiguration.py
@@ -106,6 +106,14 @@ JDBC_DRIVER_PROPERTY = "server.jdbc.driver"
 JDBC_DRIVER_PATH_PROPERTY = "server.jdbc.driver.path"
 JDBC_URL_PROPERTY = "server.jdbc.url"
 
+# connection pool (age and time are in seconds)
+JDBC_CONNECTION_POOL_TYPE = "server.jdbc.connection-pool"
+JDBC_CONNECTION_POOL_ACQUISITION_SIZE = "server.jdbc.connection-pool.acquisition-size"
+JDBC_CONNECTION_POOL_MAX_AGE = "server.jdbc.connection-pool.max-age"
+JDBC_CONNECTION_POOL_MAX_IDLE_TIME = "server.jdbc.connection-pool.max-idle-time"
+JDBC_CONNECTION_POOL_MAX_IDLE_TIME_EXCESS = "server.jdbc.connection-pool.max-idle-time-excess"
+JDBC_CONNECTION_POOL_IDLE_TEST_INTERVAL = "server.jdbc.connection-pool.idle-test-interval"
+
 JDBC_RCA_DATABASE_PROPERTY = "server.jdbc.database"
 JDBC_RCA_HOSTNAME_PROPERTY = "server.jdbc.hostname"
 JDBC_RCA_PORT_PROPERTY = "server.jdbc.port"
@@ -184,6 +192,7 @@ class ServerConfigDefaults(object):
 
     self.AMBARI_PROPERTIES_BACKUP_FILE = ""
     self.AMBARI_KRB_JAAS_LOGIN_BACKUP_FILE = ""
+
     # ownership/permissions mapping
     # path - permissions - user - group - recursive
     # Rules are executed in the same order as they are listed

http://git-wip-us.apache.org/repos/asf/ambari/blob/a56a5912/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 db16927..795ea0a 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -70,6 +70,9 @@ with patch("platform.linux_distribution", return_value = os_distro_value):
           JDBC_DATABASE_NAME_PROPERTY, OS_TYPE_PROPERTY, validate_jdk, JDBC_POSTGRES_SCHEMA_PROPERTY,
\
           RESOURCES_DIR_PROPERTY, JDBC_RCA_PASSWORD_ALIAS, JDBC_RCA_SCHEMA_PROPERTY, IS_LDAP_CONFIGURED,
\
           SSL_API, SSL_API_PORT, CLIENT_API_PORT_PROPERTY,\
+          JDBC_CONNECTION_POOL_TYPE, JDBC_CONNECTION_POOL_ACQUISITION_SIZE, \
+          JDBC_CONNECTION_POOL_IDLE_TEST_INTERVAL, JDBC_CONNECTION_POOL_MAX_AGE, JDBC_CONNECTION_POOL_MAX_IDLE_TIME,
\
+          JDBC_CONNECTION_POOL_MAX_IDLE_TIME_EXCESS,\
           LDAP_MGR_PASSWORD_PROPERTY, LDAP_MGR_PASSWORD_ALIAS, JDBC_PASSWORD_FILENAME, NR_USER_PROPERTY,
SECURITY_KEY_IS_PERSISTED, \
           SSL_TRUSTSTORE_PASSWORD_PROPERTY, SECURITY_IS_ENCRYPTION_ENABLED, SSL_TRUSTSTORE_PASSWORD_ALIAS,
\
           SECURITY_MASTER_KEY_LOCATION, SECURITY_KEYS_DIR, LDAP_PRIMARY_URL_PROPERTY, store_password_file,
\
@@ -4857,7 +4860,23 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
         found = True
 
     self.assertTrue(found)
-    pass
+
+    # verify that some properties exist
+    self.assertEquals("internal", properties.get_property(JDBC_CONNECTION_POOL_TYPE))
+
+    # now try with MySQL instead of Oracle to verify that the properties are different
+    args.dbms = "mysql"
+    args.database_index = 2
+
+    properties0 = Properties()
+    properties = Properties()
+
+    factory = DBMSConfigFactory()
+    dbConfig = factory.create(args, properties0)
+    dbConfig._store_remote_properties(properties)
+
+    # verify MySQL properties
+    self.assertEquals("c3p0", properties.get_property(JDBC_CONNECTION_POOL_TYPE))
 
 
   @not_for_platform(PLATFORM_WINDOWS)


Mime
View raw message