public static DBResourceManager initDbLibService() throws IOException { Properties props = new Properties(); File file = new File("/opt/onap/appc/data/properties/dblib.properties"); URL propURL = file.toURI().toURL(); props.load(propURL.openStream()); jdbcDataSource = new DBResourceManager(props); return jdbcDataSource; } }
retryInterval = getLongFromProperties(properties, "org.onap.dblib.connection.retry", 10000L); recoveryMode = getBooleanFromProperties(properties, "org.onap.dblib.connection.recovery", true); if(!recoveryMode) terminationTimeOut = getLongFromProperties(properties, "org.onap.dblib.termination.timeout", 300000L); monitorDbResponse = getBooleanFromProperties(properties, "org.onap.dblib.connection.monitor", false); monitoringInterval = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.interval", 1000L); monitoringInitialDelay = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.startdelay", 5000L); expectedCompletionTime = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); unprocessedFailoverThreshold = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); this.config(properties); } catch (final Exception e) {
public static CachedRowSet getData(String tableName, List<String> argList, String schema, String getselectData, String getDataClasue) throws SQLException { String selectQuery = "select " + getselectData + "from " + tableName + " where " + getDataClasue; return jdbcDataSource.getData(selectQuery, Lists.newArrayList(argList), schema); }
CachedDataSource master = findMaster(); if(master != null) { active = master; lastException = exc; if(recoveryMode){ handleGetConnectionException(active, exc); } else { if(exc instanceof SQLException) { } finally { if(LOGGER.isDebugEnabled()){ displayState();
if(!active.isFabric()) { if(this.dsQueue.size() > 1 && active.isSlave()) { CachedDataSource master = findMaster(); if(master != null) { active = master; } catch(Throwable exc){ if(recoveryMode){ handleGetConnectionException(active, exc); } else { if(exc instanceof SQLException)
public void testForceRecovery() { CachedDataSource active = this.dsQueue.first(); handleGetConnectionException(active, new Exception("test")); }
if(!active.isFabric()) { if(this.dsQueue.size() > 1 && active.isSlave()) { CachedDataSource master = findMaster(); if(master != null) { active = master; this.findMaster(); if(retryAllowed){ retryAllowed = false;
dbResourceManager.cleanUp();
if(!active.isFabric()) { if(this.dsQueue.size() > 1 && active.isSlave()) { CachedDataSource master = findMaster(); if(master != null) { active = master; handleGetConnectionException(active, exc); } finally { if(LOGGER.isDebugEnabled()){
public void test(){ CachedDataSource obj = dsQueue.first(); Exception ption = new Exception(); try { for(int i=0; i<5; i++) { handleGetConnectionException(obj, ption); } } catch(Throwable exc){ LOGGER.warn("", exc); } }
if(!active.isFabric()) { if(this.dsQueue.size() > 1 && active.isSlave()) { CachedDataSource master = findMaster(); if(master != null) { active = master;
} finally { if (dbResourceManager != null) { dbResourceManager.cleanUp(); System.exit(0);
public SvcLogicDblibStore(Properties props) { try { dbSvc = new DBResourceManager(props); JavaSingleton.setInstance(dbSvc); } catch (Exception e) { LOG.warn("Caught exception trying to create DBResourceManager", e); } }
@Override public void update(Observable observable, Object data) { // if observable is active and there is a standby available, switch if(observable instanceof SQLExecutionMonitor) { SQLExecutionMonitor monitor = (SQLExecutionMonitor)observable; if(monitor.getParent() instanceof CachedDataSource) { CachedDataSource dataSource = (CachedDataSource)monitor.getParent(); if(dataSource == dsQueue.first()) { if(recoveryMode && dsQueue.size() > 1){ handleGetConnectionException(dataSource, new Exception(data.toString())); } } } } }
dblibSvc = new DBResourceManager(dblibProps); } catch (Exception e) { LOG.error("Caught exception trying to create dblib service", e);
dbSvc = new DBResourceManager(dblibProps); JavaSingleton.setInstance(dbSvc); } catch (Exception e) {