aboutsummaryrefslogtreecommitdiffstats
path: root/services/services-onappf/src
diff options
context:
space:
mode:
Diffstat (limited to 'services/services-onappf/src')
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java14
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java12
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(