diff options
Diffstat (limited to 'prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java')
-rw-r--r-- | prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java | 25 |
1 files changed, 6 insertions, 19 deletions
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 60572cb3..4cde51bf 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 @@ -50,7 +50,6 @@ import reactor.core.publisher.Mono; public class ScheduleController { private static final Logger logger = LoggerFactory.getLogger(PrhAppConfig.class); - private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); private static final int SCHEDULING_DELAY = 20000; private static volatile List<ScheduledFuture> scheduledFutureList = new ArrayList<>(); @@ -67,14 +66,14 @@ public class ScheduleController { @RequestMapping(value = "start", method = RequestMethod.GET) @ApiOperation(value = "Start scheduling worker request") public Mono<ResponseEntity<String>> startTasks() { - logDebug("Starting scheduling worker request on on thread={} , time={} "); + logger.trace("Receiving start scheduling worker request"); return Mono.fromSupplier(this::tryToStartTask).map(this::createStartTaskResponse); } @RequestMapping(value = "stopPrh", method = RequestMethod.GET) - @ApiOperation(value = "Stop scheduling worker request") + @ApiOperation(value = "Receiving stop scheduling worker request") public Mono<ResponseEntity<String>> stopTask() { - logDebug("Stopping scheduling worker request on on thread={} , time={} "); + logger.trace("Receiving stop scheduling worker request"); return getResponseFromCancellationOfTasks(); } @@ -82,10 +81,9 @@ public class ScheduleController { private synchronized Mono<ResponseEntity<String>> getResponseFromCancellationOfTasks() { scheduledFutureList.forEach(x -> x.cancel(false)); scheduledFutureList.clear(); - return Mono.defer(() -> { - logDebug("Sending success response on stopping task execution thread={} , time={} "); - return Mono.just(new ResponseEntity<>("PRH Service has already been stopped!", HttpStatus.CREATED)); - }); + return Mono.defer(() -> + Mono.just(new ResponseEntity<>("PRH Service has already been stopped!", HttpStatus.CREATED)) + ); } @ApiOperation(value = "Start task if possible") @@ -103,20 +101,9 @@ public class ScheduleController { @ApiOperation(value = "Sends success or error response on starting task execution") private ResponseEntity<String> createStartTaskResponse(boolean wasScheduled) { if (wasScheduled) { - logDebug("Sending success response on starting task execution thread={} , time={} "); return new ResponseEntity<>("PRH Service has been started!", HttpStatus.CREATED); } else { - logDebug("Sending error response on starting task execution thread={} , time={} "); return new ResponseEntity<>("PRH Service is still running!", HttpStatus.NOT_ACCEPTABLE); } } - - private static void logDebug(String message) { - if (logger.isDebugEnabled()) { - logger.debug(message, - Thread.currentThread().getName(), - dateTimeFormatter.format( - LocalDateTime.now())); - } - } } |