From ce7b7850f765dc45ee1bbbaa2b05897e0b8ec1de Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Thu, 31 Oct 2019 16:49:49 -0300 Subject: [PATCH] Initial Job Service implementation (#1) * Initial Job Service implementation Initial Job Service implementation inserting swagger * Apply PR comments and some code refactoring, test * Fix JobScheduler when cancelling job * Fixing cancel already scheduled job when re-scheduling --- .../java/org/kie/kogito/jobs/api/Job.java | 43 +++++- .../org/kie/kogito/jobs/api/JobBuilder.java | 79 ++++++++++ addons/jobs/jobs-service/.gitignore | 2 + addons/jobs/jobs-service/pom.xml | 137 +++++++++++++++++- .../src/main/docker/Dockerfile.jvm | 31 ++++ .../src/main/docker/Dockerfile.native | 22 +++ .../service/converters/HttpConverters.java | 41 ++++++ .../service/executor/HttpJobExecutor.java | 92 ++++++++++++ .../jobs/service/executor/JobExecutor.java | 26 ++++ .../service/executor/RetryJobExecutor.java | 29 ++++ .../service/json/JacksonConfiguration.java | 53 +++++++ .../jobs/service/model/ErrorResponse.java | 30 ++++ .../service/model/HTTPRequestCallback.java | 135 +++++++++++++++++ .../jobs/service/model/ScheduledJob.java | 55 +++++++ .../repository/ReactiveJobRepository.java | 36 +++++ .../impl/InMemoryJobRepository.java | 94 ++++++++++++ .../resource/CallbackResourceTest.java | 51 +++++++ .../jobs/service/resource/JobResource.java | 89 ++++++++++++ .../resource/error/DefaultErrorMapper.java | 44 ++++++ .../scheduler/BaseTimerJobScheduler.java | 98 +++++++++++++ .../jobs/service/scheduler/JobScheduler.java | 26 ++++ .../scheduler/ReactiveJobScheduler.java | 30 ++++ .../scheduler/impl/VertxJobScheduler.java | 66 +++++++++ .../src/main/resources/application.properties | 44 ++++++ .../service/resource/JobResourceTest.java | 111 ++++++++++++++ 25 files changed, 1459 insertions(+), 5 deletions(-) create mode 100644 addons/jobs/jobs-api/src/main/java/org/kie/kogito/jobs/api/JobBuilder.java create mode 100644 addons/jobs/jobs-service/src/main/docker/Dockerfile.jvm create mode 100644 addons/jobs/jobs-service/src/main/docker/Dockerfile.native create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/converters/HttpConverters.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/executor/HttpJobExecutor.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/executor/JobExecutor.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/executor/RetryJobExecutor.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/json/JacksonConfiguration.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/model/ErrorResponse.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/model/HTTPRequestCallback.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/model/ScheduledJob.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/repository/ReactiveJobRepository.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/repository/impl/InMemoryJobRepository.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/resource/CallbackResourceTest.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/resource/JobResource.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/resource/error/DefaultErrorMapper.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/scheduler/BaseTimerJobScheduler.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/scheduler/JobScheduler.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/scheduler/ReactiveJobScheduler.java create mode 100644 addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/scheduler/impl/VertxJobScheduler.java create mode 100644 addons/jobs/jobs-service/src/main/resources/application.properties create mode 100644 addons/jobs/jobs-service/src/test/java/org/kie/kogito/jobs/service/resource/JobResourceTest.java diff --git a/addons/jobs/jobs-api/src/main/java/org/kie/kogito/jobs/api/Job.java b/addons/jobs/jobs-api/src/main/java/org/kie/kogito/jobs/api/Job.java index b9031157aac..f59312e959c 100644 --- a/addons/jobs/jobs-api/src/main/java/org/kie/kogito/jobs/api/Job.java +++ b/addons/jobs/jobs-api/src/main/java/org/kie/kogito/jobs/api/Job.java @@ -16,16 +16,17 @@ package org.kie.kogito.jobs.api; import java.time.ZonedDateTime; +import java.util.Objects; /** - * Job describes the actual entity that should be scheduled and executed + * Job describes the actual entity that should be scheduled and executed * upon given expiration time. The job requires following information * - * + * * On top of that there are additional meta data that points the job to the owner - such as process instance. *