diff options
author | a.sreekumar <ajith.sreekumar@est.tech> | 2019-04-25 12:29:06 +0000 |
---|---|---|
committer | a.sreekumar <ajith.sreekumar@est.tech> | 2019-04-25 12:29:06 +0000 |
commit | f6da9a3bafb6f4c30e7bb3accd4e17fdaaf5ce92 (patch) | |
tree | 0ab7a2eb2e96489e49f4236a222576402c814e6e /services/services-onappf/src | |
parent | ca558cfb1ea47de081527771af47abb37a8cd964 (diff) |
Changes to fix PDP-A not going to ACTIVE state
PDP-A state will now change to ACTIVE even when the policy list is
empty.
When the state is ACTIVE and PAP sends a PDP_UPDATE with policies, PDP-A
will start executing the policies.
Change-Id: Icb5b139939698920d4fa3991dcca33536c6caefc
Issue-ID: POLICY-1674
Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
Diffstat (limited to 'services/services-onappf/src')
2 files changed, 19 insertions, 7 deletions
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java index d2c7786ca..9c53fb196 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java @@ -90,8 +90,9 @@ public class PdpStateChangeMessageHandler { } else { final List<ToscaPolicy> policies = Registry.get(ApexStarterConstants.REG_APEX_TOSCA_POLICY_LIST); if (policies.isEmpty()) { + pdpStatusContext.setState(PdpState.ACTIVE); pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), - PdpResponseStatus.SUCCESS, "No policies found. Apex engine not running."); + PdpResponseStatus.SUCCESS, "State changed to active. No policies found."); } else { try { // assumed that the apex policies list contains only one entry. @@ -126,9 +127,16 @@ public class PdpStateChangeMessageHandler { pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp already in passive state"); } else { - final ApexEngineHandler apexEngineHandler = Registry.get(ApexStarterConstants.REG_APEX_ENGINE_HANDLER); + ApexEngineHandler apexEngineHandler = null; try { - apexEngineHandler.shutdown(); + apexEngineHandler = Registry.get(ApexStarterConstants.REG_APEX_ENGINE_HANDLER); + } catch (final IllegalArgumentException e) { + LOGGER.debug("ApenEngineHandler not in registry.", e); + } + try { + if (null != apexEngineHandler && apexEngineHandler.isApexEngineRunning()) { + apexEngineHandler.shutdown(); + } pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Apex pdp state changed from Active to Passive."); pdpStatusContext.setState(PdpState.PASSIVE); diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java index 31963ddc0..478d1c757 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java @@ -99,9 +99,14 @@ public class PdpUpdateMessageHandler { private PdpResponseDetails startOrStopApexEngineBasedOnPolicies(final PdpUpdate pdpUpdateMsg, final PdpMessageHandler pdpMessageHandler) { PdpResponseDetails pdpResponseDetails = null; + ApexEngineHandler apexEngineHandler = null; + try { + apexEngineHandler = Registry.get(ApexStarterConstants.REG_APEX_ENGINE_HANDLER); + } catch (final IllegalArgumentException e) { + LOGGER.debug("ApenEngineHandler not in registry.", e); + } if (pdpUpdateMsg.getPolicies().isEmpty()) { - final ApexEngineHandler apexEngineHandler = Registry.get(ApexStarterConstants.REG_APEX_ENGINE_HANDLER); - if (apexEngineHandler.isApexEngineRunning()) { + if (null != apexEngineHandler && apexEngineHandler.isApexEngineRunning()) { try { apexEngineHandler.shutdown(); } catch (final ApexStarterException e) { @@ -112,8 +117,7 @@ public class PdpUpdateMessageHandler { } } else { try { - ApexEngineHandler apexEngineHandler = Registry.get(ApexStarterConstants.REG_APEX_ENGINE_HANDLER); - if (apexEngineHandler.isApexEngineRunning()) { + if (null != apexEngineHandler && apexEngineHandler.isApexEngineRunning()) { apexEngineHandler.shutdown(); } apexEngineHandler = new ApexEngineHandler( |