summaryrefslogtreecommitdiffstats
path: root/dblib
diff options
context:
space:
mode:
Diffstat (limited to 'dblib')
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java4
-rwxr-xr-xdblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java11
-rwxr-xr-xdblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java9
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java5
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java4
5 files changed, 23 insertions, 10 deletions
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java
index 296fe70f..15aa7a1d 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2016 - 2017 ONAP
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -38,7 +40,7 @@ public class CachedDataSourceFactory {
if(config instanceof JDBCConfiguration)
return JdbcDBCachedDataSource.createInstance(config);
- return (CachedDataSource)null;
+ return null;
}
}
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
index 9acae340..047fa297 100755
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2016 - 2017 ONAP
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -68,7 +70,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb
transient protected long retryInterval = 10000L;
transient boolean recoveryMode = true;
- SortedSet<CachedDataSource> dsQueue = new ConcurrentSkipListSet<CachedDataSource>(new DataSourceComparator());
+ SortedSet<CachedDataSource> dsQueue = new ConcurrentSkipListSet<>(new DataSourceComparator());
protected final Set<CachedDataSource> broken = Collections.synchronizedSet(new HashSet<CachedDataSource>());
protected final Object monitor = new Object();
protected final Properties configProps;
@@ -80,6 +82,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb
protected final long monitoringInitialDelay;
protected final long expectedCompletionTime;
protected final long unprocessedFailoverThreshold;
+ private static final String LOGGER_ALARM_MSG="Generated alarm: DBResourceManager.getData - No active DB connection pools are available.";
public DBResourceManager(final DBLIBResourceProvider configuration) {
this(configuration.getProperties());
@@ -393,7 +396,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb
// test if there are any connection pools available
if(this.dsQueue.isEmpty()){
- LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available.");
+ LOGGER.error(LOGGER_ALARM_MSG);
throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call.");
}
@@ -457,7 +460,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb
private CachedRowSet requestDataNoRecovery(String statement, ArrayList<Object> arguments, String preferredDS) throws SQLException {
if(dsQueue.isEmpty()){
- LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available.");
+ LOGGER.error(LOGGER_ALARM_MSG);
throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call.");
}
CachedDataSource active = this.dsQueue.first();
@@ -533,7 +536,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb
private boolean writeDataNoRecovery(String statement, ArrayList<Object> arguments, String preferredDS) throws SQLException {
if(dsQueue.isEmpty()){
- LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available.");
+ LOGGER.error(LOGGER_ALARM_MSG);
throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call.");
}
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java
index a8bc58b8..5f0209b6 100755
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java
@@ -3,6 +3,7 @@
* onap
* ================================================================================
* Copyright (C) 2016 - 2017 ONAP
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,12 +22,14 @@
package org.onap.ccsdk.sli.core.dblib.config;
import java.util.Properties;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Base class responsible for parsing business logic for database configuration from given <code>Properties</code>.
*/
public abstract class BaseDBConfiguration {
+ private Logger logger = LoggerFactory.getLogger(BaseDBConfiguration.class);
/**
* Property key within a properties configuration File for db type
*/
@@ -45,7 +48,7 @@ public abstract class BaseDBConfiguration {
/**
* Property key with a properties configuration File for jdbc driver
*/
- public static final String DRIVER_NAME = "org.onap.ccsdk.sli.jdbc.driver";
+ public static final String DRIVER_NAME = "org.onap.ccsdk.sli.jdbc.driver";
/**
* Property key with a properties configuration File for db database connection name
@@ -131,6 +134,7 @@ public abstract class BaseDBConfiguration {
String value = properties.getProperty(CONNECTION_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE);
return Integer.parseInt(value);
} catch (Exception exc) {
+ logger.error("Exception",exc);
return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE);
}
}
@@ -146,6 +150,7 @@ public abstract class BaseDBConfiguration {
String value = properties.getProperty(REQUEST_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE);
return Integer.parseInt(value);
} catch (Exception exc) {
+ logger.error("Exception",exc);
return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE);
}
}
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java
index 21fdab24..fb94ea0e 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2016 - 2017 ONAP
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -30,7 +32,7 @@ public class DbConfigPool {
private final String type;
- private ArrayList<BaseDBConfiguration> configurations = new ArrayList<BaseDBConfiguration>();
+ private ArrayList<BaseDBConfiguration> configurations = new ArrayList<>();
public DbConfigPool(Properties properties) {
LOGGER.debug("Initializing DbConfigType");
@@ -38,7 +40,6 @@ public class DbConfigPool {
}
public int getTimeout() {
- // TODO Auto-generated method stub
return 0;
}
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java
index c3503576..1aa90783 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2016 - 2017 ONAP
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -44,7 +46,7 @@ public class DBConfigFactory {
static DbConfigPool getConfigparams(Properties properties) {
DbConfigPool xmlConfig = new DbConfigPool(properties);
- ArrayList<Properties> propertySets = new ArrayList<Properties>();
+ ArrayList<Properties> propertySets = new ArrayList<>();
if ("JDBC".equalsIgnoreCase(xmlConfig.getType())) {
String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS);