summaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/main
diff options
context:
space:
mode:
authorKAPIL SINGAL <ks220y@att.com>2020-11-10 14:06:51 +0000
committerGerrit Code Review <gerrit@onap.org>2020-11-10 14:06:51 +0000
commit8bd3cd5ccb72eeb2999206e16e849be47e02b122 (patch)
treef1c0fe69ec2527dd34dcde50761f66f5235303de /a1-policy-management/src/main
parente8ce2d2b528fe7bf8b563ec7f28d582a92d59b78 (diff)
parent2a5028d0d6b1d4b809ab72beafd95c65ea26c662 (diff)
Merge "Bugfix, GET policy V2"
Diffstat (limited to 'a1-policy-management/src/main')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java7
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java8
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java11
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java9
5 files changed, 22 insertions, 15 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
index ec776042..ea047cb5 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
@@ -262,12 +262,6 @@ public class PolicyController {
return Mono.just("{}");
}
- private void assertRicStateIdleSync(Ric ric) throws ServiceException {
- if (ric.getState() != Ric.RicState.AVAILABLE) {
- throw new ServiceException("Near-RT RIC: " + ric.id() + " is " + ric.getState());
- }
- }
-
private Mono<Object> assertRicStateIdle(Ric ric) {
if (ric.getState() == Ric.RicState.AVAILABLE) {
return Mono.just("{}");
@@ -408,6 +402,7 @@ public class PolicyController {
policyInfo.ricId = p.ric().id();
policyInfo.policyTypeId = p.type().id();
policyInfo.serviceId = p.ownerServiceId();
+ policyInfo.isTransient = p.isTransient();
if (!p.statusNotificationUri().isEmpty()) {
policyInfo.statusNotificationUri = p.statusNotificationUri();
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
index c032e3ad..43684a33 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
@@ -57,10 +57,12 @@ public class PolicyInfo {
@SerializedName("service_id")
public String serviceId;
- @ApiModelProperty(value = "the name of the service owning the policy", required = false)
- @JsonProperty(value = "transient", required = false)
+ @ApiModelProperty(
+ value = "if true, the policy is deleted at RIC restart. If false, its value is maintained by this service until explicitly deleted. Default false.",
+ required = false)
+ @JsonProperty(value = "transient", required = false, defaultValue = "false")
@SerializedName("transient")
- public boolean isTransient;
+ public boolean isTransient = false;
@ApiModelProperty(value = "Callback URI for policy status updates", required = false)
@JsonProperty(value = "status_notification_uri", required = false)
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 b8341240..75fd16cf 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
@@ -191,8 +191,8 @@ public class RefreshConfigTask {
private void removePoliciciesInRic(@Nullable Ric ric) {
if (ric != null) {
- RicSynchronizationTask synch =
- new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, restClientFactory);
+ RicSynchronizationTask synch = new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services,
+ restClientFactory, rics);
synch.run(ric);
}
}
@@ -202,15 +202,18 @@ public class RefreshConfigTask {
String ricId = updatedInfo.getRicConfig().ricId();
RicConfigUpdate.Type event = updatedInfo.getType();
if (event == RicConfigUpdate.Type.ADDED) {
+ logger.debug("RIC added {}", ricId);
addRic(updatedInfo.getRicConfig());
} else if (event == RicConfigUpdate.Type.REMOVED) {
+ logger.debug("RIC removed {}", ricId);
Ric ric = rics.remove(ricId);
this.policies.removePoliciesForRic(ricId);
removePoliciciesInRic(ric);
} else if (event == RicConfigUpdate.Type.CHANGED) {
+ logger.debug("RIC config updated {}", ricId);
Ric ric = this.rics.get(ricId);
if (ric == null) {
- // Should not happen,just for robustness
+ logger.error("An non existing RIC config is changed, should not happen (just for robustness)");
addRic(updatedInfo.getRicConfig());
} else {
ric.setRicConfig(updatedInfo.getRicConfig());
@@ -227,7 +230,7 @@ public class RefreshConfigTask {
void runRicSynchronization(Ric ric) {
RicSynchronizationTask synchronizationTask =
- new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, restClientFactory);
+ new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, restClientFactory, rics);
synchronizationTask.run(ric);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
index cae257cd..c13df8c3 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
@@ -211,6 +211,6 @@ public class RicSupervision {
}
RicSynchronizationTask createSynchronizationTask() {
- return new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, restClientFactory);
+ return new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, restClientFactory, rics);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
index 825418b5..b38a36b2 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
@@ -33,6 +33,7 @@ import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,15 +65,17 @@ public class RicSynchronizationTask {
private final PolicyTypes policyTypes;
private final Policies policies;
private final Services services;
+ private final Rics rics;
private final AsyncRestClientFactory restClientFactory;
public RicSynchronizationTask(A1ClientFactory a1ClientFactory, PolicyTypes policyTypes, Policies policies,
- Services services, AsyncRestClientFactory restClientFactory) {
+ Services services, AsyncRestClientFactory restClientFactory, Rics rics) {
this.a1ClientFactory = a1ClientFactory;
this.policyTypes = policyTypes;
this.policies = policies;
this.services = services;
this.restClientFactory = restClientFactory;
+ this.rics = rics;
}
public void run(Ric ric) {
@@ -129,6 +132,10 @@ public class RicSynchronizationTask {
}
private void onSynchronizationComplete(Ric ric) {
+ if (this.rics.get(ric.id()) == null) {
+ logger.debug("Policies removed in removed ric: {}", ric.id());
+ return;
+ }
logger.debug("Synchronization completed for: {}", ric.id());
ric.setState(RicState.AVAILABLE);
notifyServices(ric);