summaryrefslogtreecommitdiffstats
path: root/feature-active-standby-management/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'feature-active-standby-management/src/main')
-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
4 files changed, 48 insertions, 5 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()){