You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2017/06/22 14:42:48 UTC

[2/2] ambari git commit: AMBARI-21294. Setup should keep existing connection-pool setting in ambari.properties

AMBARI-21294. Setup should keep existing connection-pool setting in ambari.properties


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

Branch: refs/heads/branch-2.5
Commit: f6bd2b9077922f11507bda54777b8b56188cb3ed
Parents: 291625d
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Wed Jun 21 11:00:23 2017 +0200
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Thu Jun 22 16:38:30 2017 +0200

----------------------------------------------------------------------
 .../ambari_server/dbConfiguration_linux.py      | 34 +++++++++++++-------
 1 file changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f6bd2b90/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 797466d..1142d25 100644
--- a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
+++ b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
@@ -78,6 +78,14 @@ class LinuxDBMSConfig(DBMSConfig):
     self.local_admin_user = DBMSConfig._init_member_with_prop_default(options, "local_admin_user",
                                                                        properties, LOCAL_DATABASE_ADMIN_PROPERTY, "postgres")
     self.database_password = getattr(options, "database_password", "")
+
+    self.jdbc_connection_pool_type = DBMSConfig._init_member_with_prop_default(options, "jdbc_connection_pool_type", properties, JDBC_CONNECTION_POOL_TYPE, "internal")
+    self.jdbc_connection_pool_acquisition_size = DBMSConfig._init_member_with_prop_default(options, "jdbc_connection_pool_acquisition_size", properties, JDBC_CONNECTION_POOL_ACQUISITION_SIZE, "5")
+    self.jdbc_connection_pool_idle_test_interval = DBMSConfig._init_member_with_prop_default(options, "jdbc_connection_pool_idle_test_interval", properties, JDBC_CONNECTION_POOL_IDLE_TEST_INTERVAL, "7200")
+    self.jdbc_connection_pool_max_idle_time = DBMSConfig._init_member_with_prop_default(options, "jdbc_connection_pool_max_idle_time", properties, JDBC_CONNECTION_POOL_MAX_IDLE_TIME, "14400")
+    self.jdbc_connection_pool_max_idle_time_excess = DBMSConfig._init_member_with_prop_default(options, "jdbc_connection_pool_max_idle_time_excess", properties, JDBC_CONNECTION_POOL_MAX_IDLE_TIME_EXCESS, "0")
+    self.jdbc_connection_pool_max_age = DBMSConfig._init_member_with_prop_default(options, "jdbc_connection_pool_max_age", properties, JDBC_CONNECTION_POOL_MAX_AGE, "0")
+
     if not self.database_password:
       self.database_password = DBMSConfig._read_password_from_properties(properties, options)
 
@@ -316,9 +324,17 @@ class LinuxDBMSConfig(DBMSConfig):
     properties.process_pair(JDBC_RCA_USER_NAME_PROPERTY, self.database_username)
 
     self._store_password_property(properties, JDBC_RCA_PASSWORD_FILE_PROPERTY, options)
+    self._store_connection_pool_properties(properties)
 
-    # connection pooling (internal JPA by default)
-    properties.process_pair(JDBC_CONNECTION_POOL_TYPE, "internal")
+  # Store set of properties for JDBC connection pooling
+  def _store_connection_pool_properties(self, properties):
+    properties.process_pair(JDBC_CONNECTION_POOL_TYPE, self.jdbc_connection_pool_type)
+    if self.jdbc_connection_pool_type == "c3p0":
+      properties.process_pair(JDBC_CONNECTION_POOL_ACQUISITION_SIZE, self.jdbc_connection_pool_acquisition_size)
+      properties.process_pair(JDBC_CONNECTION_POOL_IDLE_TEST_INTERVAL, self.jdbc_connection_pool_idle_test_interval)
+      properties.process_pair(JDBC_CONNECTION_POOL_MAX_IDLE_TIME, self.jdbc_connection_pool_max_idle_time)
+      properties.process_pair(JDBC_CONNECTION_POOL_MAX_IDLE_TIME_EXCESS, self.jdbc_connection_pool_max_idle_time_excess)
+      properties.process_pair(JDBC_CONNECTION_POOL_MAX_AGE, self.jdbc_connection_pool_max_age)
 
 
 # PostgreSQL configuration and setup
@@ -578,8 +594,7 @@ 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_connection_pool_properties(properties)
 
     properties.process_pair(LOCAL_DATABASE_ADMIN_PROPERTY, self.local_admin_user)
 
@@ -1037,15 +1052,10 @@ class MySQLConfig(LinuxDBMSConfig):
     :param properties:  the properties object to set MySQL specific properties on
     :return:
     """
-    super(MySQLConfig, self)._store_remote_properties(properties, options)
-
     # 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")
+    self.jdbc_connection_pool_type = "c3p0"
+
+    super(MySQLConfig, self)._store_remote_properties(properties, options)
 
 
 def createMySQLConfig(options, properties, storage_type, dbId):