diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2017-08-08 11:27:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-08-08 11:27:33 +0000 |
commit | 96bca95f4610edfdabf1fddb981416235158312d (patch) | |
tree | 4eda53b3e021a1bd0c3275e33eac2c760f76cebc /integrity-monitor/src/main/java | |
parent | 84d189267f246ba6a814d1a6d4ddbe164e65b058 (diff) | |
parent | 66221823c8cb131b8cea03c4d011ddd728608451 (diff) |
Merge "[POLICY-96] Resolved sonar blockers in im/ia."
Diffstat (limited to 'integrity-monitor/src/main/java')
-rw-r--r-- | integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java | 83 |
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); |