diff options
author | Jim Hahn <jrh3@att.com> | 2021-08-17 17:22:26 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-08-17 17:23:39 -0400 |
commit | d3544f097cf6c67baf66578636d09c1148e01c50 (patch) | |
tree | f5372c9dcbf47b53faab152417f972a77380bef4 /main | |
parent | d91e75bc0c1953c034f263863c41d506170dedcf (diff) |
Synchronize updates to xacml-pdp state
Perhaps this will fix the issue wherein xacml-pdp heartbeats continue to
say "PASSIVE" even after it's set to "ACTIVE".
Issue-ID: POLICY-3531
Change-Id: I6639ed7ca793a899f62e5c80b336408f5e8b2dc6
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main')
-rw-r--r-- | main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java | 16 | ||||
-rw-r--r-- | main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java index 0b6f30ca..17995fd6 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java @@ -33,11 +33,15 @@ import org.onap.policy.models.pdp.enums.PdpResponseStatus; import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager; import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Current state of this XACML PDP. */ public class XacmlState { + private static final Logger LOGGER = LoggerFactory.getLogger(XacmlState.class); + /** * Unique name for the xacml-pdp JVM, used in PdpStatus messages. */ @@ -74,7 +78,7 @@ public class XacmlState { * @return {@code true} if this PDP should handle the message, {@code false} otherwise */ public boolean shouldHandle(PdpMessage message) { - return message.appliesTo(status.getName(), status.getPdpGroup(), status.getPdpSubgroup()); + return message.appliesTo(status.getName(), status.getPdpGroup(), status.getPdpType()); } /** @@ -82,7 +86,7 @@ public class XacmlState { * * @return a new heart beat message */ - public PdpStatus genHeartbeat() { + public synchronized PdpStatus genHeartbeat() { // first, update status fields status.setHealthy(XacmlPdpActivator.getCurrent().isAlive() ? PdpHealthStatus.HEALTHY : PdpHealthStatus.NOT_HEALTHY); @@ -96,7 +100,8 @@ public class XacmlState { * @param message message from which to update the internal state * @return a response to the message */ - public PdpStatus updateInternalState(PdpStateChange message) { + public synchronized PdpStatus updateInternalState(PdpStateChange message) { + LOGGER.info("set state of {} to {}", this, message.getState()); status.setState(message.getState()); /* @@ -120,7 +125,7 @@ public class XacmlState { * @param message message from which to update the internal state * @return a response to the message */ - public PdpStatus updateInternalState(PdpUpdate message, String errMessage) { + public synchronized PdpStatus updateInternalState(PdpUpdate message, String errMessage) { status.setPdpSubgroup(message.getPdpSubgroup()); status.setPolicies(appManager.getToscaPolicyIdentifiers()); @@ -132,7 +137,8 @@ public class XacmlState { * * @return the current PdpStatus with Terminated state */ - public PdpStatus terminatePdpMessage() { + public synchronized PdpStatus terminatePdpMessage() { + LOGGER.info("set state of {} to {}", this, PdpState.TERMINATED); status.setState(PdpState.TERMINATED); return new PdpStatus(status); } diff --git a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java index da6fdb2c..539b541b 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java @@ -54,7 +54,7 @@ public class XacmlPdpUpdatePublisher { * * @param message Incoming message */ - public void handlePdpUpdate(PdpUpdate message) { + public synchronized void handlePdpUpdate(PdpUpdate message) { // current data Map<ToscaConceptIdentifier, ToscaPolicy> deployedPolicies = policyToMap(appManager.getToscaPolicies().keySet()); |