summaryrefslogtreecommitdiffstats
path: root/feature-active-standby-management/src
diff options
context:
space:
mode:
authorMagnusen, Drew (dm741q) <dm741q@att.com>2018-04-17 11:59:43 -0500
committerPamela Dragosh <pdragosh@research.att.com>2018-04-19 18:24:06 +0000
commitdbdef1e3e3803b5848a1fad746c652f9359d4313 (patch)
tree5d16019fa041dd0279f6eeb1c6ef49b3c2a8b210 /feature-active-standby-management/src
parent4efc7394cf405b0dfe6c3dbadc09d067217847e4 (diff)
Sonar cleanup
More sonar cleanup. Resolved some of the simpler issues. Issue-ID: POLICY-728 Change-Id: If9c4718f10c6d3524239d2a05c09badb791ef2f0 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'feature-active-standby-management/src')
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java4
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java20
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java20
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java9
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java4
5 files changed, 50 insertions, 7 deletions
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java
index 6e26334b..a70c71f6 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java
@@ -45,6 +45,10 @@ public class ActiveStandbyProperties {
public static final String DB_PWD = "javax.persistence.jdbc.password";
private static Properties properties = null;
+
+ private ActiveStandbyProperties() {
+ throw new IllegalStateException("Utility class");
+ }
/*
* Initialize the parameter values from the droolsPersitence.properties file values
*
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
index ec1ce579..ed10f4c2 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
@@ -133,5 +133,25 @@ public class DroolsPdpEntity extends DroolsPdpObject implements Serializable{
public void setDesignatedDate(Date designatedDate) {
this.designatedDate = designatedDate;
}
+
+ @Override
+ public boolean equals(Object obj){
+
+ if (obj instanceof DroolsPdp) {
+ DroolsPdpEntity d = (DroolsPdpEntity) obj;
+ return this.pdpId.equals(d.getPdpId());
+ } else {
+ return false;
+ }
+
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (this.pdpId == null ? 0 : this.pdpId.hashCode());
+ return result;
+ }
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
index 141d5857..f54a18cc 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
@@ -89,4 +89,24 @@ public class DroolsPdpImpl extends DroolsPdpObject {
this.designatedDate = designatedDate;
}
+
+ @Override
+ public boolean equals(Object obj){
+
+
+ if (obj instanceof DroolsPdp) {
+ DroolsPdpImpl p = (DroolsPdpImpl) obj;
+ return this.pdpId.equals(p.getPdpId());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (this.pdpId == null ? 0 : this.pdpId.hashCode());
+ return result;
+ }
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
index 1a09d920..9b172e13 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
@@ -196,7 +196,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
//It is possible that multiple PDPs are designated lead. So, we will make a list of all designated
//PDPs and then decide which one really should be designated at the end.
- ArrayList<DroolsPdp> listOfDesignated = new ArrayList<>();
+ List<DroolsPdp> listOfDesignated = new ArrayList<>();
Collection<DroolsPdp> pdps = pdpsConnector.getDroolsPdps();
DroolsPdp designatedPdp = null;
@@ -635,11 +635,11 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
} // end run
}
- public ArrayList<DroolsPdp> santizeDesignatedList(ArrayList<DroolsPdp> listOfDesignated){
+ public List<DroolsPdp> santizeDesignatedList(List<DroolsPdp> listOfDesignated){
boolean containsDesignated = false;
boolean containsHotStandby = false;
- ArrayList<DroolsPdp> listForRemoval = new ArrayList<DroolsPdp>();
+ List<DroolsPdp> listForRemoval = new ArrayList<>();
for(DroolsPdp pdp : listOfDesignated){
if(logger.isDebugEnabled()){
logger.debug
@@ -656,12 +656,11 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
if(containsDesignated && containsHotStandby){
//remove the hot standby from the list
listOfDesignated.removeAll(listForRemoval);
- containsHotStandby = false;
}
return listOfDesignated;
}
- public DroolsPdp computeMostRecentPrimary(Collection<DroolsPdp> pdps, ArrayList<DroolsPdp> listOfDesignated){
+ public DroolsPdp computeMostRecentPrimary(Collection<DroolsPdp> pdps, List<DroolsPdp> listOfDesignated){
boolean containsDesignated = false;
for(DroolsPdp pdp : listOfDesignated){
if(pdp.isDesignated()){
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
index 66af3eaa..0ad21f03 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
@@ -26,8 +26,8 @@ import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import java.util.Properties;
-
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
@@ -321,7 +321,7 @@ public class StandbyStateManagementTest {
DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
- ArrayList<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
+ List<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
listOfDesignated.add(pdp1);
listOfDesignated.add(pdp2);
listOfDesignated.add(pdp3);