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 2017/02/03 09:44:29 UTC

[01/12] james-project git commit: JAMES-1918 apache-james-backends-cassandra test jar was bound without scope test

Repository: james-project
Updated Branches:
  refs/heads/master eeb04abaa -> b54f9604d


JAMES-1918 apache-james-backends-cassandra test jar was bound without scope test


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

Branch: refs/heads/master
Commit: 80245f1a66caf8bc1290849d3016cfc9948cb743
Parents: eeb04ab
Author: Benoit Tellier <bt...@linagora.com>
Authored: Tue Jan 24 11:03:17 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:40:26 2017 +0700

----------------------------------------------------------------------
 server/container/guice/cassandra-guice/pom.xml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/80245f1a/server/container/guice/cassandra-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
index be98559..f4699c3 100644
--- a/server/container/guice/cassandra-guice/pom.xml
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -195,6 +195,7 @@
                     <groupId>${project.groupId}</groupId>
                     <artifactId>apache-james-backends-cassandra</artifactId>
                     <type>test-jar</type>
+                    <scope>test</scope>
                 </dependency>
                 <dependency>
                     <groupId>${project.groupId}</groupId>
@@ -230,7 +231,7 @@
                     <artifactId>james-server-data-cassandra</artifactId>
                 </dependency>
                 <dependency>
-                    <groupId>org.apache.james</groupId>
+                    <groupId>${project.groupId}</groupId>
                     <artifactId>james-server-data-jmap-cassandra</artifactId>
                 </dependency>
                 <dependency>


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


[08/12] james-project git commit: JAMES-1901 Create a ElasticSearch backend project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
new file mode 100644
index 0000000..1cfce9b
--- /dev/null
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
@@ -0,0 +1,229 @@
+/****************************************************************
+ * 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.mailbox.elasticsearch;
+
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+
+import java.io.IOException;
+
+import org.apache.james.backends.es.ElasticSearchIndexer;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+
+import com.google.common.base.Throwables;
+
+public class MailboxMappingFactory {
+
+    public static XContentBuilder getMappingContent() {
+        try {
+            return jsonBuilder()
+                .startObject()
+
+                    .startObject(MailboxElasticsearchConstants.MESSAGE_TYPE)
+                        .startObject(NodeMappingFactory.PROPERTIES)
+                            .startObject(JsonMessageConstants.MESSAGE_ID)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.UID)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.LONG)
+                            .endObject()
+                            .startObject(JsonMessageConstants.MODSEQ)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.LONG)
+                            .endObject()
+                            .startObject(JsonMessageConstants.SIZE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.LONG)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_ANSWERED)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_DELETED)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_DRAFT)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_FLAGGED)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_RECENT)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_UNREAD)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.DATE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.DATE)
+                                .field(NodeMappingFactory.FORMAT, "yyyy-MM-dd'T'HH:mm:ssZ")
+                            .endObject()
+                            .startObject(JsonMessageConstants.SENT_DATE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.DATE)
+                                .field(NodeMappingFactory.FORMAT, "yyyy-MM-dd'T'HH:mm:ssZ")
+                            .endObject()
+                            .startObject(JsonMessageConstants.MEDIA_TYPE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.SUBTYPE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.USER_FLAGS)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.FROM)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.EMailer.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .startObject(NodeMappingFactory.FIELDS)
+                                            .startObject(NodeMappingFactory.RAW)
+                                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                                .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                            .endObject()
+                                        .endObject()
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.SUBJECT)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .startObject(NodeMappingFactory.FIELDS)
+                                    .startObject(NodeMappingFactory.RAW)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.TO)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.EMailer.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .startObject(NodeMappingFactory.FIELDS)
+                                            .startObject(NodeMappingFactory.RAW)
+                                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                                .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                            .endObject()
+                                        .endObject()
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.CC)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.EMailer.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.BCC)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.EMailer.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.MAILBOX_ID)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.USERS)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.PROPERTIES)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.Property.NAMESPACE)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.Property.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.Property.VALUE)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.TEXT_BODY)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .startObject(NodeMappingFactory.FIELDS)
+                                    .startObject(NodeMappingFactory.RAW)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                        .field(NodeMappingFactory.IGNORE_ABOVE, NodeMappingFactory.LUCENE_LIMIT)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.HTML_BODY)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .startObject(NodeMappingFactory.FIELDS)
+                                    .startObject(NodeMappingFactory.RAW)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                        .field(NodeMappingFactory.IGNORE_ABOVE, NodeMappingFactory.LUCENE_LIMIT)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.TEXT)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.ANALYZER, NodeMappingFactory.SNOWBALL)
+                                .field(NodeMappingFactory.IGNORE_ABOVE, NodeMappingFactory.LUCENE_LIMIT)
+                            .endObject()
+                        .endObject()
+                    .endObject()
+                .endObject();
+        } catch (IOException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/NodeMappingFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/NodeMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/NodeMappingFactory.java
deleted file mode 100644
index 751452c..0000000
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/NodeMappingFactory.java
+++ /dev/null
@@ -1,259 +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.mailbox.elasticsearch;
-
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-
-import java.io.IOException;
-
-import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-
-import com.google.common.base.Throwables;
-
-public class NodeMappingFactory {
-
-    public static final String BOOLEAN = "boolean";
-    public static final String TYPE = "type";
-    public static final String LONG = "long";
-    public static final String INDEX = "index";
-    public static final String NOT_ANALYZED = "not_analyzed";
-    public static final String STRING = "string";
-    public static final String PROPERTIES = "properties";
-    public static final String DATE = "date";
-    public static final String FORMAT = "format";
-    public static final String NESTED = "nested";
-    public static final String FIELDS = "fields";
-    public static final String RAW = "raw";
-    public static final String ANALYZER = "analyzer";
-    public static final String SNOWBALL = "snowball";
-    public static final String IGNORE_ABOVE = "ignore_above";
-    public static final int LUCENE_LIMIT = 32766;
-
-    public static Client applyMapping(Client client) {
-        return applyMapping(client, getMappingContent());
-    }
-
-    public static Client applyMapping(Client client, XContentBuilder mappingsSources) {
-        client.admin()
-            .indices()
-            .preparePutMapping(ElasticSearchIndexer.MAILBOX_INDEX)
-            .setType(ElasticSearchIndexer.MESSAGE_TYPE)
-            .setSource(mappingsSources)
-            .execute()
-            .actionGet();
-        return client;
-    }
-
-    private static XContentBuilder getMappingContent() {
-        try {
-            return jsonBuilder()
-                .startObject()
-
-                    .startObject(ElasticSearchIndexer.MESSAGE_TYPE)
-                        .startObject(PROPERTIES)
-                            .startObject(JsonMessageConstants.MESSAGE_ID)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.UID)
-                                .field(TYPE, LONG)
-                            .endObject()
-                            .startObject(JsonMessageConstants.MODSEQ)
-                                .field(TYPE, LONG)
-                            .endObject()
-                            .startObject(JsonMessageConstants.SIZE)
-                                .field(TYPE, LONG)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_ANSWERED)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_DELETED)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_DRAFT)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_FLAGGED)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_RECENT)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_UNREAD)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.DATE)
-                                .field(TYPE, DATE)
-                                .field(FORMAT, "yyyy-MM-dd'T'HH:mm:ssZ")
-                            .endObject()
-                            .startObject(JsonMessageConstants.SENT_DATE)
-                                .field(TYPE, DATE)
-                                .field(FORMAT, "yyyy-MM-dd'T'HH:mm:ssZ")
-                            .endObject()
-                            .startObject(JsonMessageConstants.MEDIA_TYPE)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.SUBTYPE)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.USER_FLAGS)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.FROM)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.EMailer.NAME)
-                                        .field(TYPE, STRING)
-                                        .startObject(FIELDS)
-                                            .startObject(RAW)
-                                                .field(TYPE, STRING)
-                                                .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                            .endObject()
-                                        .endObject()
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.SUBJECT)
-                                .field(TYPE, STRING)
-                                .startObject(FIELDS)
-                                    .startObject(RAW)
-                                        .field(TYPE, STRING)
-                                        .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.TO)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.EMailer.NAME)
-                                        .field(TYPE, STRING)
-                                        .startObject(FIELDS)
-                                            .startObject(RAW)
-                                                .field(TYPE, STRING)
-                                                .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                            .endObject()
-                                        .endObject()
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.CC)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.EMailer.NAME)
-                                        .field(TYPE, STRING)
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.BCC)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.EMailer.NAME)
-                                        .field(TYPE, STRING)
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.MAILBOX_ID)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.USERS)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.PROPERTIES)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.Property.NAMESPACE)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.Property.NAME)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.Property.VALUE)
-                                        .field(TYPE, STRING)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.TEXT_BODY)
-                                .field(TYPE, STRING)
-                                .startObject(FIELDS)
-                                    .startObject(RAW)
-                                        .field(TYPE, STRING)
-                                        .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                        .field(IGNORE_ABOVE, LUCENE_LIMIT)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.HTML_BODY)
-                                .field(TYPE, STRING)
-                                .startObject(FIELDS)
-                                    .startObject(RAW)
-                                        .field(TYPE, STRING)
-                                        .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                        .field(IGNORE_ABOVE, LUCENE_LIMIT)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.TEXT)
-                                .field(TYPE, STRING)
-                                .field(ANALYZER, SNOWBALL)
-                                .field(IGNORE_ABOVE, LUCENE_LIMIT)
-                            .endObject()
-                        .endObject()
-                    .endObject()
-                .endObject();
-        } catch (IOException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
index 850dd4c..7372e2b 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
@@ -28,10 +28,10 @@ import java.util.stream.Collectors;
 
 import javax.inject.Inject;
 
+import org.apache.james.backends.es.ElasticSearchIndexer;
 import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
index 05bc3a8..bb11268 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
@@ -19,7 +19,8 @@
 
 package org.apache.james.mailbox.elasticsearch.query;
 
-import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.elasticsearch.search.sort.FieldSortBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
index 61bca7e..d8339f7 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
@@ -26,9 +26,10 @@ import java.util.stream.StreamSupport;
 
 import javax.inject.Inject;
 
+import org.apache.james.backends.es.search.ScrollIterable;
 import org.apache.james.mailbox.MailboxSession.User;
 import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.query.SortConverter;
@@ -82,8 +83,8 @@ public class ElasticSearchSearcher {
         return query.getSearchQuery().getSorts()
             .stream()
             .reduce(
-                client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
+                client.prepareSearch(MailboxElasticsearchConstants.MAILBOX_INDEX)
+                    .setTypes(MailboxElasticsearchConstants.MESSAGE_TYPE)
                     .setScroll(TIMEOUT)
                     .addFields(JsonMessageConstants.UID, JsonMessageConstants.MAILBOX_ID, JsonMessageConstants.MESSAGE_ID)
                     .setQuery(queryConverter.from(users, query))

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterable.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterable.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterable.java
deleted file mode 100644
index 76acce1..0000000
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterable.java
+++ /dev/null
@@ -1,81 +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.mailbox.elasticsearch.search;
-
-import java.util.Iterator;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-
-public class ScrollIterable implements Iterable<SearchResponse> {
-
-    private static final TimeValue TIMEOUT = new TimeValue(60000);
-    private final Client client;
-    private final SearchRequestBuilder searchRequestBuilder;
-
-    public ScrollIterable(Client client, SearchRequestBuilder searchRequestBuilder) {
-        this.client = client;
-        this.searchRequestBuilder = searchRequestBuilder;
-    }
-
-    @Override
-    public Iterator<SearchResponse> iterator() {
-        return new ScrollIterator(client, searchRequestBuilder);
-    }
-
-    public Stream<SearchResponse> stream() {
-        return StreamSupport.stream(spliterator(), false);
-    }
-
-    public static class ScrollIterator implements Iterator<SearchResponse> {
-
-        private final Client client;
-        private ListenableActionFuture<SearchResponse> searchResponseFuture;
-
-        public ScrollIterator(Client client, SearchRequestBuilder searchRequestBuilder) {
-            this.client = client;
-            this.searchResponseFuture = searchRequestBuilder.execute();
-        }
-
-        @Override
-        public boolean hasNext() {
-            return !allSearchResponsesConsumed(searchResponseFuture.actionGet());
-        }
-
-        @Override
-        public SearchResponse next() {
-            SearchResponse result = searchResponseFuture.actionGet();
-            searchResponseFuture =  client.prepareSearchScroll(result.getScrollId())
-                .setScroll(TIMEOUT)
-                .execute();
-            return result;
-        }
-
-        private boolean allSearchResponsesConsumed(SearchResponse searchResponse) {
-            return searchResponse.getHits().getHits().length == 0;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java
deleted file mode 100644
index f5f2118..0000000
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java
+++ /dev/null
@@ -1,238 +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.mailbox.elasticsearch;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.elasticsearch.index.query.QueryBuilders.termQuery;
-
-import java.io.IOException;
-import java.util.concurrent.Executors;
-
-import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.node.Node;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.collect.Lists;
-
-public class ElasticSearchIndexerTest {
-
-    private static final int MINIMUM_BATCH_SIZE = 1;
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder);
-
-    @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
-    private Node node;
-    private ElasticSearchIndexer testee;
-
-    @Before
-    public void setup() throws IOException {
-        node = embeddedElasticSearch.getNode();
-        TestingClientProvider clientProvider = new TestingClientProvider(node);
-        DeleteByQueryPerformer deleteByQueryPerformer = new DeleteByQueryPerformer(clientProvider.get(), Executors.newSingleThreadExecutor(), MINIMUM_BATCH_SIZE) {
-            @Override
-            public void perform(QueryBuilder queryBuilder) {
-                doDeleteByQuery(queryBuilder);
-            }
-        };
-        testee = new ElasticSearchIndexer(clientProvider.get(), deleteByQueryPerformer);
-    }
-    
-    @Test
-    public void indexMessageShouldWork() throws Exception {
-        String messageId = "1";
-        String content = "{\"message\": \"trying out Elasticsearch\"}";
-        
-        testee.indexMessage(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .setQuery(QueryBuilders.matchQuery("message", "trying"))
-                    .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-    }
-    
-    @Test(expected=IllegalArgumentException.class)
-    public void indexMessageShouldThrowWhenJsonIsNull() throws InterruptedException {
-        testee.indexMessage("1", null);
-    }
-    
-    @Test
-    public void updateMessages() throws Exception {
-        String messageId = "1";
-        String content = "{\"message\": \"trying out Elasticsearch\",\"field\":\"Should be unchanged\"}";
-
-        testee.indexMessage(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation(messageId, "{\"message\": \"mastering out Elasticsearch\"}")));
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setQuery(QueryBuilders.matchQuery("message", "mastering"))
-                .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setQuery(QueryBuilders.matchQuery("field", "unchanged"))
-                .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void updateMessageShouldThrowWhenJsonIsNull() throws InterruptedException {
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation("1", null)));
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void updateMessageShouldThrowWhenIdIsNull() throws InterruptedException {
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation(null, "{\"message\": \"mastering out Elasticsearch\"}")));
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void updateMessageShouldThrowWhenJsonIsEmpty() throws InterruptedException {
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation("1", "")));
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void updateMessageShouldThrowWhenIdIsEmpty() throws InterruptedException {
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation("", "{\"message\": \"mastering out Elasticsearch\"}")));
-    }
-
-    @Test
-    public void deleteByQueryShouldWorkOnSingleMessage() throws Exception {
-        String messageId = "1:2";
-        String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}";
-
-        testee.indexMessage(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        testee.deleteAllMatchingQuery(termQuery(JsonMessageConstants.MAILBOX_ID, "1"));
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .setQuery(QueryBuilders.matchAllQuery())
-                    .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
-        }
-    }
-
-    @Test
-    public void deleteByQueryShouldWorkWhenMultipleMessages() throws Exception {
-        String messageId = "1:1";
-        String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}";
-        
-        testee.indexMessage(messageId, content);
-        
-        String messageId2 = "1:2";
-        String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"mailboxId\":\"1\"}";
-        
-        testee.indexMessage(messageId2, content2);
-        
-        String messageId3 = "2:3";
-        String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"mailboxId\":\"2\"}";
-        
-        testee.indexMessage(messageId3, content3);
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        testee.deleteAllMatchingQuery(termQuery(JsonMessageConstants.MAILBOX_ID, "1"));
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .setQuery(QueryBuilders.matchAllQuery())
-                    .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-    }
-    
-    @Test
-    public void deleteMessage() throws Exception {
-        String messageId = "1:2";
-        String content = "{\"message\": \"trying out Elasticsearch\"}";
-
-        testee.indexMessage(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        testee.deleteMessages(Lists.newArrayList(messageId));
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .setQuery(QueryBuilders.matchAllQuery())
-                    .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
-        }
-    }
-
-    @Test
-    public void deleteShouldWorkWhenMultipleMessages() throws Exception {
-        String messageId = "1:1";
-        String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}";
-
-        testee.indexMessage(messageId, content);
-
-        String messageId2 = "1:2";
-        String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"mailboxId\":\"1\"}";
-
-        testee.indexMessage(messageId2, content2);
-
-        String messageId3 = "2:3";
-        String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"mailboxId\":\"2\"}";
-
-        testee.indexMessage(messageId3, content3);
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        testee.deleteMessages(Lists.newArrayList(messageId, messageId3));
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setQuery(QueryBuilders.matchAllQuery())
-                .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index fb73266..92b2331 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -22,6 +22,12 @@ package org.apache.james.mailbox.elasticsearch;
 import java.time.ZoneId;
 import java.util.concurrent.Executors;
 
+import org.apache.james.backends.es.DeleteByQueryPerformer;
+import org.apache.james.backends.es.ElasticSearchIndexer;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
@@ -29,7 +35,6 @@ import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
 import org.apache.james.mailbox.elasticsearch.query.CriterionConverter;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
@@ -52,7 +57,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
     private static final int SEARCH_SIZE = 1;
 
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder);
+    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder, MailboxElasticsearchConstants.MAILBOX_INDEX);
 
     @Rule
     public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
@@ -65,12 +70,24 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
     @Override
     protected void initializeMailboxManager() throws Exception {
         Client client = NodeMappingFactory.applyMapping(
-            IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()).get())
-        );
+            IndexCreationFactory.createIndex(
+                new TestingClientProvider(embeddedElasticSearch.getNode()).get(),
+                MailboxElasticsearchConstants.MAILBOX_INDEX),
+            MailboxElasticsearchConstants.MAILBOX_INDEX,
+            MailboxElasticsearchConstants.MESSAGE_TYPE,
+            MailboxMappingFactory.getMappingContent());
+
         MailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
         InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
         messageSearchIndex = new ElasticSearchListeningMessageSearchIndex(mapperFactory,
-            new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor(), BATCH_SIZE)),
+            new ElasticSearchIndexer(client,
+                new DeleteByQueryPerformer(client,
+                    Executors.newSingleThreadExecutor(),
+                    BATCH_SIZE,
+                    MailboxElasticsearchConstants.MAILBOX_INDEX,
+                    MailboxElasticsearchConstants.MESSAGE_TYPE),
+                MailboxElasticsearchConstants.MAILBOX_INDEX,
+                MailboxElasticsearchConstants.MESSAGE_TYPE),
             new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE, new InMemoryId.Factory(), messageIdFactory),
             new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES, MessageSearchIndex.IndexMessageId.Required));
         storeMailboxManager = new InMemoryMailboxManager(

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/EmbeddedElasticSearch.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/EmbeddedElasticSearch.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/EmbeddedElasticSearch.java
deleted file mode 100644
index 4f199ef..0000000
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/EmbeddedElasticSearch.java
+++ /dev/null
@@ -1,116 +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.mailbox.elasticsearch;
-
-import static com.jayway.awaitility.Awaitility.await;
-import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.function.Supplier;
-
-import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
-import org.elasticsearch.action.admin.indices.flush.FlushAction;
-import org.elasticsearch.action.admin.indices.flush.FlushRequestBuilder;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.node.Node;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Throwables;
-import com.jayway.awaitility.Duration;
-
-public class EmbeddedElasticSearch extends ExternalResource {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedElasticSearch.class);
-
-    private final Supplier<Path> folder;
-    private Node node;
-
-    private static Path createTempDir(TemporaryFolder temporaryFolder) {
-        try {
-            return temporaryFolder.newFolder().toPath();
-        } catch (IOException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    public EmbeddedElasticSearch(TemporaryFolder temporaryFolder) {
-        this(() -> EmbeddedElasticSearch.createTempDir(temporaryFolder));
-    }
-
-    public EmbeddedElasticSearch(Path folder) {
-        this(() -> folder);
-    }
-
-    private EmbeddedElasticSearch(Supplier<Path> folder) {
-        this.folder = folder;
-    }
-
-    @Override
-    public void before() throws IOException {
-        node = nodeBuilder().local(true)
-            .settings(Settings.builder()
-                .put("path.home", folder.get().toAbsolutePath())
-                .build())
-            .node();
-        node.start();
-        awaitForElasticSearch();
-    }
-
-    @Override
-    public void after() {
-        awaitForElasticSearch();
-        try (Client client = node.client()) {
-            client.admin()
-                .indices()
-                .delete(new DeleteIndexRequest(ElasticSearchIndexer.MAILBOX_INDEX))
-                .actionGet();
-        } catch (Exception e) {
-            LOGGER.warn("Error while closing ES connection", e);
-        }
-        node.close();
-    }
-
-    public Node getNode() {
-        return node;
-    }
-
-    /**
-     * Sometimes, tests are too fast.
-     * This method ensure that ElasticSearch service is up and indices are updated
-     */
-    public void awaitForElasticSearch() {
-        await().atMost(Duration.TEN_SECONDS).until(this::flush);
-    }
-
-    private boolean flush() {
-        try (Client client = node.client()) {
-            new FlushRequestBuilder(client, FlushAction.INSTANCE).setForce(true).get();
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
index 4a9fc33..a9ea500 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
@@ -31,10 +31,10 @@ import java.util.List;
 
 import javax.mail.Flags;
 
+import org.apache.james.backends.es.ElasticSearchIndexer;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.MailboxSession.User;
-import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
 import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
 import org.apache.james.mailbox.model.TestId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterableTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterableTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterableTest.java
deleted file mode 100644
index 75313a1..0000000
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterableTest.java
+++ /dev/null
@@ -1,173 +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.mailbox.elasticsearch.search;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.apache.james.mailbox.elasticsearch.ClientProvider;
-import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
-import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.search.SearchHit;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-public class ScrollIterableTest {
-
-    public static final TimeValue TIMEOUT = new TimeValue(6000);
-    public static final int SIZE = 2;
-    public static final String MESSAGE = "message";
-
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder);
-
-    @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
-    private ClientProvider clientProvider;
-
-    @Before
-    public void setUp() throws Exception {
-        clientProvider = new TestingClientProvider(embeddedElasticSearch.getNode());
-        IndexCreationFactory.createIndex(clientProvider.get());
-        embeddedElasticSearch.awaitForElasticSearch();
-        NodeMappingFactory.applyMapping(clientProvider.get(), getMappingsSources());
-    }
-
-    private XContentBuilder getMappingsSources() throws IOException {
-        return jsonBuilder()
-            .startObject()
-                .startObject(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .startObject(NodeMappingFactory.PROPERTIES)
-                        .startObject(MESSAGE)
-                            .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
-                        .endObject()
-                    .endObject()
-                .endObject()
-            .endObject();
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenEmpty() {
-        try (Client client = clientProvider.get()) {
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-            assertThat(new ScrollIterable(client, searchRequestBuilder)).isEmpty();
-        }
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenOneElement() {
-        try (Client client = clientProvider.get()) {
-            String id = "1";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            embeddedElasticSearch.awaitForElasticSearch();
-
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id);
-        }
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenSizeElement() {
-        try (Client client = clientProvider.get()) {
-            String id1 = "1";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id1)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            String id2 = "2";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id2)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            embeddedElasticSearch.awaitForElasticSearch();
-
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id1, id2);
-        }
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenMoreThanSizeElement() {
-        try (Client client = clientProvider.get()) {
-            String id1 = "1";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id1)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            String id2 = "2";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id2)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            String id3 = "3";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id3)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            embeddedElasticSearch.awaitForElasticSearch();
-
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id1, id2, id3);
-        }
-    }
-
-    private List<String> convertToIdList(ScrollIterable scrollIterable) {
-        return scrollIterable.stream()
-            .flatMap(searchResponse -> Arrays.asList(searchResponse.getHits().getHits()).stream())
-            .map(SearchHit::getId)
-            .collect(Collectors.toList());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/utils/TestingClientProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/utils/TestingClientProvider.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/utils/TestingClientProvider.java
deleted file mode 100644
index 9fdaaa7..0000000
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/utils/TestingClientProvider.java
+++ /dev/null
@@ -1,37 +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.mailbox.elasticsearch.utils;
-
-import org.apache.james.mailbox.elasticsearch.ClientProvider;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.node.Node;
-
-public class TestingClientProvider implements ClientProvider {
-
-    private final Node node;
-
-    public TestingClientProvider(Node node) {
-        this.node = node;
-    }
-    
-    @Override
-    public Client get() {
-        return node.client();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/pom.xml b/mailbox/pom.xml
index e838610..ab42cf4 100644
--- a/mailbox/pom.xml
+++ b/mailbox/pom.xml
@@ -298,6 +298,25 @@
                 <version>${project.version}</version>
                 <type>test-jar</type>
             </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-backends-es</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-backends-es</artifactId>
+                <type>test-jar</type>
+                <scope>test</scope>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+                <type>test-jar</type>
+                <scope>test</scope>
+                <version>${project.version}</version>
+            </dependency>
 
             <!--
                 START Logging

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mpt/impl/imap-mailbox/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/pom.xml b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
index bc9ce66..0a4e36f 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/pom.xml
+++ b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
@@ -128,16 +128,28 @@
             <dependencies>
                 <dependency>
                     <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-mailbox-api</artifactId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <version>${project.version}</version>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <version>${project.version}</version>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <version>3.0.0-beta6-SNAPSHOT</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-mailbox-api</artifactId>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
                     <artifactId>apache-james-mailbox-elasticsearch</artifactId>
-                    <type>test-jar</type>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
index e6a09a7..6cac0a3 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
@@ -25,6 +25,12 @@ import java.time.ZoneId;
 import java.util.concurrent.Executors;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.james.backends.es.DeleteByQueryPerformer;
+import org.apache.james.backends.es.ElasticSearchIndexer;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -33,18 +39,14 @@ import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.acl.MailboxACLResolver;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
-import org.apache.james.mailbox.elasticsearch.DeleteByQueryPerformer;
-import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
 import org.apache.james.mailbox.elasticsearch.IndexAttachments;
-import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
-import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
+import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
 import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
 import org.apache.james.mailbox.elasticsearch.query.CriterionConverter;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
@@ -84,7 +86,7 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
     @Override
     public void beforeTest() throws Exception {
         this.tempDirectory = Files.createTempDirectory("elasticsearch");
-        this.embeddedElasticSearch = new EmbeddedElasticSearch(tempDirectory);
+        this.embeddedElasticSearch = new EmbeddedElasticSearch(tempDirectory, MailboxElasticsearchConstants.MAILBOX_INDEX);
         embeddedElasticSearch.before();
         initFields();
     }
@@ -102,7 +104,10 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
 
     private void initFields() {
         Client client = NodeMappingFactory.applyMapping(
-            IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()).get())
+            IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()).get(), MailboxElasticsearchConstants.MAILBOX_INDEX),
+            MailboxElasticsearchConstants.MAILBOX_INDEX,
+            MailboxElasticsearchConstants.MESSAGE_TYPE,
+            MailboxMappingFactory.getMappingContent()
         );
 
         userManager = new FakeAuthenticator();
@@ -111,7 +116,7 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
 
         ElasticSearchListeningMessageSearchIndex searchIndex = new ElasticSearchListeningMessageSearchIndex(
             factory,
-            new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor())),
+            new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor(), MailboxElasticsearchConstants.MAILBOX_INDEX, MailboxElasticsearchConstants.MESSAGE_TYPE), MailboxElasticsearchConstants.MAILBOX_INDEX, MailboxElasticsearchConstants.MESSAGE_TYPE),
             new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), new InMemoryId.Factory(), messageIdFactory),
             new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.systemDefault(), IndexAttachments.YES, MessageSearchIndex.IndexMessageId.Required));
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mpt/impl/smtp/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/pom.xml b/mpt/impl/smtp/cassandra/pom.xml
index 051bd9e..2ac1e1c 100644
--- a/mpt/impl/smtp/cassandra/pom.xml
+++ b/mpt/impl/smtp/cassandra/pom.xml
@@ -160,9 +160,9 @@
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-mailbox-elasticsearch</artifactId>
-                    <scope>test</scope>
+                    <artifactId>apache-james-backends-es</artifactId>
                     <type>test-jar</type>
+                    <scope>test</scope>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
@@ -255,7 +255,7 @@
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+                    <artifactId>apache-james-backends-es</artifactId>
                     <scope>test</scope>
                     <type>test-jar</type>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
index f90bca9..c7320f3 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
@@ -24,8 +24,9 @@ import java.util.Iterator;
 import org.apache.james.CassandraJamesServerMain;
 import org.apache.james.GuiceJamesServerImpl;
 import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
 import org.apache.james.modules.CassandraJmapServerModule;
 import org.apache.james.mpt.monitor.SystemLoggingMonitor;
 import org.apache.james.mpt.session.ExternalSessionFactory;
@@ -86,7 +87,7 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory impleme
         inMemoryDNSService = new InMemoryDNSService();
         folder = new TemporaryFolder();
         folder.create();
-        embeddedElasticSearch = new EmbeddedElasticSearch(folder.getRoot().toPath());
+        embeddedElasticSearch = new EmbeddedElasticSearch(folder.getRoot().toPath(), MailboxElasticsearchConstants.MAILBOX_INDEX);
         embeddedElasticSearch.before();
         embeddedCassandra = EmbeddedCassandra.createStartServer();
         jamesServer = createJamesServer();

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mpt/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/pom.xml b/mpt/pom.xml
index 4b5a519..aa4edb4 100644
--- a/mpt/pom.xml
+++ b/mpt/pom.xml
@@ -169,6 +169,13 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-backends-es</artifactId>
+                <type>test-jar</type>
+                <scope>test</scope>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
                 <artifactId>apache-james-backends-jpa</artifactId>
                 <type>test-jar</type>
                 <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/container/guice/cassandra-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
index 522d6bc..70fec90 100644
--- a/server/container/guice/cassandra-guice/pom.xml
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -198,6 +198,12 @@
                     <scope>test</scope>
                 </dependency>
                 <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
                     <groupId>${project.groupId}</groupId>
                     <artifactId>apache-james-mailbox-cassandra</artifactId>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
index eb979a2..8d79af2 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
@@ -26,12 +26,14 @@ import javax.inject.Singleton;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.backends.es.ClientProvider;
+import org.apache.james.backends.es.ClientProviderImpl;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
 import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.mailbox.elasticsearch.ClientProvider;
-import org.apache.james.mailbox.elasticsearch.ClientProviderImpl;
 import org.apache.james.mailbox.elasticsearch.IndexAttachments;
-import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
-import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
+import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
@@ -47,12 +49,12 @@ import com.nurkiewicz.asyncretry.AsyncRetryExecutor;
 
 public class ElasticSearchMailboxModule extends AbstractModule {
 
-    private static final int DEFAULT_CONNECTION_MAX_RETRIES = 7;
-    private static final int DEFAULT_CONNECTION_MIN_DELAY = 3000;
-    private static final boolean DEFAULT_INDEX_ATTACHMENTS = true;
     public static final String ES_CONFIG_FILE = FileSystem.FILE_PROTOCOL_AND_CONF + "elasticsearch.properties";
     public static final String ELASTICSEARCH_MASTER_HOST = "elasticsearch.masterHost";
     public static final String ELASTICSEARCH_PORT = "elasticsearch.port";
+    private static final int DEFAULT_CONNECTION_MAX_RETRIES = 7;
+    private static final int DEFAULT_CONNECTION_MIN_DELAY = 3000;
+    private static final boolean DEFAULT_INDEX_ATTACHMENTS = true;
 
     @Override
     protected void configure() {
@@ -74,9 +76,13 @@ public class ElasticSearchMailboxModule extends AbstractModule {
         Client client = getRetryer(executor, propertiesReader)
                 .getWithRetry(ctx -> clientProvider.get()).get();
         IndexCreationFactory.createIndex(client,
+            MailboxElasticsearchConstants.MAILBOX_INDEX,
             propertiesReader.getInt("elasticsearch.nb.shards"),
             propertiesReader.getInt("elasticsearch.nb.replica"));
-        NodeMappingFactory.applyMapping(client);
+        NodeMappingFactory.applyMapping(client,
+            MailboxElasticsearchConstants.MAILBOX_INDEX,
+            MailboxElasticsearchConstants.MESSAGE_TYPE,
+            MailboxMappingFactory.getMappingContent());
         return client;
     }
 


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


[05/12] james-project git commit: JAMES-1901 Enable reporting in ES for Guice/Cassandra

Posted by bt...@apache.org.
JAMES-1901 Enable reporting in ES for Guice/Cassandra


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

Branch: refs/heads/master
Commit: 6f38dcbb4480465ff146284f1fa4211d575dadfb
Parents: 894f4c4
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Dec 30 16:14:02 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:42:50 2017 +0700

----------------------------------------------------------------------
 .../destination/conf/elasticsearch.properties   |   6 +
 .../apache/james/CassandraJamesServerMain.java  |   4 +-
 .../mailbox/ElasticSearchMailboxModule.java     |   9 +-
 .../modules/server/ESMetricReporterModule.java  | 117 +++++++++++++++++++
 4 files changed, 132 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/6f38dcbb/dockerfiles/run/guice/cassandra/destination/conf/elasticsearch.properties
----------------------------------------------------------------------
diff --git a/dockerfiles/run/guice/cassandra/destination/conf/elasticsearch.properties b/dockerfiles/run/guice/cassandra/destination/conf/elasticsearch.properties
index a10cd3f..06e1852 100644
--- a/dockerfiles/run/guice/cassandra/destination/conf/elasticsearch.properties
+++ b/dockerfiles/run/guice/cassandra/destination/conf/elasticsearch.properties
@@ -28,3 +28,9 @@ elasticsearch.retryConnection.maxRetries=7
 elasticsearch.retryConnection.minDelay=3000
 # Index or not attachments (default value: true)
 elasticsearch.indexAttachments=true
+
+# Reports for metrics into ElasticSearch
+elasticsearch.http.port=9200
+elasticsearch.metrics.reports.enabled=true
+elasticsearch.metrics.reports.period=30
+elasticsearch.metrics.reports.index=james-metrics
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/6f38dcbb/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index c269263..431ea6b 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -29,6 +29,7 @@ import org.apache.james.modules.mailbox.CassandraSessionModule;
 import org.apache.james.modules.mailbox.ElasticSearchMailboxModule;
 import org.apache.james.modules.protocols.JMAPServerModule;
 import org.apache.james.modules.server.ActiveMQQueueModule;
+import org.apache.james.modules.server.ESMetricReporterModule;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.QuotaModule;
 
@@ -48,7 +49,8 @@ public class CassandraJamesServerMain {
         new CassandraSessionModule(),
         new ElasticSearchMailboxModule(),
         new QuotaModule(),
-        new ActiveMQQueueModule());
+        new ActiveMQQueueModule(),
+        new ESMetricReporterModule());
 
 
     public static void main(String[] args) throws Exception {

http://git-wip-us.apache.org/repos/asf/james-project/blob/6f38dcbb/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
index 15878dd..eb979a2 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
@@ -50,6 +50,9 @@ public class ElasticSearchMailboxModule extends AbstractModule {
     private static final int DEFAULT_CONNECTION_MAX_RETRIES = 7;
     private static final int DEFAULT_CONNECTION_MIN_DELAY = 3000;
     private static final boolean DEFAULT_INDEX_ATTACHMENTS = true;
+    public static final String ES_CONFIG_FILE = FileSystem.FILE_PROTOCOL_AND_CONF + "elasticsearch.properties";
+    public static final String ELASTICSEARCH_MASTER_HOST = "elasticsearch.masterHost";
+    public static final String ELASTICSEARCH_PORT = "elasticsearch.port";
 
     @Override
     protected void configure() {
@@ -64,10 +67,10 @@ public class ElasticSearchMailboxModule extends AbstractModule {
     @Provides
     @Singleton
     protected Client provideClientProvider(FileSystem fileSystem, AsyncRetryExecutor executor) throws ConfigurationException, FileNotFoundException, ExecutionException, InterruptedException {
-        PropertiesConfiguration propertiesReader = new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "elasticsearch.properties"));
+        PropertiesConfiguration propertiesReader = new PropertiesConfiguration(fileSystem.getFile(ES_CONFIG_FILE));
 
-        ClientProvider clientProvider = new ClientProviderImpl(propertiesReader.getString("elasticsearch.masterHost"),
-                propertiesReader.getInt("elasticsearch.port"));
+        ClientProvider clientProvider = new ClientProviderImpl(propertiesReader.getString(ELASTICSEARCH_MASTER_HOST),
+                propertiesReader.getInt(ELASTICSEARCH_PORT));
         Client client = getRetryer(executor, propertiesReader)
                 .getWithRetry(ctx -> clientProvider.get()).get();
         IndexCreationFactory.createIndex(client,

http://git-wip-us.apache.org/repos/asf/james-project/blob/6f38dcbb/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
new file mode 100644
index 0000000..fcf0eb7
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
@@ -0,0 +1,117 @@
+/****************************************************************
+ * 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.modules.server;
+
+import java.io.FileNotFoundException;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.lifecycle.api.Configurable;
+import org.apache.james.metrics.dropwizard.DropWizardMetricFactory;
+import org.apache.james.metrics.dropwizard.ESMetricReporter;
+import org.apache.james.metrics.dropwizard.ESReporterConfiguration;
+import org.apache.james.modules.mailbox.ElasticSearchMailboxModule;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class ESMetricReporterModule extends AbstractModule {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ESMetricReporterModule.class);
+    public static final boolean DEFAULT_DISABLE = false;
+    public static final int DEFAULT_ES_HTTP_PORT = 9200;
+
+    @Override
+    protected void configure() {
+        Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(ESMetricReporterStarter.class);
+    }
+
+    @Provides
+    public ESReporterConfiguration provideConfiguration(FileSystem fileSystem) throws ConfigurationException {
+        try {
+            PropertiesConfiguration propertiesReader = getPropertiesConfiguration(fileSystem);
+
+            if (isMetricEnable(propertiesReader)) {
+                return ESReporterConfiguration.enabled(
+                    propertiesReader.getString(ElasticSearchMailboxModule.ELASTICSEARCH_MASTER_HOST),
+                    propertiesReader.getInt("elasticsearch.http.port", DEFAULT_ES_HTTP_PORT),
+                    Optional.fromNullable(propertiesReader.getString("elasticsearch.metrics.reports.index", null)),
+                    Optional.fromNullable(propertiesReader.getLong("elasticsearch.metrics.reports.period", null)));
+            }
+        } catch (FileNotFoundException e) {
+            LOGGER.info("Can not locate " + ElasticSearchMailboxModule.ES_CONFIG_FILE);
+        }
+        return ESReporterConfiguration.disabled();
+    }
+
+    private boolean isMetricEnable(PropertiesConfiguration propertiesReader) {
+        return propertiesReader.getBoolean("elasticsearch.metrics.reports.enabled", DEFAULT_DISABLE);
+    }
+
+    private PropertiesConfiguration getPropertiesConfiguration(FileSystem fileSystem) throws ConfigurationException, FileNotFoundException {
+        return new PropertiesConfiguration(
+                    fileSystem.getFile(ElasticSearchMailboxModule.ES_CONFIG_FILE));
+    }
+
+    @Provides
+    public ESMetricReporter provideReporter(DropWizardMetricFactory metricFactory, ESReporterConfiguration configuration) throws ConfigurationException, ExecutionException, InterruptedException {
+        return metricFactory.provideEsReporter(configuration);
+    }
+
+    @Singleton
+    public static class ESMetricReporterStarter implements ConfigurationPerformer, Configurable {
+
+        private final ESMetricReporter esMetricReporter;
+
+        @Inject
+        public ESMetricReporterStarter(ESMetricReporter esMetricReporter) {
+            this.esMetricReporter = esMetricReporter;
+        }
+
+        @Override
+        public void initModule() {
+            esMetricReporter.start();
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(ESMetricReporterStarter.class);
+        }
+
+        @Override
+        public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+            throw new NotImplementedException();
+        }
+    }
+
+}


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


[11/12] james-project git commit: JAMES-1901 Introduce a builder for ESReporterConfiguration

Posted by bt...@apache.org.
JAMES-1901 Introduce a builder for ESReporterConfiguration


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

Branch: refs/heads/master
Commit: 263976aa4be8936fabee7c10bdbe456ee32cd519
Parents: 649b62d
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Feb 2 11:08:36 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:43:43 2017 +0700

----------------------------------------------------------------------
 .../modules/server/ESMetricReporterModule.java  | 17 ++--
 .../metrics/metrics-es-reporter/pom.xml         |  6 ++
 .../metrics/es/ESReporterConfiguration.java     | 63 +++++++++----
 .../metric/es/ESReportedConfigurationTest.java  | 95 ++++++++++++++++++++
 .../apache/james/metric/es/ESReporterTest.java  | 12 ++-
 5 files changed, 164 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/263976aa/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
index 06cf7a7..f43c5cf 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
@@ -21,7 +21,6 @@ package org.apache.james.modules.server;
 
 import java.io.FileNotFoundException;
 import java.util.List;
-import java.util.Optional;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
@@ -60,16 +59,20 @@ public class ESMetricReporterModule extends AbstractModule {
             PropertiesConfiguration propertiesReader = getPropertiesConfiguration(fileSystem);
 
             if (isMetricEnable(propertiesReader)) {
-                return ESReporterConfiguration.enabled(
-                    propertiesReader.getString(ElasticSearchMailboxModule.ELASTICSEARCH_MASTER_HOST),
-                    propertiesReader.getInt("elasticsearch.http.port", DEFAULT_ES_HTTP_PORT),
-                    Optional.ofNullable(propertiesReader.getString("elasticsearch.metrics.reports.index", null)),
-                    Optional.ofNullable(propertiesReader.getLong("elasticsearch.metrics.reports.period", null)));
+                return ESReporterConfiguration.builder()
+                    .enabled()
+                    .onHost(propertiesReader.getString(ElasticSearchMailboxModule.ELASTICSEARCH_MASTER_HOST),
+                        propertiesReader.getInt("elasticsearch.http.port", DEFAULT_ES_HTTP_PORT))
+                    .onIndex(propertiesReader.getString("elasticsearch.metrics.reports.index", null))
+                    .periodInSecond(propertiesReader.getLong("elasticsearch.metrics.reports.period", null))
+                    .build();
             }
         } catch (FileNotFoundException e) {
             LOGGER.info("Can not locate " + ElasticSearchMailboxModule.ES_CONFIG_FILE);
         }
-        return ESReporterConfiguration.disabled();
+        return ESReporterConfiguration.builder()
+            .disabled()
+            .build();
     }
 
     private boolean isMetricEnable(PropertiesConfiguration propertiesReader) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/263976aa/server/container/metrics/metrics-es-reporter/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/pom.xml b/server/container/metrics/metrics-es-reporter/pom.xml
index 97f2500..a4a9fce 100644
--- a/server/container/metrics/metrics-es-reporter/pom.xml
+++ b/server/container/metrics/metrics-es-reporter/pom.xml
@@ -159,6 +159,12 @@
                     <scope>test</scope>
                 </dependency>
                 <dependency>
+                    <groupId>org.assertj</groupId>
+                    <artifactId>assertj-core</artifactId>
+                    <version>${assertj-3.version}</version>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
                     <groupId>org.elasticsearch</groupId>
                     <artifactId>metrics-elasticsearch-reporter</artifactId>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/263976aa/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESReporterConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESReporterConfiguration.java b/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESReporterConfiguration.java
index 5b7ad0f..afed836 100644
--- a/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESReporterConfiguration.java
+++ b/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESReporterConfiguration.java
@@ -25,29 +25,56 @@ import com.google.common.base.Preconditions;
 
 public class ESReporterConfiguration {
 
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private Optional<String> host = Optional.empty();
+        private Optional<Integer> port = Optional.empty();
+        private Optional<Boolean> enabled = Optional.empty();
+        private Optional<String> index = Optional.empty();
+        private Optional<Long> periodInSecond = Optional.empty();
+
+        public Builder enabled() {
+            this.enabled = Optional.of(ENABLED);
+            return this;
+        }
+
+        public Builder disabled() {
+            this.enabled = Optional.of(DISABLED);
+            return this;
+        }
+
+        public Builder onHost(String host, int port) {
+            this.host = Optional.of(host);
+            this.port = Optional.of(port);
+            return this;
+        }
+
+        public Builder onIndex(String index) {
+            this.index = Optional.ofNullable(index);
+            return this;
+        }
+
+        public Builder periodInSecond(Long periodInSecond) {
+            this.periodInSecond = Optional.ofNullable(periodInSecond);
+            return this;
+        }
+
+        public ESReporterConfiguration build() {
+            Preconditions.checkState(enabled.isPresent(), "You must specify either enabled or disabled");
+            Preconditions.checkState(!enabled.get() || host.isPresent(), "You must specify host when enabled");
+            Preconditions.checkState(!enabled.get() || port.isPresent(), "You must specify port when enabled");
+            return new ESReporterConfiguration(host, port, enabled.get(), index, periodInSecond);
+        }
+    }
+
     public static final boolean ENABLED = true;
     public static final boolean DISABLED = !ENABLED;
     public static final String DEFAULT_INDEX = "james-metrics";
     public static final long DEFAULT_PERIOD_IN_SECOND = 60L;
 
-    public static ESReporterConfiguration disabled() {
-        return new ESReporterConfiguration(
-            Optional.empty(),
-            Optional.empty(),
-            DISABLED,
-            Optional.empty(),
-            Optional.empty());
-    }
-
-    public static ESReporterConfiguration enabled(String host, int port, Optional<String> index, Optional<Long> periodInSecond) {
-        return new ESReporterConfiguration(
-            Optional.of(host),
-            Optional.of(port),
-            ENABLED,
-            index,
-            periodInSecond);
-    }
-
     private final Optional<String> host;
     private final Optional<Integer> port;
     private final boolean enabled;

http://git-wip-us.apache.org/repos/asf/james-project/blob/263976aa/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReportedConfigurationTest.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReportedConfigurationTest.java b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReportedConfigurationTest.java
new file mode 100644
index 0000000..4359688
--- /dev/null
+++ b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReportedConfigurationTest.java
@@ -0,0 +1,95 @@
+/****************************************************************
+ * 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.metric.es;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.metrics.es.ESReporterConfiguration;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class ESReportedConfigurationTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void builderShouldThrowWhenNotToldIfEnabled() {
+        expectedException.expect(IllegalStateException.class);
+
+        ESReporterConfiguration.builder().build();
+    }
+
+    @Test
+    public void builderShouldThrowIfEnabledWithoutHostAndPort() {
+        expectedException.expect(IllegalStateException.class);
+
+        ESReporterConfiguration.builder()
+            .enabled()
+            .build();
+    }
+
+    @Test
+    public void builderShouldThrowOnNullHost() {
+        expectedException.expect(NullPointerException.class);
+
+        ESReporterConfiguration.builder()
+            .onHost(null, 18);
+    }
+
+    @Test
+    public void builderShouldWorkWhenDisabled() {
+        ESReporterConfiguration configuration = ESReporterConfiguration.builder()
+            .disabled()
+            .build();
+
+        assertThat(configuration.isEnabled()).isFalse();
+        assertThat(configuration.getIndex()).isEqualTo(ESReporterConfiguration.DEFAULT_INDEX);
+        assertThat(configuration.getPeriodInSecond()).isEqualTo(ESReporterConfiguration.DEFAULT_PERIOD_IN_SECOND);
+    }
+
+    @Test
+    public void getHostWithPortShouldThrowWhenDisabled() {
+        ESReporterConfiguration configuration = ESReporterConfiguration.builder()
+            .disabled()
+            .build();
+
+        expectedException.expect(IllegalStateException.class);
+
+        configuration.getHostWithPort();
+    }
+
+    @Test
+    public void builderShouldWorkWhenEnabled() {
+        int port = 14;
+        String host = "host";
+        ESReporterConfiguration configuration = ESReporterConfiguration.builder()
+            .enabled()
+            .onHost(host, port)
+            .build();
+
+        assertThat(configuration.isEnabled()).isTrue();
+        assertThat(configuration.getHostWithPort()).isEqualTo(host + ":" + port);
+        assertThat(configuration.getIndex()).isEqualTo(ESReporterConfiguration.DEFAULT_INDEX);
+        assertThat(configuration.getPeriodInSecond()).isEqualTo(ESReporterConfiguration.DEFAULT_PERIOD_IN_SECOND);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/263976aa/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
index 633a62c..fedc02d 100644
--- a/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
+++ b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
@@ -21,7 +21,6 @@ package org.apache.james.metric.es;
 
 import static com.jayway.awaitility.Awaitility.await;
 
-import java.util.Optional;
 import java.util.Timer;
 import java.util.TimerTask;
 
@@ -44,8 +43,8 @@ import com.jayway.awaitility.Duration;
 
 public class ESReporterTest {
 
-    public static final Optional<String> INDEX = Optional.of("index_name");
-    public static final Optional<Long> PERIOD_IN_SECOND = Optional.of(1L);
+    public static final String INDEX = "index_name";
+    public static final long PERIOD_IN_SECOND = 1L;
     public static final int DELAY_IN_MS = 100;
     public static final int PERIOD_IN_MS = 100;
     public static final int ES_APPLICATIVE_PORT = 9300;
@@ -69,7 +68,12 @@ public class ESReporterTest {
         registry = new MetricRegistry();
         timer = new Timer();
         esMetricReporter = new ESMetricReporter(
-            ESReporterConfiguration.enabled(getContainerIp(), ES_HTTP_PORT, INDEX, PERIOD_IN_SECOND),
+            ESReporterConfiguration.builder()
+                .enabled()
+                .onHost(getContainerIp(), ES_HTTP_PORT)
+                .onIndex(INDEX)
+                .periodInSecond(PERIOD_IN_SECOND)
+                .build(),
             registry);
     }
 


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


[12/12] james-project git commit: JAMES-1901 Strong typing for Index and Types

Posted by bt...@apache.org.
JAMES-1901 Strong typing for Index and Types


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

Branch: refs/heads/master
Commit: b54f9604d69be4fb268e9c98e25fd115f7cd0112
Parents: 263976a
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Feb 2 11:51:55 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:43:43 2017 +0700

----------------------------------------------------------------------
 .../backends/es/DeleteByQueryPerformer.java     | 16 ++++-----
 .../james/backends/es/ElasticSearchIndexer.java | 20 +++++++----
 .../james/backends/es/IndexCreationFactory.java |  8 ++---
 .../org/apache/james/backends/es/IndexName.java | 32 +++++++++++++++++
 .../james/backends/es/NodeMappingFactory.java   |  6 ++--
 .../org/apache/james/backends/es/TypeName.java  | 32 +++++++++++++++++
 .../backends/es/ElasticSearchIndexerTest.java   | 32 ++++++++---------
 .../backends/es/EmbeddedElasticSearch.java      | 10 +++---
 .../backends/es/search/ScrollIterableTest.java  | 38 ++++++++++----------
 .../MailboxElasticsearchConstants.java          |  7 ++--
 .../elasticsearch/MailboxMappingFactory.java    |  2 +-
 .../search/ElasticSearchSearcher.java           |  4 +--
 .../mailbox/ElasticSearchMailboxModule.java     |  4 +++
 13 files changed, 146 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
index 065fe19..6a44754 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
@@ -43,16 +43,16 @@ public class DeleteByQueryPerformer {
     private final Client client;
     private final ExecutorService executor;
     private final int batchSize;
-    private final String indexName;
-    private final String typeName;
+    private final IndexName indexName;
+    private final TypeName typeName;
 
     @Inject
-    public DeleteByQueryPerformer(Client client, @Named("AsyncExecutor") ExecutorService executor, String indexName, String typeName) {
+    public DeleteByQueryPerformer(Client client, @Named("AsyncExecutor") ExecutorService executor, IndexName indexName, TypeName typeName) {
         this(client, executor, DEFAULT_BATCH_SIZE, indexName, typeName);
     }
 
     @VisibleForTesting
-    public DeleteByQueryPerformer(Client client, @Named("AsyncExecutor") ExecutorService executor, int batchSize, String indexName, String typeName) {
+    public DeleteByQueryPerformer(Client client, @Named("AsyncExecutor") ExecutorService executor, int batchSize, IndexName indexName, TypeName typeName) {
         this.client = client;
         this.executor = executor;
         this.batchSize = batchSize;
@@ -66,8 +66,8 @@ public class DeleteByQueryPerformer {
 
     protected void doDeleteByQuery(QueryBuilder queryBuilder) {
         new ScrollIterable(client,
-            client.prepareSearch(indexName)
-                .setTypes(typeName)
+            client.prepareSearch(indexName.getValue())
+                .setTypes(typeName.getValue())
                 .setScroll(TIMEOUT)
                 .setNoFields()
                 .setQuery(queryBuilder)
@@ -80,8 +80,8 @@ public class DeleteByQueryPerformer {
         BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
         for (SearchHit hit : searchResponse.getHits()) {
             bulkRequestBuilder.add(client.prepareDelete()
-                .setIndex(indexName)
-                .setType(typeName)
+                .setIndex(indexName.getValue())
+                .setType(typeName.getValue())
                 .setId(hit.getId()));
         }
         return bulkRequestBuilder.execute();

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
index 5cbf1f4..f1df1d7 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
@@ -59,11 +59,11 @@ public class ElasticSearchIndexer {
     
     private final Client client;
     private final DeleteByQueryPerformer deleteByQueryPerformer;
-    private final String indexName;
-    private final String typeName;
+    private final IndexName indexName;
+    private final TypeName typeName;
 
     @Inject
-    public ElasticSearchIndexer(Client client, DeleteByQueryPerformer deleteByQueryPerformer, String indexName, String typeName) {
+    public ElasticSearchIndexer(Client client, DeleteByQueryPerformer deleteByQueryPerformer, IndexName indexName, TypeName typeName) {
         this.client = client;
         this.deleteByQueryPerformer = deleteByQueryPerformer;
         this.indexName = indexName;
@@ -73,7 +73,7 @@ public class ElasticSearchIndexer {
     public IndexResponse indexMessage(String id, String content) {
         checkArgument(content);
         LOGGER.debug(String.format("Indexing %s: %s", id, content));
-        return client.prepareIndex(indexName, typeName, id)
+        return client.prepareIndex(indexName.getValue(), typeName.getValue(), id)
             .setSource(content)
             .get();
     }
@@ -81,14 +81,22 @@ public class ElasticSearchIndexer {
     public BulkResponse updateMessages(List<UpdatedRepresentation> updatedDocumentParts) {
         Preconditions.checkNotNull(updatedDocumentParts);
         BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
-        updatedDocumentParts.forEach(updatedDocumentPart -> bulkRequestBuilder.add(client.prepareUpdate(indexName, typeName, updatedDocumentPart.getId())
+        updatedDocumentParts.forEach(updatedDocumentPart -> bulkRequestBuilder.add(
+            client.prepareUpdate(
+                indexName.getValue(),
+                typeName.getValue(),
+                updatedDocumentPart.getId())
             .setDoc(updatedDocumentPart.getUpdatedDocumentPart())));
         return bulkRequestBuilder.get();
     }
 
     public BulkResponse deleteMessages(List<String> ids) {
         BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
-        ids.forEach(id -> bulkRequestBuilder.add(client.prepareDelete(indexName, typeName, id)));
+        ids.forEach(id -> bulkRequestBuilder.add(
+            client.prepareDelete(
+                indexName.getValue(),
+                typeName.getValue(),
+                id)));
         return bulkRequestBuilder.get();
     }
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
index cab6021..eb6771a 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
@@ -36,7 +36,7 @@ public class IndexCreationFactory {
     private static final int DEFAULT_NB_REPLICA = 0;
     public static final String CASE_INSENSITIVE = "case_insensitive";
 
-    public static Client createIndex(Client client, String name, int nbShards, int nbReplica) {
+    public static Client createIndex(Client client, IndexName name, int nbShards, int nbReplica) {
         try {
             return createIndex(client, name, generateSetting(nbShards, nbReplica));
         } catch (IOException e) {
@@ -45,15 +45,15 @@ public class IndexCreationFactory {
         }
     }
 
-    public static Client createIndex(Client client, String name) {
+    public static Client createIndex(Client client, IndexName name) {
         return createIndex(client, name, DEFAULT_NB_SHARDS, DEFAULT_NB_REPLICA);
     }
 
-    private static Client createIndex(Client client, String name, XContentBuilder settings) {
+    private static Client createIndex(Client client, IndexName name, XContentBuilder settings) {
         try {
                 client.admin()
                     .indices()
-                    .prepareCreate(name)
+                    .prepareCreate(name.getValue())
                     .setSettings(settings)
                     .execute()
                     .actionGet();

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexName.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexName.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexName.java
new file mode 100644
index 0000000..8936bb2
--- /dev/null
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexName.java
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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.backends.es;
+
+public class IndexName {
+    private final String value;
+
+    public IndexName(String value) {
+        this.value = value;
+    }
+
+    public String getValue() {
+        return value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
index 876c741..f60bcd2 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
@@ -41,11 +41,11 @@ public class NodeMappingFactory {
     public static final String IGNORE_ABOVE = "ignore_above";
     public static final int LUCENE_LIMIT = 32766;
 
-    public static Client applyMapping(Client client, String indexName, String typeName, XContentBuilder mappingsSources) {
+    public static Client applyMapping(Client client, IndexName indexName, TypeName typeName, XContentBuilder mappingsSources) {
         client.admin()
             .indices()
-            .preparePutMapping(indexName)
-            .setType(typeName)
+            .preparePutMapping(indexName.getValue())
+            .setType(typeName.getValue())
             .setSource(mappingsSources)
             .execute()
             .actionGet();

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/TypeName.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/TypeName.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/TypeName.java
new file mode 100644
index 0000000..e6c638b
--- /dev/null
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/TypeName.java
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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.backends.es;
+
+public class TypeName {
+    private final String value;
+
+    public TypeName(String value) {
+        this.value = value;
+    }
+
+    public String getValue() {
+        return value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
index cb42956..60ce997 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
@@ -43,8 +43,8 @@ public class ElasticSearchIndexerTest {
 
     private static final int MINIMUM_BATCH_SIZE = 1;
     private static final String CONTENT = "content";
-    private static final String INDEX_NAME = "index_name";
-    private static final String TYPE_NAME = "type_name";
+    private static final IndexName INDEX_NAME = new IndexName("index_name");
+    private static final TypeName TYPE_NAME = new TypeName("type_name");
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
     private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder, INDEX_NAME);
 
@@ -80,8 +80,8 @@ public class ElasticSearchIndexerTest {
         embeddedElasticSearch.awaitForElasticSearch();
         
         try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
-                    .setTypes(TYPE_NAME)
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
+                    .setTypes(TYPE_NAME.getValue())
                     .setQuery(QueryBuilders.matchQuery("message", "trying"))
                     .get();
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
@@ -105,16 +105,16 @@ public class ElasticSearchIndexerTest {
         embeddedElasticSearch.awaitForElasticSearch();
 
         try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
-                .setTypes(TYPE_NAME)
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
+                .setTypes(TYPE_NAME.getValue())
                 .setQuery(QueryBuilders.matchQuery("message", "mastering"))
                 .get();
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
         }
 
         try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
-                .setTypes(TYPE_NAME)
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
+                .setTypes(TYPE_NAME.getValue())
                 .setQuery(QueryBuilders.matchQuery("field", "unchanged"))
                 .get();
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
@@ -153,8 +153,8 @@ public class ElasticSearchIndexerTest {
         embeddedElasticSearch.awaitForElasticSearch();
         
         try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
-                    .setTypes(TYPE_NAME)
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
+                    .setTypes(TYPE_NAME.getValue())
                     .setQuery(QueryBuilders.matchAllQuery())
                     .get();
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
@@ -183,8 +183,8 @@ public class ElasticSearchIndexerTest {
         embeddedElasticSearch.awaitForElasticSearch();
         
         try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
-                    .setTypes(TYPE_NAME)
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
+                    .setTypes(TYPE_NAME.getValue())
                     .setQuery(QueryBuilders.matchAllQuery())
                     .get();
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
@@ -203,8 +203,8 @@ public class ElasticSearchIndexerTest {
         embeddedElasticSearch.awaitForElasticSearch();
         
         try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
-                    .setTypes(TYPE_NAME)
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
+                    .setTypes(TYPE_NAME.getValue())
                     .setQuery(QueryBuilders.matchAllQuery())
                     .get();
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
@@ -233,8 +233,8 @@ public class ElasticSearchIndexerTest {
         embeddedElasticSearch.awaitForElasticSearch();
 
         try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
-                .setTypes(TYPE_NAME)
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
+                .setTypes(TYPE_NAME.getValue())
                 .setQuery(QueryBuilders.matchAllQuery())
                 .get();
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
index 2902cde..5f37189 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
@@ -45,7 +45,7 @@ public class EmbeddedElasticSearch extends ExternalResource {
     private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedElasticSearch.class);
 
     private final Supplier<Path> folder;
-    private final String indexName;
+    private final IndexName indexName;
     private Node node;
 
     private static Path createTempDir(TemporaryFolder temporaryFolder) {
@@ -56,15 +56,15 @@ public class EmbeddedElasticSearch extends ExternalResource {
         }
     }
 
-    public EmbeddedElasticSearch(TemporaryFolder temporaryFolder, String indexName) {
+    public EmbeddedElasticSearch(TemporaryFolder temporaryFolder, IndexName indexName) {
         this(() -> EmbeddedElasticSearch.createTempDir(temporaryFolder), indexName);
     }
 
-    public EmbeddedElasticSearch(Path folder, String indexName) {
+    public EmbeddedElasticSearch(Path folder, IndexName indexName) {
         this(() -> folder, indexName);
     }
 
-    private EmbeddedElasticSearch(Supplier<Path> folder, String indexName) {
+    private EmbeddedElasticSearch(Supplier<Path> folder, IndexName indexName) {
         this.folder = folder;
         this.indexName = indexName;
     }
@@ -86,7 +86,7 @@ public class EmbeddedElasticSearch extends ExternalResource {
         try (Client client = node.client()) {
             client.admin()
                 .indices()
-                .delete(new DeleteIndexRequest(indexName))
+                .delete(new DeleteIndexRequest(indexName.getValue()))
                 .actionGet();
         } catch (Exception e) {
             LOGGER.warn("Error while closing ES connection", e);

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
index 5b53a76..121b8b7 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
@@ -31,7 +31,9 @@ import java.util.stream.Collectors;
 import org.apache.james.backends.es.ClientProvider;
 import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.IndexName;
 import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.backends.es.TypeName;
 import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.client.Client;
@@ -49,8 +51,8 @@ public class ScrollIterableTest {
     public static final TimeValue TIMEOUT = new TimeValue(6000);
     public static final int SIZE = 2;
     public static final String MESSAGE = "message";
-    public static final String INDEX_NAME = "index";
-    public static final String MESSAGES = "messages";
+    public static final IndexName INDEX_NAME = new IndexName("index");
+    public static final TypeName TYPE_NAME = new TypeName("messages");
 
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
     private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder, INDEX_NAME);
@@ -65,13 +67,13 @@ public class ScrollIterableTest {
         clientProvider = new TestingClientProvider(embeddedElasticSearch.getNode());
         IndexCreationFactory.createIndex(clientProvider.get(), INDEX_NAME);
         embeddedElasticSearch.awaitForElasticSearch();
-        NodeMappingFactory.applyMapping(clientProvider.get(), INDEX_NAME, MESSAGES, getMappingsSources());
+        NodeMappingFactory.applyMapping(clientProvider.get(), INDEX_NAME, TYPE_NAME, getMappingsSources());
     }
 
     private XContentBuilder getMappingsSources() throws IOException {
         return jsonBuilder()
             .startObject()
-                .startObject(MESSAGES)
+                .startObject(TYPE_NAME.getValue())
                     .startObject(NodeMappingFactory.PROPERTIES)
                         .startObject(MESSAGE)
                             .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
@@ -84,8 +86,8 @@ public class ScrollIterableTest {
     @Test
     public void scrollIterableShouldWorkWhenEmpty() {
         try (Client client = clientProvider.get()) {
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME)
-                .setTypes(MESSAGES)
+            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
+                .setTypes(TYPE_NAME.getValue())
                 .setScroll(TIMEOUT)
                 .setQuery(matchAllQuery())
                 .setSize(SIZE);
@@ -97,14 +99,14 @@ public class ScrollIterableTest {
     public void scrollIterableShouldWorkWhenOneElement() {
         try (Client client = clientProvider.get()) {
             String id = "1";
-            client.prepareIndex(INDEX_NAME, MESSAGES, id)
+            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id)
                 .setSource(MESSAGE, "Sample message")
                 .execute();
 
             embeddedElasticSearch.awaitForElasticSearch();
 
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME)
-                .setTypes(MESSAGES)
+            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
+                .setTypes(TYPE_NAME.getValue())
                 .setScroll(TIMEOUT)
                 .setQuery(matchAllQuery())
                 .setSize(SIZE);
@@ -116,19 +118,19 @@ public class ScrollIterableTest {
     public void scrollIterableShouldWorkWhenSizeElement() {
         try (Client client = clientProvider.get()) {
             String id1 = "1";
-            client.prepareIndex(INDEX_NAME, MESSAGES, id1)
+            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id1)
                 .setSource(MESSAGE, "Sample message")
                 .execute();
 
             String id2 = "2";
-            client.prepareIndex(INDEX_NAME, MESSAGES, id2)
+            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id2)
                 .setSource(MESSAGE, "Sample message")
                 .execute();
 
             embeddedElasticSearch.awaitForElasticSearch();
 
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME)
-                .setTypes(MESSAGES)
+            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
+                .setTypes(TYPE_NAME.getValue())
                 .setScroll(TIMEOUT)
                 .setQuery(matchAllQuery())
                 .setSize(SIZE);
@@ -140,24 +142,24 @@ public class ScrollIterableTest {
     public void scrollIterableShouldWorkWhenMoreThanSizeElement() {
         try (Client client = clientProvider.get()) {
             String id1 = "1";
-            client.prepareIndex(INDEX_NAME, MESSAGES, id1)
+            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id1)
                 .setSource(MESSAGE, "Sample message")
                 .execute();
 
             String id2 = "2";
-            client.prepareIndex(INDEX_NAME, MESSAGES, id2)
+            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id2)
                 .setSource(MESSAGE, "Sample message")
                 .execute();
 
             String id3 = "3";
-            client.prepareIndex(INDEX_NAME, MESSAGES, id3)
+            client.prepareIndex(INDEX_NAME.getValue(), TYPE_NAME.getValue(), id3)
                 .setSource(MESSAGE, "Sample message")
                 .execute();
 
             embeddedElasticSearch.awaitForElasticSearch();
 
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME)
-                .setTypes(MESSAGES)
+            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
+                .setTypes(TYPE_NAME.getValue())
                 .setScroll(TIMEOUT)
                 .setQuery(matchAllQuery())
                 .setSize(SIZE);

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxElasticsearchConstants.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxElasticsearchConstants.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxElasticsearchConstants.java
index 4977950..4cf9bd1 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxElasticsearchConstants.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxElasticsearchConstants.java
@@ -19,7 +19,10 @@
 
 package org.apache.james.mailbox.elasticsearch;
 
+import org.apache.james.backends.es.IndexName;
+import org.apache.james.backends.es.TypeName;
+
 public interface MailboxElasticsearchConstants {
-    String MAILBOX_INDEX = "mailbox";
-    String MESSAGE_TYPE = "message";
+    IndexName MAILBOX_INDEX = new IndexName("mailbox");
+    TypeName MESSAGE_TYPE = new TypeName("message");
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
index 1cfce9b..ad2d16b 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
@@ -38,7 +38,7 @@ public class MailboxMappingFactory {
             return jsonBuilder()
                 .startObject()
 
-                    .startObject(MailboxElasticsearchConstants.MESSAGE_TYPE)
+                    .startObject(MailboxElasticsearchConstants.MESSAGE_TYPE.getValue())
                         .startObject(NodeMappingFactory.PROPERTIES)
                             .startObject(JsonMessageConstants.MESSAGE_ID)
                                 .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
index d8339f7..1599559 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
@@ -83,8 +83,8 @@ public class ElasticSearchSearcher {
         return query.getSearchQuery().getSorts()
             .stream()
             .reduce(
-                client.prepareSearch(MailboxElasticsearchConstants.MAILBOX_INDEX)
-                    .setTypes(MailboxElasticsearchConstants.MESSAGE_TYPE)
+                client.prepareSearch(MailboxElasticsearchConstants.MAILBOX_INDEX.getValue())
+                    .setTypes(MailboxElasticsearchConstants.MESSAGE_TYPE.getValue())
                     .setScroll(TIMEOUT)
                     .addFields(JsonMessageConstants.UID, JsonMessageConstants.MAILBOX_ID, JsonMessageConstants.MESSAGE_ID)
                     .setQuery(queryConverter.from(users, query))

http://git-wip-us.apache.org/repos/asf/james-project/blob/b54f9604/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
index 8d79af2..bbea50a 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
@@ -29,7 +29,9 @@ import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.james.backends.es.ClientProvider;
 import org.apache.james.backends.es.ClientProviderImpl;
 import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.IndexName;
 import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.backends.es.TypeName;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.mailbox.elasticsearch.IndexAttachments;
 import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
@@ -58,6 +60,8 @@ public class ElasticSearchMailboxModule extends AbstractModule {
 
     @Override
     protected void configure() {
+        bind(IndexName.class).toInstance(MailboxElasticsearchConstants.MAILBOX_INDEX);
+        bind(TypeName.class).toInstance(MailboxElasticsearchConstants.MESSAGE_TYPE);
         bind(ElasticSearchListeningMessageSearchIndex.class).in(Scopes.SINGLETON);
         bind(MessageSearchIndex.class).to(ElasticSearchListeningMessageSearchIndex.class);
         bind(ListeningMessageSearchIndex.class).to(ElasticSearchListeningMessageSearchIndex.class);


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


[06/12] james-project git commit: JAMES-1901 Move ES metrics reporter to a dedicated project

Posted by bt...@apache.org.
JAMES-1901 Move ES metrics reporter to a dedicated project


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

Branch: refs/heads/master
Commit: ea114d7a0e31ca1eb8b88076efcd03fa8c0d5e4e
Parents: 6f38dcb
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Jan 23 14:14:58 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:43:35 2017 +0700

----------------------------------------------------------------------
 server/container/guice/cassandra-guice/pom.xml  |   5 +
 .../modules/server/ESMetricReporterModule.java  |  17 +-
 .../metrics/metrics-dropwizard/pom.xml          |   4 -
 .../dropwizard/DropWizardMetricFactory.java     |  10 +-
 .../metrics/dropwizard/ESMetricReporter.java    |  69 -------
 .../dropwizard/ESReporterConfiguration.java     |  81 --------
 .../metrics/metrics-es-reporter/pom.xml         | 205 +++++++++++++++++++
 .../james/metrics/es/ESMetricReporter.java      |  69 +++++++
 .../metrics/es/ESReporterConfiguration.java     |  82 ++++++++
 .../META-INF/org/apache/james/spring-server.xml |   6 +-
 server/pom.xml                                  |   1 +
 11 files changed, 376 insertions(+), 173 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/guice/cassandra-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
index f4699c3..522d6bc 100644
--- a/server/container/guice/cassandra-guice/pom.xml
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -235,6 +235,11 @@
                     <artifactId>james-server-data-jmap-cassandra</artifactId>
                 </dependency>
                 <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>metrics-es-reporter</artifactId>
+                    <version>${project.version}</version>
+                </dependency>
+                <dependency>
                     <groupId>${project.groupId}</groupId>
                     <artifactId>james-server-guice-common</artifactId>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
index fcf0eb7..06cf7a7 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
@@ -21,7 +21,7 @@ package org.apache.james.modules.server;
 
 import java.io.FileNotFoundException;
 import java.util.List;
-import java.util.concurrent.ExecutionException;
+import java.util.Optional;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
@@ -29,15 +29,13 @@ import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.lang.NotImplementedException;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.lifecycle.api.Configurable;
-import org.apache.james.metrics.dropwizard.DropWizardMetricFactory;
-import org.apache.james.metrics.dropwizard.ESMetricReporter;
-import org.apache.james.metrics.dropwizard.ESReporterConfiguration;
+import org.apache.james.metrics.es.ESMetricReporter;
+import org.apache.james.metrics.es.ESReporterConfiguration;
 import org.apache.james.modules.mailbox.ElasticSearchMailboxModule;
 import org.apache.james.utils.ConfigurationPerformer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
@@ -65,8 +63,8 @@ public class ESMetricReporterModule extends AbstractModule {
                 return ESReporterConfiguration.enabled(
                     propertiesReader.getString(ElasticSearchMailboxModule.ELASTICSEARCH_MASTER_HOST),
                     propertiesReader.getInt("elasticsearch.http.port", DEFAULT_ES_HTTP_PORT),
-                    Optional.fromNullable(propertiesReader.getString("elasticsearch.metrics.reports.index", null)),
-                    Optional.fromNullable(propertiesReader.getLong("elasticsearch.metrics.reports.period", null)));
+                    Optional.ofNullable(propertiesReader.getString("elasticsearch.metrics.reports.index", null)),
+                    Optional.ofNullable(propertiesReader.getLong("elasticsearch.metrics.reports.period", null)));
             }
         } catch (FileNotFoundException e) {
             LOGGER.info("Can not locate " + ElasticSearchMailboxModule.ES_CONFIG_FILE);
@@ -83,11 +81,6 @@ public class ESMetricReporterModule extends AbstractModule {
                     fileSystem.getFile(ElasticSearchMailboxModule.ES_CONFIG_FILE));
     }
 
-    @Provides
-    public ESMetricReporter provideReporter(DropWizardMetricFactory metricFactory, ESReporterConfiguration configuration) throws ConfigurationException, ExecutionException, InterruptedException {
-        return metricFactory.provideEsReporter(configuration);
-    }
-
     @Singleton
     public static class ESMetricReporterStarter implements ConfigurationPerformer, Configurable {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/metrics/metrics-dropwizard/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-dropwizard/pom.xml b/server/container/metrics/metrics-dropwizard/pom.xml
index 5ad3440..3d40daf 100644
--- a/server/container/metrics/metrics-dropwizard/pom.xml
+++ b/server/container/metrics/metrics-dropwizard/pom.xml
@@ -57,10 +57,6 @@
             <groupId>javax.inject</groupId>
             <artifactId>javax.inject</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.elasticsearch</groupId>
-            <artifactId>metrics-elasticsearch-reporter</artifactId>
-        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
index 005ae34..4eee021 100644
--- a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
+++ b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
@@ -20,6 +20,7 @@
 package org.apache.james.metrics.dropwizard;
 
 import javax.annotation.PreDestroy;
+import javax.inject.Inject;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.metrics.api.Metric;
@@ -33,16 +34,13 @@ public class DropWizardMetricFactory implements MetricFactory {
     private final MetricRegistry metricRegistry;
     private final JmxReporter jmxReporter;
 
-    public DropWizardMetricFactory() {
-        this.metricRegistry = new MetricRegistry();
+    @Inject
+    public DropWizardMetricFactory(MetricRegistry metricRegistry) {
+        this.metricRegistry = metricRegistry;
         this.jmxReporter = JmxReporter.forRegistry(metricRegistry)
             .build();
     }
 
-    public ESMetricReporter provideEsReporter(ESReporterConfiguration esReporterConfiguration) {
-        return new ESMetricReporter(esReporterConfiguration, metricRegistry);
-    }
-
     @Override
     public Metric generate(String name) {
         return new DropWizardMetric(metricRegistry.counter(name));

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESMetricReporter.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESMetricReporter.java b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESMetricReporter.java
deleted file mode 100644
index 6d782ce..0000000
--- a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESMetricReporter.java
+++ /dev/null
@@ -1,69 +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.metrics.dropwizard;
-
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
-import javax.annotation.PreDestroy;
-
-import org.elasticsearch.metrics.ElasticsearchReporter;
-
-import com.codahale.metrics.MetricRegistry;
-import com.google.common.base.Optional;
-import com.google.common.base.Throwables;
-
-public class ESMetricReporter {
-
-    private final Optional<ElasticsearchReporter> reporter;
-    private final ESReporterConfiguration esReporterConfiguration;
-
-    public ESMetricReporter(ESReporterConfiguration esReporterConfiguration, MetricRegistry registry) {
-        this.reporter = getReporter(esReporterConfiguration, registry);
-        this.esReporterConfiguration = esReporterConfiguration;
-    }
-
-    private Optional<ElasticsearchReporter> getReporter(ESReporterConfiguration esReporterConfiguration, MetricRegistry registry) {
-        if (esReporterConfiguration.isEnabled()) {
-            try {
-                return Optional.of(ElasticsearchReporter.forRegistry(registry)
-                    .hosts(esReporterConfiguration.getHostWithPort())
-                    .index(esReporterConfiguration.getIndex())
-                    .build());
-            } catch (IOException e) {
-                throw Throwables.propagate(e);
-            }
-        }   
-        return Optional.absent();
-    }
-
-    public void start() {
-        if (reporter.isPresent()) {
-            reporter.get().start(esReporterConfiguration.getPeriodInSecond(), TimeUnit.SECONDS);
-        }
-    }
-
-    @PreDestroy
-    public void stop() {
-        if (reporter.isPresent()) {
-            reporter.get().stop();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESReporterConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESReporterConfiguration.java b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESReporterConfiguration.java
deleted file mode 100644
index 06e669f..0000000
--- a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESReporterConfiguration.java
+++ /dev/null
@@ -1,81 +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.metrics.dropwizard;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
-public class ESReporterConfiguration {
-
-    public static final boolean ENABLED = true;
-    public static final boolean DISABLED = !ENABLED;
-    public static final String DEFAULT_INDEX = "james-metrics";
-    public static final long DEFAULT_PERIOD_IN_SECOND = 60L;
-
-    public static ESReporterConfiguration disabled() {
-        return new ESReporterConfiguration(
-            Optional.<String>absent(),
-            Optional.<Integer>absent(),
-            DISABLED,
-            Optional.<String>absent(),
-            Optional.<Long>absent());
-    }
-
-    public static ESReporterConfiguration enabled(String host, int port, Optional<String> index, Optional<Long> periodInSecond) {
-        return new ESReporterConfiguration(
-            Optional.of(host),
-            Optional.of(port),
-            ENABLED,
-            index,
-            periodInSecond);
-    }
-
-    private final Optional<String> host;
-    private final Optional<Integer> port;
-    private final boolean enabled;
-    private final Optional<String> index;
-    private final Optional<Long> periodInSecond;
-
-    public ESReporterConfiguration(Optional<String> host, Optional<Integer> port, boolean enabled, Optional<String> index, Optional<Long> periodInSecond) {
-        this.host = host;
-        this.port = port;
-        this.enabled = enabled;
-        this.index = index;
-        this.periodInSecond = periodInSecond;
-    }
-
-    public String getHostWithPort() {
-        Preconditions.checkState(host.isPresent());
-        Preconditions.checkState(port.isPresent());
-        return host.get() + ":" + port.get();
-    }
-
-    public boolean isEnabled() {
-        return enabled;
-    }
-
-    public String getIndex() {
-        return index.or(DEFAULT_INDEX);
-    }
-
-    public long getPeriodInSecond() {
-        return periodInSecond.or(DEFAULT_PERIOD_IN_SECOND);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/metrics/metrics-es-reporter/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/pom.xml b/server/container/metrics/metrics-es-reporter/pom.xml
new file mode 100644
index 0000000..5373502
--- /dev/null
+++ b/server/container/metrics/metrics-es-reporter/pom.xml
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>james-server</artifactId>
+        <groupId>org.apache.james</groupId>
+        <version>3.0.0-beta6-SNAPSHOT</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>metrics-es-reporter</artifactId>
+
+    <profiles>
+        <profile>
+            <id>disable-build-for-older-jdk</id>
+            <activation>
+                <jdk>(,1.8)</jdk>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-jar-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-jar</id>
+                                <phase>none</phase>
+                            </execution>
+                            <execution>
+                                <id>jar</id>
+                                <phase>none</phase>
+                            </execution>
+                            <execution>
+                                <id>test-jar</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-compile</id>
+                                <phase>none</phase>
+                            </execution>
+                            <execution>
+                                <id>default-testCompile</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-test</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-source-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>attach-sources</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-install-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-install</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-resources-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-resources</id>
+                                <phase>none</phase>
+                            </execution>
+                            <execution>
+                                <id>default-testResources</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-site-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>attach-descriptor</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>build-for-jdk-8</id>
+            <activation>
+                <jdk>[1.8,)</jdk>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>com.google.guava</groupId>
+                    <artifactId>guava</artifactId>
+                </dependency>
+                <dependency>
+                    <groupId>io.dropwizard.metrics</groupId>
+                    <artifactId>metrics-core</artifactId>
+                </dependency>
+                <dependency>
+                    <groupId>javax.inject</groupId>
+                    <artifactId>javax.inject</artifactId>
+                </dependency>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.elasticsearch</groupId>
+                    <artifactId>metrics-elasticsearch-reporter</artifactId>
+                </dependency>
+            </dependencies>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <configuration>
+                            <source>1.8</source>
+                            <target>1.8</target>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>animal-sniffer-java-8</id>
+            <activation>
+                <jdk>[1.8,)</jdk>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>animal-sniffer-maven-plugin</artifactId>
+                        <configuration>
+                            <signature>
+                                <groupId>org.codehaus.mojo.signature</groupId>
+                                <artifactId>java18</artifactId>
+                                <version>1.0</version>
+                            </signature>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>check_java_8</id>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>check</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESMetricReporter.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESMetricReporter.java b/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESMetricReporter.java
new file mode 100644
index 0000000..bc81cf8
--- /dev/null
+++ b/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESMetricReporter.java
@@ -0,0 +1,69 @@
+/****************************************************************
+ * 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.metrics.es;
+
+import java.io.IOException;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+
+import org.elasticsearch.metrics.ElasticsearchReporter;
+
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.ScheduledReporter;
+import com.google.common.base.Throwables;
+
+public class ESMetricReporter {
+
+    private final Optional<ElasticsearchReporter> reporter;
+    private final ESReporterConfiguration esReporterConfiguration;
+
+    @Inject
+    public ESMetricReporter(ESReporterConfiguration esReporterConfiguration, MetricRegistry registry) {
+        this.reporter = getReporter(esReporterConfiguration, registry);
+        this.esReporterConfiguration = esReporterConfiguration;
+    }
+
+    private Optional<ElasticsearchReporter> getReporter(ESReporterConfiguration esReporterConfiguration, MetricRegistry registry) {
+        if (esReporterConfiguration.isEnabled()) {
+            try {
+                return Optional.of(ElasticsearchReporter.forRegistry(registry)
+                    .hosts(esReporterConfiguration.getHostWithPort())
+                    .index(esReporterConfiguration.getIndex())
+                    .build());
+            } catch (IOException e) {
+                throw Throwables.propagate(e);
+            }
+        }   
+        return Optional.empty();
+    }
+
+    public void start() {
+        reporter.ifPresent(elasticsearchReporter ->
+            elasticsearchReporter.start(esReporterConfiguration.getPeriodInSecond(), TimeUnit.SECONDS));
+    }
+
+    @PreDestroy
+    public void stop() {
+        reporter.ifPresent(ScheduledReporter::stop);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESReporterConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESReporterConfiguration.java b/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESReporterConfiguration.java
new file mode 100644
index 0000000..5b7ad0f
--- /dev/null
+++ b/server/container/metrics/metrics-es-reporter/src/main/java/org/apache/james/metrics/es/ESReporterConfiguration.java
@@ -0,0 +1,82 @@
+/****************************************************************
+ * 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.metrics.es;
+
+import java.util.Optional;
+
+import com.google.common.base.Preconditions;
+
+public class ESReporterConfiguration {
+
+    public static final boolean ENABLED = true;
+    public static final boolean DISABLED = !ENABLED;
+    public static final String DEFAULT_INDEX = "james-metrics";
+    public static final long DEFAULT_PERIOD_IN_SECOND = 60L;
+
+    public static ESReporterConfiguration disabled() {
+        return new ESReporterConfiguration(
+            Optional.empty(),
+            Optional.empty(),
+            DISABLED,
+            Optional.empty(),
+            Optional.empty());
+    }
+
+    public static ESReporterConfiguration enabled(String host, int port, Optional<String> index, Optional<Long> periodInSecond) {
+        return new ESReporterConfiguration(
+            Optional.of(host),
+            Optional.of(port),
+            ENABLED,
+            index,
+            periodInSecond);
+    }
+
+    private final Optional<String> host;
+    private final Optional<Integer> port;
+    private final boolean enabled;
+    private final Optional<String> index;
+    private final Optional<Long> periodInSecond;
+
+    public ESReporterConfiguration(Optional<String> host, Optional<Integer> port, boolean enabled, Optional<String> index, Optional<Long> periodInSecond) {
+        this.host = host;
+        this.port = port;
+        this.enabled = enabled;
+        this.index = index;
+        this.periodInSecond = periodInSecond;
+    }
+
+    public String getHostWithPort() {
+        Preconditions.checkState(host.isPresent());
+        Preconditions.checkState(port.isPresent());
+        return host.get() + ":" + port.get();
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public String getIndex() {
+        return index.orElse(DEFAULT_INDEX);
+    }
+
+    public long getPeriodInSecond() {
+        return periodInSecond.orElse(DEFAULT_PERIOD_IN_SECOND);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
----------------------------------------------------------------------
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 deaaf91..aec7db9 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
@@ -294,6 +294,10 @@
     ======================================================================
     -->
 
-    <bean id="metricFactory" class="org.apache.james.metrics.dropwizard.DropWizardMetricFactory"/>
+    <bean id="metricFactory" class="org.apache.james.metrics.dropwizard.DropWizardMetricFactory">
+        <constructor-arg index="0" ref="metricRegistry"/>
+    </bean>
+
+    <bean id="metricRegistry" class="com.codahale.metrics.MetricRegistry"/>
 
 </beans>

http://git-wip-us.apache.org/repos/asf/james-project/blob/ea114d7a/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index 66fdedf..3569df4 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -65,6 +65,7 @@
         <module>container/mailbox-adapter</module>
         <module>container/metrics/metrics-api</module>
         <module>container/metrics/metrics-dropwizard</module>
+        <module>container/metrics/metrics-es-reporter</module>
         <module>container/spring</module>
         <module>container/util</module>
         <module>container/util-java8</module>


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


[10/12] james-project git commit: JAMES-1901 Add integration test from publishing metrics on ElasticSearch

Posted by bt...@apache.org.
JAMES-1901 Add integration test from publishing metrics on ElasticSearch


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

Branch: refs/heads/master
Commit: 649b62d2cd6a2509d1f28d9f1bf87d4000538237
Parents: 1688bc6
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Jan 23 18:46:31 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:43:43 2017 +0700

----------------------------------------------------------------------
 .../metrics/metrics-es-reporter/pom.xml         |  25 ++++
 .../apache/james/metric/es/ESReporterTest.java  | 120 +++++++++++++++++++
 2 files changed, 145 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/649b62d2/server/container/metrics/metrics-es-reporter/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/pom.xml b/server/container/metrics/metrics-es-reporter/pom.xml
index 5373502..97f2500 100644
--- a/server/container/metrics/metrics-es-reporter/pom.xml
+++ b/server/container/metrics/metrics-es-reporter/pom.xml
@@ -127,6 +127,21 @@
             </activation>
             <dependencies>
                 <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>james-server-metrics-dropwizard</artifactId>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>james-server-util-java8</artifactId>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
                     <groupId>com.google.guava</groupId>
                     <artifactId>guava</artifactId>
                 </dependency>
@@ -147,6 +162,16 @@
                     <groupId>org.elasticsearch</groupId>
                     <artifactId>metrics-elasticsearch-reporter</artifactId>
                 </dependency>
+                <dependency>
+                    <groupId>org.elasticsearch</groupId>
+                    <artifactId>elasticsearch</artifactId>
+                    <version>2.2.1</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.testcontainers</groupId>
+                    <artifactId>testcontainers</artifactId>
+                    <scope>test</scope>
+                </dependency>
             </dependencies>
             <build>
                 <plugins>

http://git-wip-us.apache.org/repos/asf/james-project/blob/649b62d2/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
new file mode 100644
index 0000000..633a62c
--- /dev/null
+++ b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
@@ -0,0 +1,120 @@
+/****************************************************************
+ * 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.metric.es;
+
+import static com.jayway.awaitility.Awaitility.await;
+
+import java.util.Optional;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.james.backends.es.ClientProvider;
+import org.apache.james.backends.es.ClientProviderImpl;
+import org.apache.james.metrics.api.Metric;
+import org.apache.james.metrics.dropwizard.DropWizardMetricFactory;
+import org.apache.james.metrics.es.ESMetricReporter;
+import org.apache.james.metrics.es.ESReporterConfiguration;
+import org.apache.james.util.streams.SwarmGenericContainer;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import com.codahale.metrics.MetricRegistry;
+import com.jayway.awaitility.Duration;
+
+public class ESReporterTest {
+
+    public static final Optional<String> INDEX = Optional.of("index_name");
+    public static final Optional<Long> PERIOD_IN_SECOND = Optional.of(1L);
+    public static final int DELAY_IN_MS = 100;
+    public static final int PERIOD_IN_MS = 100;
+    public static final int ES_APPLICATIVE_PORT = 9300;
+    public static final int ES_HTTP_PORT = 9200;
+
+    @Rule
+    public SwarmGenericContainer esContainer = new SwarmGenericContainer("elasticsearch:2.2.2")
+        .withAffinityToContainer();
+
+    private ClientProvider clientProvider;
+    private ESMetricReporter esMetricReporter;
+    private MetricRegistry registry;
+    private Timer timer;
+
+    @Before
+    public void setUp() {
+        clientProvider = new ClientProviderImpl(getContainerIp(), ES_APPLICATIVE_PORT);
+        await().atMost(Duration.ONE_MINUTE)
+            .until(() -> elasticSearchStarted(clientProvider));
+
+        registry = new MetricRegistry();
+        timer = new Timer();
+        esMetricReporter = new ESMetricReporter(
+            ESReporterConfiguration.enabled(getContainerIp(), ES_HTTP_PORT, INDEX, PERIOD_IN_SECOND),
+            registry);
+    }
+
+    @After
+    public void tearDown() {
+        timer.cancel();
+        esMetricReporter.stop();
+    }
+
+    @Test
+    public void esMetricReporterShouldProduceDocumentsOnAnElasticsearchContainer() {
+        esMetricReporter.start();
+
+        Metric metric = new DropWizardMetricFactory(registry).generate("probe");
+        TimerTask timerTask = new TimerTask() {
+            @Override
+            public void run() {
+                metric.increment();
+            }
+        };
+        timer.schedule(timerTask, DELAY_IN_MS, PERIOD_IN_MS);
+
+        await().atMost(Duration.TEN_MINUTES)
+            .until(() -> done(clientProvider));
+    }
+
+    private boolean elasticSearchStarted(ClientProvider clientProvider) {
+        try (Client client = clientProvider.get()) {
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    private boolean done(ClientProvider clientProvider) {
+        try (Client client = clientProvider.get()) {
+            return client.prepareSearch().setQuery(QueryBuilders.matchAllQuery()).get().getHits().totalHits() > 0;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    @SuppressWarnings("deprecation")
+    private String getContainerIp() {
+        return esContainer.getContainerInfo().getNetworkSettings().getIpAddress();
+    }
+
+}


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


[07/12] james-project git commit: JAMES-1901 Create a ElasticSearch backend project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
index efb5508..3568efb 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
@@ -18,7 +18,9 @@
  ****************************************************************/
 
 package org.apache.james;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+
+import org.apache.james.backends.es.EmbeddedElasticSearch;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
 import org.apache.james.modules.TestElasticSearchModule;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TemporaryFolder;
@@ -31,7 +33,7 @@ import com.google.inject.Module;
 public class EmbeddedElasticSearchRule implements GuiceModuleTestRule {
 
     private final TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private final EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
+    private final EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder, MailboxElasticsearchConstants.MAILBOX_INDEX);
 
     private final RuleChain chain = RuleChain
         .outerRule(temporaryFolder)

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
index 3642f6e..150308d 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
@@ -26,9 +26,10 @@ import java.util.EnumSet;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.jmap.methods.GetMessageListMethod;
 import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
 import org.apache.james.modules.TestElasticSearchModule;
 import org.apache.james.modules.TestFilesystemModule;
 import org.apache.james.modules.TestJMAPServerModule;
@@ -48,7 +49,7 @@ public class JamesCapabilitiesServerTest {
 
     private GuiceJamesServerImpl server;
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
+    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder, MailboxElasticsearchConstants.MAILBOX_INDEX);
 
     @Rule
     public RuleChain chain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
index 69de08a..140f0a7 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
@@ -26,7 +26,7 @@ import javax.inject.Singleton;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.junit.rules.TemporaryFolder;
 
 import com.datastax.driver.core.Session;

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
index 2254476..e9a89cd 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
@@ -21,10 +21,13 @@ package org.apache.james.modules;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Provides;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
-import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
+
+import org.apache.james.backends.es.EmbeddedElasticSearch;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.backends.es.utils.TestingClientProvider;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
+import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory;
 import org.elasticsearch.client.Client;
 
 import javax.inject.Singleton;
@@ -45,8 +48,11 @@ public class TestElasticSearchModule extends AbstractModule{
     @Provides
     @Singleton
     protected Client provideClientProvider() {
-        return NodeMappingFactory.applyMapping(
-            IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()).get())
-        );
+        Client client = new TestingClientProvider(embeddedElasticSearch.getNode()).get();
+        IndexCreationFactory.createIndex(client, MailboxElasticsearchConstants.MAILBOX_INDEX);
+        return NodeMappingFactory.applyMapping(client,
+            MailboxElasticsearchConstants.MAILBOX_INDEX,
+            MailboxElasticsearchConstants.MESSAGE_TYPE,
+            MailboxMappingFactory.getMappingContent());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index 3569df4..46687c4 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -350,6 +350,17 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-backends-es</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-backends-es</artifactId>
+                <type>test-jar</type>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
                 <artifactId>apache-james-backends-jpa</artifactId>
                 <version>${project.version}</version>
             </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
index 60f3d42..13c1463 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
@@ -149,6 +149,12 @@
             </activation>
             <dependencies>
                 <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
                     <groupId>${project.groupId}</groupId>
                     <artifactId>apache-james-mailbox-api</artifactId>
                     <type>test-jar</type>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/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 a024d86..79f5cfd 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
@@ -26,9 +26,10 @@ import javax.inject.Inject;
 import org.apache.james.CassandraJamesServerMain;
 import org.apache.james.JmapJamesServer;
 import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.jmap.methods.integration.cucumber.MainStepdefs;
 import org.apache.james.mailbox.cassandra.CassandraMessageId;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
 import org.apache.james.modules.CassandraJmapServerModule;
 import org.junit.rules.TemporaryFolder;
 
@@ -43,7 +44,7 @@ public class CassandraStepdefs {
 
     private final MainStepdefs mainStepdefs;
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
+    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder, MailboxElasticsearchConstants.MAILBOX_INDEX);
     private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
 
     @Inject

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/protocols/jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/pom.xml
index a9df9da..7a76231 100644
--- a/server/protocols/jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/pom.xml
@@ -33,6 +33,7 @@
     <packaging>pom</packaging>
 
     <modules>
+        <module>cassandra-jmap-integration-testing</module>
         <module>jmap-integration-testing-common</module>
     </modules>
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/protocols/webadmin-integration-test/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/pom.xml b/server/protocols/webadmin-integration-test/pom.xml
index eaf7ce6..5f3d9db 100644
--- a/server/protocols/webadmin-integration-test/pom.xml
+++ b/server/protocols/webadmin-integration-test/pom.xml
@@ -149,6 +149,12 @@
             <dependencies>
                 <dependency>
                     <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
                     <artifactId>apache-james-mailbox-elasticsearch</artifactId>
                     <type>test-jar</type>
                     <scope>test</scope>


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


[03/12] james-project git commit: JAMES-1917 Improve inMemory guice documentation

Posted by bt...@apache.org.
JAMES-1917 Improve inMemory guice documentation

Configuration was outdated.


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

Branch: refs/heads/master
Commit: 31ef8219f3358e1022faf446ac8ff97306fcba95
Parents: a615668
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Jan 25 09:44:20 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:40:44 2017 +0700

----------------------------------------------------------------------
 .../sample-configuration/lmtpserver.xml         | 41 ------------
 server/container/guice/memory-guice/README.adoc | 21 ++++---
 .../sample-configuration/jmap.properties        |  2 +-
 .../sample-configuration/jwt_publickey          |  9 +++
 .../sample-configuration/logback.xml            | 15 +++++
 .../sample-configuration/mailetcontainer.xml    |  9 +--
 .../sample-configuration/managesieveserver.xml  | 65 ++++++++++++++++++++
 .../memory-guice/sample-configuration/quota.xml | 53 ++++++++++++++++
 .../sample-configuration/webadmin.properties    | 22 +++++++
 9 files changed, 184 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/31ef8219/server/container/guice/cassandra-guice/sample-configuration/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/lmtpserver.xml b/server/container/guice/cassandra-guice/sample-configuration/lmtpserver.xml
deleted file mode 100644
index 87a0caa..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/lmtpserver.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<lmtpservers>
-
-    <lmtpserver enabled="false">
-        <jmxName>lmtpserver</jmxName>
-        <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
-        <bind>127.0.0.1:1024</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <connectiontimeout>1200</connectiontimeout>
-        <!-- Set the maximum simultaneous incoming connections for this service -->
-        <connectionLimit>0</connectionLimit>
-        <!-- Set the maximum simultaneous incoming connections per IP for this service -->
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <!--  This sets the maximum allowed message size (in kilobytes) for this -->
-        <!--  LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
-        <maxmessagesize>0</maxmessagesize>
-        <handlerchain>
-            <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </lmtpserver>
-
-</lmtpservers>

http://git-wip-us.apache.org/repos/asf/james-project/blob/31ef8219/server/container/guice/memory-guice/README.adoc
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/README.adoc b/server/container/guice/memory-guice/README.adoc
index b896354..36be5f4 100644
--- a/server/container/guice/memory-guice/README.adoc
+++ b/server/container/guice/memory-guice/README.adoc
@@ -6,33 +6,40 @@
 
  * Java 8 SDK
  * Docker
- * Maven
+ * Maven 3
 
 === Building the artifacts
 
-An usual compilation using maven will produce two artifacts into target directory :
+An usual compilation using maven will produce two artifacts into target directory:
 
  * james-server-memory-guice-${version}.jar
  * james-server-memory-guice-${version}.lib
 
+ You can for example run in the base of this git repository:
+
+ ```
+ mvn clean install
+ ```
+
 == Running
 
 === James Launch
 
 To run james, you have to create a directory containing required configuration files.
 
-A sample directory (appropriately named sample-directory) is provided with some
-default values you may need to replace.
+James requires the configuration to be in a subfolder of working directory that is called **conf**. A sample directory
+(appropriately named sample-directory) is provided with some default values you may need to replace. You will need to
+rename it into **conf** if you intend to use it.
 
-You also need to generate a keystore with the following command :
+You also need to generate a keystore with the following command:
 [source]
 ----
 $ keytool -genkey -alias james -keyalg RSA -keystore conf/keystore
 ----
 
-Once everything is set up, you just have to run the jar with :
+Once everything is set up, you just have to run the jar with:
 
 [source]
 ----
-$ java -Dworking.directory=sample-configuration -jar target/james-server-memory-guice-${version}.jar
+$ java -Dworking.directory=. -jar target/james-server-memory-guice-${version}.jar
 ----

http://git-wip-us.apache.org/repos/asf/james-project/blob/31ef8219/server/container/guice/memory-guice/sample-configuration/jmap.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/sample-configuration/jmap.properties b/server/container/guice/memory-guice/sample-configuration/jmap.properties
index d785ccd..071bafb 100644
--- a/server/container/guice/memory-guice/sample-configuration/jmap.properties
+++ b/server/container/guice/memory-guice/sample-configuration/jmap.properties
@@ -8,4 +8,4 @@ tls.secret=james72laBalle
 # The following entry specify the link to the URL of the public key file,
 # which should be a PEM format file.
 #
-jwt.publickeypem.url=
\ No newline at end of file
+jwt.publickeypem.url=file://conf/jwt_publickey
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/31ef8219/server/container/guice/memory-guice/sample-configuration/jwt_publickey
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/sample-configuration/jwt_publickey b/server/container/guice/memory-guice/sample-configuration/jwt_publickey
new file mode 100644
index 0000000..53914e0
--- /dev/null
+++ b/server/container/guice/memory-guice/sample-configuration/jwt_publickey
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtlChO/nlVP27MpdkG0Bh
+16XrMRf6M4NeyGa7j5+1UKm42IKUf3lM28oe82MqIIRyvskPc11NuzSor8HmvH8H
+lhDs5DyJtx2qp35AT0zCqfwlaDnlDc/QDlZv1CoRZGpQk1Inyh6SbZwYpxxwh0fi
++d/4RpE3LBVo8wgOaXPylOlHxsDizfkL8QwXItyakBfMO6jWQRrj7/9WDhGf4Hi+
+GQur1tPGZDl9mvCoRHjFrD5M/yypIPlfMGWFVEvV5jClNMLAQ9bYFuOc7H1fEWw6
+U1LZUUbJW9/CH45YXz82CYqkrfbnQxqRb2iVbVjs/sHopHd1NTiCfUtwvcYJiBVj
+kwIDAQAB
+-----END PUBLIC KEY-----

http://git-wip-us.apache.org/repos/asf/james-project/blob/31ef8219/server/container/guice/memory-guice/sample-configuration/logback.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/sample-configuration/logback.xml b/server/container/guice/memory-guice/sample-configuration/logback.xml
new file mode 100644
index 0000000..3deaa5a
--- /dev/null
+++ b/server/container/guice/memory-guice/sample-configuration/logback.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+                <encoder>
+                        <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
+                        <immediateFlush>false</immediateFlush>
+                </encoder>
+        </appender>
+
+        <root level="INFO">
+                <appender-ref ref="CONSOLE" />
+        </root>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/james-project/blob/31ef8219/server/container/guice/memory-guice/sample-configuration/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/sample-configuration/mailetcontainer.xml b/server/container/guice/memory-guice/sample-configuration/mailetcontainer.xml
index 968b59c..40885cd 100644
--- a/server/container/guice/memory-guice/sample-configuration/mailetcontainer.xml
+++ b/server/container/guice/memory-guice/sample-configuration/mailetcontainer.xml
@@ -80,12 +80,13 @@
                 <name>X-WasSigned</name>
                 <value>true</value>
             </mailet>
+            <mailet match="All" class="RemoveMimeHeader">
+                <name>bcc</name>
+            </mailet>
             <mailet match="All" class="RecipientRewriteTable" />
+            <mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.VacationMailet"/>
+            <mailet match="RecipientIsLocal" class="Sieve"/>
             <mailet match="RecipientIsLocal" class="LocalDelivery"/>
-            <mailet match="HostIsLocal" class="ToProcessor">
-                <processor>local-address-error</processor>
-                <notice>550 - Requested action not taken: no such user here</notice>
-            </mailet>
             <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
                 <outgoingQueue>outgoing</outgoingQueue>
                 <delayTime>5000, 100000, 500000</delayTime>

http://git-wip-us.apache.org/repos/asf/james-project/blob/31ef8219/server/container/guice/memory-guice/sample-configuration/managesieveserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/sample-configuration/managesieveserver.xml b/server/container/guice/memory-guice/sample-configuration/managesieveserver.xml
new file mode 100644
index 0000000..7b0b85a
--- /dev/null
+++ b/server/container/guice/memory-guice/sample-configuration/managesieveserver.xml
@@ -0,0 +1,65 @@
+<?xml version="1.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.                                           
+ -->
+ 
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+ 
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<managesieveservers>
+
+   <managesieveserver enabled="false">
+
+     <jmxName>managesieveserver</jmxName>
+
+     <bind>0.0.0.0:4190</bind>
+
+     <connectionBacklog>200</connectionBacklog>
+
+     <tls socketTLS="false" startTLS="false">
+       <!-- To create a new keystore execute:
+        keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+         -->
+       <keystore>file://conf/keystore</keystore>
+       <secret>james72laBalle</secret>
+       <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+       <!-- The algorithm is optional and only needs to be specified when using something other
+        than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. -->
+       <algorithm>SunX509</algorithm>
+     </tls>
+         
+        <!-- connection timeout in secconds -->
+        <connectiontimeout>360</connectiontimeout>
+
+        <!-- Set the maximum simultaneous incoming connections for this service -->
+        <connectionLimit>0</connectionLimit>
+         
+        <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+        <connectionLimitPerIP>0</connectionLimitPerIP>
+        <maxmessagesize>0</maxmessagesize>
+        <addressBracketsEnforcement>true</addressBracketsEnforcement>
+  
+   </managesieveserver>
+
+</managesieveservers>
+
+

http://git-wip-us.apache.org/repos/asf/james-project/blob/31ef8219/server/container/guice/memory-guice/sample-configuration/quota.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/sample-configuration/quota.xml b/server/container/guice/memory-guice/sample-configuration/quota.xml
new file mode 100644
index 0000000..70162e0
--- /dev/null
+++ b/server/container/guice/memory-guice/sample-configuration/quota.xml
@@ -0,0 +1,53 @@
+<?xml version="1.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.
+ -->
+
+<!--
+   This template file can be used as example for James Server configuration
+   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<!--
+        This configuration file allows you to customize the way quota are handled on this server.
+        You need to rename it in quota.xml so that it gets interpreted by James on startup.
+
+        The different configuration options are detailed here.
+
+        Read RFC-2087 for full details.
+-->
+
+<quota>
+    <quotaRootResolver>
+        <provider>default</provider>
+    </quotaRootResolver>
+    <currentQuotaManager>
+        <provider>cassandra</provider>
+    </currentQuotaManager>
+    <maxQuotaManager>
+        <provider>cassandra</provider>
+    </maxQuotaManager>
+    <quotaManager>
+        <provider>store</provider>
+    </quotaManager>
+    <updates>
+        <provider>event</provider>
+    </updates>
+</quota>

http://git-wip-us.apache.org/repos/asf/james-project/blob/31ef8219/server/container/guice/memory-guice/sample-configuration/webadmin.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/sample-configuration/webadmin.properties b/server/container/guice/memory-guice/sample-configuration/webadmin.properties
new file mode 100644
index 0000000..70a6cb9
--- /dev/null
+++ b/server/container/guice/memory-guice/sample-configuration/webadmin.properties
@@ -0,0 +1,22 @@
+#  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.
+
+#  This template file can be used as example for James Server configuration
+#  DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+
+enabled=true
+port=8000
\ No newline at end of file


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


[09/12] james-project git commit: JAMES-1901 Create a ElasticSearch backend project

Posted by bt...@apache.org.
JAMES-1901 Create a ElasticSearch backend project


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

Branch: refs/heads/master
Commit: 1688bc6f98c217fdf82475e47d1636c7b78d3533
Parents: ea114d7
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Jan 23 18:51:49 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:43:39 2017 +0700

----------------------------------------------------------------------
 backends-common/elasticsearch/pom.xml           | 222 ++++++++++++++++
 .../james/backends/es/ClientProvider.java       |  26 ++
 .../james/backends/es/ClientProviderImpl.java   |  48 ++++
 .../backends/es/DeleteByQueryPerformer.java     |  90 +++++++
 .../james/backends/es/ElasticSearchIndexer.java | 102 ++++++++
 .../james/backends/es/IndexCreationFactory.java |  84 ++++++
 .../james/backends/es/NodeMappingFactory.java   |  55 ++++
 .../backends/es/search/ScrollIterable.java      |  81 ++++++
 .../backends/es/ElasticSearchIndexerTest.java   | 244 +++++++++++++++++
 .../backends/es/EmbeddedElasticSearch.java      | 118 +++++++++
 .../backends/es/search/ScrollIterableTest.java  | 174 +++++++++++++
 .../es/utils/TestingClientProvider.java         |  37 +++
 backends-common/pom.xml                         |  13 +
 mailbox/elasticsearch/pom.xml                   |  15 +-
 .../mailbox/elasticsearch/ClientProvider.java   |  26 --
 .../elasticsearch/ClientProviderImpl.java       |  48 ----
 .../elasticsearch/DeleteByQueryPerformer.java   |  86 ------
 .../elasticsearch/ElasticSearchIndexer.java     | 100 -------
 .../elasticsearch/IndexCreationFactory.java     |  84 ------
 .../MailboxElasticsearchConstants.java          |  25 ++
 .../elasticsearch/MailboxMappingFactory.java    | 229 ++++++++++++++++
 .../elasticsearch/NodeMappingFactory.java       | 259 -------------------
 ...lasticSearchListeningMessageSearchIndex.java |   2 +-
 .../elasticsearch/query/SortConverter.java      |   3 +-
 .../search/ElasticSearchSearcher.java           |   7 +-
 .../elasticsearch/search/ScrollIterable.java    |  81 ------
 .../elasticsearch/ElasticSearchIndexerTest.java | 238 -----------------
 .../ElasticSearchIntegrationTest.java           |  27 +-
 .../elasticsearch/EmbeddedElasticSearch.java    | 116 ---------
 ...hListeningMailboxMessageSearchIndexTest.java |   2 +-
 .../search/ScrollIterableTest.java              | 173 -------------
 .../utils/TestingClientProvider.java            |  37 ---
 mailbox/pom.xml                                 |  19 ++
 mpt/impl/imap-mailbox/elasticsearch/pom.xml     |  18 +-
 .../host/ElasticSearchHostSystem.java           |  23 +-
 mpt/impl/smtp/cassandra/pom.xml                 |   6 +-
 .../smtp/host/CassandraJamesSmtpHostSystem.java |   5 +-
 mpt/pom.xml                                     |   7 +
 server/container/guice/cassandra-guice/pom.xml  |   6 +
 .../mailbox/ElasticSearchMailboxModule.java     |  22 +-
 .../apache/james/EmbeddedElasticSearchRule.java |   6 +-
 .../james/JamesCapabilitiesServerTest.java      |   5 +-
 .../modules/CassandraJmapServerModule.java      |   2 +-
 .../james/modules/TestElasticSearchModule.java  |  20 +-
 server/pom.xml                                  |  11 +
 .../cassandra-jmap-integration-testing/pom.xml  |   6 +
 .../cassandra/cucumber/CassandraStepdefs.java   |   5 +-
 .../protocols/jmap-integration-testing/pom.xml  |   1 +
 .../protocols/webadmin-integration-test/pom.xml |   6 +
 49 files changed, 1717 insertions(+), 1303 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/pom.xml b/backends-common/elasticsearch/pom.xml
new file mode 100644
index 0000000..624ec16
--- /dev/null
+++ b/backends-common/elasticsearch/pom.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>james-backends-common</artifactId>
+        <groupId>org.apache.james</groupId>
+        <version>3.0.0-beta6-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>apache-james-backends-es</artifactId>
+
+    <profiles>
+        <profile>
+            <id>disable-build-for-older-jdk</id>
+            <activation>
+                <jdk>(,1.8)</jdk>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-jar-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-jar</id>
+                                <phase>none</phase>
+                            </execution>
+                            <execution>
+                                <id>jar</id>
+                                <phase>none</phase>
+                            </execution>
+                            <execution>
+                                <id>test-jar</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-compile</id>
+                                <phase>none</phase>
+                            </execution>
+                            <execution>
+                                <id>default-testCompile</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-test</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-source-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>attach-sources</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-install-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-install</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-resources-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>default-resources</id>
+                                <phase>none</phase>
+                            </execution>
+                            <execution>
+                                <id>default-testResources</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-site-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>attach-descriptor</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>build-for-jdk-8</id>
+            <activation>
+                <jdk>[1.8,)</jdk>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>james-server-util-java8</artifactId>
+                </dependency>
+                <dependency>
+                    <groupId>com.jayway.awaitility</groupId>
+                    <artifactId>awaitility</artifactId>
+                    <version>1.6.3</version>
+                </dependency>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </dependency>
+                <dependency>
+                    <groupId>org.assertj</groupId>
+                    <artifactId>assertj-core</artifactId>
+                    <version>${assertj-3.version}</version>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.elasticsearch</groupId>
+                    <artifactId>elasticsearch</artifactId>
+                    <version>2.2.1</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.elasticsearch</groupId>
+                    <artifactId>elasticsearch</artifactId>
+                    <version>2.2.1</version>
+                    <scope>test</scope>
+                    <type>test-jar</type>
+                </dependency>
+                <dependency>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </dependency>
+            </dependencies>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-assembly-plugin</artifactId>
+                        <configuration>
+                            <archive>
+                                <manifest>
+                                    <mainClass>fully.qualified.MainClass</mainClass>
+                                </manifest>
+                            </archive>
+                            <descriptorRefs>
+                                <descriptorRef>jar-with-dependencies</descriptorRef>
+                            </descriptorRefs>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <configuration>
+                            <source>1.8</source>
+                            <target>1.8</target>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>animal-sniffer-java-8</id>
+            <activation>
+                <jdk>[1.8,)</jdk>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>animal-sniffer-maven-plugin</artifactId>
+                        <configuration>
+                            <signature>
+                                <groupId>org.codehaus.mojo.signature</groupId>
+                                <artifactId>java18</artifactId>
+                                <version>1.0</version>
+                            </signature>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>check_java_8</id>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>check</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ClientProvider.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ClientProvider.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ClientProvider.java
new file mode 100644
index 0000000..81ed92f
--- /dev/null
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ClientProvider.java
@@ -0,0 +1,26 @@
+/****************************************************************
+ * 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.backends.es;
+
+import org.elasticsearch.client.Client;
+
+public interface ClientProvider {
+
+    Client get();
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ClientProviderImpl.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ClientProviderImpl.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ClientProviderImpl.java
new file mode 100644
index 0000000..118d077
--- /dev/null
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ClientProviderImpl.java
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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.backends.es;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.elasticsearch.client.Client;
+import org.elasticsearch.client.transport.TransportClient;
+import org.elasticsearch.common.transport.InetSocketTransportAddress;
+
+import com.google.common.base.Throwables;
+
+public class ClientProviderImpl implements ClientProvider {
+
+    private final String host;
+    private final int port;
+    
+    public ClientProviderImpl(String host, int port) {
+        this.host = host;
+        this.port = port;
+    }
+
+    public Client get() {
+        try {
+            return TransportClient.builder().build()
+                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port));
+        } catch (UnknownHostException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
new file mode 100644
index 0000000..065fe19
--- /dev/null
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/DeleteByQueryPerformer.java
@@ -0,0 +1,90 @@
+/****************************************************************
+ * 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.backends.es;
+
+import java.util.concurrent.ExecutorService;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.james.backends.es.search.ScrollIterable;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.bulk.BulkRequestBuilder;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.search.SearchHit;
+
+import com.google.common.annotations.VisibleForTesting;
+
+public class DeleteByQueryPerformer {
+    public static final int DEFAULT_BATCH_SIZE = 100;
+    public static final TimeValue TIMEOUT = new TimeValue(60000);
+
+    private final Client client;
+    private final ExecutorService executor;
+    private final int batchSize;
+    private final String indexName;
+    private final String typeName;
+
+    @Inject
+    public DeleteByQueryPerformer(Client client, @Named("AsyncExecutor") ExecutorService executor, String indexName, String typeName) {
+        this(client, executor, DEFAULT_BATCH_SIZE, indexName, typeName);
+    }
+
+    @VisibleForTesting
+    public DeleteByQueryPerformer(Client client, @Named("AsyncExecutor") ExecutorService executor, int batchSize, String indexName, String typeName) {
+        this.client = client;
+        this.executor = executor;
+        this.batchSize = batchSize;
+        this.indexName = indexName;
+        this.typeName = typeName;
+    }
+
+    public void perform(QueryBuilder queryBuilder) {
+        executor.execute(() -> doDeleteByQuery(queryBuilder));
+    }
+
+    protected void doDeleteByQuery(QueryBuilder queryBuilder) {
+        new ScrollIterable(client,
+            client.prepareSearch(indexName)
+                .setTypes(typeName)
+                .setScroll(TIMEOUT)
+                .setNoFields()
+                .setQuery(queryBuilder)
+                .setSize(batchSize))
+            .stream()
+            .forEach(searchResponse -> deleteRetrievedIds(client, searchResponse));
+    }
+
+    private ListenableActionFuture<BulkResponse> deleteRetrievedIds(Client client, SearchResponse searchResponse) {
+        BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
+        for (SearchHit hit : searchResponse.getHits()) {
+            bulkRequestBuilder.add(client.prepareDelete()
+                .setIndex(indexName)
+                .setType(typeName)
+                .setId(hit.getId()));
+        }
+        return bulkRequestBuilder.execute();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
new file mode 100644
index 0000000..5cbf1f4
--- /dev/null
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
@@ -0,0 +1,102 @@
+/****************************************************************
+ * 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.backends.es;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.elasticsearch.action.bulk.BulkRequestBuilder;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.Strings;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+
+public class ElasticSearchIndexer {
+
+    public static class UpdatedRepresentation {
+        private final String id;
+        private final String updatedDocumentPart;
+
+        public UpdatedRepresentation(String id, String updatedDocumentPart) {
+            Preconditions.checkArgument(!Strings.isNullOrEmpty(id), "Updated id must be specified " + id);
+            Preconditions.checkArgument(!Strings.isNullOrEmpty(updatedDocumentPart), "Updated document must be specified");
+            this.id = id;
+            this.updatedDocumentPart = updatedDocumentPart;
+        }
+
+        public String getId() {
+            return id;
+        }
+
+        public String getUpdatedDocumentPart() {
+            return updatedDocumentPart;
+        }
+    }
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchIndexer.class);
+    
+    private final Client client;
+    private final DeleteByQueryPerformer deleteByQueryPerformer;
+    private final String indexName;
+    private final String typeName;
+
+    @Inject
+    public ElasticSearchIndexer(Client client, DeleteByQueryPerformer deleteByQueryPerformer, String indexName, String typeName) {
+        this.client = client;
+        this.deleteByQueryPerformer = deleteByQueryPerformer;
+        this.indexName = indexName;
+        this.typeName = typeName;
+    }
+    
+    public IndexResponse indexMessage(String id, String content) {
+        checkArgument(content);
+        LOGGER.debug(String.format("Indexing %s: %s", id, content));
+        return client.prepareIndex(indexName, typeName, id)
+            .setSource(content)
+            .get();
+    }
+
+    public BulkResponse updateMessages(List<UpdatedRepresentation> updatedDocumentParts) {
+        Preconditions.checkNotNull(updatedDocumentParts);
+        BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
+        updatedDocumentParts.forEach(updatedDocumentPart -> bulkRequestBuilder.add(client.prepareUpdate(indexName, typeName, updatedDocumentPart.getId())
+            .setDoc(updatedDocumentPart.getUpdatedDocumentPart())));
+        return bulkRequestBuilder.get();
+    }
+
+    public BulkResponse deleteMessages(List<String> ids) {
+        BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
+        ids.forEach(id -> bulkRequestBuilder.add(client.prepareDelete(indexName, typeName, id)));
+        return bulkRequestBuilder.get();
+    }
+    
+    public void deleteAllMatchingQuery(QueryBuilder queryBuilder) {
+        deleteByQueryPerformer.perform(queryBuilder);
+    }
+
+    private void checkArgument(String content) {
+        Preconditions.checkArgument(content != null, "content should be provided");
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
new file mode 100644
index 0000000..cab6021
--- /dev/null
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
@@ -0,0 +1,84 @@
+/****************************************************************
+ * 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.backends.es;
+
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+
+import java.io.IOException;
+
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.indices.IndexAlreadyExistsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IndexCreationFactory {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(IndexCreationFactory.class);
+    private static final int DEFAULT_NB_SHARDS = 1;
+    private static final int DEFAULT_NB_REPLICA = 0;
+    public static final String CASE_INSENSITIVE = "case_insensitive";
+
+    public static Client createIndex(Client client, String name, int nbShards, int nbReplica) {
+        try {
+            return createIndex(client, name, generateSetting(nbShards, nbReplica));
+        } catch (IOException e) {
+            LOGGER.error("Error while creating index : ", e);
+            return client;
+        }
+    }
+
+    public static Client createIndex(Client client, String name) {
+        return createIndex(client, name, DEFAULT_NB_SHARDS, DEFAULT_NB_REPLICA);
+    }
+
+    private static Client createIndex(Client client, String name, XContentBuilder settings) {
+        try {
+                client.admin()
+                    .indices()
+                    .prepareCreate(name)
+                    .setSettings(settings)
+                    .execute()
+                    .actionGet();
+        } catch (IndexAlreadyExistsException exception) {
+            LOGGER.info("Index [" + name + "] already exist");
+        }
+        return client;
+    }
+
+    private static XContentBuilder generateSetting(int nbShards, int nbReplica) throws IOException {
+        return jsonBuilder()
+            .startObject()
+                .field("number_of_shards", nbShards)
+                .field("number_of_replicas", nbReplica)
+                .startObject("analysis")
+                    .startObject("analyzer")
+                        .startObject(CASE_INSENSITIVE)
+                            .field("tokenizer", "keyword")
+                            .startArray("filter")
+                                .value("lowercase")
+                            .endArray()
+                        .endObject()
+                    .endObject()
+                .endObject()
+            .endObject();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
new file mode 100644
index 0000000..876c741
--- /dev/null
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.backends.es;
+
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+
+public class NodeMappingFactory {
+
+    public static final String BOOLEAN = "boolean";
+    public static final String TYPE = "type";
+    public static final String LONG = "long";
+    public static final String INDEX = "index";
+    public static final String NOT_ANALYZED = "not_analyzed";
+    public static final String STRING = "string";
+    public static final String PROPERTIES = "properties";
+    public static final String DATE = "date";
+    public static final String FORMAT = "format";
+    public static final String NESTED = "nested";
+    public static final String FIELDS = "fields";
+    public static final String RAW = "raw";
+    public static final String ANALYZER = "analyzer";
+    public static final String SNOWBALL = "snowball";
+    public static final String IGNORE_ABOVE = "ignore_above";
+    public static final int LUCENE_LIMIT = 32766;
+
+    public static Client applyMapping(Client client, String indexName, String typeName, XContentBuilder mappingsSources) {
+        client.admin()
+            .indices()
+            .preparePutMapping(indexName)
+            .setType(typeName)
+            .setSource(mappingsSources)
+            .execute()
+            .actionGet();
+        return client;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/search/ScrollIterable.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/search/ScrollIterable.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/search/ScrollIterable.java
new file mode 100644
index 0000000..a43160f
--- /dev/null
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/search/ScrollIterable.java
@@ -0,0 +1,81 @@
+/****************************************************************
+ * 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.backends.es.search;
+
+import java.util.Iterator;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.search.SearchRequestBuilder;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+
+public class ScrollIterable implements Iterable<SearchResponse> {
+
+    private static final TimeValue TIMEOUT = new TimeValue(60000);
+    private final Client client;
+    private final SearchRequestBuilder searchRequestBuilder;
+
+    public ScrollIterable(Client client, SearchRequestBuilder searchRequestBuilder) {
+        this.client = client;
+        this.searchRequestBuilder = searchRequestBuilder;
+    }
+
+    @Override
+    public Iterator<SearchResponse> iterator() {
+        return new ScrollIterator(client, searchRequestBuilder);
+    }
+
+    public Stream<SearchResponse> stream() {
+        return StreamSupport.stream(spliterator(), false);
+    }
+
+    public static class ScrollIterator implements Iterator<SearchResponse> {
+
+        private final Client client;
+        private ListenableActionFuture<SearchResponse> searchResponseFuture;
+
+        public ScrollIterator(Client client, SearchRequestBuilder searchRequestBuilder) {
+            this.client = client;
+            this.searchResponseFuture = searchRequestBuilder.execute();
+        }
+
+        @Override
+        public boolean hasNext() {
+            return !allSearchResponsesConsumed(searchResponseFuture.actionGet());
+        }
+
+        @Override
+        public SearchResponse next() {
+            SearchResponse result = searchResponseFuture.actionGet();
+            searchResponseFuture =  client.prepareSearchScroll(result.getScrollId())
+                .setScroll(TIMEOUT)
+                .execute();
+            return result;
+        }
+
+        private boolean allSearchResponsesConsumed(SearchResponse searchResponse) {
+            return searchResponse.getHits().getHits().length == 0;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
new file mode 100644
index 0000000..cb42956
--- /dev/null
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
@@ -0,0 +1,244 @@
+/****************************************************************
+ * 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.backends.es;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+
+import java.io.IOException;
+import java.util.concurrent.Executors;
+
+import org.apache.james.backends.es.utils.TestingClientProvider;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.node.Node;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.common.collect.Lists;
+
+public class ElasticSearchIndexerTest {
+
+    private static final int MINIMUM_BATCH_SIZE = 1;
+    private static final String CONTENT = "content";
+    private static final String INDEX_NAME = "index_name";
+    private static final String TYPE_NAME = "type_name";
+    private TemporaryFolder temporaryFolder = new TemporaryFolder();
+    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder, INDEX_NAME);
+
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
+
+    private Node node;
+    private ElasticSearchIndexer testee;
+
+    @Before
+    public void setup() throws IOException {
+        node = embeddedElasticSearch.getNode();
+        TestingClientProvider clientProvider = new TestingClientProvider(node);
+        DeleteByQueryPerformer deleteByQueryPerformer = new DeleteByQueryPerformer(clientProvider.get(),
+            Executors.newSingleThreadExecutor(),
+            MINIMUM_BATCH_SIZE,
+            INDEX_NAME,
+            TYPE_NAME) {
+            @Override
+            public void perform(QueryBuilder queryBuilder) {
+                doDeleteByQuery(queryBuilder);
+            }
+        };
+        testee = new ElasticSearchIndexer(clientProvider.get(), deleteByQueryPerformer, INDEX_NAME, TYPE_NAME);
+    }
+    
+    @Test
+    public void indexMessageShouldWork() throws Exception {
+        String messageId = "1";
+        String content = "{\"message\": \"trying out Elasticsearch\"}";
+        
+        testee.indexMessage(messageId, content);
+        embeddedElasticSearch.awaitForElasticSearch();
+        
+        try (Client client = node.client()) {
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
+                    .setTypes(TYPE_NAME)
+                    .setQuery(QueryBuilders.matchQuery("message", "trying"))
+                    .get();
+            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
+        }
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void indexMessageShouldThrowWhenJsonIsNull() throws InterruptedException {
+        testee.indexMessage("1", null);
+    }
+    
+    @Test
+    public void updateMessages() throws Exception {
+        String messageId = "1";
+        String content = "{\"message\": \"trying out Elasticsearch\",\"field\":\"Should be unchanged\"}";
+
+        testee.indexMessage(messageId, content);
+        embeddedElasticSearch.awaitForElasticSearch();
+
+        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation(messageId, "{\"message\": \"mastering out Elasticsearch\"}")));
+        embeddedElasticSearch.awaitForElasticSearch();
+
+        try (Client client = node.client()) {
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
+                .setTypes(TYPE_NAME)
+                .setQuery(QueryBuilders.matchQuery("message", "mastering"))
+                .get();
+            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
+        }
+
+        try (Client client = node.client()) {
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
+                .setTypes(TYPE_NAME)
+                .setQuery(QueryBuilders.matchQuery("field", "unchanged"))
+                .get();
+            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
+        }
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void updateMessageShouldThrowWhenJsonIsNull() throws InterruptedException {
+        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation("1", null)));
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void updateMessageShouldThrowWhenIdIsNull() throws InterruptedException {
+        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation(null, "{\"message\": \"mastering out Elasticsearch\"}")));
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void updateMessageShouldThrowWhenJsonIsEmpty() throws InterruptedException {
+        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation("1", "")));
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void updateMessageShouldThrowWhenIdIsEmpty() throws InterruptedException {
+        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation("", "{\"message\": \"mastering out Elasticsearch\"}")));
+    }
+
+    @Test
+    public void deleteByQueryShouldWorkOnSingleMessage() throws Exception {
+        String messageId = "1:2";
+        String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}";
+
+        testee.indexMessage(messageId, content);
+        embeddedElasticSearch.awaitForElasticSearch();
+        
+        testee.deleteAllMatchingQuery(termQuery("property", "1"));
+        embeddedElasticSearch.awaitForElasticSearch();
+        
+        try (Client client = node.client()) {
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
+                    .setTypes(TYPE_NAME)
+                    .setQuery(QueryBuilders.matchAllQuery())
+                    .get();
+            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
+        }
+    }
+
+    @Test
+    public void deleteByQueryShouldWorkWhenMultipleMessages() throws Exception {
+        String messageId = "1:1";
+        String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}";
+        
+        testee.indexMessage(messageId, content);
+        
+        String messageId2 = "1:2";
+        String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"property\":\"1\"}";
+        
+        testee.indexMessage(messageId2, content2);
+        
+        String messageId3 = "2:3";
+        String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"property\":\"2\"}";
+        
+        testee.indexMessage(messageId3, content3);
+        embeddedElasticSearch.awaitForElasticSearch();
+
+        testee.deleteAllMatchingQuery(termQuery("property", "1"));
+        embeddedElasticSearch.awaitForElasticSearch();
+        
+        try (Client client = node.client()) {
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
+                    .setTypes(TYPE_NAME)
+                    .setQuery(QueryBuilders.matchAllQuery())
+                    .get();
+            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
+        }
+    }
+    
+    @Test
+    public void deleteMessage() throws Exception {
+        String messageId = "1:2";
+        String content = "{\"message\": \"trying out Elasticsearch\"}";
+
+        testee.indexMessage(messageId, content);
+        embeddedElasticSearch.awaitForElasticSearch();
+
+        testee.deleteMessages(Lists.newArrayList(messageId));
+        embeddedElasticSearch.awaitForElasticSearch();
+        
+        try (Client client = node.client()) {
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
+                    .setTypes(TYPE_NAME)
+                    .setQuery(QueryBuilders.matchAllQuery())
+                    .get();
+            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
+        }
+    }
+
+    @Test
+    public void deleteShouldWorkWhenMultipleMessages() throws Exception {
+        String messageId = "1:1";
+        String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}";
+
+        testee.indexMessage(messageId, content);
+
+        String messageId2 = "1:2";
+        String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"mailboxId\":\"1\"}";
+
+        testee.indexMessage(messageId2, content2);
+
+        String messageId3 = "2:3";
+        String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"mailboxId\":\"2\"}";
+
+        testee.indexMessage(messageId3, content3);
+        embeddedElasticSearch.awaitForElasticSearch();
+
+        testee.deleteMessages(Lists.newArrayList(messageId, messageId3));
+        embeddedElasticSearch.awaitForElasticSearch();
+
+        try (Client client = node.client()) {
+            SearchResponse searchResponse = client.prepareSearch(INDEX_NAME)
+                .setTypes(TYPE_NAME)
+                .setQuery(QueryBuilders.matchAllQuery())
+                .get();
+            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
new file mode 100644
index 0000000..2902cde
--- /dev/null
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
@@ -0,0 +1,118 @@
+/****************************************************************
+ * 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.backends.es;
+
+import static com.jayway.awaitility.Awaitility.await;
+import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.function.Supplier;
+
+import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
+import org.elasticsearch.action.admin.indices.flush.FlushAction;
+import org.elasticsearch.action.admin.indices.flush.FlushRequestBuilder;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.node.Node;
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TemporaryFolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Throwables;
+import com.jayway.awaitility.Duration;
+
+public class EmbeddedElasticSearch extends ExternalResource {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedElasticSearch.class);
+
+    private final Supplier<Path> folder;
+    private final String indexName;
+    private Node node;
+
+    private static Path createTempDir(TemporaryFolder temporaryFolder) {
+        try {
+            return temporaryFolder.newFolder().toPath();
+        } catch (IOException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+    public EmbeddedElasticSearch(TemporaryFolder temporaryFolder, String indexName) {
+        this(() -> EmbeddedElasticSearch.createTempDir(temporaryFolder), indexName);
+    }
+
+    public EmbeddedElasticSearch(Path folder, String indexName) {
+        this(() -> folder, indexName);
+    }
+
+    private EmbeddedElasticSearch(Supplier<Path> folder, String indexName) {
+        this.folder = folder;
+        this.indexName = indexName;
+    }
+
+    @Override
+    public void before() throws IOException {
+        node = nodeBuilder().local(true)
+            .settings(Settings.builder()
+                .put("path.home", folder.get().toAbsolutePath())
+                .build())
+            .node();
+        node.start();
+        awaitForElasticSearch();
+    }
+
+    @Override
+    public void after() {
+        awaitForElasticSearch();
+        try (Client client = node.client()) {
+            client.admin()
+                .indices()
+                .delete(new DeleteIndexRequest(indexName))
+                .actionGet();
+        } catch (Exception e) {
+            LOGGER.warn("Error while closing ES connection", e);
+        }
+        node.close();
+    }
+
+    public Node getNode() {
+        return node;
+    }
+
+    /**
+     * Sometimes, tests are too fast.
+     * This method ensure that ElasticSearch service is up and indices are updated
+     */
+    public void awaitForElasticSearch() {
+        await().atMost(Duration.TEN_SECONDS).until(this::flush);
+    }
+
+    private boolean flush() {
+        try (Client client = node.client()) {
+            new FlushRequestBuilder(client, FlushAction.INSTANCE).setForce(true).get();
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
new file mode 100644
index 0000000..5b53a76
--- /dev/null
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
@@ -0,0 +1,174 @@
+/****************************************************************
+ * 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.backends.es.search;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.james.backends.es.ClientProvider;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.backends.es.utils.TestingClientProvider;
+import org.elasticsearch.action.search.SearchRequestBuilder;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.search.SearchHit;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+public class ScrollIterableTest {
+
+    public static final TimeValue TIMEOUT = new TimeValue(6000);
+    public static final int SIZE = 2;
+    public static final String MESSAGE = "message";
+    public static final String INDEX_NAME = "index";
+    public static final String MESSAGES = "messages";
+
+    private TemporaryFolder temporaryFolder = new TemporaryFolder();
+    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder, INDEX_NAME);
+
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
+
+    private ClientProvider clientProvider;
+
+    @Before
+    public void setUp() throws Exception {
+        clientProvider = new TestingClientProvider(embeddedElasticSearch.getNode());
+        IndexCreationFactory.createIndex(clientProvider.get(), INDEX_NAME);
+        embeddedElasticSearch.awaitForElasticSearch();
+        NodeMappingFactory.applyMapping(clientProvider.get(), INDEX_NAME, MESSAGES, getMappingsSources());
+    }
+
+    private XContentBuilder getMappingsSources() throws IOException {
+        return jsonBuilder()
+            .startObject()
+                .startObject(MESSAGES)
+                    .startObject(NodeMappingFactory.PROPERTIES)
+                        .startObject(MESSAGE)
+                            .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                        .endObject()
+                    .endObject()
+                .endObject()
+            .endObject();
+    }
+
+    @Test
+    public void scrollIterableShouldWorkWhenEmpty() {
+        try (Client client = clientProvider.get()) {
+            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME)
+                .setTypes(MESSAGES)
+                .setScroll(TIMEOUT)
+                .setQuery(matchAllQuery())
+                .setSize(SIZE);
+            assertThat(new ScrollIterable(client, searchRequestBuilder)).isEmpty();
+        }
+    }
+
+    @Test
+    public void scrollIterableShouldWorkWhenOneElement() {
+        try (Client client = clientProvider.get()) {
+            String id = "1";
+            client.prepareIndex(INDEX_NAME, MESSAGES, id)
+                .setSource(MESSAGE, "Sample message")
+                .execute();
+
+            embeddedElasticSearch.awaitForElasticSearch();
+
+            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME)
+                .setTypes(MESSAGES)
+                .setScroll(TIMEOUT)
+                .setQuery(matchAllQuery())
+                .setSize(SIZE);
+            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id);
+        }
+    }
+
+    @Test
+    public void scrollIterableShouldWorkWhenSizeElement() {
+        try (Client client = clientProvider.get()) {
+            String id1 = "1";
+            client.prepareIndex(INDEX_NAME, MESSAGES, id1)
+                .setSource(MESSAGE, "Sample message")
+                .execute();
+
+            String id2 = "2";
+            client.prepareIndex(INDEX_NAME, MESSAGES, id2)
+                .setSource(MESSAGE, "Sample message")
+                .execute();
+
+            embeddedElasticSearch.awaitForElasticSearch();
+
+            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME)
+                .setTypes(MESSAGES)
+                .setScroll(TIMEOUT)
+                .setQuery(matchAllQuery())
+                .setSize(SIZE);
+            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id1, id2);
+        }
+    }
+
+    @Test
+    public void scrollIterableShouldWorkWhenMoreThanSizeElement() {
+        try (Client client = clientProvider.get()) {
+            String id1 = "1";
+            client.prepareIndex(INDEX_NAME, MESSAGES, id1)
+                .setSource(MESSAGE, "Sample message")
+                .execute();
+
+            String id2 = "2";
+            client.prepareIndex(INDEX_NAME, MESSAGES, id2)
+                .setSource(MESSAGE, "Sample message")
+                .execute();
+
+            String id3 = "3";
+            client.prepareIndex(INDEX_NAME, MESSAGES, id3)
+                .setSource(MESSAGE, "Sample message")
+                .execute();
+
+            embeddedElasticSearch.awaitForElasticSearch();
+
+            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME)
+                .setTypes(MESSAGES)
+                .setScroll(TIMEOUT)
+                .setQuery(matchAllQuery())
+                .setSize(SIZE);
+            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id1, id2, id3);
+        }
+    }
+
+    private List<String> convertToIdList(ScrollIterable scrollIterable) {
+        return scrollIterable.stream()
+            .flatMap(searchResponse -> Arrays.stream(searchResponse.getHits().getHits()))
+            .map(SearchHit::getId)
+            .collect(Collectors.toList());
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/utils/TestingClientProvider.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/utils/TestingClientProvider.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/utils/TestingClientProvider.java
new file mode 100644
index 0000000..2de4fe5
--- /dev/null
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/utils/TestingClientProvider.java
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.backends.es.utils;
+
+import org.apache.james.backends.es.ClientProvider;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.node.Node;
+
+public class TestingClientProvider implements ClientProvider {
+
+    private final Node node;
+
+    public TestingClientProvider(Node node) {
+        this.node = node;
+    }
+    
+    @Override
+    public Client get() {
+        return node.client();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/backends-common/pom.xml
----------------------------------------------------------------------
diff --git a/backends-common/pom.xml b/backends-common/pom.xml
index 34df193..aaaaf3e 100644
--- a/backends-common/pom.xml
+++ b/backends-common/pom.xml
@@ -35,11 +35,14 @@
 
     <properties>
         <assertj-3.version>3.2.0</assertj-3.version>
+        <junit.version>4.11</junit.version>
+        <slf4j.version>1.7.7</slf4j.version>
     </properties>
 
     <modules>
         <module>cassandra</module>
         <module>jpa</module>
+        <module>elasticsearch</module>
     </modules>
 
     <dependencyManagement>
@@ -59,6 +62,16 @@
                 <artifactId>javax.inject</artifactId>
                 <version>1</version>
             </dependency>
+            <dependency>
+                <groupId>junit</groupId>
+                <artifactId>junit</artifactId>
+                <version>${junit.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-api</artifactId>
+                <version>${slf4j.version}</version>
+            </dependency>
         </dependencies>
 
     </dependencyManagement>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/pom.xml b/mailbox/elasticsearch/pom.xml
index bfe0c5b..dd2698d 100644
--- a/mailbox/elasticsearch/pom.xml
+++ b/mailbox/elasticsearch/pom.xml
@@ -159,6 +159,16 @@
             </build>
 	        <dependencies>
                 <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
                     <groupId>${project.groupId}</groupId>
                     <artifactId>apache-james-mailbox-api</artifactId>
                 </dependency>
@@ -205,11 +215,6 @@
                     <artifactId>guava</artifactId>
                 </dependency>
                 <dependency>
-                    <groupId>com.jayway.awaitility</groupId>
-                    <artifactId>awaitility</artifactId>
-                    <version>1.6.3</version>
-                </dependency>
-                <dependency>
                     <groupId>javax.inject</groupId>
                     <artifactId>javax.inject</artifactId>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ClientProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ClientProvider.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ClientProvider.java
deleted file mode 100644
index cd512e5..0000000
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ClientProvider.java
+++ /dev/null
@@ -1,26 +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.mailbox.elasticsearch;
-
-import org.elasticsearch.client.Client;
-
-public interface ClientProvider {
-
-    Client get();
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ClientProviderImpl.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ClientProviderImpl.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ClientProviderImpl.java
deleted file mode 100644
index 3e088af..0000000
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ClientProviderImpl.java
+++ /dev/null
@@ -1,48 +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.mailbox.elasticsearch;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.elasticsearch.client.Client;
-import org.elasticsearch.client.transport.TransportClient;
-import org.elasticsearch.common.transport.InetSocketTransportAddress;
-
-import com.google.common.base.Throwables;
-
-public class ClientProviderImpl implements ClientProvider {
-
-    private final String host;
-    private final int port;
-    
-    public ClientProviderImpl(String host, int port) {
-        this.host = host;
-        this.port = port;
-    }
-
-    public Client get() {
-        try {
-            return TransportClient.builder().build()
-                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port));
-        } catch (UnknownHostException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/DeleteByQueryPerformer.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/DeleteByQueryPerformer.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/DeleteByQueryPerformer.java
deleted file mode 100644
index be81654..0000000
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/DeleteByQueryPerformer.java
+++ /dev/null
@@ -1,86 +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.mailbox.elasticsearch;
-
-import java.util.concurrent.ExecutorService;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.apache.james.mailbox.elasticsearch.search.ScrollIterable;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.bulk.BulkRequestBuilder;
-import org.elasticsearch.action.bulk.BulkResponse;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.search.SearchHit;
-
-import com.google.common.annotations.VisibleForTesting;
-
-public class DeleteByQueryPerformer {
-    public static final int DEFAULT_BATCH_SIZE = 100;
-    public static final TimeValue TIMEOUT = new TimeValue(60000);
-
-    private final Client client;
-    private final ExecutorService executor;
-    private final int batchSize;
-
-    @Inject
-    public DeleteByQueryPerformer(Client client, @Named("AsyncExecutor") ExecutorService executor) {
-        this(client, executor, DEFAULT_BATCH_SIZE);
-    }
-
-    @VisibleForTesting
-    DeleteByQueryPerformer(Client client, @Named("AsyncExecutor") ExecutorService executor, int batchSize) {
-        this.client = client;
-        this.executor = executor;
-        this.batchSize = batchSize;
-    }
-
-    public void perform(QueryBuilder queryBuilder) {
-        executor.execute(() -> doDeleteByQuery(queryBuilder));
-    }
-
-    protected void doDeleteByQuery(QueryBuilder queryBuilder) {
-        new ScrollIterable(client,
-            client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setScroll(TIMEOUT)
-                .setNoFields()
-                .setQuery(queryBuilder)
-                .setSize(batchSize))
-            .stream()
-            .forEach(searchResponse -> deleteRetrievedIds(client, searchResponse));
-    }
-
-    private ListenableActionFuture<BulkResponse> deleteRetrievedIds(Client client, SearchResponse searchResponse) {
-        BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
-        for (SearchHit hit : searchResponse.getHits()) {
-            bulkRequestBuilder.add(client.prepareDelete()
-                .setIndex(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setType(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setId(hit.getId()));
-        }
-        return bulkRequestBuilder.execute();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexer.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexer.java
deleted file mode 100644
index 523fa22..0000000
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexer.java
+++ /dev/null
@@ -1,100 +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.mailbox.elasticsearch;
-
-import java.util.List;
-
-import javax.inject.Inject;
-
-import org.elasticsearch.action.bulk.BulkRequestBuilder;
-import org.elasticsearch.action.bulk.BulkResponse;
-import org.elasticsearch.action.index.IndexResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.Strings;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-public class ElasticSearchIndexer {
-
-    public static class UpdatedRepresentation {
-        private final String id;
-        private final String updatedDocumentPart;
-
-        public UpdatedRepresentation(String id, String updatedDocumentPart) {
-            Preconditions.checkArgument(!Strings.isNullOrEmpty(id), "Updated id must be specified " + id);
-            Preconditions.checkArgument(!Strings.isNullOrEmpty(updatedDocumentPart), "Updated document must be specified");
-            this.id = id;
-            this.updatedDocumentPart = updatedDocumentPart;
-        }
-
-        public String getId() {
-            return id;
-        }
-
-        public String getUpdatedDocumentPart() {
-            return updatedDocumentPart;
-        }
-    }
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchIndexer.class);
-    public static final String MAILBOX_INDEX = "mailbox";
-    public static final String MESSAGE_TYPE = "message";
-    
-    private final Client client;
-    private final DeleteByQueryPerformer deleteByQueryPerformer;
-
-    @Inject
-    public ElasticSearchIndexer(Client client, DeleteByQueryPerformer deleteByQueryPerformer) {
-        this.client = client;
-        this.deleteByQueryPerformer = deleteByQueryPerformer;
-    }
-    
-    public IndexResponse indexMessage(String id, String content) {
-        checkArgument(content);
-        LOGGER.debug(String.format("Indexing %s: %s", id, content));
-        return client.prepareIndex(MAILBOX_INDEX, MESSAGE_TYPE, id)
-            .setSource(content)
-            .get();
-    }
-
-    public BulkResponse updateMessages(List<UpdatedRepresentation> updatedDocumentParts) {
-        Preconditions.checkNotNull(updatedDocumentParts);
-        BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
-        updatedDocumentParts.forEach(updatedDocumentPart -> bulkRequestBuilder.add(client.prepareUpdate(MAILBOX_INDEX, MESSAGE_TYPE, updatedDocumentPart.getId())
-            .setDoc(updatedDocumentPart.getUpdatedDocumentPart())));
-        return bulkRequestBuilder.get();
-    }
-
-    public BulkResponse deleteMessages(List<String> ids) {
-        BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
-        ids.forEach(id -> bulkRequestBuilder.add(client.prepareDelete(MAILBOX_INDEX, MESSAGE_TYPE, id)));
-        return bulkRequestBuilder.get();
-    }
-    
-    public void deleteAllMatchingQuery(QueryBuilder queryBuilder) {
-        deleteByQueryPerformer.perform(queryBuilder);
-    }
-
-    private void checkArgument(String content) {
-        Preconditions.checkArgument(content != null, "content should be provided");
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/IndexCreationFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/IndexCreationFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/IndexCreationFactory.java
deleted file mode 100644
index c4a8060..0000000
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/IndexCreationFactory.java
+++ /dev/null
@@ -1,84 +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.mailbox.elasticsearch;
-
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-
-import java.io.IOException;
-
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.indices.IndexAlreadyExistsException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class IndexCreationFactory {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(IndexCreationFactory.class);
-    private static final int DEFAULT_NB_SHARDS = 1;
-    private static final int DEFAULT_NB_REPLICA = 0;
-    public static final String CASE_INSENSITIVE = "case_insensitive";
-
-    public static Client createIndex(Client client, int nbShards, int nbReplica) {
-        try {
-            return createIndex(client, generateSetting(nbShards, nbReplica));
-        } catch (IOException e) {
-            LOGGER.error("Error while creating index : ", e);
-            return client;
-        }
-    }
-
-    public static Client createIndex(Client client) {
-        return createIndex(client, DEFAULT_NB_SHARDS, DEFAULT_NB_REPLICA);
-    }
-
-    private static Client createIndex(Client client, XContentBuilder settings) {
-        try {
-                client.admin()
-                    .indices()
-                    .prepareCreate(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setSettings(settings)
-                    .execute()
-                    .actionGet();
-        } catch (IndexAlreadyExistsException exception) {
-            LOGGER.info("Index [" + ElasticSearchIndexer.MAILBOX_INDEX + "] already exist");
-        }
-        return client;
-    }
-
-    private static XContentBuilder generateSetting(int nbShards, int nbReplica) throws IOException {
-        return jsonBuilder()
-            .startObject()
-                .field("number_of_shards", nbShards)
-                .field("number_of_replicas", nbReplica)
-                .startObject("analysis")
-                    .startObject("analyzer")
-                        .startObject(CASE_INSENSITIVE)
-                            .field("tokenizer", "keyword")
-                            .startArray("filter")
-                                .value("lowercase")
-                            .endArray()
-                        .endObject()
-                    .endObject()
-                .endObject()
-            .endObject();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxElasticsearchConstants.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxElasticsearchConstants.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxElasticsearchConstants.java
new file mode 100644
index 0000000..4977950
--- /dev/null
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxElasticsearchConstants.java
@@ -0,0 +1,25 @@
+/****************************************************************
+ * 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.mailbox.elasticsearch;
+
+public interface MailboxElasticsearchConstants {
+    String MAILBOX_INDEX = "mailbox";
+    String MESSAGE_TYPE = "message";
+}


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


[04/12] james-project git commit: JAMES-1901 Wrap EsMetric reporter and configure it

Posted by bt...@apache.org.
JAMES-1901 Wrap EsMetric reporter and configure it


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

Branch: refs/heads/master
Commit: 894f4c484e80cb33bf86c31d4f8872185483fdb6
Parents: 31ef821
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Dec 30 15:22:49 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:42:50 2017 +0700

----------------------------------------------------------------------
 .../metrics/metrics-dropwizard/pom.xml          |  4 +
 .../dropwizard/DropWizardMetricFactory.java     |  4 +
 .../metrics/dropwizard/ESMetricReporter.java    | 69 +++++++++++++++++
 .../dropwizard/ESReporterConfiguration.java     | 81 ++++++++++++++++++++
 server/pom.xml                                  |  5 ++
 5 files changed, 163 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/894f4c48/server/container/metrics/metrics-dropwizard/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-dropwizard/pom.xml b/server/container/metrics/metrics-dropwizard/pom.xml
index 3d40daf..5ad3440 100644
--- a/server/container/metrics/metrics-dropwizard/pom.xml
+++ b/server/container/metrics/metrics-dropwizard/pom.xml
@@ -57,6 +57,10 @@
             <groupId>javax.inject</groupId>
             <artifactId>javax.inject</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.elasticsearch</groupId>
+            <artifactId>metrics-elasticsearch-reporter</artifactId>
+        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/894f4c48/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
index 8c7f731..005ae34 100644
--- a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
+++ b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
@@ -39,6 +39,10 @@ public class DropWizardMetricFactory implements MetricFactory {
             .build();
     }
 
+    public ESMetricReporter provideEsReporter(ESReporterConfiguration esReporterConfiguration) {
+        return new ESMetricReporter(esReporterConfiguration, metricRegistry);
+    }
+
     @Override
     public Metric generate(String name) {
         return new DropWizardMetric(metricRegistry.counter(name));

http://git-wip-us.apache.org/repos/asf/james-project/blob/894f4c48/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESMetricReporter.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESMetricReporter.java b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESMetricReporter.java
new file mode 100644
index 0000000..6d782ce
--- /dev/null
+++ b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESMetricReporter.java
@@ -0,0 +1,69 @@
+/****************************************************************
+ * 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.metrics.dropwizard;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import javax.annotation.PreDestroy;
+
+import org.elasticsearch.metrics.ElasticsearchReporter;
+
+import com.codahale.metrics.MetricRegistry;
+import com.google.common.base.Optional;
+import com.google.common.base.Throwables;
+
+public class ESMetricReporter {
+
+    private final Optional<ElasticsearchReporter> reporter;
+    private final ESReporterConfiguration esReporterConfiguration;
+
+    public ESMetricReporter(ESReporterConfiguration esReporterConfiguration, MetricRegistry registry) {
+        this.reporter = getReporter(esReporterConfiguration, registry);
+        this.esReporterConfiguration = esReporterConfiguration;
+    }
+
+    private Optional<ElasticsearchReporter> getReporter(ESReporterConfiguration esReporterConfiguration, MetricRegistry registry) {
+        if (esReporterConfiguration.isEnabled()) {
+            try {
+                return Optional.of(ElasticsearchReporter.forRegistry(registry)
+                    .hosts(esReporterConfiguration.getHostWithPort())
+                    .index(esReporterConfiguration.getIndex())
+                    .build());
+            } catch (IOException e) {
+                throw Throwables.propagate(e);
+            }
+        }   
+        return Optional.absent();
+    }
+
+    public void start() {
+        if (reporter.isPresent()) {
+            reporter.get().start(esReporterConfiguration.getPeriodInSecond(), TimeUnit.SECONDS);
+        }
+    }
+
+    @PreDestroy
+    public void stop() {
+        if (reporter.isPresent()) {
+            reporter.get().stop();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/894f4c48/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESReporterConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESReporterConfiguration.java b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESReporterConfiguration.java
new file mode 100644
index 0000000..06e669f
--- /dev/null
+++ b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/ESReporterConfiguration.java
@@ -0,0 +1,81 @@
+/****************************************************************
+ * 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.metrics.dropwizard;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
+public class ESReporterConfiguration {
+
+    public static final boolean ENABLED = true;
+    public static final boolean DISABLED = !ENABLED;
+    public static final String DEFAULT_INDEX = "james-metrics";
+    public static final long DEFAULT_PERIOD_IN_SECOND = 60L;
+
+    public static ESReporterConfiguration disabled() {
+        return new ESReporterConfiguration(
+            Optional.<String>absent(),
+            Optional.<Integer>absent(),
+            DISABLED,
+            Optional.<String>absent(),
+            Optional.<Long>absent());
+    }
+
+    public static ESReporterConfiguration enabled(String host, int port, Optional<String> index, Optional<Long> periodInSecond) {
+        return new ESReporterConfiguration(
+            Optional.of(host),
+            Optional.of(port),
+            ENABLED,
+            index,
+            periodInSecond);
+    }
+
+    private final Optional<String> host;
+    private final Optional<Integer> port;
+    private final boolean enabled;
+    private final Optional<String> index;
+    private final Optional<Long> periodInSecond;
+
+    public ESReporterConfiguration(Optional<String> host, Optional<Integer> port, boolean enabled, Optional<String> index, Optional<Long> periodInSecond) {
+        this.host = host;
+        this.port = port;
+        this.enabled = enabled;
+        this.index = index;
+        this.periodInSecond = periodInSecond;
+    }
+
+    public String getHostWithPort() {
+        Preconditions.checkState(host.isPresent());
+        Preconditions.checkState(port.isPresent());
+        return host.get() + ":" + port.get();
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public String getIndex() {
+        return index.or(DEFAULT_INDEX);
+    }
+
+    public long getPeriodInSecond() {
+        return periodInSecond.or(DEFAULT_PERIOD_IN_SECOND);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/894f4c48/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index ab2eca5..66fdedf 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -1561,6 +1561,11 @@
                 <version>${jetty.version}</version>
             </dependency>
             <dependency>
+                <groupId>org.elasticsearch</groupId>
+                <artifactId>metrics-elasticsearch-reporter</artifactId>
+                <version>2.2.0</version>
+            </dependency>
+            <dependency>
                 <groupId>org.testcontainers</groupId>
                 <artifactId>testcontainers</artifactId>
                 <version>${testcontainers-version}</version>


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


[02/12] james-project git commit: JAMES-1917 Lighten documentation for Guice JPA and Cassandra

Posted by bt...@apache.org.
JAMES-1917 Lighten documentation for Guice JPA and Cassandra

Configuration is already present and automatically up to date in docker related folders. Better to use it.


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

Branch: refs/heads/master
Commit: a615668c9707c6fac05c7975f271c768b2ccf6bb
Parents: 80245f1
Author: Benoit Tellier <bt...@linagora.com>
Authored: Tue Jan 24 11:01:13 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Feb 3 16:40:39 2017 +0700

----------------------------------------------------------------------
 .../container/guice/cassandra-guice/README.adoc |  33 +++--
 .../sample-configuration/cassandra.properties   |   5 -
 .../sample-configuration/dnsservice.xml         |  29 ----
 .../sample-configuration/domainlist.xml         |  28 ----
 .../elasticsearch.properties                    |  28 ----
 .../sample-configuration/imapserver.xml         |  54 --------
 .../sample-configuration/jmap.properties        |  11 --
 .../sample-configuration/jmx.properties         |  28 ----
 .../sample-configuration/mailetcontainer.xml    | 138 -------------------
 .../mailrepositorystore.xml                     |  34 -----
 .../sample-configuration/pop3server.xml         |  42 ------
 .../recipientrewritetable.xml                   |  27 ----
 .../sample-configuration/smtpserver.xml         | 105 --------------
 .../sample-configuration/usersrepository.xml    |  27 ----
 server/container/guice/jpa-guice/README.adoc    |  26 ++--
 .../sample-configuration/dnsservice.xml         |  29 ----
 .../sample-configuration/domainlist.xml         |  28 ----
 .../sample-configuration/imapserver.xml         |  54 --------
 .../james-database.properties                   |  40 ------
 .../sample-configuration/jmx.properties         |  28 ----
 .../sample-configuration/lmtpserver.xml         |  41 ------
 .../sample-configuration/mailetcontainer.xml    | 137 ------------------
 .../mailrepositorystore.xml                     |  34 -----
 .../sample-configuration/pop3server.xml         |  42 ------
 .../recipientrewritetable.xml                   |  27 ----
 .../sample-configuration/smtpserver.xml         | 105 --------------
 .../sample-configuration/usersrepository.xml    |  27 ----
 27 files changed, 37 insertions(+), 1170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/README.adoc
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/README.adoc b/server/container/guice/cassandra-guice/README.adoc
index e3648ff..f930b89 100644
--- a/server/container/guice/cassandra-guice/README.adoc
+++ b/server/container/guice/cassandra-guice/README.adoc
@@ -5,15 +5,21 @@
 === Requirements
 
  * Java 8 SDK
- * Docker
- * Maven
+ * Docker \u2215 ElasticSearch 2.2.1 and Cassandra 2.2.3
+ * Maven 3
 
 === Building the artifacts
 
-An usual compilation using maven will produce two artifacts into target directory :
+An usual compilation using maven will produce two artifacts into target directory:
 
- * james-server-cassandra-guice-${version}.jar
- * james-server-cassandra-guice-${version}.lib
+ * james-server-cassandra-guice.jar
+ * james-server-cassandra-guice.lib
+
+You can for example run in the base of this git repository:
+
+```
+mvn clean install
+```
 
 == Running
 
@@ -26,20 +32,25 @@ An usual compilation using maven will produce two artifacts into target director
 
 To run james, you have to create a directory containing required configuration files.
 
-A sample directory (appropriately named sample-directory) is provided with some
-default value you may need to replace.
+James requires the configuration to be in a subfolder of working directory that is called **conf**. You can get a sample
+directory for configuration from dockerfiles/run/guice/cassandra/destination/conf. You might need to adapt it to your needs.
 
-You also need to generate a keystore with the following command :
+You also need to generate a keystore in your conf folder with the following command:
 [source]
 ----
 $ keytool -genkey -alias james -keyalg RSA -keystore conf/keystore
 ----
 
-You need to have a Cassandra and an ElasticSearch instance running.
+You need to have a Cassandra and an ElasticSearch instance running. You can either install the servers or launch them via docker:
+
+```bash
+$ docker run -d --port 9042:9042 --name=cassandra cassandra:2.2.3
+$ docker run -d --port 9200:9200 --port 9300:9300 --name=elasticsearch elasticsearch:2.2.1
+```
 
-Once everything is set up, you just have to run the jar with :
+Once everything is set up, you just have to run the jar with:
 
 [source]
 ----
-$ java -Dworking.directory=sample-configuration -jar target/james-server-cassandra-guice-${version}.jar
+$ java -Dworking.directory=. -jar target/james-server-cassandra-guice.jar
 ----

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/cassandra.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/cassandra.properties b/server/container/guice/cassandra-guice/sample-configuration/cassandra.properties
deleted file mode 100644
index 80b8426..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/cassandra.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-# Configuration file for cassandra mailbox
-
-cassandra.nodes=172.17.0.2:9042
-cassandra.keyspace=apache_james
-cassandra.replication.factor=1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/dnsservice.xml b/server/container/guice/cassandra-guice/sample-configuration/dnsservice.xml
deleted file mode 100644
index 0978a00..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/dnsservice.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<dnsservice>
-  <servers>
-    <server>8.8.8.8</server>
-    <server>62.210.16.6</server>
-  </servers>
-  <autodiscover>false</autodiscover>
-  <authoritative>false</authoritative>
-  <maxcachesize>50000</maxcachesize>
-</dnsservice>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/domainlist.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/domainlist.xml b/server/container/guice/cassandra-guice/sample-configuration/domainlist.xml
deleted file mode 100644
index 8d00118..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/domainlist.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
-    <domainnames>
-        <domainname>james.apache.org</domainname>
-    </domainnames>
-    <autodetect>true</autodetect>
-    <autodetectIP>true</autodetectIP>
-    <defaultDomain>localhost</defaultDomain>
-</domainlist>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/elasticsearch.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/elasticsearch.properties b/server/container/guice/cassandra-guice/sample-configuration/elasticsearch.properties
deleted file mode 100644
index 67b280b..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/elasticsearch.properties
+++ /dev/null
@@ -1,28 +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.
-
-#  This template file can be used as example for James Server configuration
-#  DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-
-# Configuration file for ElasticSearch
-
-elasticsearch.masterHost=172.17.0.1
-elasticsearch.port=9300
-elasticsearch.nb.shards=1
-elasticsearch.nb.replica=0
-# Index or not attachments (default value: true)
-elasticsearch.indexAttachments=true

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/imapserver.xml b/server/container/guice/cassandra-guice/sample-configuration/imapserver.xml
deleted file mode 100644
index c03b978..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/imapserver.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.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.
--->
-
-
-<imapservers>
-	<imapserver enabled="true">
-		<jmxName>imapserver</jmxName>
-		<bind>0.0.0.0:1143</bind>
-		<connectionBacklog>200</connectionBacklog>
-		<tls socketTLS="false" startTLS="true">
-			<!-- To create a new keystore execute:
-            keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
-              -->
-			<keystore>file://conf/keystore</keystore>
-			<secret>james72laBalle</secret>
-			<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-		</tls>
-		<connectionLimit>0</connectionLimit>
-		<connectionLimitPerIP>0</connectionLimitPerIP>
-	</imapserver>
-	<imapserver enabled="true">
-		<jmxName>imapserver-ssl</jmxName>
-		<bind>0.0.0.0:1993</bind>
-		<connectionBacklog>200</connectionBacklog>
-		<tls socketTLS="true" startTLS="false">
-			<!-- To create a new keystore execute:
-              keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
-             -->
-			<keystore>file://conf/keystore</keystore>
-			<secret>james72laBalle</secret>
-			<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-		</tls>
-		<connectionLimit>0</connectionLimit>
-		<connectionLimitPerIP>0</connectionLimitPerIP>
-	</imapserver>
-</imapservers>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/jmap.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/jmap.properties b/server/container/guice/cassandra-guice/sample-configuration/jmap.properties
deleted file mode 100644
index d785ccd..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/jmap.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# Configuration file for JMAP
-
-tls.keystoreURL=file://conf/keystore
-tls.secret=james72laBalle
-
-#
-# If you wish to use OAuth authentication, you should provide a valid JWT public key.
-# The following entry specify the link to the URL of the public key file,
-# which should be a PEM format file.
-#
-jwt.publickeypem.url=
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/jmx.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/jmx.properties b/server/container/guice/cassandra-guice/sample-configuration/jmx.properties
deleted file mode 100644
index a1dbdf8..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/jmx.properties
+++ /dev/null
@@ -1,28 +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.
-#
-
-#  This template file can be used as example for James Server configuration
-#  DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-
-#  This template file can be used as example for James Server configuration
-#  DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-
-# See http://james.apache.org/server/3/config.html for usage
-
-jmx.address=127.0.0.1
-jmx.port=9999

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/mailetcontainer.xml b/server/container/guice/cassandra-guice/sample-configuration/mailetcontainer.xml
deleted file mode 100644
index bad37f5..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/mailetcontainer.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailetcontainer enableJmx="true">
-
-    <context>
-        <postmaster>postmaster@james.minet.net</postmaster>
-    </context>
-
-    <spooler>
-        <threads>20</threads>
-    </spooler>
-
-    <processors>
-        <processor state="root" enableJmx="true">
-            <mailet match="All" class="PostmasterAlias"/>
-            <mailet match="RelayLimit=30" class="Null"/>
-            <!-- Hook on sievemanager@james.linagora.com
-                 Mail send to this address will get interpreted with SIEVE Manage -->
-            <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
-                <processor>sieve-manager-check</processor>
-            </mailet>
-            <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
-                <processor>transport</processor>
-            </mailet>
-            <mailet match="All" class="SetMailAttribute">
-                <spamChecked>true</spamChecked>
-            </mailet>
-            <mailet match="SMTPAuthSuccessful" class="ToProcessor">
-                <processor>transport</processor>
-            </mailet>
-            <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
-                <processor>transport</processor>
-            </mailet>
-            <!-- Check for delivery from a known spam server -->
-            <!-- This set of matchers/mailets redirect all emails from known -->
-            <!-- black holes, open relays, and spam servers to the spam processor -->
-            <!-- For this set to function properly, the spam processor must be configured. -->
-            <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
-                <processor>spam</processor>
-                <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
-            </mailet>
-            <mailet match="All" class="ToProcessor">
-                <processor>transport</processor>
-            </mailet>
-        </processor>
-
-        <processor state="error" enableJmx="true">
-            <mailet match="All" class="Bounce"/>
-            <mailet match="All" class="ToRepository">
-                <repositoryPath>file://var/mail/error/</repositoryPath>
-            </mailet>
-        </processor>
-
-
-        <processor state="transport" enableJmx="true">
-            <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
-                <name>X-UserIsAuth</name>
-                <value>true</value>
-            </mailet>
-            <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
-                <name>X-WasSigned</name>
-                <value>true</value>
-            </mailet>
-            <mailet match="All" class="RecipientRewriteTable" />
-            <mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.VacationMailet"/>
-            <mailet match="RecipientIsLocal" class="LocalDelivery"/>
-            <mailet match="HostIsLocal" class="ToProcessor">
-                <processor>local-address-error</processor>
-                <notice>550 - Requested action not taken: no such user here</notice>
-            </mailet>
-            <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
-                <outgoingQueue>outgoing</outgoingQueue>
-                <delayTime>5000, 100000, 500000</delayTime>
-                <maxRetries>25</maxRetries>
-                <maxDnsProblemRetries>0</maxDnsProblemRetries>
-                <deliveryThreads>10</deliveryThreads>
-                <sendpartial>true</sendpartial>
-                <bounceProcessor>bounces</bounceProcessor>
-            </mailet>
-            <mailet match="All" class="ToProcessor">
-                <processor>relay-denied</processor>
-            </mailet>
-        </processor>
-
-        <processor state="spam" enableJmx="true">
-            <mailet match="All" class="ToRepository">
-                <repositoryPath>file://var/mail/spam/</repositoryPath>
-            </mailet>
-        </processor>
-
-        <processor state="local-address-error" enableJmx="true">
-            <mailet match="All" class="Bounce">
-                <attachment>none</attachment>
-            </mailet>
-            <mailet match="All" class="ToRepository">
-                <repositoryPath>file://var/mail/address-error/</repositoryPath>
-            </mailet>
-        </processor>
-
-        <processor state="relay-denied" enableJmx="true">
-            <mailet match="All" class="Bounce">
-                <attachment>none</attachment>
-            </mailet>
-            <mailet match="All" class="ToRepository">
-                <repositoryPath>file://var/mail/relay-denied/</repositoryPath>
-                <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
-            </mailet>
-        </processor>
-
-        <processor state="bounces" enableJmx="true">
-            <mailet match="All" class="DSNBounce">
-                <passThrough>false</passThrough>
-            </mailet>
-        </processor>
-    </processors>
-
-</mailetcontainer>
-
-

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/mailrepositorystore.xml b/server/container/guice/cassandra-guice/sample-configuration/mailrepositorystore.xml
deleted file mode 100644
index acca810..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/mailrepositorystore.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailrepositorystore>
-    <mailrepositories>
-        <!-- File based repositories.  These repositories store all message data -->
-        <!-- in the file system. -->
-        <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
-            <protocols>
-                <protocol>file</protocol>
-            </protocols>
-            <!-- Set if the messages should be listed sorted. False by default -->
-            <config FIFO="false" CACHEKEYS="true"/>
-        </mailrepository>
-    </mailrepositories>
-</mailrepositorystore>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/pop3server.xml b/server/container/guice/cassandra-guice/sample-configuration/pop3server.xml
deleted file mode 100644
index c57c832..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/pop3server.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-
-<pop3servers>
-    <pop3server enabled="false">
-        <jmxName>pop3server</jmxName>
-        <bind>0.0.0.0:1110</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <tls socketTLS="false" startTLS="false">
-            <!-- To create a new keystore execute:
-                  keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
-             -->
-            <keystore>file://conf/keystore</keystore>
-            <secret>james72laBalle</secret>
-            <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-        </tls>
-        <connectiontimeout>1200</connectiontimeout>
-        <connectionLimit>0</connectionLimit>
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <handlerchain>
-            <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </pop3server>
-</pop3servers>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/recipientrewritetable.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/recipientrewritetable.xml b/server/container/guice/cassandra-guice/sample-configuration/recipientrewritetable.xml
deleted file mode 100644
index 7e7f586..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/recipientrewritetable.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<!-- The default table for storing James' RecipientRewriteTable mappings. -->
-<recipientrewritetable class="org.apache.james.rrt.jpa.JPARecipientRewriteTable">
-  <recursiveMapping>true</recursiveMapping>
-  <mappingLimit>10</mappingLimit>
-  <mapping>some@domain=some</mapping>
-</recipientrewritetable>
-

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/smtpserver.xml b/server/container/guice/cassandra-guice/sample-configuration/smtpserver.xml
deleted file mode 100644
index c34fcd1..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/smtpserver.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?xml version="1.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.
- -->
-
-<smtpservers>
-    <smtpserver enabled="true">
-        <jmxName>smtpserver-global</jmxName>
-        <bind>0.0.0.0:1025</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <tls socketTLS="false" startTLS="false">
-            <keystore>file://conf/keystore</keystore>
-            <secret>james72laBalle</secret>
-            <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-            <algorithm>SunX509</algorithm>
-        </tls>
-        <connectiontimeout>360</connectiontimeout>
-        <connectionLimit>0</connectionLimit>
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <authRequired>false</authRequired>
-        <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
-        <verifyIdentity>true</verifyIdentity>
-        <maxmessagesize>0</maxmessagesize>
-        <addressBracketsEnforcement>true</addressBracketsEnforcement>
-        <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
-        <handlerchain>
-            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </smtpserver>
-    <smtpserver enabled="true">
-        <jmxName>smtpserver-TLS</jmxName>
-        <bind>0.0.0.0:1465</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <tls socketTLS="true" startTLS="false">
-            <keystore>file://conf/keystore</keystore>
-            <secret>james72laBalle</secret>
-            <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-            <algorithm>SunX509</algorithm>
-        </tls>
-        <connectiontimeout>360</connectiontimeout>
-        <connectionLimit>0</connectionLimit>
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <!--
-           Authorize only local users
-        -->
-        <authRequired>true</authRequired>
-        <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
-        <!-- Trust authenticated users -->
-        <verifyIdentity>false</verifyIdentity>
-        <maxmessagesize>0</maxmessagesize>
-        <addressBracketsEnforcement>true</addressBracketsEnforcement>
-        <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
-        <handlerchain>
-            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </smtpserver>
-    <smtpserver enabled="true">
-        <jmxName>smtpserver-authenticated</jmxName>
-        <bind>0.0.0.0:1587</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <tls socketTLS="false" startTLS="true">
-            <keystore>file://conf/keystore</keystore>
-            <secret>james72laBalle</secret>
-            <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-            <algorithm>SunX509</algorithm>
-        </tls>
-        <connectiontimeout>360</connectiontimeout>
-        <connectionLimit>0</connectionLimit>
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <!--
-           Authorize only local users
-        -->
-        <authRequired>true</authRequired>
-        <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
-        <!-- Trust authenticated users -->
-        <verifyIdentity>false</verifyIdentity>
-        <maxmessagesize>0</maxmessagesize>
-        <addressBracketsEnforcement>true</addressBracketsEnforcement>
-        <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
-        <handlerchain>
-            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </smtpserver>
-</smtpservers>
-
-

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/cassandra-guice/sample-configuration/usersrepository.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/usersrepository.xml b/server/container/guice/cassandra-guice/sample-configuration/usersrepository.xml
deleted file mode 100644
index fc76107..0000000
--- a/server/container/guice/cassandra-guice/sample-configuration/usersrepository.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<usersrepository name="LocalUsers" class="org.apache.james.user.jpa.JPAUsersRepository">
-    <destination URL="file://users/"/>
-    <algorithm>MD5</algorithm>
-    <enableVirtualHosting>true</enableVirtualHosting>
-    <enableForwarding>true</enableForwarding>
-</usersrepository>
-

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/README.adoc
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/README.adoc b/server/container/guice/jpa-guice/README.adoc
index 8f47705..4db218f 100644
--- a/server/container/guice/jpa-guice/README.adoc
+++ b/server/container/guice/jpa-guice/README.adoc
@@ -6,35 +6,39 @@
 
  * Java 8 SDK
  * Docker
- * Maven
+ * Maven 3
 
 === Building the artifacts
 
-An usual compilation using maven will produce two artifacts into target directory :
+An usual compilation using maven will produce two artifacts into target directory:
 
- * james-server-jpa-guice-${version}.jar
- * james-server-jpa-guice-${version}.lib
+ * james-server-jpa-guice.jar
+ * james-server-jpa-guice.lib
 
-== Running
+You can for example run in the base of this git repository:
 
-=== Requirements
+```
+mvn clean install
+```
+
+== Running
 
 === James Launch
 
 To run james, you have to create a directory containing required configuration files.
 
-A sample directory (appropriately named sample-directory) is provided with some
-default value you may need to replace.
+James requires the configuration to be in a subfolder of working directory that is called **conf**. You can get a sample
+directory for configuration from dockerfiles/run/guice/jpa/destination/conf. You might need to adapt it to your needs.
 
-You also need to generate a keystore with the following command :
+You also need to generate a keystore in your conf folder with the following command:
 [source]
 ----
 $ keytool -genkey -alias james -keyalg RSA -keystore conf/keystore
 ----
 
-Once everything is set up, you just have to run the jar with :
+Once everything is set up, you just have to run the jar with:
 
 [source]
 ----
-$ java -Dworking.directory=sample-configuration -jar target/james-server-jpa-guice-${version}.jar
+$ java -Dworking.directory=. -jar target/james-server-jpa-guice.jar
 ----

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/dnsservice.xml b/server/container/guice/jpa-guice/sample-configuration/dnsservice.xml
deleted file mode 100644
index 0978a00..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/dnsservice.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<dnsservice>
-  <servers>
-    <server>8.8.8.8</server>
-    <server>62.210.16.6</server>
-  </servers>
-  <autodiscover>false</autodiscover>
-  <authoritative>false</authoritative>
-  <maxcachesize>50000</maxcachesize>
-</dnsservice>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/domainlist.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/domainlist.xml b/server/container/guice/jpa-guice/sample-configuration/domainlist.xml
deleted file mode 100644
index 8d00118..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/domainlist.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
-    <domainnames>
-        <domainname>james.apache.org</domainname>
-    </domainnames>
-    <autodetect>true</autodetect>
-    <autodetectIP>true</autodetectIP>
-    <defaultDomain>localhost</defaultDomain>
-</domainlist>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/imapserver.xml b/server/container/guice/jpa-guice/sample-configuration/imapserver.xml
deleted file mode 100644
index c03b978..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/imapserver.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.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.
--->
-
-
-<imapservers>
-	<imapserver enabled="true">
-		<jmxName>imapserver</jmxName>
-		<bind>0.0.0.0:1143</bind>
-		<connectionBacklog>200</connectionBacklog>
-		<tls socketTLS="false" startTLS="true">
-			<!-- To create a new keystore execute:
-            keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
-              -->
-			<keystore>file://conf/keystore</keystore>
-			<secret>james72laBalle</secret>
-			<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-		</tls>
-		<connectionLimit>0</connectionLimit>
-		<connectionLimitPerIP>0</connectionLimitPerIP>
-	</imapserver>
-	<imapserver enabled="true">
-		<jmxName>imapserver-ssl</jmxName>
-		<bind>0.0.0.0:1993</bind>
-		<connectionBacklog>200</connectionBacklog>
-		<tls socketTLS="true" startTLS="false">
-			<!-- To create a new keystore execute:
-              keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
-             -->
-			<keystore>file://conf/keystore</keystore>
-			<secret>james72laBalle</secret>
-			<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-		</tls>
-		<connectionLimit>0</connectionLimit>
-		<connectionLimitPerIP>0</connectionLimitPerIP>
-	</imapserver>
-</imapservers>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/james-database.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/james-database.properties b/server/container/guice/jpa-guice/sample-configuration/james-database.properties
deleted file mode 100644
index b3ac7eb..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/james-database.properties
+++ /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.
-
-#  This template file can be used as example for James Server configuration
-#  DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-
-# See http://james.apache.org/server/3/config.html for usage
-
-# Use derby as default
-database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
-database.url=jdbc:derby:../var/store/derby;create=true
-database.username=app
-database.password=app
-
-# Supported adapters are:
-# DB2, DERBY, H2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE 
-vendorAdapter.database=DERBY
-
-# Use streaming for Blobs
-# This is only supported on a limited set of databases atm. You should check if its supported by your DB before enable
-# it. 
-# 
-# See:
-# http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html  #7.11.  LOB Streaming 
-# 
-openjpa.streaming=false
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/jmx.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/jmx.properties b/server/container/guice/jpa-guice/sample-configuration/jmx.properties
deleted file mode 100644
index a1dbdf8..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/jmx.properties
+++ /dev/null
@@ -1,28 +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.
-#
-
-#  This template file can be used as example for James Server configuration
-#  DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-
-#  This template file can be used as example for James Server configuration
-#  DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-
-# See http://james.apache.org/server/3/config.html for usage
-
-jmx.address=127.0.0.1
-jmx.port=9999

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/lmtpserver.xml b/server/container/guice/jpa-guice/sample-configuration/lmtpserver.xml
deleted file mode 100644
index 87a0caa..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/lmtpserver.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<lmtpservers>
-
-    <lmtpserver enabled="false">
-        <jmxName>lmtpserver</jmxName>
-        <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
-        <bind>127.0.0.1:1024</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <connectiontimeout>1200</connectiontimeout>
-        <!-- Set the maximum simultaneous incoming connections for this service -->
-        <connectionLimit>0</connectionLimit>
-        <!-- Set the maximum simultaneous incoming connections per IP for this service -->
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <!--  This sets the maximum allowed message size (in kilobytes) for this -->
-        <!--  LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
-        <maxmessagesize>0</maxmessagesize>
-        <handlerchain>
-            <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </lmtpserver>
-
-</lmtpservers>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/mailetcontainer.xml b/server/container/guice/jpa-guice/sample-configuration/mailetcontainer.xml
deleted file mode 100644
index 968b59c..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/mailetcontainer.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailetcontainer enableJmx="true">
-
-    <context>
-        <postmaster>postmaster@james.minet.net</postmaster>
-    </context>
-
-    <spooler>
-        <threads>20</threads>
-    </spooler>
-
-    <processors>
-        <processor state="root" enableJmx="true">
-            <mailet match="All" class="PostmasterAlias"/>
-            <mailet match="RelayLimit=30" class="Null"/>
-            <!-- Hook on sievemanager@james.linagora.com
-                 Mail send to this address will get interpreted with SIEVE Manage -->
-            <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
-                <processor>sieve-manager-check</processor>
-            </mailet>
-            <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
-                <processor>transport</processor>
-            </mailet>
-            <mailet match="All" class="SetMailAttribute">
-                <spamChecked>true</spamChecked>
-            </mailet>
-            <mailet match="SMTPAuthSuccessful" class="ToProcessor">
-                <processor>transport</processor>
-            </mailet>
-            <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
-                <processor>transport</processor>
-            </mailet>
-            <!-- Check for delivery from a known spam server -->
-            <!-- This set of matchers/mailets redirect all emails from known -->
-            <!-- black holes, open relays, and spam servers to the spam processor -->
-            <!-- For this set to function properly, the spam processor must be configured. -->
-            <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
-                <processor>spam</processor>
-                <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
-            </mailet>
-            <mailet match="All" class="ToProcessor">
-                <processor>transport</processor>
-            </mailet>
-        </processor>
-
-        <processor state="error" enableJmx="true">
-            <mailet match="All" class="Bounce"/>
-            <mailet match="All" class="ToRepository">
-                <repositoryPath>file://var/mail/error/</repositoryPath>
-            </mailet>
-        </processor>
-
-
-        <processor state="transport" enableJmx="true">
-            <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
-                <name>X-UserIsAuth</name>
-                <value>true</value>
-            </mailet>
-            <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
-                <name>X-WasSigned</name>
-                <value>true</value>
-            </mailet>
-            <mailet match="All" class="RecipientRewriteTable" />
-            <mailet match="RecipientIsLocal" class="LocalDelivery"/>
-            <mailet match="HostIsLocal" class="ToProcessor">
-                <processor>local-address-error</processor>
-                <notice>550 - Requested action not taken: no such user here</notice>
-            </mailet>
-            <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
-                <outgoingQueue>outgoing</outgoingQueue>
-                <delayTime>5000, 100000, 500000</delayTime>
-                <maxRetries>25</maxRetries>
-                <maxDnsProblemRetries>0</maxDnsProblemRetries>
-                <deliveryThreads>10</deliveryThreads>
-                <sendpartial>true</sendpartial>
-                <bounceProcessor>bounces</bounceProcessor>
-            </mailet>
-            <mailet match="All" class="ToProcessor">
-                <processor>relay-denied</processor>
-            </mailet>
-        </processor>
-
-        <processor state="spam" enableJmx="true">
-            <mailet match="All" class="ToRepository">
-                <repositoryPath>file://var/mail/spam/</repositoryPath>
-            </mailet>
-        </processor>
-
-        <processor state="local-address-error" enableJmx="true">
-            <mailet match="All" class="Bounce">
-                <attachment>none</attachment>
-            </mailet>
-            <mailet match="All" class="ToRepository">
-                <repositoryPath>file://var/mail/address-error/</repositoryPath>
-            </mailet>
-        </processor>
-
-        <processor state="relay-denied" enableJmx="true">
-            <mailet match="All" class="Bounce">
-                <attachment>none</attachment>
-            </mailet>
-            <mailet match="All" class="ToRepository">
-                <repositoryPath>file://var/mail/relay-denied/</repositoryPath>
-                <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
-            </mailet>
-        </processor>
-
-        <processor state="bounces" enableJmx="true">
-            <mailet match="All" class="DSNBounce">
-                <passThrough>false</passThrough>
-            </mailet>
-        </processor>
-    </processors>
-
-</mailetcontainer>
-
-

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/mailrepositorystore.xml b/server/container/guice/jpa-guice/sample-configuration/mailrepositorystore.xml
deleted file mode 100644
index acca810..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/mailrepositorystore.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailrepositorystore>
-    <mailrepositories>
-        <!-- File based repositories.  These repositories store all message data -->
-        <!-- in the file system. -->
-        <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
-            <protocols>
-                <protocol>file</protocol>
-            </protocols>
-            <!-- Set if the messages should be listed sorted. False by default -->
-            <config FIFO="false" CACHEKEYS="true"/>
-        </mailrepository>
-    </mailrepositories>
-</mailrepositorystore>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/pop3server.xml b/server/container/guice/jpa-guice/sample-configuration/pop3server.xml
deleted file mode 100644
index c57c832..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/pop3server.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-
-<pop3servers>
-    <pop3server enabled="false">
-        <jmxName>pop3server</jmxName>
-        <bind>0.0.0.0:1110</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <tls socketTLS="false" startTLS="false">
-            <!-- To create a new keystore execute:
-                  keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
-             -->
-            <keystore>file://conf/keystore</keystore>
-            <secret>james72laBalle</secret>
-            <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-        </tls>
-        <connectiontimeout>1200</connectiontimeout>
-        <connectionLimit>0</connectionLimit>
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <handlerchain>
-            <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </pop3server>
-</pop3servers>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/recipientrewritetable.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/recipientrewritetable.xml b/server/container/guice/jpa-guice/sample-configuration/recipientrewritetable.xml
deleted file mode 100644
index 7e7f586..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/recipientrewritetable.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<!-- The default table for storing James' RecipientRewriteTable mappings. -->
-<recipientrewritetable class="org.apache.james.rrt.jpa.JPARecipientRewriteTable">
-  <recursiveMapping>true</recursiveMapping>
-  <mappingLimit>10</mappingLimit>
-  <mapping>some@domain=some</mapping>
-</recipientrewritetable>
-

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/smtpserver.xml b/server/container/guice/jpa-guice/sample-configuration/smtpserver.xml
deleted file mode 100644
index c34fcd1..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/smtpserver.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?xml version="1.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.
- -->
-
-<smtpservers>
-    <smtpserver enabled="true">
-        <jmxName>smtpserver-global</jmxName>
-        <bind>0.0.0.0:1025</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <tls socketTLS="false" startTLS="false">
-            <keystore>file://conf/keystore</keystore>
-            <secret>james72laBalle</secret>
-            <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-            <algorithm>SunX509</algorithm>
-        </tls>
-        <connectiontimeout>360</connectiontimeout>
-        <connectionLimit>0</connectionLimit>
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <authRequired>false</authRequired>
-        <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
-        <verifyIdentity>true</verifyIdentity>
-        <maxmessagesize>0</maxmessagesize>
-        <addressBracketsEnforcement>true</addressBracketsEnforcement>
-        <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
-        <handlerchain>
-            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </smtpserver>
-    <smtpserver enabled="true">
-        <jmxName>smtpserver-TLS</jmxName>
-        <bind>0.0.0.0:1465</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <tls socketTLS="true" startTLS="false">
-            <keystore>file://conf/keystore</keystore>
-            <secret>james72laBalle</secret>
-            <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-            <algorithm>SunX509</algorithm>
-        </tls>
-        <connectiontimeout>360</connectiontimeout>
-        <connectionLimit>0</connectionLimit>
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <!--
-           Authorize only local users
-        -->
-        <authRequired>true</authRequired>
-        <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
-        <!-- Trust authenticated users -->
-        <verifyIdentity>false</verifyIdentity>
-        <maxmessagesize>0</maxmessagesize>
-        <addressBracketsEnforcement>true</addressBracketsEnforcement>
-        <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
-        <handlerchain>
-            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </smtpserver>
-    <smtpserver enabled="true">
-        <jmxName>smtpserver-authenticated</jmxName>
-        <bind>0.0.0.0:1587</bind>
-        <connectionBacklog>200</connectionBacklog>
-        <tls socketTLS="false" startTLS="true">
-            <keystore>file://conf/keystore</keystore>
-            <secret>james72laBalle</secret>
-            <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-            <algorithm>SunX509</algorithm>
-        </tls>
-        <connectiontimeout>360</connectiontimeout>
-        <connectionLimit>0</connectionLimit>
-        <connectionLimitPerIP>0</connectionLimitPerIP>
-        <!--
-           Authorize only local users
-        -->
-        <authRequired>true</authRequired>
-        <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
-        <!-- Trust authenticated users -->
-        <verifyIdentity>false</verifyIdentity>
-        <maxmessagesize>0</maxmessagesize>
-        <addressBracketsEnforcement>true</addressBracketsEnforcement>
-        <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
-        <handlerchain>
-            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
-        </handlerchain>
-    </smtpserver>
-</smtpservers>
-
-

http://git-wip-us.apache.org/repos/asf/james-project/blob/a615668c/server/container/guice/jpa-guice/sample-configuration/usersrepository.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/sample-configuration/usersrepository.xml b/server/container/guice/jpa-guice/sample-configuration/usersrepository.xml
deleted file mode 100644
index fc76107..0000000
--- a/server/container/guice/jpa-guice/sample-configuration/usersrepository.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.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.                                           
- -->
-
-<usersrepository name="LocalUsers" class="org.apache.james.user.jpa.JPAUsersRepository">
-    <destination URL="file://users/"/>
-    <algorithm>MD5</algorithm>
-    <enableVirtualHosting>true</enableVirtualHosting>
-    <enableForwarding>true</enableForwarding>
-</usersrepository>
-


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