X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fclients%2FSdncOscA1Client.java;h=2daa4d6821f95bf289f984c521f79594a85baf16;hb=fd0947fdae1ce5e195b4ef3926581acc1b75613d;hp=fcb3236aff782d84369f8614eecdcf913986e508;hpb=341ee94ee4d8995e03c7886c96f9250c7d3901fe;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java index fcb3236a..2daa4d68 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java @@ -48,6 +48,8 @@ import reactor.core.publisher.Mono; @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally public class SdncOscA1Client implements A1Client { + static final int CONCURRENCY_RIC = 1; // How may paralell requests that is sent to one NearRT RIC + @Value.Immutable @org.immutables.gson.Gson.TypeAdapters public interface AdapterRequest { @@ -157,18 +159,27 @@ public class SdncOscA1Client implements A1Client { public Flux deleteAllPolicies() { if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) { return getPolicyIds() // - .flatMap(policyId -> deletePolicyById("", policyId)); // + .flatMap(policyId -> deletePolicyById("", policyId), CONCURRENCY_RIC); // } else if (this.protocolType == A1ProtocolType.SDNC_OSC_OSC_V1) { OscA1Client.UriBuilder uriBuilder = new OscA1Client.UriBuilder(ricConfig); return getPolicyTypeIdentities() // - .flatMapMany(Flux::fromIterable) - .flatMap(type -> post(GET_POLICY_RPC, uriBuilder.createGetPolicyIdsUri(type), Optional.empty())) // - .flatMap(SdncJsonHelper::parseJsonArrayOfString); + .flatMapMany(Flux::fromIterable) // + .flatMap(type -> oscDeleteInstancesForType(uriBuilder, type), CONCURRENCY_RIC); } else { return Flux.error(createIllegalProtocolException()); } } + private Flux oscGetInstancesForType(OscA1Client.UriBuilder uriBuilder, String type) { + return post(GET_POLICY_RPC, uriBuilder.createGetPolicyIdsUri(type), Optional.empty()) // + .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); + } + + private Flux oscDeleteInstancesForType(OscA1Client.UriBuilder uriBuilder, String type) { + return oscGetInstancesForType(uriBuilder, type) // + .flatMap(instance -> deletePolicyById(type, instance), CONCURRENCY_RIC); + } + @Override public Mono getProtocolVersion() { return tryStdProtocolVersion() //