From dbdef1e3e3803b5848a1fad746c652f9359d4313 Mon Sep 17 00:00:00 2001 From: "Magnusen, Drew (dm741q)" Date: Tue, 17 Apr 2018 11:59:43 -0500 Subject: Sonar cleanup More sonar cleanup. Resolved some of the simpler issues. Issue-ID: POLICY-728 Change-Id: If9c4718f10c6d3524239d2a05c09badb791ef2f0 Signed-off-by: Magnusen, Drew (dm741q) --- .../activestandby/ActiveStandbyProperties.java | 4 ++++ .../policy/drools/activestandby/DroolsPdpEntity.java | 20 ++++++++++++++++++++ .../policy/drools/activestandby/DroolsPdpImpl.java | 20 ++++++++++++++++++++ .../activestandby/DroolsPdpsElectionHandler.java | 9 ++++----- 4 files changed, 48 insertions(+), 5 deletions(-) (limited to 'feature-active-standby-management/src/main/java/org') 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 listOfDesignated = new ArrayList<>(); + List listOfDesignated = new ArrayList<>(); Collection pdps = pdpsConnector.getDroolsPdps(); DroolsPdp designatedPdp = null; @@ -635,11 +635,11 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker { } // end run } - public ArrayList santizeDesignatedList(ArrayList listOfDesignated){ + public List santizeDesignatedList(List listOfDesignated){ boolean containsDesignated = false; boolean containsHotStandby = false; - ArrayList listForRemoval = new ArrayList(); + List 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 pdps, ArrayList listOfDesignated){ + public DroolsPdp computeMostRecentPrimary(Collection pdps, List listOfDesignated){ boolean containsDesignated = false; for(DroolsPdp pdp : listOfDesignated){ if(pdp.isDesignated()){ -- cgit 1.2.3-korg