aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-06-18 15:26:10 +0000
committerGerrit Code Review <gerrit@onap.org>2019-06-18 15:26:10 +0000
commit7c69f07593a8c7474bd7a69a65979dc0635f1526 (patch)
tree79ce2336642ada485244a830a5c79011eac54617 /asdc-controller
parent703517112032025146a968db5c830c7389f5166f (diff)
parent1a592b9e45f95d694fbf649f41304f148e3c40fe (diff)
Merge "Changes related to eviction of connections"
Diffstat (limited to 'asdc-controller')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java14
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java16
-rw-r--r--asdc-controller/src/main/resources/application.yaml28
3 files changed, 35 insertions, 23 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java b/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java
index 3494945020..39bb836ff8 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java
@@ -20,11 +20,9 @@
package org.onap.so.asdc;
-
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
@@ -36,6 +34,8 @@ import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
@Configuration
@EnableTransactionManagement
@@ -44,11 +44,17 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Profile({"!test"})
public class CatalogDBConfig {
+ @Bean
+ @ConfigurationProperties(prefix = "spring.datasource.hikari")
+ public HikariConfig catalogDbConfig() {
+ return new HikariConfig();
+ }
+
@Primary
@Bean(name = "dataSource")
- @ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource() {
- return DataSourceBuilder.create().build();
+ HikariConfig hikariConfig = this.catalogDbConfig();
+ return new HikariDataSource(hikariConfig);
}
@Primary
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java b/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java
index 8320da01cf..821b2dacff 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java
@@ -20,11 +20,9 @@
package org.onap.so.asdc;
-
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
@@ -35,6 +33,8 @@ import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
@Configuration
@EnableTransactionManagement
@@ -43,13 +43,18 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Profile({"!test"})
public class RequestDBConfig {
+ @Bean
+ @ConfigurationProperties(prefix = "request.datasource.hikari")
+ public HikariConfig requestDbConfig() {
+ return new HikariConfig();
+ }
+
@Bean(name = "requestDataSource")
- @ConfigurationProperties(prefix = "request.datasource")
public DataSource dataSource() {
- return DataSourceBuilder.create().build();
+ HikariConfig hikariConfig = this.requestDbConfig();
+ return new HikariDataSource(hikariConfig);
}
-
@Bean(name = "requestEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
@Qualifier("requestDataSource") DataSource dataSource) {
@@ -57,7 +62,6 @@ public class RequestDBConfig {
.build();
}
-
@Bean(name = "requestTransactionManager")
public PlatformTransactionManager transactionManager(
@Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
diff --git a/asdc-controller/src/main/resources/application.yaml b/asdc-controller/src/main/resources/application.yaml
index 2d0a2acf94..beb40e5e65 100644
--- a/asdc-controller/src/main/resources/application.yaml
+++ b/asdc-controller/src/main/resources/application.yaml
@@ -4,15 +4,13 @@ server:
spring:
datasource:
- jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb
- username: ${DB_USERNAME}
- password: ${DB_PASSWORD}
- driver-class-name: org.mariadb.jdbc.Driver
- dbcp2:
- initial-size: 5
- max-total: 20
- validation-query: select 1
- test-on-borrow: true
+ hikari:
+ jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb
+ username: ${DB_USERNAME}
+ password: ${DB_PASSWORD}
+ driver-class-name: org.mariadb.jdbc.Driver
+ pool-name: catdb-pool
+ registerMbeans: true
jpa:
show-sql: true
hibernate:
@@ -23,10 +21,14 @@ spring:
request:
datasource:
- jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb
- username: ${DB_USERNAME}
- password: ${DB_PASSWORD}
- driver-class-name: org.mariadb.jdbc.Driver
+ hikari:
+ jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb
+ username: ${DB_USERNAME}
+ password: ${DB_PASSWORD}
+ driver-class-name: org.mariadb.jdbc.Driver
+ pool-name: reqdb-pool
+ registerMbeans: true
+
#Actuator
management:
endpoints: