From 84ca89aa01518324f9c76bb58150deeba096e6a6 Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Mon, 5 Oct 2020 13:12:43 +0200 Subject: Removing all policies from RIC when removed from configuration Change-Id: I9f47f7369eef021b8d2a7e3fb73c4fc432fe7f56 Issue-ID: CCSDK-2502 Signed-off-by: PatrikBuhr --- .../oran/a1policymanagementservice/repository/Rics.java | 5 +++-- .../a1policymanagementservice/tasks/RefreshConfigTask.java | 12 +++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'a1-policy-management/src/main/java') diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Rics.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Rics.java index 75c16da1..b6ec7491 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Rics.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Rics.java @@ -27,6 +27,7 @@ import java.util.Optional; import java.util.Vector; import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException; +import org.springframework.lang.Nullable; /** * Dynamic representation of all Rics in the system. @@ -54,8 +55,8 @@ public class Rics { return registeredRics.get(ricId); } - public synchronized void remove(String ricId) { - registeredRics.remove(ricId); + public synchronized @Nullable Ric remove(String ricId) { + return registeredRics.remove(ricId); } public synchronized int size() { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java index 5da066f3..b63a8acd 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java @@ -63,6 +63,7 @@ import org.springframework.stereotype.Component; import reactor.core.Disposable; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import reactor.util.annotation.Nullable; /** * Regularly refreshes the configuration from Consul or from a local @@ -195,6 +196,14 @@ public class RefreshConfigTask { return (filepath != null && (new File(filepath).exists())); } + private void removePoliciciesInRic(@Nullable Ric ric) { + if (ric != null) { + RicSynchronizationTask synch = + new RicSynchronizationTask(this.a1ClientFactory, this.policyTypes, this.policies, this.services); + synch.run(ric); + } + } + private void handleUpdatedRicConfig(RicConfigUpdate updatedInfo) { synchronized (this.rics) { String ricId = updatedInfo.getRicConfig().ricId(); @@ -202,8 +211,9 @@ public class RefreshConfigTask { if (event == RicConfigUpdate.Type.ADDED) { addRic(updatedInfo.getRicConfig()); } else if (event == RicConfigUpdate.Type.REMOVED) { - rics.remove(ricId); + Ric ric = rics.remove(ricId); this.policies.removePoliciesForRic(ricId); + removePoliciciesInRic(ric); } else if (event == RicConfigUpdate.Type.CHANGED) { Ric ric = this.rics.get(ricId); if (ric == null) { -- cgit 1.2.3-korg