From 974b67dd4021e6e839eaad25366bffe6d7a414c8 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 31 Mar 2017 15:03:13 -0400 Subject: [SDNC-5] Rebase sdnc-core Upgrade to OpenDaylight Boron release, and sync changes made since 16.10 release to ONAP SDN-C distribution Change-Id: I20bef9e6d0008c4436b5624ce839bbb70ecc20a5 Signed-off-by: Dan Timoney --- .../resource/dblib/CachedDataSourceFactory.java | 8 +- .../sdnc/sli/resource/dblib/DBResourceManager.java | 20 +- .../sli/resource/dblib/config/DbConfigPool.java | 4 - .../factory/AbstractDBResourceManagerFactory.java | 9 +- .../factory/AbstractResourceManagerFactory.java | 11 +- .../resource/dblib/factory/DBConfigFactory.java | 14 +- .../dblib/jdbc/JdbcDBCachedDataSource.java | 252 +++++++++++++++++++++ .../dblib/jndi/JNDIDbResourceManagerFactory.java | 167 -------------- .../resource/dblib/jndi/JndiCachedDataSource.java | 131 ----------- dblib/provider/src/main/resources/dblib.properties | 2 +- 10 files changed, 270 insertions(+), 348 deletions(-) create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jndi/JNDIDbResourceManagerFactory.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jndi/JndiCachedDataSource.java (limited to 'dblib/provider/src/main') diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java index f774748..3e51ed9 100644 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java @@ -23,9 +23,8 @@ package org.openecomp.sdnc.sli.resource.dblib; import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.config.JndiConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.jdbc.JdbcDBCachedDataSource; import org.openecomp.sdnc.sli.resource.dblib.jdbc.MySQLCachedDataSource; -import org.openecomp.sdnc.sli.resource.dblib.jndi.JndiCachedDataSource; /** * @version $Revision: 1.1 $ @@ -38,9 +37,8 @@ public class CachedDataSourceFactory { public static CachedDataSource createDataSource(BaseDBConfiguration config) { if(config instanceof JDBCConfiguration) - return MySQLCachedDataSource.createInstance(config); - if(config instanceof JndiConfiguration) - return JndiCachedDataSource.createInstance(config); + return JdbcDBCachedDataSource.createInstance(config); + return (CachedDataSource)null; } diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java index 7f85c42..401c013 100644 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java @@ -53,7 +53,6 @@ import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.sun.rowset.providers.RIOptimisticProvider; /** * @version $Revision: 1.15 $ @@ -87,7 +86,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } return 0; } - + }); protected final Set broken = Collections.synchronizedSet(new HashSet()); protected final Object monitor = new Object(); @@ -131,17 +130,6 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb worker.setName("DBResourcemanagerWatchThread"); worker.setDaemon(true); worker.start(); - - try { - RIOptimisticProvider rio = new RIOptimisticProvider(); - LOGGER.info("Class " + rio.getClass().getName() + " found."); - Class clas = this.getClass().getClassLoader().loadClass("com.sun.rowset.providers.RIOptimisticProvider"); - if(clas != null) { - LOGGER.info("Class " + rio.getClass().getName() + " found by classloader."); - } - } catch(Exception exc) { - LOGGER.info("Failed resolving RIOptimisticProvider class", exc); - } } private void config(Properties ctx) throws Exception { @@ -320,7 +308,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb Collections.reverse(sources); } - + // loop through available data sources to retrieve data. while(!sources.isEmpty()) { @@ -428,7 +416,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public boolean writeData(String statement, ArrayList arguments, String preferredDS) throws SQLException { return writeDataNoRecovery(statement, arguments, preferredDS); } - + CachedDataSource findMaster() { CachedDataSource master = null; CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]); @@ -468,7 +456,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb active = master; } } - + return active.writeData(statement, arguments); } catch(Throwable exc){ String message = exc.getMessage(); diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java index 90ea6bc..117f932 100644 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java @@ -46,10 +46,6 @@ public class DbConfigPool { return type; } - public JndiConfiguration[] getJndiDbSourceArray() { - return configurations.toArray(new JndiConfiguration[configurations.size()]); - } - public JDBCConfiguration[] getJDBCbSourceArray() { return configurations.toArray(new JDBCConfiguration[configurations.size()]); } diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java index e6b1a35..f4291a7 100644 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java @@ -21,7 +21,6 @@ package org.openecomp.sdnc.sli.resource.dblib.factory; import org.openecomp.sdnc.sli.resource.dblib.jdbc.JdbcDbResourceManagerFactory; -import org.openecomp.sdnc.sli.resource.dblib.jndi.JNDIDbResourceManagerFactory; /** * @version $Revision: 1.1 $ @@ -33,13 +32,7 @@ import org.openecomp.sdnc.sli.resource.dblib.jndi.JNDIDbResourceManagerFactory; public class AbstractDBResourceManagerFactory { public static AbstractResourceManagerFactory getFactory(String type) throws FactoryNotDefinedException { - - if("JNDI".equals(type)){ - try { - return JNDIDbResourceManagerFactory.createIntstance(); - } catch (Exception e) { - } - } + // JDBC return JdbcDbResourceManagerFactory.createIntstance(); } diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java index 148ddac..29ec061 100644 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java @@ -32,7 +32,6 @@ import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager; import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.config.JndiConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,20 +48,15 @@ public abstract class AbstractResourceManagerFactory { public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager) throws Exception; public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager dbResourceManager, String sourceName) throws SQLException ; - + public static AbstractResourceManagerFactory createIntstance() throws FactoryNotDefinedException { throw new FactoryNotDefinedException("Factory method 'createIntstance' needs to be overriden in DBResourceManagerFactory"); } - public class DBInitTask implements Callable + public class DBInitTask implements Callable { private BaseDBConfiguration config = null; private Set activeTasks; - - public DBInitTask(JndiConfiguration jndiConfig, Set tasks){ - this.config = jndiConfig; - this.activeTasks = tasks; - } public DBInitTask(JDBCConfiguration jdbcconfig, Set tasks) { this.config = jdbcconfig; @@ -97,6 +91,7 @@ public abstract class AbstractResourceManagerFactory { worker.start(); } else { if(LOGGER.isDebugEnabled()) + if(ds != null) LOGGER.debug("Completed CachedDataSource.Call from "+ds.getDbConnectionName()); } } diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java index 7044082..3530459 100644 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java @@ -25,10 +25,11 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.Properties; +import org.slf4j.LoggerFactory; + import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.config.JndiConfiguration; /** * @version $Revision: 1.1 $ @@ -44,7 +45,7 @@ public class DBConfigFactory { } static DbConfigPool getConfigparams(Properties properties){ - org.slf4j.LoggerFactory.getLogger(DBConfigFactory.class).info(properties.toString()); + LoggerFactory.getLogger(DBConfigFactory.class).info(properties.toString()); DbConfigPool xmlConfig = new DbConfigPool(properties); ArrayList propertySets = new ArrayList(); @@ -78,7 +79,7 @@ public class DBConfigFactory { } } catch (Exception e) { - org.slf4j.LoggerFactory.getLogger(DBConfigFactory.class).warn("",e); + LoggerFactory.getLogger(DBConfigFactory.class).warn("",e); } return xmlConfig; @@ -89,15 +90,12 @@ public class DBConfigFactory { String type = props.getProperty(BaseDBConfiguration.DATABASE_TYPE); BaseDBConfiguration config = null; - - if("JNDI".equalsIgnoreCase(type)) { - config = new JndiConfiguration(props); - } + if("JDBC".equalsIgnoreCase(type)) { config = new JDBCConfiguration(props); } return config; - + } } diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java new file mode 100644 index 0000000..ee3d4ff --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java @@ -0,0 +1,252 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.sli.resource.dblib.jdbc; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLFeatureNotSupportedException; + +import org.apache.tomcat.jdbc.pool.DataSource; +import org.apache.tomcat.jdbc.pool.PoolProperties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.openecomp.sdnc.sli.resource.dblib.CachedDataSource; +import org.openecomp.sdnc.sli.resource.dblib.DBConfigException; +import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; +import com.mysql.jdbc.Driver; + + +/** + * @version $Revision: 1.7 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ + +public class JdbcDBCachedDataSource extends CachedDataSource +{ + private String dbUserId; + private String dbPasswd; + private String dbUrl; + + private int minLimit; + private int maxLimit; + private int initialLimit; + + private static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; + + private static Logger LOGGER = LoggerFactory.getLogger(JdbcDBCachedDataSource.class); + + /** + * @param jdbcElem + * @param alarmLog + * @param occManager + * @throws Exception + */ + public JdbcDBCachedDataSource(BaseDBConfiguration jdbcElem) + { + super(jdbcElem); + } + + @Override + protected void configure(BaseDBConfiguration xmlElem) throws DBConfigException + { + BaseDBConfiguration jdbcConfig = (BaseDBConfiguration)xmlElem; + if(jdbcConfig.getConnTimeout() > 0){ + this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); + } + if(jdbcConfig.getRequestTimeout() > 0){ + this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); + } + + // set connection pool name + String dbConnectionName = jdbcConfig.getDbConnectionName(); + super.setDbConnectionName(dbConnectionName); + // Configure the JDBC connection + dbUserId = jdbcConfig.getDbUserId(); + if (dbUserId == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + dbPasswd = jdbcConfig.getDbPasswd(); + if (dbPasswd == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + /* + dbDriver = jdbcConfig.getDbDriver(); + if (dbDriver == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new ScpTblUpdateError(errorMsg); + } + */ + + minLimit = jdbcConfig.getDbMinLimit(); +// if (minLimit == null) +// { +// String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); +// } + maxLimit = jdbcConfig.getDbMaxLimit(); +// if (maxLimit == null) +// { +// String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); +// } + initialLimit = jdbcConfig.getDbInitialLimit(); +// if (initialLimit == null) +// { +// String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); +// } + + dbUrl = jdbcConfig.getDbUrl(); + if(dbUrl == null){ + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + try { + Driver dr = new com.mysql.jdbc.Driver(); + Class clazz = Class.forName("com.mysql.jdbc.Driver") ; + + PoolProperties p = new PoolProperties(); + p.setDriverClassName("com.mysql.jdbc.Driver"); + p.setUrl(dbUrl); + p.setUsername(dbUserId); + p.setPassword(dbPasswd); + p.setJmxEnabled(true); + p.setTestWhileIdle(false); + p.setTestOnBorrow(true); + p.setValidationQuery("SELECT 1"); + p.setTestOnReturn(false); + p.setValidationInterval(30000); + p.setTimeBetweenEvictionRunsMillis(30000); + p.setInitialSize(initialLimit); + p.setMaxActive(maxLimit); + p.setMaxIdle(maxLimit); + p.setMaxWait(10000); + p.setRemoveAbandonedTimeout(60); + p.setMinEvictableIdleTimeMillis(30000); + p.setMinIdle(minLimit); + p.setLogAbandoned(true); + p.setRemoveAbandoned(true); + p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" + + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"); + + DataSource dataSource = new DataSource(p); + + synchronized(this) + { + this.ds = dataSource; + Connection con = null; + PreparedStatement st = null; + ResultSet rs = null; + + try { + con = dataSource.getConnection(); + st = con.prepareStatement("Select 1 FROM DUAL"); + rs = st.executeQuery(); + } catch(Exception exc) { + LOGGER.error(exc.getMessage()); + } finally { + if(rs != null) rs.close(); + if(st != null) st.close(); + if(con != null) con.close(); + } + + initialized = true; + LOGGER.info("MySQLDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); + } + +// } catch (SQLException exc) { +// initialized = false; +// StringBuffer sb = new StringBuffer(); +// sb.append("Failed to initialize MySQLDataSource<"); +// sb.append(dbConnectionName).append(">. Reason: "); +// sb.append(exc.getMessage()); +// LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +//// throw new DBConfigException(e.getMessage()); + } catch (Exception exc) { + initialized = false; + StringBuffer sb = new StringBuffer(); + sb.append("Failed to initialize MySQLCachedDataSource <"); + sb.append(dbConnectionName).append(">. Reason: "); + sb.append(exc.getMessage()); + LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +// throw new DBConfigException(e.getMessage()); + } + } + + public final String getDbUrl() + { + return dbUrl; + } + + public final String getDbUserId() + { + return dbUserId; + } + + public final String getDbPasswd() + { + return dbPasswd; + } + + public static JdbcDBCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { + return new JdbcDBCachedDataSource(config); + } + + public String toString(){ + return getDbConnectionName(); + } + + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } + + public void cleanUp(){ + DataSource dataSource = (DataSource)ds; + dataSource.getPool().purge(); + int active = dataSource.getActive(); + int size = dataSource.getSize(); + dataSource.close(true); + super.cleanUp(); + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jndi/JNDIDbResourceManagerFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jndi/JNDIDbResourceManagerFactory.java deleted file mode 100644 index 2888bc5..0000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jndi/JNDIDbResourceManagerFactory.java +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.sli.resource.dblib.jndi; - -import java.sql.SQLException; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; - -import org.openecomp.sdnc.sli.resource.dblib.CachedDataSource; -import org.openecomp.sdnc.sli.resource.dblib.CachedDataSourceFactory; -import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager; -import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; -import org.openecomp.sdnc.sli.resource.dblib.config.JndiConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.factory.AbstractResourceManagerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @version $Revision: 1.6 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public class JNDIDbResourceManagerFactory extends AbstractResourceManagerFactory { - - private static Logger LOGGER = LoggerFactory.getLogger(JNDIDbResourceManagerFactory.class); - - class MyFutureTask extends FutureTask - { - - public MyFutureTask(Callable result) { - super((Callable)result); - } - - } - - public CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager, String sourceName) throws SQLException - { - // here create the data sources objects - JndiConfiguration[] list = dbConfig.getJndiDbSourceArray(); - CachedDataSource[] cachedDS = new CachedDataSource[1]; - - for(int i=0, max=list.length; i[] futures = new MyFutureTask[list.length]; - final Set tasks = new HashSet(); - if(LOGGER.isDebugEnabled()) - LOGGER.debug("Creating datasources."); - for(int i=0, max=list.length; i0){ -// config.setJndiContextFactory(manager.getJndiContextFactoryStr()); -// } -// if(manager.getJndiURLStr()!=null && manager.getJndiURLStr().trim().length()>0){ -// config.setJndiURL(manager.getJndiURLStr()); -// } - DBInitTask task = new DBInitTask(config, tasks); - tasks.add(task); - futures[i] = new MyFutureTask(task); - } - - try { - synchronized(tasks){ - for(int i=0, max=list.length; i 0){ - this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); - } - if(jdbcConfig.getRequestTimeout() > 0){ - this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); - } - - super.setDbConnectionName(jdbcConfig.getJndiConnectionName()); - - if(jndiContextFactoryStr == null || jndiContextFactoryStr.length() == 0) - { -// throw new DBConfigException("The jndi configuration is incomplete: jndiContextFactory"); - } - if(jndiURLStr == null || jndiContextFactoryStr.length() == 0) - { -// throw new ScpTblUpdateError("The jndi configuration is incomplete: jndiURL"); - } - if(jndiSourceStr == null || jndiSourceStr.length() == 0) - { - throw new DBConfigException("The jndi configuration is incomplete: jndiSource"); - } - - Properties env = new Properties(); - Context ctx; - try - { - if(jndiContextFactoryStr != null && jndiContextFactoryStr.length() != 0){ - env.put(Context.INITIAL_CONTEXT_FACTORY, jndiContextFactoryStr); - ctx = new InitialContext(env); - } else { - ctx = new InitialContext(); - } - ds = (javax.sql.DataSource) ctx.lookup (jndiSourceStr); - if(ds == null) - { - this.initialized = false; - LOGGER.error("AS_CONF_ERROR: Failed to initialize DataSource <"+getDbConnectionName()+"> using JNDI <"+jndiSourceStr+">"); - return; - } else { - this.initialized = true; - LOGGER.info("JndiCachedDataSource <"+getDbConnectionName()+"> configured successfully."); - return; - } - } catch (NamingException exc) { - this.initialized = false; - LOGGER.error("AS_CONF_ERROR" + exc.getMessage()); - - } catch(Throwable exc) { - this.initialized = false; - LOGGER.error("AS_CONF_ERROR: " + exc.getMessage()); - } - } - - public static JndiCachedDataSource createInstance(BaseDBConfiguration config) { - return new JndiCachedDataSource(config); - } - - public String toString(){ - return getDbConnectionName(); - } - - public java.util.logging.Logger getParentLogger() - throws SQLFeatureNotSupportedException { - // TODO Auto-generated method stub - return null; - } -} diff --git a/dblib/provider/src/main/resources/dblib.properties b/dblib/provider/src/main/resources/dblib.properties index 3872288..0f28f1f 100755 --- a/dblib/provider/src/main/resources/dblib.properties +++ b/dblib/provider/src/main/resources/dblib.properties @@ -3,7 +3,7 @@ org.openecomp.sdnc.sli.jdbc.hosts=sdnctldb01,sdnctldb02 org.openecomp.sdnc.sli.jdbc.url=jdbc:mysql://DBHOST:3306/sdnctl org.openecomp.sdnc.sli.jdbc.database=sdnctl org.openecomp.sdnc.sli.jdbc.user=sdnctl -org.openecomp.sdnc.sli.jdbc.password=gamma +org.openecomp.sdnc.sli.jdbc.password={password for sdnctl} org.openecomp.sdnc.sli.jdbc.connection.name=sdnctldb01 org.openecomp.sdnc.sli.jdbc.connection.timeout=50 -- cgit 1.2.3-korg