X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=enrichment-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fenrichment%2Ftasks%2FProducerSupervision.java;h=b4c21d4658ebf9027f4783320322199673686141;hb=bfe1c4049297589c4ade863b12e3d6a6cb7abc99;hp=3b62fa74f17ae591f1299a718f6f1eceb6704a6b;hpb=d67b199561749fe13880ac349ad924862beb782a;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java index 3b62fa74..b4c21d46 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java @@ -1,9 +1,9 @@ /*- * ========================LICENSE_START================================= - * ONAP : ccsdk oran - * ====================================================================== - * Copyright (C) 2020 Nordix Foundation. All rights reserved. - * ====================================================================== + * O-RAN-SC + * %% + * Copyright (C) 2020 Nordix Foundation + * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,7 +21,9 @@ package org.oransc.enrichment.tasks; import org.oransc.enrichment.clients.AsyncRestClient; +import org.oransc.enrichment.clients.AsyncRestClientFactory; import org.oransc.enrichment.configuration.ApplicationConfig; +import org.oransc.enrichment.controllers.consumer.ConsumerCallbacks; import org.oransc.enrichment.repository.EiJobs; import org.oransc.enrichment.repository.EiProducer; import org.oransc.enrichment.repository.EiProducers; @@ -45,17 +47,22 @@ import reactor.core.publisher.Mono; public class ProducerSupervision { private static final Logger logger = LoggerFactory.getLogger(ProducerSupervision.class); - @Autowired - ApplicationConfig applicationConfig; - - @Autowired - EiProducers eiProducers; - - @Autowired - EiJobs eiJobs; + private final EiProducers eiProducers; + private final EiJobs eiJobs; + private final EiTypes eiTypes; + private final AsyncRestClient restClient; + private final ConsumerCallbacks consumerCallbacks; @Autowired - EiTypes eiTypes; + public ProducerSupervision(ApplicationConfig applicationConfig, EiProducers eiProducers, EiJobs eiJobs, + EiTypes eiTypes, ConsumerCallbacks consumerCallbacks) { + AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(applicationConfig.getWebClientConfig()); + this.restClient = restClientFactory.createRestClientNoHttpProxy(""); + this.eiJobs = eiJobs; + this.eiProducers = eiProducers; + this.eiTypes = eiTypes; + this.consumerCallbacks = consumerCallbacks; + } @Scheduled(fixedRate = 1000 * 60 * 5) public void checkAllProducers() { @@ -69,7 +76,7 @@ public class ProducerSupervision { } private Mono checkOneProducer(EiProducer producer) { - return restClient().get(producer.getProducerSupervisionCallbackUrl()) // + return restClient.get(producer.getProducerSupervisionCallbackUrl()) // .onErrorResume(throwable -> { handleNonRespondingProducer(throwable, producer); return Mono.empty(); @@ -83,6 +90,7 @@ public class ProducerSupervision { producer.setAliveStatus(false); if (producer.isDead()) { this.eiProducers.deregisterProducer(producer, this.eiTypes, this.eiJobs); + this.consumerCallbacks.notifyConsumersProducerDeleted(producer); } } @@ -91,8 +99,4 @@ public class ProducerSupervision { producer.setAliveStatus(true); } - private AsyncRestClient restClient() { - return new AsyncRestClient("", this.applicationConfig.getWebClientConfig()); - } - }