Cycle between configuration & tasks removed 38/72738/1
authorpkaras <piotr.karas@nokia.com>
Thu, 15 Nov 2018 08:15:49 +0000 (09:15 +0100)
committerpkaras <piotr.karas@nokia.com>
Thu, 15 Nov 2018 08:15:49 +0000 (09:15 +0100)
Change-Id: Ida3b77ab3f3d197d8ca0bf81f344801df46e6627
Issue-ID: DCAEGEN2-974
Signed-off-by: piotr.karas <piotr.karas@nokia.com>
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java [moved from prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java with 91% similarity]

index 1e1e049..c9667ed 100644 (file)
@@ -65,7 +65,7 @@ public class CloudConfiguration extends AppConfig {
         this.prhConfigurationProvider = prhConfigurationProvider;
     }
 
-    protected void runTask() {
+    public void runTask() {
         Flux.defer(() -> EnvironmentProcessor.evaluate(systemEnvironment))
             .subscribeOn(Schedulers.parallel())
             .subscribe(this::parsingConfigSuccess, this::parsingConfigError);
index 9386b9e..aa91365 100644 (file)
@@ -22,7 +22,7 @@ package org.onap.dcaegen2.services.prh.controllers;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.onap.dcaegen2.services.prh.configuration.SchedulerConfig;
+import org.onap.dcaegen2.services.prh.tasks.ScheduledTasksRunner;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -42,25 +42,25 @@ public class ScheduleController {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleController.class);
 
-    private final SchedulerConfig schedulerConfig;
+    private final ScheduledTasksRunner scheduledTasksRunner;
 
     @Autowired
-    public ScheduleController(SchedulerConfig schedulerConfig) {
-        this.schedulerConfig = schedulerConfig;
+    public ScheduleController(ScheduledTasksRunner scheduledTasksRunner) {
+        this.scheduledTasksRunner = scheduledTasksRunner;
     }
 
     @RequestMapping(value = "start", method = RequestMethod.GET)
     @ApiOperation(value = "Start scheduling worker request")
     public Mono<ResponseEntity<String>> startTasks() {
         LOGGER.trace("Receiving start scheduling worker request");
-        return Mono.fromSupplier(schedulerConfig::tryToStartTask).map(this::createStartTaskResponse);
+        return Mono.fromSupplier(scheduledTasksRunner::tryToStartTask).map(this::createStartTaskResponse);
     }
 
     @RequestMapping(value = "stopPrh", method = RequestMethod.GET)
     @ApiOperation(value = "Receiving stop scheduling worker request")
     public Mono<ResponseEntity<String>> stopTask() {
         LOGGER.trace("Receiving stop scheduling worker request");
-        return schedulerConfig.getResponseFromCancellationOfTasks();
+        return scheduledTasksRunner.getResponseFromCancellationOfTasks();
     }
 
     @ApiOperation(value = "Sends success or error response on starting task execution")
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.dcaegen2.services.prh.configuration;
+package org.onap.dcaegen2.services.prh.tasks;
 
 import io.swagger.annotations.ApiOperation;
 import java.time.Duration;
@@ -27,7 +27,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ScheduledFuture;
 import javax.annotation.PostConstruct;
-import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks;
+
+import org.onap.dcaegen2.services.prh.configuration.CloudConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Marker;
@@ -46,11 +47,11 @@ import reactor.core.publisher.Mono;
  */
 @Configuration
 @EnableScheduling
-public class SchedulerConfig {
+public class ScheduledTasksRunner {
 
     private static final int SCHEDULING_DELAY_FOR_PRH_TASKS = 10;
     private static final int SCHEDULING_REQUEST_FOR_CONFIGURATION_DELAY = 5;
-    private static final Logger LOGGER = LoggerFactory.getLogger(SchedulerConfig.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ScheduledTasksRunner.class);
     private static final Marker ENTRY = MarkerFactory.getMarker("ENTRY");
     private static volatile List<ScheduledFuture> scheduledPrhTaskFutureList = new ArrayList<>();
 
@@ -59,9 +60,9 @@ public class SchedulerConfig {
     private final CloudConfiguration cloudConfiguration;
 
     @Autowired
-    public SchedulerConfig(TaskScheduler taskScheduler,
-        ScheduledTasks scheduledTask,
-        CloudConfiguration cloudConfiguration) {
+    public ScheduledTasksRunner(TaskScheduler taskScheduler,
+                                ScheduledTasks scheduledTask,
+                                CloudConfiguration cloudConfiguration) {
         this.taskScheduler = taskScheduler;
         this.scheduledTask = scheduledTask;
         this.cloudConfiguration = cloudConfiguration;