You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/07/20 11:19:36 UTC

[04/10] james-project git commit: JAMES-2470 Cassandra cleanup should rely on CleanupTasks and not probes

JAMES-2470 Cassandra cleanup should rely on CleanupTasks and not probes


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/99339b11
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/99339b11
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/99339b11

Branch: refs/heads/master
Commit: 99339b113ae45cfc8741d84577ea3526d304669e
Parents: c1ae826
Author: benwa <bt...@linagora.com>
Authored: Thu Jul 19 17:24:36 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Jul 20 18:18:14 2018 +0700

----------------------------------------------------------------------
 .../james/server/CassandraCleanupProbe.java     | 40 --------------------
 .../server/CassandraTruncateTableTask.java      | 40 ++++++++++++++++++++
 .../org/apache/james/DockerCassandraRule.java   |  7 ++--
 .../cassandra/cucumber/CassandraStepdefs.java   |  6 +--
 4 files changed, 46 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/99339b11/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraCleanupProbe.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraCleanupProbe.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraCleanupProbe.java
deleted file mode 100644
index fe8989d..0000000
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraCleanupProbe.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************
- * 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        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "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                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.server;
-
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-
-import org.apache.james.backends.cassandra.init.CassandraTableManager;
-import org.apache.james.utils.GuiceProbe;
-
-public class CassandraCleanupProbe implements GuiceProbe {
-    private final CassandraTableManager tableManager;
-
-    @Inject
-    public CassandraCleanupProbe(CassandraTableManager tableManager) {
-        this.tableManager = tableManager;
-    }
-
-    @PreDestroy
-    public void clearAllTables() {
-        tableManager.clearAllTables();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/99339b11/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraTruncateTableTask.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraTruncateTableTask.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraTruncateTableTask.java
new file mode 100644
index 0000000..741e6a6
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraTruncateTableTask.java
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "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                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server;
+
+import javax.inject.Inject;
+
+import org.apache.james.CleanupTasksPerformer;
+import org.apache.james.backends.cassandra.init.CassandraTableManager;
+
+public class CassandraTruncateTableTask implements CleanupTasksPerformer.CleanupTask {
+    private final CassandraTableManager tableManager;
+
+    @Inject
+    public CassandraTruncateTableTask(CassandraTableManager tableManager) {
+        this.tableManager = tableManager;
+    }
+
+    @Override
+    public Result run() {
+        tableManager.clearAllTables();
+        return Result.COMPLETED;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/99339b11/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java
index cbf2fe4..d8d0369 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java
@@ -20,9 +20,8 @@
 package org.apache.james;
 
 import org.apache.james.backends.cassandra.init.configuration.ClusterConfiguration;
-import org.apache.james.server.CassandraCleanupProbe;
+import org.apache.james.server.CassandraTruncateTableTask;
 import org.apache.james.util.Host;
-import org.apache.james.utils.GuiceProbe;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 import org.testcontainers.containers.GenericContainer;
@@ -54,9 +53,9 @@ public class DockerCassandraRule implements GuiceModuleTestRule {
                 .maxRetry(20)
                 .minDelay(5000)
                 .build()),
-            binder -> Multibinder.newSetBinder(binder, GuiceProbe.class)
+            binder -> Multibinder.newSetBinder(binder, CleanupTasksPerformer.CleanupTask.class)
                 .addBinding()
-                .to(CassandraCleanupProbe.class));
+                .to(CassandraTruncateTableTask.class));
     }
 
     public String getIp() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/99339b11/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
index 1e16410..1fd8703 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
@@ -27,6 +27,7 @@ import javax.inject.Inject;
 
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
+import org.apache.james.CleanupTasksPerformer;
 import org.apache.james.DockerCassandraRule;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.backends.es.EmbeddedElasticSearch;
@@ -40,9 +41,8 @@ import org.apache.james.mailbox.store.search.PDFTextExtractor;
 import org.apache.james.modules.TestESMetricReporterModule;
 import org.apache.james.modules.TestElasticSearchModule;
 import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.server.CassandraCleanupProbe;
+import org.apache.james.server.CassandraTruncateTableTask;
 import org.apache.james.server.core.configuration.Configuration;
-import org.apache.james.utils.GuiceProbe;
 import org.junit.rules.TemporaryFolder;
 
 import com.github.fge.lambdas.runnable.ThrowingRunnable;
@@ -86,7 +86,7 @@ public class CassandraStepdefs {
             .overrideWith(cassandraServer.getModule())
             .overrideWith(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class))
             .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))
-            .overrideWith(binder -> Multibinder.newSetBinder(binder, GuiceProbe.class).addBinding().to(CassandraCleanupProbe.class));
+            .overrideWith(binder -> Multibinder.newSetBinder(binder, CleanupTasksPerformer.CleanupTask.class).addBinding().to(CassandraTruncateTableTask.class));
         mainStepdefs.awaitMethod = () -> embeddedElasticSearch.awaitForElasticSearch();
         mainStepdefs.init();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org