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;
@Override
protected void hookOnError(Throwable throwable) {
logger.warn("Synchronization failure for ric: {}, reason: {}", ric.name(), throwable.getMessage());
- ric.setState(RicState.UNDEFINED);
+ ric.setState(RicState.UNAVAILABLE);
}
@Override
private void onSynchronizationComplete(Ric ric) {
logger.debug("Synchronization completed for: {}", ric.name());
- ric.setState(RicState.IDLE);
+ ric.setState(RicState.AVAILABLE);
notifyAllServices("Synchronization completed for:" + ric.name());
}
createNotificationClient(url) //
.put("", body) //
.subscribe( //
- notUsed -> logger.debug("Service {} notified", service.getName()), throwable -> logger
- .warn("Service notification failed for service: {}", service.getName(), throwable),
+ notUsed -> logger.debug("Service {} notified", service.getName()),
+ throwable -> logger.warn("Service notification failed for service: {}. Cause: {}",
+ service.getName(), throwable.getMessage()),
() -> logger.debug("All services notified"));
}
}
}
private Flux<Object> deleteAllPolicyInstances(Ric ric, Throwable t) {
- logger.warn("Recreation of policies failed for ric: {}, reason: {}", ric.name(), t.getMessage());
+ logger.debug("Recreation of policies failed for ric: {}, reason: {}", ric.name(), t.getMessage());
deleteAllPoliciesInRepository(ric);
Flux<PolicyType> synchronizedTypes = this.a1ClientFactory.createA1Client(ric) //
.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); //
}
.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);
}
}