aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkaras <piotr.karas@nokia.com>2018-11-15 09:15:49 +0100
committerpkaras <piotr.karas@nokia.com>2018-11-15 09:15:49 +0100
commita07ea7cc1f8b8673afbd31f4cfdcda2d6c8e8c2b (patch)
tree796197747ad69a868e9541d56a1452363639623e
parent0634ab9a23757b7f56c8ec4012c77f480ac8ee7f (diff)
Cycle between configuration & tasks removed
Change-Id: Ida3b77ab3f3d197d8ca0bf81f344801df46e6627 Issue-ID: DCAEGEN2-974 Signed-off-by: piotr.karas <piotr.karas@nokia.com>
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java12
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java (renamed from prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java)15
3 files changed, 15 insertions, 14 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
index 1e1e0491..c9667ed6 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
@@ -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);
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
index 9386b9e8..aa913654 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
@@ -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")
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
index 76ba5ec6..956ffead 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
@@ -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;