Repository: james-project
Updated Branches:
  refs/heads/master 396d68490 -> dec2685fa


JAMES-2291 Introduce table for Cassandra Mail Repository


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

Branch: refs/heads/master
Commit: 5a983ca9d91a93b18ef8dd717955bae5bdad6d66
Parents: a7aad0b
Author: Raphael Ouazana <[email protected]>
Authored: Tue Jan 23 17:39:05 2018 +0100
Committer: benwa <[email protected]>
Committed: Thu Jan 25 12:02:53 2018 +0700

----------------------------------------------------------------------
 .../mailrepository-cassandra/pom.xml            | 10 +++
 .../CassandraMailRepositoryModule.java          | 94 ++++++++++++++++++++
 .../cassandra/MailRepositoryTable.java          | 51 +++++++++++
 3 files changed, 155 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5a983ca9/server/mailrepository/mailrepository-cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-cassandra/pom.xml 
b/server/mailrepository/mailrepository-cassandra/pom.xml
index 9a6d5ac..4c4ef0f 100644
--- a/server/mailrepository/mailrepository-cassandra/pom.xml
+++ b/server/mailrepository/mailrepository-cassandra/pom.xml
@@ -35,6 +35,16 @@
     <dependencies>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>apache-james-backends-cassandra</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>apache-james-backends-cassandra</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>james-server-core</artifactId>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/5a983ca9/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryModule.java
----------------------------------------------------------------------
diff --git 
a/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryModule.java
 
b/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryModule.java
new file mode 100644
index 0000000..4369db0
--- /dev/null
+++ 
b/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryModule.java
@@ -0,0 +1,94 @@
+/****************************************************************
+ * 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.mailrepository.cassandra;
+
+import static com.datastax.driver.core.DataType.bigint;
+import static com.datastax.driver.core.DataType.blob;
+import static com.datastax.driver.core.DataType.counter;
+import static com.datastax.driver.core.DataType.list;
+import static com.datastax.driver.core.DataType.map;
+import static com.datastax.driver.core.DataType.text;
+import static com.datastax.driver.core.DataType.timestamp;
+import static com.datastax.driver.core.schemabuilder.SchemaBuilder.frozen;
+
+import java.util.List;
+
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.backends.cassandra.components.CassandraTable;
+import org.apache.james.backends.cassandra.components.CassandraType;
+
+import com.datastax.driver.core.schemabuilder.SchemaBuilder;
+import com.google.common.collect.ImmutableList;
+
+public class CassandraMailRepositoryModule implements CassandraModule {
+
+    private final List<CassandraTable> tables;
+    private final List<CassandraType> types;
+
+    public CassandraMailRepositoryModule() {
+        tables = ImmutableList.of(
+            new CassandraTable(MailRepositoryTable.COUNT_TABLE,
+                SchemaBuilder.createTable(MailRepositoryTable.COUNT_TABLE)
+                    .ifNotExists()
+                    .addPartitionKey(MailRepositoryTable.REPOSITORY_NAME, 
text())
+                    .addColumn(MailRepositoryTable.COUNT, counter())),
+            new CassandraTable(MailRepositoryTable.KEYS_TABLE_NAME,
+                SchemaBuilder.createTable(MailRepositoryTable.KEYS_TABLE_NAME)
+                    .ifNotExists()
+                    .addPartitionKey(MailRepositoryTable.REPOSITORY_NAME, 
text())
+                    .addClusteringColumn(MailRepositoryTable.MAIL_KEY, 
text())),
+            new CassandraTable(MailRepositoryTable.CONTENT_TABLE_NAME,
+                
SchemaBuilder.createTable(MailRepositoryTable.CONTENT_TABLE_NAME)
+                    .ifNotExists()
+                    .addPartitionKey(MailRepositoryTable.REPOSITORY_NAME, 
text())
+                    .addPartitionKey(MailRepositoryTable.MAIL_KEY, text())
+                    .addColumn(MailRepositoryTable.MESSAGE_SIZE, bigint())
+                    .addColumn(MailRepositoryTable.STATE, text())
+                    .addColumn(MailRepositoryTable.HEADER_BLOB_ID, text())
+                    .addColumn(MailRepositoryTable.BODY_BLOB_ID, text())
+                    .addColumn(MailRepositoryTable.ATTRIBUTES, map(text(), 
blob()))
+                    .addColumn(MailRepositoryTable.ERROR_MESSAGE, text())
+                    .addColumn(MailRepositoryTable.SENDER, text())
+                    .addColumn(MailRepositoryTable.RECIPIENTS, list(text()))
+                    .addColumn(MailRepositoryTable.REMOTE_HOST, text())
+                    .addColumn(MailRepositoryTable.REMOTE_ADDR, text())
+                    .addColumn(MailRepositoryTable.LAST_UPDATED, timestamp())
+                    
.addUDTMapColumn(MailRepositoryTable.PER_RECIPIENT_SPECIFIC_HEADERS, text(), 
frozen(MailRepositoryTable.HEADER_TYPE))
+                    .withOptions()
+                    .comment("Stores the mails for a given repository. " +
+                        "Content is stored with other blobs")));
+        types = ImmutableList.of(
+            new CassandraType(MailRepositoryTable.HEADER_TYPE,
+                SchemaBuilder.createType(MailRepositoryTable.HEADER_TYPE)
+                    .ifNotExists()
+                    .addColumn(MailRepositoryTable.HEADER_NAME, text())
+                    .addColumn(MailRepositoryTable.HEADER_VALUE, text())));
+    }
+
+    @Override
+    public List<CassandraTable> moduleTables() {
+        return tables;
+    }
+
+    @Override
+    public List<CassandraType> moduleTypes() {
+        return types;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/5a983ca9/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/MailRepositoryTable.java
----------------------------------------------------------------------
diff --git 
a/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/MailRepositoryTable.java
 
b/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/MailRepositoryTable.java
new file mode 100644
index 0000000..6b48074
--- /dev/null
+++ 
b/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/MailRepositoryTable.java
@@ -0,0 +1,51 @@
+/****************************************************************
+ * 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.mailrepository.cassandra;
+
+public interface MailRepositoryTable {
+    String KEYS_TABLE_NAME = "mailRepositoryKeys";
+    String CONTENT_TABLE_NAME = "mailRepositoryContent";
+    String COUNT_TABLE = "mailRepositoryCount";
+
+    String REPOSITORY_NAME = "name";
+
+    String MAIL_KEY = "mailKey";
+    String MESSAGE_SIZE = "messageSize";
+    String HEADER_BLOB_ID = "headerBlobId";
+    String BODY_BLOB_ID = "bodyBlobId";
+    String STATE = "state";
+    String SENDER = "sender";
+    String RECIPIENTS = "recipients";
+    String ATTRIBUTES = "attributes";
+    String ERROR_MESSAGE = "errorMessage";
+    String REMOTE_HOST = "remoteHost";
+    String REMOTE_ADDR = "remoteAddr";
+    String LAST_UPDATED = "lastUpdated";
+    String PER_RECIPIENT_SPECIFIC_HEADERS = "perRecipientSpecificHeaders";
+
+    String[] MAIL_PROPERTIES = { MAIL_KEY, MESSAGE_SIZE, STATE, SENDER, 
RECIPIENTS, ATTRIBUTES, ERROR_MESSAGE, REMOTE_ADDR,
+        REMOTE_HOST, LAST_UPDATED, PER_RECIPIENT_SPECIFIC_HEADERS, 
HEADER_BLOB_ID, BODY_BLOB_ID };
+
+    String COUNT = "count";
+
+    String HEADER_TYPE = "header";
+    String HEADER_NAME = "headerName";
+    String HEADER_VALUE = "headerValue";
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to