X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=enrichment-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fenrichment%2Fcontrollers%2Fconsumer%2FConsumerCallbacks.java;h=c222cfab642a01f132ba1f44a0341829a9acf7bc;hb=1da5c887797ae8cb715ad0b16b388aae18cda948;hp=cded953562d0a96d48c3828e2934b093cebece2b;hpb=530fa60a49e8f870cea442a338b148783fbe2ab7;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerCallbacks.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerCallbacks.java index cded9535..c222cfab 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerCallbacks.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerCallbacks.java @@ -55,7 +55,7 @@ public class ConsumerCallbacks { @Autowired public ConsumerCallbacks(ApplicationConfig config, EiTypes eiTypes, EiJobs eiJobs) { AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config.getWebClientConfig()); - this.restClient = restClientFactory.createRestClient(""); + this.restClient = restClientFactory.createRestClientUseHttpProxy(""); this.eiTypes = eiTypes; this.eiJobs = eiJobs; } @@ -63,25 +63,39 @@ public class ConsumerCallbacks { public void notifyConsumersProducerDeleted(EiProducer eiProducer) { for (EiType type : eiProducer.getEiTypes()) { if (this.eiTypes.get(type.getId()) == null) { + // The type is removed for (EiJob job : this.eiJobs.getJobsForType(type)) { - noifyJobOwner(job, new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.DISABLED)); + if (job.isLastStatusReportedEnabled()) { + noifyJobOwner(job, new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.DISABLED)); + job.setLastReportedStatus(false); + } } } } } + public void notifyConsumersProducerAdded(EiProducer eiProducer) { + for (EiType type : eiProducer.getEiTypes()) { + notifyConsumersTypeAdded(type); + } + } + public void notifyConsumersTypeAdded(EiType eiType) { for (EiJob job : this.eiJobs.getJobsForType(eiType)) { - noifyJobOwner(job, new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.ENABLED)); + if (!job.isLastStatusReportedEnabled()) { + noifyJobOwner(job, new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.ENABLED)); + job.setLastReportedStatus(true); + } } } private void noifyJobOwner(EiJob job, ConsumerEiJobStatus status) { - if (!job.jobStatusUrl().isEmpty()) { + if (!job.getJobStatusUrl().isEmpty()) { String body = gson.toJson(status); - this.restClient.post(job.jobStatusUrl(), body) // - .subscribe(notUsed -> logger.debug("Consumer notified OK {}", job.id()), // - throwable -> logger.warn("Consumer notify failed {} {}", job.jobStatusUrl(), throwable.toString()), // + this.restClient.post(job.getJobStatusUrl(), body) // + .subscribe(notUsed -> logger.debug("Consumer notified OK {}", job.getId()), // + throwable -> logger.warn("Consumer notify failed {} {}", job.getJobStatusUrl(), + throwable.toString()), // null); } }