From 8a6170b76693a10c37237978c33e94b3f8bf8f0d Mon Sep 17 00:00:00 2001 From: Kevin McKiou Date: Mon, 24 Jul 2017 17:52:01 -0500 Subject: [POLICY-105] Modifications to RefreshStateAudit Made the refreshStateAudit configurable and changed the default interval to 10 minutes from 1 minute. Added a check to fpCheck to check the state of the dependent before setting the opstate to disabled. Added a refresh to the forwardprogressentity object in stateAudit() so that we are not reading stale timestamp data. Change-Id: I394feca083fc1fb356d11b9f6886e566c31f248a Signed-off-by: Kevin McKiou --- .../policy/common/im/IntegrityMonitor.java | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'integrity-monitor/src/main/java/org/openecomp/policy/common/im/IntegrityMonitor.java') diff --git a/integrity-monitor/src/main/java/org/openecomp/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/openecomp/policy/common/im/IntegrityMonitor.java index a4218942..57182f7a 100644 --- a/integrity-monitor/src/main/java/org/openecomp/policy/common/im/IntegrityMonitor.java +++ b/integrity-monitor/src/main/java/org/openecomp/policy/common/im/IntegrityMonitor.java @@ -133,7 +133,7 @@ public class IntegrityMonitor { private static String jmxFqdn = null; - // this is the max interval allowed without any forward progress counter updates + // this is the max interval seconds allowed without any forward progress counter updates private static int maxFpcUpdateInterval = IntegrityMonitorProperties.DEFAULT_MAX_FPC_UPDATE_INTERVAL; // Node types @@ -153,7 +153,7 @@ public class IntegrityMonitor { private static String site_name; private static String node_type; private Date refreshStateAuditLastRunDate; - private int refreshStateAuditIntervalMs = 60000; //run it once per minute + private static long refreshStateAuditIntervalMs = 600000; //run it once per 10 minutes //lock objects private final Object evaluateSanityLock = new Object(); @@ -626,8 +626,10 @@ public class IntegrityMonitor { // create instance of StateMangement class for dependent StateManagement depStateManager = new StateManagement(emf, dep); if (depStateManager != null) { - logger.info("Forward progress not detected for dependent resource " + dep + ". Setting dependent's state to disable failed."); - depStateManager.disableFailed(); + 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 @@ -1181,6 +1183,13 @@ public class IntegrityMonitor { } } + if (prop.getProperty(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS) != null){ + try{ + refreshStateAuditIntervalMs = Long.parseLong(prop.getProperty(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS)); + }catch(NumberFormatException e){ + logger.warn("Ignored invalid property: " + IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS); + } + } return; } @@ -1272,9 +1281,7 @@ public class IntegrityMonitor { * check their operational state. If it is not disabled, then disable them. */ public void stateAudit() { - - //TODO add stateAuditIntervalMs to the IntegrityMonitor properties here and in droolspdp - // monitoring interval checks + if (stateAuditIntervalMs <= 0) { return; // stateAudit is disabled } @@ -1308,11 +1315,13 @@ public class IntegrityMonitor { if(fpe.getResourceName().equals(IntegrityMonitor.resourceName)){ continue; } + //Make sure you are not getting a cached version + em.refresh(fpe); long diffMs = date.getTime() - fpe.getLastUpdated().getTime(); logger.debug("IntegrityMonitor.stateAudit(): diffMs = " + diffMs); //Threshold for a stale entry - long staleMs = failedCounterThreshold * monitorInterval * 1000; + long staleMs = maxFpcUpdateInterval * 1000; logger.debug("IntegrityMonitor.stateAudit(): staleMs = " + staleMs); if(diffMs > staleMs){ @@ -1449,6 +1458,10 @@ public class IntegrityMonitor { * send a notification to all registered observers. */ private void refreshStateAudit(){ + if(refreshStateAuditIntervalMs <=0){ + // The audit is deactivated + return; + } synchronized(refreshStateAuditLock){ logger.debug("refreshStateAudit: entry"); Date now = new Date(); -- cgit 1.2.3-korg