X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=enrichment-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fenrichment%2Ftasks%2FProducerSupervision.java;h=f239a4876001eb05b7299bc261a77d78fc4b3b4d;hb=refs%2Fchanges%2F28%2F4828%2F2;hp=3b62fa74f17ae591f1299a718f6f1eceb6704a6b;hpb=5d97a401dc1e26f64ad57daab90f924da9c12c64;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..f239a487 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,6 +21,7 @@ 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.repository.EiJobs; import org.oransc.enrichment.repository.EiProducer; @@ -45,17 +46,20 @@ 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; @Autowired - EiTypes eiTypes; + public ProducerSupervision(ApplicationConfig applicationConfig, EiProducers eiProducers, EiJobs eiJobs, + EiTypes eiTypes) { + AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(applicationConfig.getWebClientConfig()); + this.restClient = restClientFactory.createRestClient(""); + this.eiJobs = eiJobs; + this.eiProducers = eiProducers; + this.eiTypes = eiTypes; + } @Scheduled(fixedRate = 1000 * 60 * 5) public void checkAllProducers() { @@ -69,7 +73,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(); @@ -91,8 +95,4 @@ public class ProducerSupervision { producer.setAliveStatus(true); } - private AsyncRestClient restClient() { - return new AsyncRestClient("", this.applicationConfig.getWebClientConfig()); - } - }