This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6ea145ad712dc133b4934f8f9efbcfa87a7390a0 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Fri Sep 27 10:18:56 2019 +0700 JAMES-2813 Split TaskManager API from Memory implementation --- pom.xml | 11 ++++++++ .../james/modules/server/HostnameModule.java | 2 +- .../adapter/mailbox/ReIndexerManagementTest.java | 3 +-- .../META-INF/org/apache/james/spring-server.xml | 2 +- server/pom.xml | 1 + .../routes/CassandraMappingsRoutesTest.java | 2 +- .../routes/CassandraMigrationRoutesTest.java | 2 +- .../james/webadmin/dto/ExecutionDetailsDto.java | 2 +- .../james/webadmin/routes/TasksRoutesTest.java | 2 +- .../routes/DeletedMessagesVaultRoutesTest.java | 2 +- .../routes/EventDeadLettersRoutesTest.java | 2 +- .../webadmin/routes/ReindexingRoutesTest.java | 2 +- .../james/webadmin/routes/MailQueueRoutesTest.java | 2 +- .../webadmin/routes/MailQueueRoutesUnitTest.java | 2 +- .../routes/MailRepositoriesRoutesTest.java | 2 +- server/{task => task-api}/pom.xml | 13 ++-------- .../src/main/java/org/apache/james/task/Task.java | 0 .../main/java/org/apache/james/task/TaskId.java | 0 .../java/org/apache/james/task/TaskManager.java | 0 .../apache/james/task/TaskNotFoundException.java | 0 .../main/java/org/apache/james/task/TaskType.java | 0 .../scala/org/apache/james/task/Hostname.scala} | 29 +++++++++++++--------- .../apache/james/task/TaskExecutionDetails.scala | 4 +-- .../java/org/apache/james/task/CompletedTask.java | 0 .../java/org/apache/james/task/FailedTask.java | 0 .../org/apache/james/task/MemoryReferenceTask.java | 0 .../java/org/apache/james/task/TaskIdTest.java | 0 .../org/apache/james/task/TaskManagerContract.java | 0 .../test/java/org/apache/james/task/TaskTest.java | 0 .../java/org/apache/james/task/TaskTypeTest.java | 0 .../java/org/apache/james/task/ThrowingTask.java | 0 server/task-distributed/pom.xml | 6 +++++ ...assandraTaskExecutionDetailsProjectionDAO.scala | 3 +-- .../eventsourcing/distributed/TaskEventDTO.scala | 2 +- .../distributed/DistributedTaskManagerTest.java | 8 +++--- .../distributed/TaskEventsSerializationTest.java | 13 +++++----- server/task-json/pom.xml | 4 +-- server/task/pom.xml | 10 ++++++++ .../org/apache/james/task/MemoryTaskManager.java | 3 +-- .../james/task/eventsourcing/CommandHandlers.scala | 2 +- .../apache/james/task/eventsourcing/Events.scala | 20 +-------------- .../james/task/eventsourcing/TaskAggregate.scala | 2 +- .../TaskExecutionDetailsProjection.scala | 5 ++-- .../apache/james/task/MemoryTaskManagerTest.java | 2 -- .../EventSourcingTaskManagerTest.java | 3 +-- .../TerminationSubscriberContract.java | 3 ++- .../james/task/TaskExecutionDetailsFixture.scala | 1 - 47 files changed, 86 insertions(+), 86 deletions(-) diff --git a/pom.xml b/pom.xml index b9f4542..9687e74 100644 --- a/pom.xml +++ b/pom.xml @@ -1726,6 +1726,17 @@ </dependency> <dependency> <groupId>${james.groupId}</groupId> + <artifactId>james-server-task-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-task-api</artifactId> + <type>test-jar</type> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> <artifactId>james-server-task-distributed</artifactId> <version>${project.version}</version> </dependency> diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java index de590a1..4253b52 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java @@ -20,7 +20,7 @@ package org.apache.james.modules.server; -import org.apache.james.task.eventsourcing.Hostname; +import org.apache.james.task.Hostname; import com.google.inject.AbstractModule; diff --git a/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/ReIndexerManagementTest.java b/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/ReIndexerManagementTest.java index db04843..6d567e6 100644 --- a/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/ReIndexerManagementTest.java +++ b/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/ReIndexerManagementTest.java @@ -28,11 +28,10 @@ import static org.mockito.Mockito.when; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.indexer.ReIndexer; import org.apache.james.mailbox.model.MailboxPath; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; import org.apache.james.task.Task; import org.apache.james.task.TaskManager; -import org.apache.james.task.eventsourcing.Hostname; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml index 49b7a48..665e7be 100644 --- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml +++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml @@ -285,7 +285,7 @@ <bean id="sievemanagerbean" class="org.apache.james.sieverepository.lib.SieveRepositoryManagement"/> - <bean id="hostname" class="org.apache.james.task.eventsourcing.Hostname" factory-method="fromLocalHostname" /> + <bean id="hostname" class="org.apache.james.task.Hostname" factory-method="fromLocalHostname" /> <bean id="taskManager" class="org.apache.james.task.MemoryTaskManager"> <constructor-arg index="0" ref="hostname"/> </bean> diff --git a/server/pom.xml b/server/pom.xml index 22b1c68..3456b55 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -107,6 +107,7 @@ <module>task-distributed</module> <module>task-json</module> <module>testing</module> + <module>task-api</module> </modules> <properties> diff --git a/server/protocols/webadmin/webadmin-cassandra-data/src/test/java/org/apache/james/webadmin/routes/CassandraMappingsRoutesTest.java b/server/protocols/webadmin/webadmin-cassandra-data/src/test/java/org/apache/james/webadmin/routes/CassandraMappingsRoutesTest.java index cd2d09b..22a0a22 100644 --- a/server/protocols/webadmin/webadmin-cassandra-data/src/test/java/org/apache/james/webadmin/routes/CassandraMappingsRoutesTest.java +++ b/server/protocols/webadmin/webadmin-cassandra-data/src/test/java/org/apache/james/webadmin/routes/CassandraMappingsRoutesTest.java @@ -36,8 +36,8 @@ import org.apache.james.rrt.cassandra.CassandraRecipientRewriteTableDAO; import org.apache.james.rrt.cassandra.migration.MappingsSourcesMigration; import org.apache.james.rrt.lib.Mapping; import org.apache.james.rrt.lib.MappingSource; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.webadmin.WebAdminServer; import org.apache.james.webadmin.WebAdminUtils; import org.apache.james.webadmin.service.CassandraMappingsService; diff --git a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java index b3471b5..e156375 100644 --- a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java +++ b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java @@ -44,8 +44,8 @@ import org.apache.james.backends.cassandra.migration.MigrationTask; import org.apache.james.backends.cassandra.versions.CassandraSchemaVersionDAO; import org.apache.james.backends.cassandra.versions.SchemaTransition; import org.apache.james.backends.cassandra.versions.SchemaVersion; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.webadmin.WebAdminServer; import org.apache.james.webadmin.WebAdminUtils; import org.apache.james.webadmin.utils.JsonTransformer; diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/dto/ExecutionDetailsDto.java b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/dto/ExecutionDetailsDto.java index 7819977..413a525 100644 --- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/dto/ExecutionDetailsDto.java +++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/dto/ExecutionDetailsDto.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Optional; import java.util.UUID; +import org.apache.james.task.Hostname; import org.apache.james.task.TaskExecutionDetails; -import org.apache.james.task.eventsourcing.Hostname; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java index ad77c96..b119037 100644 --- a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java +++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java @@ -33,11 +33,11 @@ import static org.hamcrest.Matchers.nullValue; import java.util.UUID; import java.util.concurrent.CountDownLatch; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; import org.apache.james.task.Task; import org.apache.james.task.TaskId; import org.apache.james.task.TaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.webadmin.WebAdminServer; import org.apache.james.webadmin.WebAdminUtils; import org.apache.james.webadmin.utils.JsonTransformer; diff --git a/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java index f93461e..8744c9f 100644 --- a/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java +++ b/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java @@ -101,8 +101,8 @@ import org.apache.james.mailbox.model.MessageResult; import org.apache.james.mailbox.model.MultimailboxesSearchQuery; import org.apache.james.mailbox.model.SearchQuery; import org.apache.james.metrics.api.NoopMetricFactory; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.user.memory.MemoryUsersRepository; import org.apache.james.utils.UpdatableTickingClock; import org.apache.james.vault.DeletedMessage; diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/EventDeadLettersRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/EventDeadLettersRoutesTest.java index 14bee4a..1e3fb4d 100644 --- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/EventDeadLettersRoutesTest.java +++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/EventDeadLettersRoutesTest.java @@ -50,8 +50,8 @@ import org.apache.james.mailbox.store.event.EventFactory; import org.apache.james.mailbox.store.quota.DefaultUserQuotaRootResolver; import org.apache.james.mailbox.util.EventCollector; import org.apache.james.metrics.api.NoopMetricFactory; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.webadmin.WebAdminServer; import org.apache.james.webadmin.WebAdminUtils; import org.apache.james.webadmin.service.EventDeadLettersRedeliverService; diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java index b8c09d7..482e618 100644 --- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java +++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java @@ -46,8 +46,8 @@ import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.webadmin.WebAdminServer; import org.apache.james.webadmin.WebAdminUtils; import org.apache.james.webadmin.service.PreviousReIndexingService; diff --git a/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesTest.java b/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesTest.java index 526bfaf..2cd4f49 100644 --- a/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesTest.java +++ b/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesTest.java @@ -43,9 +43,9 @@ import org.apache.james.queue.api.ManageableMailQueue; import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory; import org.apache.james.queue.memory.MemoryMailQueueFactory; import org.apache.james.queue.memory.MemoryMailQueueFactory.MemoryMailQueue; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; import org.apache.james.task.TaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.webadmin.WebAdminServer; import org.apache.james.webadmin.WebAdminUtils; import org.apache.james.webadmin.service.ClearMailQueueTask; diff --git a/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesUnitTest.java b/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesUnitTest.java index 872c213..f67bc12 100644 --- a/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesUnitTest.java +++ b/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesUnitTest.java @@ -25,8 +25,8 @@ import java.util.Optional; import org.apache.james.queue.api.MailQueueFactory; import org.apache.james.queue.api.ManageableMailQueue; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.webadmin.utils.JsonTransformer; import org.junit.Before; import org.junit.Test; diff --git a/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java b/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java index c2ad252..8ad526b 100644 --- a/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java +++ b/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java @@ -63,8 +63,8 @@ import org.apache.james.queue.api.MailQueueFactory; import org.apache.james.queue.api.ManageableMailQueue; import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory; import org.apache.james.queue.memory.MemoryMailQueueFactory; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryTaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.util.ClassLoaderUtils; import org.apache.james.webadmin.Constants; import org.apache.james.webadmin.WebAdminServer; diff --git a/server/task/pom.xml b/server/task-api/pom.xml similarity index 85% copy from server/task/pom.xml copy to server/task-api/pom.xml index 7d99611..24ae48a 100644 --- a/server/task/pom.xml +++ b/server/task-api/pom.xml @@ -27,21 +27,12 @@ <version>3.5.0-SNAPSHOT</version> </parent> - <artifactId>james-server-task</artifactId> - <name>Apache James :: Server :: Task</name> + <artifactId>james-server-task-api</artifactId> + <name>Apache James :: Server :: Task :: API</name> <dependencies> <dependency> <groupId>${james.groupId}</groupId> - <artifactId>event-sourcing-core</artifactId> - </dependency> - <dependency> - <groupId>${james.groupId}</groupId> - <artifactId>event-sourcing-event-store-memory</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>${james.groupId}</groupId> <artifactId>james-server-util</artifactId> </dependency> <dependency> diff --git a/server/task/src/main/java/org/apache/james/task/Task.java b/server/task-api/src/main/java/org/apache/james/task/Task.java similarity index 100% rename from server/task/src/main/java/org/apache/james/task/Task.java rename to server/task-api/src/main/java/org/apache/james/task/Task.java diff --git a/server/task/src/main/java/org/apache/james/task/TaskId.java b/server/task-api/src/main/java/org/apache/james/task/TaskId.java similarity index 100% rename from server/task/src/main/java/org/apache/james/task/TaskId.java rename to server/task-api/src/main/java/org/apache/james/task/TaskId.java diff --git a/server/task/src/main/java/org/apache/james/task/TaskManager.java b/server/task-api/src/main/java/org/apache/james/task/TaskManager.java similarity index 100% rename from server/task/src/main/java/org/apache/james/task/TaskManager.java rename to server/task-api/src/main/java/org/apache/james/task/TaskManager.java diff --git a/server/task/src/main/java/org/apache/james/task/TaskNotFoundException.java b/server/task-api/src/main/java/org/apache/james/task/TaskNotFoundException.java similarity index 100% rename from server/task/src/main/java/org/apache/james/task/TaskNotFoundException.java rename to server/task-api/src/main/java/org/apache/james/task/TaskNotFoundException.java diff --git a/server/task/src/main/java/org/apache/james/task/TaskType.java b/server/task-api/src/main/java/org/apache/james/task/TaskType.java similarity index 100% rename from server/task/src/main/java/org/apache/james/task/TaskType.java rename to server/task-api/src/main/java/org/apache/james/task/TaskType.java diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java b/server/task-api/src/main/scala/org/apache/james/task/Hostname.scala similarity index 57% copy from server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java copy to server/task-api/src/main/scala/org/apache/james/task/Hostname.scala index de590a1..6036b6c 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/HostnameModule.java +++ b/server/task-api/src/main/scala/org/apache/james/task/Hostname.scala @@ -1,5 +1,4 @@ -/** - * ************************************************************* +/** ************************************************************** * Licensed to the Apache Software Foundation (ASF) under one * * or more contributor license agreements. See the NOTICE file * * distributed with this work for additional information * @@ -8,7 +7,7 @@ * "License"); you may not use this file except in compliance * * with the License. You may obtain a copy of the License at * * * - * http://www.apache.org/licenses/LICENSE-2.0 * + * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, * * software distributed under the License is distributed on an * @@ -16,17 +15,23 @@ * KIND, either express or implied. See the License for the * * specific language governing permissions and limitations * * under the License. * - ***************************************************************/ + * ***************************************************************/ -package org.apache.james.modules.server; +package org.apache.james.task -import org.apache.james.task.eventsourcing.Hostname; +import java.net.{InetAddress, UnknownHostException} -import com.google.inject.AbstractModule; +object Hostname { + def fromLocalHostname = try new Hostname(InetAddress.getLocalHost.getHostName) + catch { + case e: UnknownHostException => + throw new UnconfigurableHostnameException("Hostname can not be retrieved", e) + } +} + +case class Hostname(private val value: String) { + def asString: String = value +} -public class HostnameModule extends AbstractModule { - @Override - protected void configure() { - bind(Hostname.class).toInstance(Hostname.fromLocalHostname()); - } +private class UnconfigurableHostnameException(val message: String, val originException: Exception) extends RuntimeException(message, originException) { } diff --git a/server/task/src/main/scala/org/apache/james/task/TaskExecutionDetails.scala b/server/task-api/src/main/scala/org/apache/james/task/TaskExecutionDetails.scala similarity index 99% rename from server/task/src/main/scala/org/apache/james/task/TaskExecutionDetails.scala rename to server/task-api/src/main/scala/org/apache/james/task/TaskExecutionDetails.scala index d541bf4..829877d2 100644 --- a/server/task/src/main/scala/org/apache/james/task/TaskExecutionDetails.scala +++ b/server/task-api/src/main/scala/org/apache/james/task/TaskExecutionDetails.scala @@ -22,10 +22,8 @@ package org.apache.james.task import java.time.ZonedDateTime import java.util.{Objects, Optional} -import org.apache.james.task.TaskManager.Status._ -import org.apache.james.task.eventsourcing.Hostname - import com.google.common.base.MoreObjects +import org.apache.james.task.TaskManager.Status._ object TaskExecutionDetails { diff --git a/server/task/src/test/java/org/apache/james/task/CompletedTask.java b/server/task-api/src/test/java/org/apache/james/task/CompletedTask.java similarity index 100% rename from server/task/src/test/java/org/apache/james/task/CompletedTask.java rename to server/task-api/src/test/java/org/apache/james/task/CompletedTask.java diff --git a/server/task/src/test/java/org/apache/james/task/FailedTask.java b/server/task-api/src/test/java/org/apache/james/task/FailedTask.java similarity index 100% rename from server/task/src/test/java/org/apache/james/task/FailedTask.java rename to server/task-api/src/test/java/org/apache/james/task/FailedTask.java diff --git a/server/task/src/test/java/org/apache/james/task/MemoryReferenceTask.java b/server/task-api/src/test/java/org/apache/james/task/MemoryReferenceTask.java similarity index 100% rename from server/task/src/test/java/org/apache/james/task/MemoryReferenceTask.java rename to server/task-api/src/test/java/org/apache/james/task/MemoryReferenceTask.java diff --git a/server/task/src/test/java/org/apache/james/task/TaskIdTest.java b/server/task-api/src/test/java/org/apache/james/task/TaskIdTest.java similarity index 100% rename from server/task/src/test/java/org/apache/james/task/TaskIdTest.java rename to server/task-api/src/test/java/org/apache/james/task/TaskIdTest.java diff --git a/server/task/src/test/java/org/apache/james/task/TaskManagerContract.java b/server/task-api/src/test/java/org/apache/james/task/TaskManagerContract.java similarity index 100% rename from server/task/src/test/java/org/apache/james/task/TaskManagerContract.java rename to server/task-api/src/test/java/org/apache/james/task/TaskManagerContract.java diff --git a/server/task/src/test/java/org/apache/james/task/TaskTest.java b/server/task-api/src/test/java/org/apache/james/task/TaskTest.java similarity index 100% rename from server/task/src/test/java/org/apache/james/task/TaskTest.java rename to server/task-api/src/test/java/org/apache/james/task/TaskTest.java diff --git a/server/task/src/test/java/org/apache/james/task/TaskTypeTest.java b/server/task-api/src/test/java/org/apache/james/task/TaskTypeTest.java similarity index 100% rename from server/task/src/test/java/org/apache/james/task/TaskTypeTest.java rename to server/task-api/src/test/java/org/apache/james/task/TaskTypeTest.java diff --git a/server/task/src/test/java/org/apache/james/task/ThrowingTask.java b/server/task-api/src/test/java/org/apache/james/task/ThrowingTask.java similarity index 100% rename from server/task/src/test/java/org/apache/james/task/ThrowingTask.java rename to server/task-api/src/test/java/org/apache/james/task/ThrowingTask.java diff --git a/server/task-distributed/pom.xml b/server/task-distributed/pom.xml index 9719c9c..8ddeabc 100644 --- a/server/task-distributed/pom.xml +++ b/server/task-distributed/pom.xml @@ -82,6 +82,12 @@ </dependency> <dependency> <groupId>${james.groupId}</groupId> + <artifactId>james-server-task-api</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> <artifactId>james-server-task-json</artifactId> </dependency> <dependency> diff --git a/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionDAO.scala b/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionDAO.scala index 232def3..9f44472 100644 --- a/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionDAO.scala +++ b/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/cassandra/CassandraTaskExecutionDetailsProjectionDAO.scala @@ -26,9 +26,8 @@ import com.datastax.driver.core.{Row, Session} import javax.inject.Inject import org.apache.james.backends.cassandra.init.{CassandraTypesProvider, CassandraZonedDateTimeModule} import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor -import org.apache.james.task.eventsourcing.Hostname import org.apache.james.task.eventsourcing.cassandra.CassandraTaskExecutionDetailsProjectionTable._ -import org.apache.james.task.{TaskExecutionDetails, TaskId, TaskManager, TaskType} +import org.apache.james.task.{Hostname, TaskExecutionDetails, TaskId, TaskManager, TaskType} import reactor.core.publisher.{Flux, Mono} @Inject diff --git a/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/distributed/TaskEventDTO.scala b/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/distributed/TaskEventDTO.scala index 8ff3093..41f8e09 100644 --- a/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/distributed/TaskEventDTO.scala +++ b/server/task-distributed/src/main/scala/org/apache/james/task/eventsourcing/distributed/TaskEventDTO.scala @@ -23,8 +23,8 @@ import com.fasterxml.jackson.annotation.JsonProperty import org.apache.james.eventsourcing.EventId import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTO import org.apache.james.server.task.json.JsonTaskSerializer -import org.apache.james.task.{Task, TaskId} import org.apache.james.task.eventsourcing._ +import org.apache.james.task.{Hostname, Task, TaskId} sealed abstract class TaskEventDTO(val getType: String, val getAggregate: String, val getEvent: Int) extends EventDTO { protected def domainAggregateId: TaskAggregateId = TaskAggregateId(TaskId.fromString(getAggregate)) diff --git a/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/DistributedTaskManagerTest.java b/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/DistributedTaskManagerTest.java index 767d0ff..2554d4f 100644 --- a/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/DistributedTaskManagerTest.java +++ b/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/DistributedTaskManagerTest.java @@ -27,12 +27,12 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.tuple.Pair; -import org.apache.james.backends.rabbitmq.RabbitMQExtension; import org.apache.james.backends.cassandra.CassandraCluster; import org.apache.james.backends.cassandra.CassandraClusterExtension; import org.apache.james.backends.cassandra.components.CassandraModule; import org.apache.james.backends.cassandra.init.CassandraZonedDateTimeModule; import org.apache.james.backends.cassandra.versions.CassandraSchemaVersionModule; +import org.apache.james.backends.rabbitmq.RabbitMQExtension; import org.apache.james.eventsourcing.eventstore.EventStore; import org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStoreExtension; import org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStoreModule; @@ -43,6 +43,7 @@ import org.apache.james.server.task.json.dto.MemoryReferenceTaskStore; import org.apache.james.server.task.json.dto.TestTaskDTOModules; import org.apache.james.task.CompletedTask; import org.apache.james.task.CountDownLatchExtension; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryReferenceTask; import org.apache.james.task.Task; import org.apache.james.task.TaskExecutionDetails; @@ -50,14 +51,11 @@ import org.apache.james.task.TaskId; import org.apache.james.task.TaskManager; import org.apache.james.task.TaskManagerContract; import org.apache.james.task.eventsourcing.EventSourcingTaskManager; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.task.eventsourcing.TaskExecutionDetailsProjection; import org.apache.james.task.eventsourcing.WorkQueueSupplier; import org.apache.james.task.eventsourcing.cassandra.CassandraTaskExecutionDetailsProjection; import org.apache.james.task.eventsourcing.cassandra.CassandraTaskExecutionDetailsProjectionDAO; import org.apache.james.task.eventsourcing.cassandra.CassandraTaskExecutionDetailsProjectionModule; - -import com.github.steveash.guavate.Guavate; import org.awaitility.Awaitility; import org.awaitility.Duration; import org.junit.jupiter.api.BeforeEach; @@ -65,6 +63,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; +import com.github.steveash.guavate.Guavate; + @ExtendWith(CountDownLatchExtension.class) class DistributedTaskManagerTest implements TaskManagerContract { diff --git a/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/TaskEventsSerializationTest.java b/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/TaskEventsSerializationTest.java index eaf03ec..307919a 100644 --- a/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/TaskEventsSerializationTest.java +++ b/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/TaskEventsSerializationTest.java @@ -24,23 +24,20 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import java.util.stream.Stream; -import com.github.steveash.guavate.Guavate; -import net.javacrumbs.jsonunit.assertj.JsonAssertions; import org.apache.james.eventsourcing.EventId; import org.apache.james.eventsourcing.eventstore.cassandra.JsonEventSerializer; import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule; import org.apache.james.server.task.json.JsonTaskSerializer; - import org.apache.james.server.task.json.dto.TestTaskDTOModules; import org.apache.james.task.CompletedTask; +import org.apache.james.task.Hostname; import org.apache.james.task.Task; import org.apache.james.task.TaskId; -import org.apache.james.task.eventsourcing.Created; -import org.apache.james.task.eventsourcing.Cancelled; import org.apache.james.task.eventsourcing.CancelRequested; +import org.apache.james.task.eventsourcing.Cancelled; import org.apache.james.task.eventsourcing.Completed; +import org.apache.james.task.eventsourcing.Created; import org.apache.james.task.eventsourcing.Failed; -import org.apache.james.task.eventsourcing.Hostname; import org.apache.james.task.eventsourcing.Started; import org.apache.james.task.eventsourcing.TaskAggregateId; import org.apache.james.task.eventsourcing.TaskEvent; @@ -48,6 +45,10 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import com.github.steveash.guavate.Guavate; + +import net.javacrumbs.jsonunit.assertj.JsonAssertions; + class TaskEventsSerializationTest { private static final JsonTaskSerializer TASK_SERIALIZER = new JsonTaskSerializer(TestTaskDTOModules.COMPLETED_TASK_MODULE); private static final List<EventDTOModule<?, ?>> MODULES = TasksSerializationModule.MODULES.apply(TASK_SERIALIZER); diff --git a/server/task-json/pom.xml b/server/task-json/pom.xml index 7159106..3dbf985 100644 --- a/server/task-json/pom.xml +++ b/server/task-json/pom.xml @@ -37,11 +37,11 @@ </dependency> <dependency> <groupId>${james.groupId}</groupId> - <artifactId>james-server-task</artifactId> + <artifactId>james-server-task-api</artifactId> </dependency> <dependency> <groupId>${james.groupId}</groupId> - <artifactId>james-server-task</artifactId> + <artifactId>james-server-task-api</artifactId> <type>test-jar</type> <scope>test</scope> </dependency> diff --git a/server/task/pom.xml b/server/task/pom.xml index 7d99611..9c005b2 100644 --- a/server/task/pom.xml +++ b/server/task/pom.xml @@ -46,6 +46,16 @@ </dependency> <dependency> <groupId>${james.groupId}</groupId> + <artifactId>james-server-task-api</artifactId> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-task-api</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> <artifactId>testing-base</artifactId> <scope>test</scope> </dependency> diff --git a/server/task/src/main/java/org/apache/james/task/MemoryTaskManager.java b/server/task/src/main/java/org/apache/james/task/MemoryTaskManager.java index 611cbde..ccc651b 100644 --- a/server/task/src/main/java/org/apache/james/task/MemoryTaskManager.java +++ b/server/task/src/main/java/org/apache/james/task/MemoryTaskManager.java @@ -30,10 +30,9 @@ import java.util.function.Consumer; import javax.annotation.PreDestroy; import javax.inject.Inject; -import org.apache.james.task.eventsourcing.Hostname; - import com.github.steveash.guavate.Guavate; import com.google.common.collect.ImmutableList; + import reactor.core.publisher.Flux; import reactor.core.scheduler.Schedulers; diff --git a/server/task/src/main/scala/org/apache/james/task/eventsourcing/CommandHandlers.scala b/server/task/src/main/scala/org/apache/james/task/eventsourcing/CommandHandlers.scala index d585e74..4666d9a 100644 --- a/server/task/src/main/scala/org/apache/james/task/eventsourcing/CommandHandlers.scala +++ b/server/task/src/main/scala/org/apache/james/task/eventsourcing/CommandHandlers.scala @@ -22,8 +22,8 @@ import java.util import org.apache.james.eventsourcing.eventstore.History import org.apache.james.eventsourcing.{CommandHandler, Event} -import org.apache.james.task.TaskId import org.apache.james.task.eventsourcing.TaskCommand._ +import org.apache.james.task.{Hostname, TaskId} sealed abstract class TaskCommandHandler[T <: TaskCommand] extends CommandHandler[T] { diff --git a/server/task/src/main/scala/org/apache/james/task/eventsourcing/Events.scala b/server/task/src/main/scala/org/apache/james/task/eventsourcing/Events.scala index 68730bd..3aff0ff 100644 --- a/server/task/src/main/scala/org/apache/james/task/eventsourcing/Events.scala +++ b/server/task/src/main/scala/org/apache/james/task/eventsourcing/Events.scala @@ -18,11 +18,9 @@ * ***************************************************************/ package org.apache.james.task.eventsourcing -import java.net.{InetAddress, UnknownHostException} - import org.apache.james.eventsourcing.{Event, EventId} -import org.apache.james.task.Task import org.apache.james.task.Task.Result +import org.apache.james.task.{Hostname, Task} sealed abstract class TaskEvent(aggregateId: TaskAggregateId, val eventId: EventId) extends Event { override def getAggregateId: TaskAggregateId = aggregateId @@ -30,22 +28,6 @@ sealed abstract class TaskEvent(aggregateId: TaskAggregateId, val eventId: Event sealed abstract class TerminalTaskEvent(aggregateId: TaskAggregateId, override val eventId: EventId) extends TaskEvent(aggregateId, eventId) -case class Hostname(private val value: String) { - def asString: String = value -} - -object Hostname { - def fromLocalHostname = try new Hostname(InetAddress.getLocalHost.getHostName) - catch { - case e: UnknownHostException => - throw new UnconfigurableHostnameException("Hostname can not be retrieved", e) - } -} - -private class UnconfigurableHostnameException(val message: String, val originException: Exception) extends RuntimeException(message, originException) { -} - - case class Created(aggregateId: TaskAggregateId, override val eventId: EventId, task: Task, hostname: Hostname) extends TaskEvent(aggregateId, eventId) case class Started(aggregateId: TaskAggregateId, override val eventId: EventId, hostname: Hostname) extends TaskEvent(aggregateId, eventId) diff --git a/server/task/src/main/scala/org/apache/james/task/eventsourcing/TaskAggregate.scala b/server/task/src/main/scala/org/apache/james/task/eventsourcing/TaskAggregate.scala index ae86433..f5634c0 100644 --- a/server/task/src/main/scala/org/apache/james/task/eventsourcing/TaskAggregate.scala +++ b/server/task/src/main/scala/org/apache/james/task/eventsourcing/TaskAggregate.scala @@ -22,9 +22,9 @@ import java.util import org.apache.james.eventsourcing.eventstore.History import org.apache.james.eventsourcing.{Event, EventId} -import org.apache.james.task.Task import org.apache.james.task.Task.Result import org.apache.james.task.TaskManager.Status +import org.apache.james.task.{Hostname, Task} import scala.collection.JavaConverters._ diff --git a/server/task/src/main/scala/org/apache/james/task/eventsourcing/TaskExecutionDetailsProjection.scala b/server/task/src/main/scala/org/apache/james/task/eventsourcing/TaskExecutionDetailsProjection.scala index a6ffff2..90f1abc 100644 --- a/server/task/src/main/scala/org/apache/james/task/eventsourcing/TaskExecutionDetailsProjection.scala +++ b/server/task/src/main/scala/org/apache/james/task/eventsourcing/TaskExecutionDetailsProjection.scala @@ -21,8 +21,9 @@ package org.apache.james.task.eventsourcing import java.util.concurrent.ConcurrentHashMap import org.apache.james.eventsourcing.Subscriber -import org.apache.james.task.{TaskExecutionDetails, TaskId} -import collection.JavaConverters._ +import org.apache.james.task.{Hostname, TaskExecutionDetails, TaskId} + +import scala.collection.JavaConverters._ trait TaskExecutionDetailsProjection { def asSubscriber(hostname: Hostname): Subscriber = { diff --git a/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java b/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java index 01c5eb1..7ac6f96 100644 --- a/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java +++ b/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java @@ -19,8 +19,6 @@ package org.apache.james.task; -import org.apache.james.task.eventsourcing.Hostname; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/server/task/src/test/java/org/apache/james/task/eventsourcing/EventSourcingTaskManagerTest.java b/server/task/src/test/java/org/apache/james/task/eventsourcing/EventSourcingTaskManagerTest.java index cb5f19a..891c346 100644 --- a/server/task/src/test/java/org/apache/james/task/eventsourcing/EventSourcingTaskManagerTest.java +++ b/server/task/src/test/java/org/apache/james/task/eventsourcing/EventSourcingTaskManagerTest.java @@ -22,10 +22,10 @@ package org.apache.james.task.eventsourcing; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Duration.ONE_HUNDRED_MILLISECONDS; -import org.apache.james.eventsourcing.EventSourcingSystem; import org.apache.james.eventsourcing.eventstore.EventStore; import org.apache.james.eventsourcing.eventstore.memory.InMemoryEventStore; import org.apache.james.task.CountDownLatchExtension; +import org.apache.james.task.Hostname; import org.apache.james.task.MemoryWorkQueue; import org.apache.james.task.SerialTaskManagerWorker; import org.apache.james.task.Task; @@ -33,7 +33,6 @@ import org.apache.james.task.TaskId; import org.apache.james.task.TaskManager; import org.apache.james.task.TaskManagerContract; import org.apache.james.task.TaskManagerWorker; - import org.awaitility.Awaitility; import org.awaitility.core.ConditionFactory; import org.junit.jupiter.api.AfterEach; diff --git a/server/task/src/test/java/org/apache/james/task/eventsourcing/TerminationSubscriberContract.java b/server/task/src/test/java/org/apache/james/task/eventsourcing/TerminationSubscriberContract.java index 5b0f5ff..882f6d7 100644 --- a/server/task/src/test/java/org/apache/james/task/eventsourcing/TerminationSubscriberContract.java +++ b/server/task/src/test/java/org/apache/james/task/eventsourcing/TerminationSubscriberContract.java @@ -27,11 +27,12 @@ import java.util.List; import org.apache.james.eventsourcing.Event; import org.apache.james.eventsourcing.EventId; +import org.apache.james.task.Hostname; import org.apache.james.task.Task; import org.apache.james.task.TaskId; - import org.assertj.core.api.ListAssert; import org.junit.jupiter.api.Test; + import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; diff --git a/server/task/src/test/scala/org/apache/james/task/TaskExecutionDetailsFixture.scala b/server/task/src/test/scala/org/apache/james/task/TaskExecutionDetailsFixture.scala index b6310f8..6bc9d05 100644 --- a/server/task/src/test/scala/org/apache/james/task/TaskExecutionDetailsFixture.scala +++ b/server/task/src/test/scala/org/apache/james/task/TaskExecutionDetailsFixture.scala @@ -22,7 +22,6 @@ import java.time.{LocalDateTime, ZoneId, ZonedDateTime} import java.util.Optional import org.apache.james.task.TaskExecutionDetails.AdditionalInformation -import org.apache.james.task.eventsourcing.Hostname object TaskExecutionDetailsFixture { val SUBMITTED_DATE = ZonedDateTime.of(LocalDateTime.of(2000, 1, 1, 0, 0), ZoneId.of("Europe/Paris")) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org