Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-20859 b5333870a -> f760516c2


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/45a29900
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/45a29900
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/45a29900

Branch: refs/heads/branch-feature-AMBARI-20859
Commit: 45a29900bf849678347e33c14587f8ffca855383
Parents: 5fc8ccc
Author: Attila Doroszlai <[email protected]>
Authored: Wed Jun 21 11:00:23 2017 +0200
Committer: Attila Doroszlai <[email protected]>
Committed: Thu Jun 22 16:37:58 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/45a29900/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 dac3141..38dfa8c 100644
--- a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
+++ b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
@@ -82,6 +82,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)
 
@@ -320,9 +328,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
@@ -582,8 +598,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)
 
@@ -1036,15 +1051,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):

Reply via email to