diff options
Diffstat (limited to 'dblib')
5 files changed, 32 insertions, 21 deletions
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java index 296fe70f..15aa7a1d 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java @@ -4,6 +4,8 @@ * ================================================================================ * 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 @@ -38,7 +40,7 @@ public class CachedDataSourceFactory { if(config instanceof JDBCConfiguration) return JdbcDBCachedDataSource.createInstance(config); - return (CachedDataSource)null; + return null; } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 9acae340..047fa297 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -4,6 +4,8 @@ * ================================================================================ * 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 @@ -68,7 +70,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb transient protected long retryInterval = 10000L; transient boolean recoveryMode = true; - SortedSet<CachedDataSource> dsQueue = new ConcurrentSkipListSet<CachedDataSource>(new DataSourceComparator()); + SortedSet<CachedDataSource> dsQueue = new ConcurrentSkipListSet<>(new DataSourceComparator()); protected final Set<CachedDataSource> broken = Collections.synchronizedSet(new HashSet<CachedDataSource>()); protected final Object monitor = new Object(); protected final Properties configProps; @@ -80,6 +82,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb protected final long monitoringInitialDelay; protected final long expectedCompletionTime; protected final long unprocessedFailoverThreshold; + private static final String LOGGER_ALARM_MSG="Generated alarm: DBResourceManager.getData - No active DB connection pools are available."; public DBResourceManager(final DBLIBResourceProvider configuration) { this(configuration.getProperties()); @@ -393,7 +396,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb // test if there are any connection pools available if(this.dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + LOGGER.error(LOGGER_ALARM_MSG); throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); } @@ -457,7 +460,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb private CachedRowSet requestDataNoRecovery(String statement, ArrayList<Object> arguments, String preferredDS) throws SQLException { if(dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + LOGGER.error(LOGGER_ALARM_MSG); throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); } CachedDataSource active = this.dsQueue.first(); @@ -533,7 +536,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb private boolean writeDataNoRecovery(String statement, ArrayList<Object> arguments, String preferredDS) throws SQLException { if(dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + LOGGER.error(LOGGER_ALARM_MSG); throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java index 21fdab24..fb94ea0e 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java @@ -4,6 +4,8 @@ * ================================================================================ * 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 @@ -30,7 +32,7 @@ public class DbConfigPool { private final String type; - private ArrayList<BaseDBConfiguration> configurations = new ArrayList<BaseDBConfiguration>(); + private ArrayList<BaseDBConfiguration> configurations = new ArrayList<>(); public DbConfigPool(Properties properties) { LOGGER.debug("Initializing DbConfigType"); @@ -38,7 +40,6 @@ public class DbConfigPool { } public int getTimeout() { - // TODO Auto-generated method stub return 0; } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java index c3503576..1aa90783 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java @@ -4,6 +4,8 @@ * ================================================================================ * 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 @@ -44,7 +46,7 @@ public class DBConfigFactory { static DbConfigPool getConfigparams(Properties properties) { DbConfigPool xmlConfig = new DbConfigPool(properties); - ArrayList<Properties> propertySets = new ArrayList<Properties>(); + ArrayList<Properties> propertySets = new ArrayList<>(); if ("JDBC".equalsIgnoreCase(xmlConfig.getType())) { String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS); diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java index 4bfa058a..b44e2f89 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java @@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicLong; public class PollingWorker implements Runnable { - private Logger LOGGER = LoggerFactory.getLogger(PollingWorker.class); + private Logger logger = LoggerFactory.getLogger(PollingWorker.class); private static PollingWorker self = null; @@ -47,17 +47,6 @@ public class PollingWorker implements Runnable { private static boolean enabled = false; private Timer timer = null; - public static void post(long starttime){ - PollingWorker temp = self; - if(temp != null && enabled) { - temp.register(new TestSample(starttime)); - } - } - - public static void createInistance(Properties props){ - self = new PollingWorker(props); - } - private PollingWorker(Properties ctxprops){ if(ctxprops==null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm") == null){ enabled = false; @@ -89,6 +78,18 @@ public class PollingWorker implements Runnable { timer.schedule(new MyTimerTask(), interval*1000L, interval*1000L); } } + public static void post(long starttime){ + PollingWorker temp = self; + if(temp != null && enabled) { + temp.register(new TestSample(starttime)); + } + } + + public static void createInistance(Properties props){ + self = new PollingWorker(props); + } + + private void register(TestSample object){ try { @@ -113,12 +114,14 @@ public class PollingWorker implements Runnable { consume((TestSample)next); } else { System.out.println(next.getClass().getName()); + logger.error(next.getClass().getName()); } } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); + } } @@ -146,7 +149,7 @@ public class PollingWorker implements Runnable { } sb.append(tmp2[i].get()).append("\t"); } - LOGGER.info(sb.toString()); + logger.info(sb.toString()); } class MyTimerTask extends TimerTask{ |