diff options
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; |