summaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2020-10-05 13:12:43 +0200
committerPatrikBuhr <patrik.buhr@est.tech>2020-10-08 15:54:53 +0200
commit84ca89aa01518324f9c76bb58150deeba096e6a6 (patch)
tree8ee1e1332e7c706fd70b44fd33821aa4716137cd /a1-policy-management/src
parent535be96db56357f41970fd256abe7eb35fe4d98a (diff)
Removing all policies from RIC when removed from configuration
Change-Id: I9f47f7369eef021b8d2a7e3fb73c4fc432fe7f56 Issue-ID: CCSDK-2502 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Diffstat (limited to 'a1-policy-management/src')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Rics.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java12
2 files changed, 14 insertions, 3 deletions
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) {