summaryrefslogtreecommitdiffstats
path: root/integrity-monitor/src
diff options
context:
space:
mode:
authorMagnusen, Drew (dm741q) <dm741q@att.com>2017-08-04 12:51:14 -0500
committerMagnusen, Drew (dm741q) <dm741q@att.com>2017-08-04 12:52:38 -0500
commit66221823c8cb131b8cea03c4d011ddd728608451 (patch)
tree78576114739d849c75c90dc7b2b52c9429162a29 /integrity-monitor/src
parent09ca5f00b5fb88d35987e1922c34cae8469ed79d (diff)
[POLICY-96] Resolved sonar blockers in im/ia.
Resolved 7 sonar blockers in the integrity monitor and integrity audit projects. Change-Id: I7bba7619d3b71f7aebcc2642d07a64876ee7aea0 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'integrity-monitor/src')
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java83
1 files changed, 57 insertions, 26 deletions
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
index 06e9b3de..fef1dd54 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
@@ -544,42 +544,75 @@ public class IntegrityMonitor {
//verify that the ForwardProgress is current (check last_updated)
if(error_msg==null){
- Date date = new Date();
- long diffMs = date.getTime() - forwardProgressEntity.getLastUpdated().getTime();
- logger.debug("IntegrityMonitor.stateCheck(): diffMs = " + diffMs);
+ if (forwardProgressEntity != null && stateManagementEntity != null) {
+ Date date = new Date();
+ long diffMs = date.getTime() - forwardProgressEntity.getLastUpdated().getTime();
+ logger.debug("IntegrityMonitor.stateCheck(): diffMs = " + diffMs);
- //Threshold for a stale entry
- long staleMs = failedCounterThreshold * monitorInterval * 1000;
- logger.debug("IntegrityMonitor.stateCheck(): staleMs = " + staleMs);
+ //Threshold for a stale entry
+ long staleMs = failedCounterThreshold * monitorInterval * 1000;
+ logger.debug("IntegrityMonitor.stateCheck(): staleMs = " + staleMs);
- if(diffMs > staleMs){
- //ForwardProgress is stale. Disable it
- try {
- if(!stateManagementEntity.getOpState().equals(StateManagement.DISABLED)){
- logger.debug("IntegrityMonitor.stateCheck(): Changing OpStat = disabled for " + dep);
- stateManager.disableFailed(dep);
+ if(diffMs > staleMs){
+ //ForwardProgress is stale. Disable it
+ try {
+ if(!stateManagementEntity.getOpState().equals(StateManagement.DISABLED)){
+ logger.debug("IntegrityMonitor.stateCheck(): Changing OpStat = disabled for " + dep);
+ stateManager.disableFailed(dep);
+ }
+ } catch (Exception e) {
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + e.getMessage();
+ logger.debug(msg);
+ logger.error(msg);
}
- } catch (Exception e) {
+ }
+ }
+ else {
+
+ if(forwardProgressEntity == null) {
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + " forwardProgressEntity == null.";
+ logger.debug(msg);
+ logger.error(msg);
+ }
+
+ else if(stateManagementEntity == null) {
String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
- + "; " + e.getMessage();
+ + "; " + " stateManagementEntity == null.";
logger.debug(msg);
logger.error(msg);
}
+
+ else {
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + " forwardProgressEntity or stateManagementEntity == null.";
+ logger.debug(msg);
+ logger.error(msg);
+
+ }
}
}
// check operation, admin and standby states of dependent resource
if (error_msg == null) {
- if ((stateManager.getAdminState() != null) && stateManagementEntity.getAdminState().equals(StateManagement.LOCKED)) {
- error_msg = dep + ": resource is administratively locked";
- logger.debug(error_msg);
- logger.error(error_msg);
- } else if ((stateManager.getOpState() != null) && stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
- error_msg = dep + ": resource is operationally disabled";
- logger.debug(error_msg);
- logger.error(error_msg);
- } else if ((stateManager.getStandbyStatus() != null) && stateManagementEntity.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
- error_msg = dep + ": resource is cold standby";
+ if(stateManagementEntity != null) {
+ if ((stateManager.getAdminState() != null) && stateManagementEntity.getAdminState().equals(StateManagement.LOCKED)) {
+ error_msg = dep + ": resource is administratively locked";
+ logger.debug(error_msg);
+ logger.error(error_msg);
+ } else if ((stateManager.getOpState() != null) && stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
+ error_msg = dep + ": resource is operationally disabled";
+ logger.debug(error_msg);
+ logger.error(error_msg);
+ } else if ((stateManager.getStandbyStatus() != null) && stateManagementEntity.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
+ error_msg = dep + ": resource is cold standby";
+ logger.debug(error_msg);
+ logger.error(error_msg);
+ }
+ }
+ else {
+ error_msg = dep + ": could not check standy state of resource. stateManagementEntity == null.";
logger.debug(error_msg);
logger.error(error_msg);
}
@@ -622,12 +655,10 @@ public class IntegrityMonitor {
try {
// create instance of StateMangement class for dependent
StateManagement depStateManager = new StateManagement(emf, dep);
- if (depStateManager != null) {
if(!depStateManager.getOpState().equals(StateManagement.DISABLED)){
logger.info("Forward progress not detected for dependent resource " + dep + ". Setting dependent's state to disable failed.");
depStateManager.disableFailed();
}
- }
} catch (Exception e) {
// ignore errors
logger.info("Update dependent state failed with exception: " + e);