summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-09-25 19:29:12 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-25 19:29:12 +0000
commite66b47fd3bef54a055b081e6d8be86ebda3505c2 (patch)
treee4cb7c7719043033d92e1ba14be1014b011cf8e9
parent857e086044637992fe7ba69e8bd423805c329ad7 (diff)
parent7cdcaa3b9923e30eea689c6cd16e766ea9190d05 (diff)
Merge "Remove sonar blocker and critical"
-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
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java5
5 files changed, 35 insertions, 25 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
}
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 a4a97968..4f7469cc 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
@@ -38,10 +38,7 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.onap.policy.common.im.AdministrativeStateException;
import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.StandbyStatusException;
@@ -57,6 +54,8 @@ import org.onap.policy.drools.activestandby.JpaDroolsPdpsConnector;
import org.onap.policy.drools.activestandby.PMStandbyStateChangeNotifier;
import org.onap.policy.drools.core.PolicySessionFeatureAPI;
import org.onap.policy.drools.statemanagement.StateManagementFeatureAPI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/*
* All JUnits are designed to run in the local development environment