james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1688161 - in /james/mpt/trunk: ./ impl/imap-mailbox/ impl/imap-mailbox/elasticsearch/ impl/imap-mailbox/elasticsearch/src/ impl/imap-mailbox/elasticsearch/src/test/ impl/imap-mailbox/elasticsearch/src/test/java/ impl/imap-mailbox/elasticse...
Date Mon, 29 Jun 2015 08:57:56 GMT
Author: btellier
Date: Mon Jun 29 08:57:55 2015
New Revision: 1688161

URL: http://svn.apache.org/r1688161
Log:
MAILBOX-155 Creating ElasticSearch module for MPT

Added:
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/ElasticSearchMailboxTestModule.java
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
Modified:
    james/mpt/trunk/impl/imap-mailbox/elasticsearch/pom.xml
    james/mpt/trunk/impl/imap-mailbox/jcr/pom.xml
    james/mpt/trunk/impl/imap-mailbox/pom.xml
    james/mpt/trunk/pom.xml

Modified: james/mpt/trunk/impl/imap-mailbox/elasticsearch/pom.xml
URL: http://svn.apache.org/viewvc/james/mpt/trunk/impl/imap-mailbox/elasticsearch/pom.xml?rev=1688161&r1=1688160&r2=1688161&view=diff
==============================================================================
--- james/mpt/trunk/impl/imap-mailbox/elasticsearch/pom.xml (original)
+++ james/mpt/trunk/impl/imap-mailbox/elasticsearch/pom.xml Mon Jun 29 08:57:55 2015
@@ -53,10 +53,156 @@
             <artifactId>apache-james-mailbox-store</artifactId>
         </dependency>
         <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.james</groupId>
             <artifactId>apache-james-mpt-imapmailbox-core</artifactId>
         </dependency>
     </dependencies>
 
-
+    <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>
+            <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>disable-animal-sniffer</id>
+            <activation>
+                <jdk>[1.6,)</jdk>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>animal-sniffer-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>check_java_6</id>
+                                <phase>none</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>
\ No newline at end of file

Added: james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/ElasticSearchMailboxTestModule.java
URL: http://svn.apache.org/viewvc/james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/ElasticSearchMailboxTestModule.java?rev=1688161&view=auto
==============================================================================
--- james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/ElasticSearchMailboxTestModule.java
(added)
+++ james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/ElasticSearchMailboxTestModule.java
Mon Jun 29 08:57:55 2015
@@ -0,0 +1,33 @@
+/****************************************************************
+ * 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.mpt.imapmailbox.elasticsearch;
+
+import com.google.inject.AbstractModule;
+import org.apache.james.mpt.api.HostSystem;
+import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.elasticsearch.host.ElasticSearchHostSystem;
+
+public class ElasticSearchMailboxTestModule extends AbstractModule {
+    @Override
+    protected void configure() {
+        bind(ImapHostSystem.class).to(ElasticSearchHostSystem.class);
+        bind(HostSystem.class).to(ElasticSearchHostSystem.class);
+    }
+}

Added: james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
URL: http://svn.apache.org/viewvc/james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java?rev=1688161&view=auto
==============================================================================
--- james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
(added)
+++ james/mpt/trunk/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
Mon Jun 29 08:57:55 2015
@@ -0,0 +1,129 @@
+/****************************************************************
+ * 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.mpt.imapmailbox.elasticsearch.host;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
+import org.apache.james.imap.main.DefaultImapDecoderFactory;
+import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
+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.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.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.exception.MailboxException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.MockAuthenticator;
+import org.apache.james.mailbox.store.StoreMailboxManager;
+import org.apache.james.mailbox.store.StoreSubscriptionManager;
+import org.apache.james.mpt.host.JamesImapHostSystem;
+import org.apache.james.mpt.imapmailbox.MailboxCreationDelegate;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+
+public class ElasticSearchHostSystem extends JamesImapHostSystem {
+
+    private EmbeddedElasticSearch embeddedElasticSearch;
+    private Path tempDirectory;
+    private StoreMailboxManager<InMemoryId> mailboxManager;
+    private MockAuthenticator userManager;
+
+    @Inject
+    public ElasticSearchHostSystem() throws Throwable {
+        this.tempDirectory = Files.createTempDirectory("elasticsearch");
+        this.embeddedElasticSearch = new EmbeddedElasticSearch(tempDirectory);
+        embeddedElasticSearch.before();
+        initFields();
+    }
+
+    public EmbeddedElasticSearch getEmbeddedElasticSearch() {
+        return embeddedElasticSearch;
+    }
+
+    public boolean addUser(String user, String password) throws Exception {
+        userManager.addUser(user, password);
+        return true;
+    }
+
+    @Override
+    protected void resetData() throws Exception {
+        embeddedElasticSearch.after();
+        FileUtils.deleteDirectory(tempDirectory.toFile());
+        this.embeddedElasticSearch = new EmbeddedElasticSearch(tempDirectory);
+        this.tempDirectory = Files.createTempDirectory("elasticsearch");
+        embeddedElasticSearch.before();
+        initFields();
+    }
+
+    private void initFields() {
+        NodeMappingFactory.applyMapping(
+            IndexCreationFactory.createIndex(embeddedElasticSearch.getNode())
+        );
+
+        userManager = new MockAuthenticator();
+        InMemoryMailboxSessionMapperFactory factory = new InMemoryMailboxSessionMapperFactory();
+
+        ElasticSearchListeningMessageSearchIndex<InMemoryId> searchIndex = new ElasticSearchListeningMessageSearchIndex<>(
+            factory,
+            new ElasticSearchIndexer(embeddedElasticSearch.getNode()),
+            new ElasticSearchSearcher<InMemoryId>(embeddedElasticSearch.getNode(),
new QueryConverter(new CriterionConverter())),
+            new MessageToElasticSearchJson());
+
+        MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
+        GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
+
+        mailboxManager = new StoreMailboxManager<InMemoryId>(factory, userManager,
aclResolver, groupMembershipResolver);
+        mailboxManager.setMessageSearchIndex(searchIndex);
+
+        try {
+            mailboxManager.init();
+        } catch (MailboxException e) {
+            throw Throwables.propagate(e);
+        }
+
+        final ImapProcessor defaultImapProcessorFactory = DefaultImapProcessorFactory.createDefaultProcessor(mailboxManager,
new StoreSubscriptionManager(factory));
+        configure(new DefaultImapDecoderFactory().buildImapDecoder(),
+            new DefaultImapEncoderFactory().buildImapEncoder(),
+            defaultImapProcessorFactory);
+
+        embeddedElasticSearch.awaitForElasticSearch();
+    }
+
+    @Override
+    public void createMailbox(MailboxPath mailboxPath) throws Exception{
+        new MailboxCreationDelegate(mailboxManager).createMailbox(mailboxPath);
+    }
+
+}

Modified: james/mpt/trunk/impl/imap-mailbox/jcr/pom.xml
URL: http://svn.apache.org/viewvc/james/mpt/trunk/impl/imap-mailbox/jcr/pom.xml?rev=1688161&r1=1688160&r2=1688161&view=diff
==============================================================================
--- james/mpt/trunk/impl/imap-mailbox/jcr/pom.xml (original)
+++ james/mpt/trunk/impl/imap-mailbox/jcr/pom.xml Mon Jun 29 08:57:55 2015
@@ -43,9 +43,11 @@
             <artifactId>apache-james-mailbox-jcr</artifactId>
             <scope>test</scope>
         </dependency>
+        <!-- Use lucene 2.4.1 for now to let jcr tests pass -->
         <dependency>
             <groupId>org.apache.lucene</groupId>
             <artifactId>lucene-core</artifactId>
+            <version>${lucene-core.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>

Modified: james/mpt/trunk/impl/imap-mailbox/pom.xml
URL: http://svn.apache.org/viewvc/james/mpt/trunk/impl/imap-mailbox/pom.xml?rev=1688161&r1=1688160&r2=1688161&view=diff
==============================================================================
--- james/mpt/trunk/impl/imap-mailbox/pom.xml (original)
+++ james/mpt/trunk/impl/imap-mailbox/pom.xml Mon Jun 29 08:57:55 2015
@@ -38,13 +38,13 @@
     <modules>
         <module>core</module>
         <module>cassandra</module>
+        <module>elasticsearch</module>
         <module>hbase</module>
         <module>inmemory</module>
         <module>jcr</module>
         <module>jpa</module>
         <module>maildir</module>
         <module>cyrus</module>
-        <module>elasticsearch</module>
     </modules>
     
     <dependencyManagement>

Modified: james/mpt/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/mpt/trunk/pom.xml?rev=1688161&r1=1688160&r2=1688161&view=diff
==============================================================================
--- james/mpt/trunk/pom.xml (original)
+++ james/mpt/trunk/pom.xml Mon Jun 29 08:57:55 2015
@@ -309,12 +309,6 @@
                 <type>test-jar</type>
                 <version>${hbase.version}</version>
             </dependency>
-            <!-- Use lucene 2.4.1 for now to let jcr tests pass -->
-            <dependency>
-                <groupId>org.apache.lucene</groupId>
-                <artifactId>lucene-core</artifactId>
-                <version>${lucene-core.version}</version>
-            </dependency>
             <dependency>
                 <groupId>com.google.inject</groupId>
                 <artifactId>guice</artifactId>



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


Mime
View raw message