diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2022-10-18 12:08:45 -0500 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2022-10-19 08:31:02 -0500 |
commit | 6652164b384221018bf605b1d5fb809425b26a8e (patch) | |
tree | 6e440f5379010f5bbb20841384c55b86da37b533 /feature-lifecycle/src/main | |
parent | e58a8c52dadfe14b8b77c8eb7c236697c710ddd5 (diff) |
Support optional cluster name in policy engine
This allows also for correlation with running pod hostnames
in the case of multiple drools pdp flavors coexist.
Issue-ID: POLICY-4403
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: I81affeeec622e6c0e9627651bf34c0775a796827
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/main')
2 files changed, 22 insertions, 11 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java index 611ac240..09dcab00 100644 --- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java +++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java @@ -39,6 +39,7 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import lombok.AccessLevel; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @@ -153,6 +154,8 @@ public class LifecycleFsm implements Startable { @Setter protected String pdpType; + protected volatile String pdpName; + @Getter protected Set<String> mandatoryPolicyTypes = new HashSet<>(); @@ -186,12 +189,6 @@ public class LifecycleFsm implements Startable { logger.info("The mandatory Policy Types are {}. Compliance is {}", mandatoryPolicyTypes, isMandatoryPolicyTypesCompliant()); - - stats.setPdpInstanceId(PolicyEngineConstants.PDP_NAME); - } - - public String getName() { - return PolicyEngineConstants.PDP_NAME; } @GsonJsonIgnore @@ -205,6 +202,18 @@ public class LifecycleFsm implements Startable { } /** + * Returns the PDP Name. + */ + public String getPdpName() { + if (this.pdpName == null) { + this.pdpName = PolicyEngineConstants.getManager().getPdpName(); + this.stats.setPdpInstanceId(pdpName); + } + + return this.pdpName; + } + + /** * Current state. */ public PdpState state() { @@ -231,6 +240,8 @@ public class LifecycleFsm implements Startable { @Override public synchronized boolean start() { + this.pdpName = PolicyEngineConstants.getManager().getPdpName(); + stats.setPdpInstanceId(pdpName); logger.info("lifecycle event: start engine"); return state.start(); } @@ -651,7 +662,7 @@ public class LifecycleFsm implements Startable { protected PdpStatus statusPayload(@NonNull PdpState state) { var status = new PdpStatus(); - status.setName(getName()); + status.setName(getPdpName()); status.setPdpGroup(group); status.setPdpSubgroup(subGroup); status.setState(state); @@ -711,7 +722,7 @@ public class LifecycleFsm implements Startable { } protected boolean isItMe(String name, String group, String subgroup) { - if (Objects.equals(name, getName())) { + if (Objects.equals(name, getPdpName())) { return true; } diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java index 494c708b..5a534639 100644 --- a/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java +++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -155,7 +155,7 @@ public class RestLifecycleManager { change.setPdpGroup(LifecycleFeature.getFsm().getGroup()); change.setPdpSubgroup(LifecycleFeature.getFsm().getSubGroup()); change.setState(PdpState.valueOf(state)); - change.setName(LifecycleFeature.getFsm().getName()); + change.setName(LifecycleFeature.getFsm().getPdpName()); return Response.status(Response.Status.OK).entity(LifecycleFeature.getFsm().stateChange(change)).build(); } @@ -442,7 +442,7 @@ public class RestLifecycleManager { private PdpUpdate getPolicyUpdate() { var update = new PdpUpdate(); - update.setName(LifecycleFeature.getFsm().getName()); + update.setName(LifecycleFeature.getFsm().getPdpName()); update.setPdpGroup(LifecycleFeature.getFsm().getGroup()); update.setPdpSubgroup(LifecycleFeature.getFsm().getSubGroup()); return update; |