/*- * ============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.SQLException; import java.util.Arrays; import java.util.HashSet; import java.util.List; 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.DataSourceComparator; 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.factory.AbstractResourceManagerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @version $Revision: 1.6 $ * Change Log * Author Date Comments * ============== ======== ==================================================== * Rich Tabedzki */ public class JdbcDbResourceManagerFactory extends AbstractResourceManagerFactory { private static Logger LOGGER = LoggerFactory.getLogger(JdbcDbResourceManagerFactory.class ); private JdbcDbResourceManagerFactory(){ } 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 JDBCConfiguration[] list = dbConfig.getJDBCbSourceArray(); 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 " + list.length + " datasources."); } for(int i=0, max=list.length; i