aboutsummaryrefslogtreecommitdiffstats
path: root/dblib/provider/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'dblib/provider/src/main/java/org')
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java2
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java4
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java6
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java34
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java289
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java18
6 files changed, 243 insertions, 110 deletions
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java
index 2e1a6e95..f30212dc 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java
@@ -23,5 +23,5 @@ package org.onap.ccsdk.sli.core.dblib;
import java.util.Observer;
public interface DBResourceObserver extends Observer {
- public boolean isMonitorDbResponse();
+ boolean isMonitorDbResponse();
}
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java
index 7921fa5c..fdfb47bc 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java
@@ -27,7 +27,7 @@ import javax.sql.rowset.CachedRowSet;
public interface DataAccessor {
- public abstract CachedRowSet getData(String statement, ArrayList<String> arguments, String preferredDS)
- throws SQLException;
+ CachedRowSet getData(String statement, ArrayList<String> arguments, String preferredDS)
+ throws SQLException;
}
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java
index bc14fb8b..4cfcc731 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java
@@ -24,10 +24,10 @@ import java.util.Comparator;
public interface DataSourceComparator extends Comparator <CachedDataSource>{
- public abstract CachedDataSource getLastUsed();
+ CachedDataSource getLastUsed();
- public abstract void setLastUsed(CachedDataSource lastUsed);
+ void setLastUsed(CachedDataSource lastUsed);
- public abstract int compare(CachedDataSource ds1, CachedDataSource ds2);
+ int compare(CachedDataSource ds1, CachedDataSource ds2);
}
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java
index 0dea664d..b31de354 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java
@@ -28,22 +28,22 @@ import javax.sql.rowset.CachedRowSet;
public interface DbLibService {
- /* (non-Javadoc)
- * @see DataAccessor#getData(java.lang.String, java.util.ArrayList)
- */
- public abstract CachedRowSet getData(String statement,
- ArrayList<String> arguments, String preferredDS)
- throws SQLException;
-
- /* (non-Javadoc)
- * @see DataAccessor#writeData(java.lang.String, java.util.ArrayList)
- */
- public abstract boolean writeData(String statement,
- ArrayList<String> arguments, String preferredDS)
- throws SQLException;
-
- public abstract boolean isActive();
-
- public abstract Connection getConnection() throws SQLException;
+ /* (non-Javadoc)
+ * @see DataAccessor#getData(java.lang.String, java.util.ArrayList)
+ */
+ CachedRowSet getData(String statement,
+ ArrayList<String> arguments, String preferredDS)
+ throws SQLException;
+
+ /* (non-Javadoc)
+ * @see DataAccessor#writeData(java.lang.String, java.util.ArrayList)
+ */
+ boolean writeData(String statement,
+ ArrayList<String> arguments, String preferredDS)
+ throws SQLException;
+
+ boolean isActive();
+
+ Connection getConnection() throws SQLException;
}
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 4b738d42..d53be0e7 100644
--- 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
@@ -22,83 +22,216 @@ package org.onap.ccsdk.sli.core.dblib.config;
import java.util.Properties;
+/**
+ * Base class responsible for parsing business logic for database configuration from given <code>Properties</code>.
+ */
public abstract class BaseDBConfiguration {
- public static final String DATABASE_TYPE = "org.onap.ccsdk.sli.dbtype";
- public static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url";
- public static final String DATABASE_NAME = "org.onap.ccsdk.sli.jdbc.database";
- public static final String CONNECTION_NAME = "org.onap.ccsdk.sli.jdbc.connection.name";
- public static final String DATABASE_USER = "org.onap.ccsdk.sli.jdbc.user";
- public static final String DATABASE_PSSWD = "org.onap.ccsdk.sli.jdbc.password";
- public static final String CONNECTION_TIMEOUT="org.onap.ccsdk.sli.jdbc.connection.timeout";
- public static final String REQUEST_TIMEOUT = "org.onap.ccsdk.sli.jdbc.request.timeout";
- public static final String MIN_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.min";
- public static final String MAX_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.max";
- public static final String INIT_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.init";
- public static final String DATABASE_HOSTS = "org.onap.ccsdk.sli.jdbc.hosts";
-
-
- protected final Properties props;
-
- public BaseDBConfiguration(Properties properties) {
- this.props = properties;
- }
-
- public int getConnTimeout() {
- try {
- String value = props.getProperty(CONNECTION_TIMEOUT);
- return Integer.parseInt(value);
- } catch(Exception exc) {
- return -1;
- }
- }
-
- public int getRequestTimeout() {
- try {
- String value = props.getProperty(REQUEST_TIMEOUT);
- if(value == null)
- return -1;
- return Integer.parseInt(value);
- } catch(Exception exc) {
- return -1;
- }
- }
-
- public String getDbConnectionName() {
- return props.getProperty(CONNECTION_NAME);
- }
-
- public String getDatabaseName() {
- return props.getProperty(DATABASE_NAME);
- }
-
- public String getDbUserId() {
- return props.getProperty(DATABASE_USER);
- }
-
- public String getDbPasswd() {
- return props.getProperty(DATABASE_PSSWD);
- }
-
- public int getDbMinLimit() {
- String value = props.getProperty(MIN_LIMIT);
- return Integer.parseInt(value);
- }
-
- public int getDbMaxLimit() {
- String value = props.getProperty(MAX_LIMIT);
- return Integer.parseInt(value);
- }
-
- public int getDbInitialLimit() {
- String value = props.getProperty(INIT_LIMIT);
- return Integer.parseInt(value);
- }
-
- public String getDbUrl() {
- return props.getProperty(DATABASE_URL);
- }
-
- public String getServerGroup() {
- return null;
- }
+
+ /**
+ * Property key within a properties configuration File for db type
+ */
+ public static final String DATABASE_TYPE = "org.onap.ccsdk.sli.dbtype";
+
+ /**
+ * Property key with a properties configuration File for db url
+ */
+ public static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url";
+
+ /**
+ * Property key with a properties configuration File for database name
+ */
+ public static final String DATABASE_NAME = "org.onap.ccsdk.sli.jdbc.database";
+
+ /**
+ * Property key with a properties configuration File for db database connection name
+ */
+ public static final String CONNECTION_NAME = "org.onap.ccsdk.sli.jdbc.connection.name";
+
+ /**
+ * Property key with a properties configuration File for database user
+ */
+ public static final String DATABASE_USER = "org.onap.ccsdk.sli.jdbc.user";
+
+ /**
+ * Property key with a properties configuration File for database password for associated with
+ * <code>org.onap.ccsdk.sli.jdbc.user</code>.
+ */
+ public static final String DATABASE_PSSWD = "org.onap.ccsdk.sli.jdbc.password";
+
+ /**
+ * Property key with a properties configuration File for database connection timeout
+ */
+ public static final String CONNECTION_TIMEOUT="org.onap.ccsdk.sli.jdbc.connection.timeout";
+
+ /**
+ * Property key with a properties configuration File for database request timeout
+ */
+ public static final String REQUEST_TIMEOUT = "org.onap.ccsdk.sli.jdbc.request.timeout";
+
+ /**
+ * Property key with a properties configuration File for database minimum limit
+ */
+ public static final String MIN_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.min";
+
+ /**
+ * Property key with a properties configuration File for database maximum limit
+ */
+ public static final String MAX_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.max";
+
+ /**
+ * Property key with a properties configuration File for database initial limit
+ */
+ public static final String INIT_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.init";
+
+ /**
+ * Property key with a properties configuration File for database hosts
+ */
+ public static final String DATABASE_HOSTS = "org.onap.ccsdk.sli.jdbc.hosts";
+
+ /**
+ * default value when the connection timeout is not present or cannot be parsed
+ */
+ private static final int DEFAULT_CONNECTION_TIMEOUT = -1;
+
+ /**
+ * default value when the request timeout is not present or cannot be parsed
+ */
+ private static final int DEFAULT_REQUEST_TIMEOUT = -1;
+
+ /**
+ * A set of properties with database configuration information.
+ */
+ protected final Properties properties;
+
+ /**
+ * Builds a configuration based on given properties
+ *
+ * @param properties properties represented by the public constant keys defined by this class
+ */
+ public BaseDBConfiguration(final Properties properties) {
+ this.properties = properties;
+ }
+
+ /**
+ * Extracts the connection timeout.
+ *
+ * @return the connection timeout, or <code>DEFAULT_CONNECTION_TIMEOUT</code> if not present
+ */
+ public int getConnTimeout() {
+ return extractProperty(properties, CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
+ }
+
+ /**
+ * Extracts the request timeout.
+ *
+ * @return the request timeout, or <code>DEFAULT_REQUEST_TIMEOUT</code> if not present
+ */
+ public int getRequestTimeout() {
+ return extractProperty(properties, REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT);
+ }
+
+ /**
+ * A utility method to extract int property from Properties.
+ *
+ * @param properties a set of <code>Properties</code>
+ * @param propertyKey the key in question
+ * @param defaultValue the value to return if the key does not exist
+ * @return Either the property value for <code>propertyKey</code> or <code>defaultValue</code> if not present
+ */
+ private static int extractProperty(final Properties properties, final String propertyKey, final int defaultValue) {
+ try {
+ final String valueString = properties.getProperty(propertyKey, Integer.toString(defaultValue));
+ return Integer.parseInt(valueString);
+ } catch(final NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * Extracts the db connection name.
+ *
+ * @return the db connection name, or <code>null</code> if not present
+ */
+ public String getDbConnectionName() {
+ return properties.getProperty(CONNECTION_NAME);
+ }
+
+ /**
+ * Extracts the db name.
+ *
+ * @return the db name, or <code>null</code> if not present
+ */
+ public String getDatabaseName() {
+ return properties.getProperty(DATABASE_NAME);
+ }
+
+ /**
+ * Extracts the db user id.
+ *
+ * @return the db user id, or <code>null</code> if not present
+ */
+ public String getDbUserId() {
+ return properties.getProperty(DATABASE_USER);
+ }
+
+ /**
+ * Extracts the db password.
+ *
+ * @return the db password, or <code>null</code> if not present
+ */
+ public String getDbPasswd() {
+ return properties.getProperty(DATABASE_PSSWD);
+ }
+
+ /**
+ * Extracts the db min limit.
+ *
+ * @return the db min limit
+ * @throws NumberFormatException if the property is not specified, or cannot be parsed as an <code>Integer</code>.
+ */
+ public int getDbMinLimit() throws NumberFormatException {
+ String value = properties.getProperty(MIN_LIMIT);
+ return Integer.parseInt(value);
+ }
+
+ /**
+ * Extracts the db max limit.
+ *
+ * @return the db max limit
+ * @throws NumberFormatException if the property is not specified, or cannot be parsed as an <code>Integer</code>.
+ */
+ public int getDbMaxLimit() throws NumberFormatException {
+ String value = properties.getProperty(MAX_LIMIT);
+ return Integer.parseInt(value);
+ }
+
+ /**
+ * Extracts the db initial limit.
+ *
+ * @return the db initial limit
+ * @throws NumberFormatException if the property is not specified, or cannot be parsed as an <code>Integer</code>.
+ */
+ public int getDbInitialLimit() throws NumberFormatException {
+ String value = properties.getProperty(INIT_LIMIT);
+ return Integer.parseInt(value);
+ }
+
+ /**
+ * Extracts the db url.
+ *
+ * @return the db url, or <code>null</code> if not present
+ */
+ public String getDbUrl() {
+ return properties.getProperty(DATABASE_URL);
+ }
+
+ /**
+ * Extracts the db server group.
+ *
+ * @return <code>null</code>
+ */
+ @Deprecated
+ public String getServerGroup() {
+ return null;
+ }
}
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java
index c17696a8..2fdde1ee 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java
@@ -21,17 +21,17 @@
package org.onap.ccsdk.sli.core.dblib.pm;
public interface SQLExecutionMonitorObserver {
- public String getDbConnectionName();
+ String getDbConnectionName();
- public long getInterval();
- public void setInterval(long value);
+ long getInterval();
+ void setInterval(long value);
- public long getInitialDelay();
- public void setInitialDelay(long value);
+ long getInitialDelay();
+ void setInitialDelay(long value);
- public long getExpectedCompletionTime();
- public void setExpectedCompletionTime(long value);
+ long getExpectedCompletionTime();
+ void setExpectedCompletionTime(long value);
- public long getUnprocessedFailoverThreshold();
- public void setUnprocessedFailoverThreshold(long value);
+ long getUnprocessedFailoverThreshold();
+ void setUnprocessedFailoverThreshold(long value);
}