Add webconfig for dmaap/rapp rest client
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / tasks / RicSynchronizationTask.java
index ae91d4b..6ae55c4 100644 (file)
@@ -58,6 +58,7 @@ import reactor.core.publisher.SignalType;
 public class RicSynchronizationTask {
 
     private static final Logger logger = LoggerFactory.getLogger(RicSynchronizationTask.class);
+    static final int CONCURRENCY_RIC = 1; // How may paralell requests that is sent to one NearRT RIC
 
     private final A1ClientFactory a1ClientFactory;
     private final PolicyTypes policyTypes;
@@ -133,7 +134,7 @@ public class RicSynchronizationTask {
     private void notifyAllServices(String body) {
         for (Service service : services.getAll()) {
             String url = service.getCallbackUrl();
-            if (service.getCallbackUrl().length() > 0) {
+            if (url.length() > 0) {
                 createNotificationClient(url) //
                     .put("", body) //
                     .subscribe( //
@@ -159,7 +160,7 @@ public class RicSynchronizationTask {
     }
 
     AsyncRestClient createNotificationClient(final String url) {
-        return new AsyncRestClient(url);
+        return new AsyncRestClient(url, this.a1ClientFactory.getAppConfig().getWebClientConfig());
     }
 
     private Flux<PolicyType> synchronizePolicyTypes(Ric ric, A1Client a1Client) {
@@ -167,7 +168,7 @@ public class RicSynchronizationTask {
             .doOnNext(x -> ric.clearSupportedPolicyTypes()) //
             .flatMapMany(Flux::fromIterable) //
             .doOnNext(typeId -> logger.debug("For ric: {}, handling type: {}", ric.getConfig().name(), typeId)) //
-            .flatMap(policyTypeId -> getPolicyType(policyTypeId, a1Client)) //
+            .flatMap(policyTypeId -> getPolicyType(policyTypeId, a1Client), CONCURRENCY_RIC) //
             .doOnNext(ric::addSupportedPolicyType); //
     }
 
@@ -197,9 +198,17 @@ public class RicSynchronizationTask {
             .flatMapMany(notUsed -> Flux.just(policy));
     }
 
+    private boolean checkTransient(Policy policy) {
+        if (policy.isTransient()) {
+            this.policies.remove(policy);
+        }
+        return policy.isTransient();
+    }
+
     private Flux<Policy> recreateAllPoliciesInRic(Ric ric, A1Client a1Client) {
         return Flux.fromIterable(policies.getForRic(ric.name())) //
-            .flatMap(policy -> putPolicy(policy, ric, a1Client));
+            .filter(policy -> !checkTransient(policy)) //
+            .flatMap(policy -> putPolicy(policy, ric, a1Client), CONCURRENCY_RIC);
     }
 
 }