diff options
author | jrh3 <jrh3@att.com> | 2019-06-11 10:56:25 -0400 |
---|---|---|
committer | jrh3 <jrh3@att.com> | 2019-06-11 17:23:35 -0400 |
commit | a240d7a4020d0346040fe4d86682a6ab8fcd757a (patch) | |
tree | 31b2fa3a76c38f00a0ab5a45fca5a4d17508e45f /main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java | |
parent | fde702471743115e7492951873dd48ba3dbc66bb (diff) |
Add PDP heart beat expiration timer
Added heart beat interval to the PDP-UPDATE message sent in response
to a heart beat message received from a PDP.
Added timers to detect missing heart beats and remove the PDP from
the DB - PdpTracker.
Modified current heart beat listener to update PdpTracker when a
heart beat is received.
Allow 3 missed heart beats instead of 2.
Change-Id: I81621fefbe494e0c4d6f0b9767b00b2a9dd398d8
Issue-ID: POLICY-1795
Signed-off-by: jrh3 <jrh3@att.com>
Diffstat (limited to 'main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java')
-rw-r--r-- | main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java index 7ef9c594..f5184c93 100644 --- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java +++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java @@ -28,6 +28,7 @@ import java.util.Optional; import java.util.TreeMap; import org.apache.commons.lang3.builder.EqualsBuilder; +import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.pdp.concepts.Pdp; @@ -44,6 +45,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper; import org.onap.policy.pap.main.PolicyPapException; +import org.onap.policy.pap.main.parameters.PapParameterGroup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,9 +56,10 @@ import org.slf4j.LoggerFactory; * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ public class PdpStatusMessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(PdpStatusMessageHandler.class); + private static final String PAP_GROUP_PARAMS_NAME = "PapGroup"; + /** * Lock used when updating PDPs. */ @@ -70,7 +73,12 @@ public class PdpStatusMessageHandler { /** * Factory for PAP DAO. */ - PolicyModelsProviderFactoryWrapper modelProviderWrapper; + private final PolicyModelsProviderFactoryWrapper modelProviderWrapper; + + /** + * Heart beat interval, in milliseconds, to pass to PDPs. + */ + private final long heartBeatMs; /** * Constructs the object. @@ -79,6 +87,9 @@ public class PdpStatusMessageHandler { modelProviderWrapper = Registry.get(PapConstants.REG_PAP_DAO_FACTORY, PolicyModelsProviderFactoryWrapper.class); updateLock = Registry.get(PapConstants.REG_PDP_MODIFY_LOCK, Object.class); requestMap = Registry.get(PapConstants.REG_PDP_MODIFY_MAP, PdpModifyRequestMap.class); + + PapParameterGroup params = ParameterService.get(PAP_GROUP_PARAMS_NAME); + heartBeatMs = params.getPdpParameters().getHeartBeatMs(); } /** @@ -94,6 +105,15 @@ public class PdpStatusMessageHandler { } else { handlePdpHeartbeat(message, databaseProvider); } + + /* + * Indicate that a heart beat was received from the PDP. This is invoked + * only if handleXxx() does not throw an exception. + */ + if (message.getName() != null) { + PdpTracker pdpTracker = Registry.get(PapConstants.REG_PDP_TRACKER); + pdpTracker.add(message.getName()); + } } catch (final PolicyPapException exp) { LOGGER.error("Operation Failed", exp); } catch (final Exception exp) { @@ -297,6 +317,7 @@ public class PdpStatusMessageHandler { update.setPdpGroup(pdpGroupName); update.setPdpSubgroup(subGroup.getPdpType()); update.setPolicies(getToscaPolicies(subGroup, databaseProvider)); + update.setPdpHeartbeatIntervalMs(heartBeatMs); LOGGER.debug("Created PdpUpdate message - {}", update); return update; |