}
protected abstract DataSource configure(BaseDBConfiguration jdbcElem) throws DBConfigException;
+ protected abstract int getAvailableConnections();
/*
* (non-Javadoc)
isSlave = true;
}
if (isSlave) {
- LOGGER.debug("SQL SLAVE : {} on server {}", connectionName, hostname);
+ LOGGER.debug("SQL SLAVE : {} on server {}, pool {}", connectionName, getDbConnectionName(), getAvailableConnections());
} else {
- LOGGER.debug("SQL MASTER : {} on server {}", connectionName, hostname);
+ LOGGER.debug("SQL MASTER : {} on server {}, pool {}", connectionName, getDbConnectionName(), getAvailableConnections());
}
return isSlave;
}
* 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.
public class TerminatingCachedDataSource extends CachedDataSource implements SQLExecutionMonitorObserver {
+ private static final int DEFAULT_AVAILABLE_CONNECTIONS = 0;
+
public TerminatingCachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException {
super(jdbcElem);
}
return null;
}
+ @Override
+ protected int getAvailableConnections() {
+ return DEFAULT_AVAILABLE_CONNECTIONS;
+ }
}
*/
public abstract class BaseDBConfiguration {
- private Logger logger = LoggerFactory.getLogger(BaseDBConfiguration.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(BaseDBConfiguration.class);
/**
* Property key within a properties configuration File for db type
*/
String value = properties.getProperty(CONNECTION_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE);
return Integer.parseInt(value);
} catch (Exception exc) {
- logger.error("Exception",exc);
+ LOGGER.error("Exception",exc);
return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE);
}
}
String value = properties.getProperty(REQUEST_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE);
return Integer.parseInt(value);
} catch (Exception exc) {
- logger.error("Exception",exc);
+ LOGGER.error("Exception",exc);
return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE);
}
}
public String getDbUrl() {
return properties.getProperty(DATABASE_URL);
}
+
+ public boolean containsKey(String propertyname) {
+ return properties.containsKey(propertyname);
+ }
+
+ public String getProperty(String propertyname) {
+ return properties.getProperty(propertyname);
+ }
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * 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.onap.ccsdk.sli.core.dblib.config;
+
+import java.util.Properties;
+
+public class TerminatingConfiguration extends BaseDBConfiguration {
+
+ public TerminatingConfiguration() {
+ super(new Properties());
+ }
+
+}
dataSource.close(true);
super.cleanUp();
}
+
+ @Override
+ protected int getAvailableConnections() {
+ return org.apache.tomcat.jdbc.pool.DataSource.class.cast(ds).getSize();
+ }
}