aboutsummaryrefslogtreecommitdiffstats
path: root/feature-active-standby-management/src/main
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-09-24 08:34:24 -0400
committerPamela Dragosh <pdragosh@research.att.com>2017-09-24 08:35:04 -0400
commit7cdcaa3b9923e30eea689c6cd16e766ea9190d05 (patch)
tree3ab0d3b01cc5f5a4f7616c0c15707d2c8f752c74 /feature-active-standby-management/src/main
parent9e7c10d65864e7fe95a6289f046b7c7e7b334b2e (diff)
Remove sonar blocker and critical
Removed unused import Null pointer exception Does not evaluate to true override hashCode log exception cast long public static final Issue-ID: POLICY-261 Change-Id: I2d90f8503fcc5ed7d13aff31143b8fb69c689e18 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'feature-active-standby-management/src/main')
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java18
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java9
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java18
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java10
4 files changed, 33 insertions, 22 deletions
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
index d40a9e0f..d2c542fb 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
@@ -106,6 +106,10 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureAPI,
logger.error("ActiveStandbyFeature failed to initialize. "
+ "Unable to get instance of StateManagementFeatureAPI "
+ "with resourceID: {}", myPdp.getPdpId());
+ //
+ // Cannot add observer since stateManagementFeature is null
+ //
+ return;
}
@@ -172,15 +176,13 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureAPI,
myPdp = new DroolsPdpImpl(resourceName,false,4,new Date());
}
- if(myPdp != null){
- String site_name = ActiveStandbyProperties.getProperty(ActiveStandbyProperties.SITE_NAME);
- if (site_name == null) {
- site_name = "";
- }else{
- site_name = site_name.trim();
- }
- myPdp.setSiteName(site_name);
+ String site_name = ActiveStandbyProperties.getProperty(ActiveStandbyProperties.SITE_NAME);
+ if (site_name == null) {
+ site_name = "";
+ }else{
+ site_name = site_name.trim();
}
+ myPdp.setSiteName(site_name);
if(electionHandler == null){
electionHandler = new DroolsPdpsElectionHandler(conn,myPdp);
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java
index e434c834..8c1d9f2e 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java
@@ -31,6 +31,15 @@ public abstract class DroolsPdpObject implements DroolsPdp{
return false;
}
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (this.getPdpId() == null ? 0 : this.getPdpId().hashCode());
+ result = prime * result + (this.getSiteName() == null ? 0 : this.getSiteName().hashCode());
+ result = prime * result + this.getPriority();
+ return super.hashCode();
+ }
private int nullSafeCompare(String one, String two){
if(one != null && two != null){
return one.compareTo(two);
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 6edf11f8..b0f1a12a 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
@@ -256,7 +256,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.error
("DesignatedWaiter.run: myPdp: {} "
+ "Caught Exception attempting to demote myPdp,"
- + "message= {}", myPdp.getPdpId(), e.getMessage());
+ + "message= {}", myPdp.getPdpId(), e);
}
}else{
// Don't demote a remote PDP that is current. It should catch itself
@@ -318,7 +318,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.error
("DesignatedWaiter.run: myPdp: {} Caught Exception "
+ "attempting to disableFail myPdp {}, message= {}",
- myPdp.getPdpId(), myPdp.getPdpId(), e.getMessage());
+ myPdp.getPdpId(), myPdp.getPdpId(), e);
}
} else { //it is a remote PDP that is failed
if(logger.isDebugEnabled()){
@@ -336,7 +336,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.error
("DesignatedWaiter.run: for PDP {} Caught Exception attempting to "
+ "disableFail({}), message= {}",
- pdp.getPdpId(), pdp.getPdpId(), e.getMessage());
+ pdp.getPdpId(), pdp.getPdpId(), e);
}
}
@@ -378,7 +378,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.error
("DesignatedWaiter.run: myPdp: {} Caught Exception "
+ "attempting to demote myPdp {}, message = {}", myPdp.getPdpId(),
- myPdp.getPdpId(), e.getMessage());
+ myPdp.getPdpId(), e);
}
}
@@ -438,7 +438,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.error
("DesignatedWaiter.run: myPdp: {} Caught Exception attempting to "
+ "disableFail myPdp {}, message= {}",
- myPdp.getPdpId(), myPdp.getPdpId(), e.getMessage());
+ myPdp.getPdpId(), myPdp.getPdpId(), e);
}
}else{//it is remote
if(logger.isDebugEnabled()){
@@ -455,7 +455,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.error
("DesignatedWaiter.run: for PDP {}"
+ " Caught Exception attempting to disableFail({})"
- + ", message=", pdp.getPdpId(), pdp.getPdpId(), e.getMessage());
+ + ", message=", pdp.getPdpId(), pdp.getPdpId(), e);
}
}
}
@@ -551,7 +551,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
} catch (Exception e) {
logger.error
("ERROR: DesignatedWaiter.run: Caught Exception attempting to promote PDP={}"
- + ", message=", myPdp.getPdpId(), e.getMessage());
+ + ", message=", myPdp.getPdpId(), e);
myPdp.setDesignated(false);
pdpsConnector.setDesignated(myPdp,false);
isDesignated = false;
@@ -571,7 +571,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.error
("ERROR: DesignatedWaiter.run: Caught StandbyStatusException "
+ "attempting to promote then demote PDP={}, message=",
- myPdp.getPdpId(), e1.getMessage());
+ myPdp.getPdpId(), e1);
}
}
@@ -850,7 +850,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.error
("DesignatedWaiter.run: myPdp: {} Caught Exception attempting to "
+ "demote myPdp {} myPdp.getPdpId(), message= {}", myPdp.getPdpId(),
- e.getMessage());
+ e);
}
}
} //end: for(DroolsPdp pdp : listOfDesignated)
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java
index ce62bf89..5a6dd8fa 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java
@@ -80,16 +80,16 @@ public class PMStandbyStateChangeNotifier extends StateChangeNotifier {
private long waitInterval;
private boolean isNowActivating;
private String previousStandbyStatus;
- public static String NONE = "none";
- public static String UNSUPPORTED = "unsupported";
- public static String HOTSTANDBY_OR_COLDSTANDBY = "hotstandby_or_coldstandby";
+ public static final String NONE = "none";
+ public static final String UNSUPPORTED = "unsupported";
+ public static final String HOTSTANDBY_OR_COLDSTANDBY = "hotstandby_or_coldstandby";
public PMStandbyStateChangeNotifier(){
pdpUpdateInterval = Integer.parseInt(ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_UPDATE_INTERVAL));
isWaitingForActivation = false;
startTimeWaitingForActivationMs = new Date().getTime();
//delay the activate so the DesignatedWaiter can run twice - give it an extra 2 seconds
- waitInterval = 2*pdpUpdateInterval + 2000;
+ waitInterval = 2*pdpUpdateInterval + 2000L;
isNowActivating=false;
previousStandbyStatus = PMStandbyStateChangeNotifier.NONE;
}
@@ -248,7 +248,7 @@ public class PMStandbyStateChangeNotifier extends StateChangeNotifier {
delayActivateTimer.cancel();
}catch(Exception e){
if(logger.isDebugEnabled()){
- logger.debug("handleStateChange: PROVIDING_SERVICE no delayActivationTimer existed.");
+ logger.debug("handleStateChange: PROVIDING_SERVICE no delayActivationTimer existed.", e);
}
//If you end of here, there was no active timer
}