From c157d989c9e8634ad7d2d4456a235fa8ce34da81 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 18 Dec 2018 14:56:29 +0530 Subject: fixed sonar issues and formatted code formatted code and added equals and hashcode method as per sonar standards Issue-ID: CCSDK-525 Change-Id: Idaa0a6a0a82315189a9365064d4f196e4689ee57 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/dblib/pm/PollingWorker.java | 127 +++++++++++++-------- 1 file changed, 78 insertions(+), 49 deletions(-) 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 b44e2f89..905944b1 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 @@ -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 @@ -26,13 +28,12 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; import java.util.TreeSet; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.atomic.AtomicLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.atomic.AtomicLong; - public class PollingWorker implements Runnable { private Logger logger = LoggerFactory.getLogger(PollingWorker.class); @@ -47,71 +48,72 @@ public class PollingWorker implements Runnable { private static boolean enabled = false; private Timer timer = null; - private PollingWorker(Properties ctxprops){ - if(ctxprops==null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm") == null){ + private PollingWorker(Properties ctxprops) { + if (ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm") == null) { enabled = false; } else { - if("true".equalsIgnoreCase((String)ctxprops.getProperty("org.onap.ccsdk.dblib.pm"))){ + if ("true".equalsIgnoreCase((String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm"))) { enabled = true; } else { enabled = false; } } - interval = Long.parseLong(( ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval") == null) ? "60" : (String)ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval")); + interval = Long.parseLong((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval") == null) + ? "60" : (String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval")); // '0' bucket is to count exceptions - String sampling[] = ((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")==null) ? "0,2,5,10,20,50,100" : (String)ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")).split(","); + String sampling[] = ((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling") == null) + ? "0,2,5,10,20,50,100" : (String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")).split(","); - if(enabled){ + if (enabled) { bucketUnit = new int[sampling.length]; - for(int i=0, max = bucketUnit.length; i