aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-06-17 10:51:08 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-06-17 11:03:23 -0400
commit1a592b9e45f95d694fbf649f41304f148e3c40fe (patch)
tree90a9749a8b6e59e375b67206529d5118a7facf5e /mso-api-handlers/mso-api-handler-infra
parent984f8da49f06c1563b4496572c54147014aa94bb (diff)
Changes related to eviction of connections
These are changes related to ASDC controller for evicting database connection pool when ip address changes Included other appllications such as requestDB, CatalogDB, API Handler, BPMN, OpenstackAdapter etc Change-Id: I9a96ea12fb0c10643a204a58d55360bebba326fe Issue-ID: SO-2018 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java22
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml23
4 files changed, 55 insertions, 18 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java
index bc1972a593..5beb4810ec 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java
@@ -21,17 +21,18 @@
package org.onap.so.apihandlerinfra;
import java.util.concurrent.Executor;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator;
@SpringBootApplication(scanBasePackages = {"org.onap"})
@EnableAsync
+@EnableScheduling
public class ApiHandlerApplication {
@Value("${mso.async.core-pool-size}")
@@ -53,6 +54,7 @@ public class ApiHandlerApplication {
public static void main(String[] args) {
SpringApplication.run(ApiHandlerApplication.class, args);
+ java.security.Security.setProperty("networkaddress.cache.ttl", "10");
System.getProperties().setProperty("mso.db", "MARIADB");
System.getProperties().setProperty("server.name", "Springboot");
setLogsDir();
@@ -69,4 +71,5 @@ public class ApiHandlerApplication {
executor.initialize();
return executor;
}
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java
index 4d81695e55..0db63e7493 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java
@@ -23,8 +23,8 @@ package org.onap.so.apihandlerinfra.configuration;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
+import org.springframework.beans.factory.annotation.Autowired;
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;
@@ -32,10 +32,13 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.jmx.export.MBeanExporter;
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 +47,23 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Profile({"!test"})
public class CatalogDBConfig {
+ @Autowired(required = false)
+ private MBeanExporter mBeanExporter;
+
+ @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();
+ if (mBeanExporter != null) {
+ mBeanExporter.addExcludedBean("dataSource");
+ }
+ HikariConfig hikariConfig = this.catalogDbConfig();
+ return new HikariDataSource(hikariConfig);
}
@Primary
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java
index 1bc54ffe7b..02cbf2f3bf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java
@@ -23,18 +23,21 @@ package org.onap.so.apihandlerinfra.configuration;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
+import org.springframework.beans.factory.annotation.Autowired;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.jmx.export.MBeanExporter;
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 +46,24 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Profile({"!test"})
public class RequestDBConfig {
+ @Autowired(required = false)
+ private MBeanExporter mBeanExporter;
+
+ @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();
+ if (mBeanExporter != null) {
+ mBeanExporter.addExcludedBean("requestDataSource");
+ }
+ HikariConfig hikariConfig = this.requestDbConfig();
+ return new HikariDataSource(hikariConfig);
}
-
@Bean(name = "requestEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
@Qualifier("requestDataSource") DataSource dataSource) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
index 03934edf20..136acfb9e1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
@@ -29,10 +29,13 @@ mso:
spring:
datasource:
- jdbcUrl: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb
- username: ${DB_USERNAME}
- password: ${DB_PASSWORD}
- driver-class-name: org.mariadb.jdbc.Driver
+ hikari:
+ jdbcUrl: 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:
@@ -45,11 +48,13 @@ spring:
request:
datasource:
- jdbcUrl: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb
- username: ${DB_USERNAME}
- password: ${DB_PASSWORD}
- driver-class-name: org.mariadb.jdbc.Driver
-
+ hikari:
+ jdbcUrl: 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: