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 ad...@apache.org on 2019/07/04 08:33:28 UTC
[james-project] branch master updated (9d244d5 -> aec776e)
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.
from 9d244d5 JAMES-2813 small fixes on TaskManagerContract
new 7257bc8 JAMES-2806 add deleteBucket method in BlobStore
new 53d3ed7 JAMES-2806 implement buckets with memory BlobStore
new 2672ea9 JAMES-2806 add contract for BlobStore with custom buckets
new 1a7e058 JAMES-2806 Add deleteBucket implementation for memory and its contract
new 6ec43fb JAMES-2806 add a metric for deleteBucket method and test in its contract
new 2a2af71 JAMES-2806 add tests for deleteBucket with UnionBlobStore
new 40292be Merge remote-tracking branch 'rcordier/james-2806-bucket-name-memory'
new 9ebaa14 JAMES-2807 Create POJOs for DeletedMessageMetadataVault API
new c7177df JAMES-2807 DeletedMessageMetadataVault API and memory skeleton
new 5063bfc JAMES-2807 Implement Memory DeletedMessageMetadataVault and related contract
new 092e127 JAMES-2807 Simplify maven structure for the vault
new e7b5683 JAMES-2807 Make it clear that DeletedMessageMetadataVault do not actually store buckets
new aec776e Merge remote-tracking branch 'btellier/JAMES-2807'
The 13 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
mailbox/plugin/deleted-messages-vault/pom.xml | 4 +
.../MemoryDeletedMessageMetadataVault.java | 115 ++++++++++++
.../DeletedMessageMetadataVault.java} | 21 +--
.../DeletedMessageWithStorageInformation.java} | 51 +++---
.../james/vault/metadata/StorageInformation.java | 44 ++---
.../MemoryDeletedMessageMetadataVaultTest.java | 19 +-
.../DeletedMessageMetadataVaultContract.java | 199 +++++++++++++++++++++
.../DeletedMessageVaultMetadataFixture.java | 23 +--
.../DeletedMessageWithStorageInformationTest.java | 24 ++-
.../vault/metadata/StorageInformationTest.java | 30 ++--
mailbox/pom.xml | 3 +
.../java/org/apache/james/blob/api/BlobStore.java | 2 +
.../apache/james/blob/api/MetricableBlobStore.java | 7 +
.../james/blob/api/BucketBlobStoreContract.java | 142 +++++++++++++++
.../blob/api/MetricableBlobStoreContract.java | 14 ++
.../james/blob/cassandra/CassandraBlobsDAO.java | 6 +
.../blob/cassandra/CassandraBlobsDAOTest.java | 7 +
.../apache/james/blob/memory/MemoryBlobStore.java | 44 +++--
.../james/blob/memory/MemoryBlobStoreTest.java | 3 +-
.../blob/objectstorage/ObjectStorageBlobsDAO.java | 6 +
.../objectstorage/ObjectStorageBlobsDAOTest.java | 7 +
.../apache/james/blob/union/UnionBlobStore.java | 7 +
.../james/blob/union/UnionBlobStoreTest.java | 49 +++++
23 files changed, 692 insertions(+), 135 deletions(-)
create mode 100644 mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVault.java
copy mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/{DeletedMessageVault.java => metadata/DeletedMessageMetadataVault.java} (68%)
copy mailbox/plugin/{quota-search/src/main/java/org/apache/james/quota/search/Limit.java => deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageWithStorageInformation.java} (56%)
copy server/data/data-library/src/main/java/org/apache/james/dlp/eventsourcing/commands/ClearCommand.java => mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/StorageInformation.java (62%)
copy server/mailrepository/mailrepository-memory/src/test/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryTest.java => mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVaultTest.java (68%)
create mode 100644 mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageMetadataVaultContract.java
copy server/container/guice/blob-memory-guice/src/main/java/org/apache/james/modules/BlobMemoryModule.java => mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageVaultMetadataFixture.java (69%)
copy server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/impl/DefineRulesCommandTest.java => mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageWithStorageInformationTest.java (67%)
copy mailet/api/src/test/java/org/apache/mailet/AttributeNameTest.java => mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/StorageInformationTest.java (70%)
create mode 100644 server/blob/blob-api/src/test/java/org/apache/james/blob/api/BucketBlobStoreContract.java
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 10/13: JAMES-2807 Simplify maven structure for the
vault
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 092e127f8f324b1f51bce87b58882856c517227b
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jul 1 14:17:53 2019 +0700
JAMES-2807 Simplify maven structure for the vault
Define the metadata storage API within the vault API.
As the memory implementation is shipped as part of the vault API, include
the memory implementation for metadata storage there too.
---
.../pom.xml | 87 ----------------------
.../deleted-messages-vault-blobstore/pom.xml | 86 ---------------------
mailbox/plugin/deleted-messages-vault/pom.xml | 4 +
.../MemoryDeletedMessageMetadataVault.java | 5 +-
.../metadata}/DeletedMessageMetadataVault.java | 2 +-
.../DeletedMessageWithStorageInformation.java | 4 +-
.../james/vault/metadata}/StorageInformation.java | 2 +-
.../MemoryDeletedMessageMetadataVaultTest.java | 4 +-
.../DeletedMessageMetadataVaultContract.java | 9 ++-
.../DeletedMessageVaultMetadataFixture.java | 2 +-
.../DeletedMessageWithStorageInformationTest.java | 5 +-
.../vault/metadata}/StorageInformationTest.java | 6 +-
mailbox/pom.xml | 2 -
pom.xml | 11 ---
14 files changed, 28 insertions(+), 201 deletions(-)
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml b/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml
deleted file mode 100644
index faf54ee..0000000
--- a/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>apache-james-mailbox</artifactId>
- <groupId>org.apache.james</groupId>
- <version>3.4.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore-memory</artifactId>
- <name>Apache James :: Mailbox :: Plugin :: Deleted Messages Vault :: BlobStore :: Memory</name>
- <description>Memory implementation of the metadata storage API required by the Deleted Messages Vault implementation on top of BlobStore</description>
-
- <dependencies>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-api</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-deleted-messages-vault</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-memory</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-memory</artifactId>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.platform</groupId>
- <artifactId>junit-platform-launcher</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/pom.xml b/mailbox/plugin/deleted-messages-vault-blobstore/pom.xml
deleted file mode 100644
index 5575f57..0000000
--- a/mailbox/plugin/deleted-messages-vault-blobstore/pom.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<?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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>apache-james-mailbox</artifactId>
- <groupId>org.apache.james</groupId>
- <version>3.4.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
- <name>Apache James :: Mailbox :: Plugin :: Deleted Messages Vault :: BlobStore</name>
- <description>Apache James Mailbox Deleted Messages Vault implementation on top of BlobStore</description>
-
- <dependencies>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-api</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-deleted-messages-vault</artifactId>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-deleted-messages-vault</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-memory</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-memory</artifactId>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>blob-api</artifactId>
- </dependency>
- <dependency>
- <groupId>nl.jqno.equalsverifier</groupId>
- <artifactId>equalsverifier</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.platform</groupId>
- <artifactId>junit-platform-launcher</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/mailbox/plugin/deleted-messages-vault/pom.xml b/mailbox/plugin/deleted-messages-vault/pom.xml
index b8f44b7..f7bff9c 100644
--- a/mailbox/plugin/deleted-messages-vault/pom.xml
+++ b/mailbox/plugin/deleted-messages-vault/pom.xml
@@ -78,6 +78,10 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>blob-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>james-server-core</artifactId>
</dependency>
<dependency>
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVault.java
similarity index 94%
rename from mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java
rename to mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVault.java
index 4bafe68..ccf5fc6 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java
+++ b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVault.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.vault;
+package org.apache.james.vault.memory.metadata;
import java.util.HashMap;
import java.util.Map;
@@ -26,6 +26,9 @@ import java.util.Optional;
import org.apache.james.blob.api.BucketName;
import org.apache.james.core.User;
import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.vault.metadata.DeletedMessageMetadataVault;
+import org.apache.james.vault.metadata.DeletedMessageWithStorageInformation;
+import org.apache.james.vault.metadata.StorageInformation;
import org.reactivestreams.Publisher;
import com.google.common.collect.HashBasedTable;
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageMetadataVault.java b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageMetadataVault.java
similarity index 97%
rename from mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageMetadataVault.java
rename to mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageMetadataVault.java
index 809a34b..25b5a4a 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageMetadataVault.java
+++ b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageMetadataVault.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.vault;
+package org.apache.james.vault.metadata;
import org.apache.james.blob.api.BucketName;
import org.apache.james.core.User;
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageWithStorageInformation.java
similarity index 96%
rename from mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java
rename to mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageWithStorageInformation.java
index 1c17a38..0859431 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java
+++ b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageWithStorageInformation.java
@@ -17,10 +17,12 @@
* under the License. *
****************************************************************/
-package org.apache.james.vault;
+package org.apache.james.vault.metadata;
import java.util.Objects;
+import org.apache.james.vault.DeletedMessage;
+
import com.google.common.base.Preconditions;
public class DeletedMessageWithStorageInformation {
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/StorageInformation.java b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/StorageInformation.java
similarity index 98%
rename from mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/StorageInformation.java
rename to mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/StorageInformation.java
index 4ebc6ca..7933789 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/StorageInformation.java
+++ b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/StorageInformation.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.vault;
+package org.apache.james.vault.metadata;
import java.util.Objects;
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/test/java/org/apache/james/vault/MemoryDeletedMessageMetadataVaultTest.java b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVaultTest.java
similarity index 89%
rename from mailbox/plugin/deleted-messages-vault-blobstore-memory/src/test/java/org/apache/james/vault/MemoryDeletedMessageMetadataVaultTest.java
rename to mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVaultTest.java
index 5a5cb5a..0176b26 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/test/java/org/apache/james/vault/MemoryDeletedMessageMetadataVaultTest.java
+++ b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVaultTest.java
@@ -17,8 +17,10 @@
* under the License. *
****************************************************************/
-package org.apache.james.vault;
+package org.apache.james.vault.memory.metadata;
+import org.apache.james.vault.metadata.DeletedMessageMetadataVault;
+import org.apache.james.vault.metadata.DeletedMessageMetadataVaultContract;
import org.junit.jupiter.api.BeforeEach;
public class MemoryDeletedMessageMetadataVaultTest implements DeletedMessageMetadataVaultContract {
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageMetadataVaultContract.java b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageMetadataVaultContract.java
similarity index 95%
rename from mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageMetadataVaultContract.java
rename to mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageMetadataVaultContract.java
index 714c911..3b85bc5 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageMetadataVaultContract.java
+++ b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageMetadataVaultContract.java
@@ -17,12 +17,12 @@
* under the License. *
****************************************************************/
-package org.apache.james.vault;
+package org.apache.james.vault.metadata;
import static org.apache.james.vault.DeletedMessageFixture.USER;
-import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.BLOB_ID_2;
-import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.BUCKET_NAME;
-import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.STORAGE_INFORMATION;
+import static org.apache.james.vault.metadata.DeletedMessageVaultMetadataFixture.BLOB_ID_2;
+import static org.apache.james.vault.metadata.DeletedMessageVaultMetadataFixture.BUCKET_NAME;
+import static org.apache.james.vault.metadata.DeletedMessageVaultMetadataFixture.STORAGE_INFORMATION;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
@@ -30,6 +30,7 @@ import java.util.Optional;
import java.util.stream.Stream;
import org.apache.james.blob.api.BucketName;
+import org.apache.james.vault.DeletedMessageFixture;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageVaultMetadataFixture.java
similarity index 97%
rename from mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java
rename to mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageVaultMetadataFixture.java
index 8bc4ec4..684f929 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java
+++ b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageVaultMetadataFixture.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.vault;
+package org.apache.james.vault.metadata;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BucketName;
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageWithStorageInformationTest.java b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageWithStorageInformationTest.java
similarity index 91%
rename from mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageWithStorageInformationTest.java
rename to mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageWithStorageInformationTest.java
index a79a67f..d5415f0 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageWithStorageInformationTest.java
+++ b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageWithStorageInformationTest.java
@@ -17,11 +17,12 @@
* under the License. *
****************************************************************/
-package org.apache.james.vault;
+package org.apache.james.vault.metadata;
-import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.STORAGE_INFORMATION;
+import static org.apache.james.vault.metadata.DeletedMessageVaultMetadataFixture.STORAGE_INFORMATION;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import org.apache.james.vault.DeletedMessageFixture;
import org.junit.jupiter.api.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/StorageInformationTest.java b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/StorageInformationTest.java
similarity index 89%
rename from mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/StorageInformationTest.java
rename to mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/StorageInformationTest.java
index b55cf55..6642ab8 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/StorageInformationTest.java
+++ b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/StorageInformationTest.java
@@ -17,10 +17,10 @@
* under the License. *
****************************************************************/
-package org.apache.james.vault;
+package org.apache.james.vault.metadata;
-import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.BLOB_ID;
-import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.BUCKET_NAME;
+import static org.apache.james.vault.metadata.DeletedMessageVaultMetadataFixture.BLOB_ID;
+import static org.apache.james.vault.metadata.DeletedMessageVaultMetadataFixture.BUCKET_NAME;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.jupiter.api.Test;
diff --git a/mailbox/pom.xml b/mailbox/pom.xml
index ef22a91..ce5ecca 100644
--- a/mailbox/pom.xml
+++ b/mailbox/pom.xml
@@ -52,8 +52,6 @@
<module>memory</module>
<module>plugin/deleted-messages-vault</module>
- <module>plugin/deleted-messages-vault-blobstore</module>
- <module>plugin/deleted-messages-vault-blobstore-memory</module>
<module>plugin/quota-mailing</module>
<module>plugin/quota-mailing-cassandra</module>
diff --git a/pom.xml b/pom.xml
index de07d51..52b56ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -775,17 +775,6 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
- <type>test-jar</type>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
<artifactId>apache-james-mailbox-elasticsearch</artifactId>
<version>${project.version}</version>
</dependency>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 09/13: JAMES-2807 Implement Memory
DeletedMessageMetadataVault and related contract
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 5063bfca0d28010a508fa7b132a0b6b4b199ab7d
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Jun 25 14:14:26 2019 +0700
JAMES-2807 Implement Memory DeletedMessageMetadataVault and related contract
---
.../pom.xml | 51 +++++-
.../vault/MemoryDeletedMessageMetadataVault.java | 68 ++++++-
.../MemoryDeletedMessageMetadataVaultTest.java} | 22 ++-
.../DeletedMessageWithStorageInformation.java | 16 +-
.../vault/DeletedMessageMetadataVaultContract.java | 198 +++++++++++++++++++++
.../vault/DeletedMessageVaultMetadataFixture.java | 1 +
6 files changed, 331 insertions(+), 25 deletions(-)
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml b/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml
index d5ae54e..faf54ee 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml
+++ b/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml
@@ -31,10 +31,57 @@
<dependencies>
<dependency>
- <groupId>org.apache.james</groupId>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-deleted-messages-vault</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-launcher</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
-
</project>
\ No newline at end of file
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java b/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java
index 33f11f6..4bafe68 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java
+++ b/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java
@@ -19,40 +19,94 @@
package org.apache.james.vault;
-import org.apache.commons.lang3.NotImplementedException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
import org.apache.james.blob.api.BucketName;
import org.apache.james.core.User;
import org.apache.james.mailbox.model.MessageId;
import org.reactivestreams.Publisher;
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Table;
+
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
public class MemoryDeletedMessageMetadataVault implements DeletedMessageMetadataVault {
+ private final Table<BucketName, User, Map<MessageId, DeletedMessageWithStorageInformation>> table;
+
+ public MemoryDeletedMessageMetadataVault() {
+ table = HashBasedTable.create();
+ }
+
@Override
public Publisher<Void> store(DeletedMessageWithStorageInformation deletedMessage) {
- throw new NotImplementedException("Not yet implemented");
+ BucketName bucketName = deletedMessage.getStorageInformation().getBucketName();
+ User owner = deletedMessage.getDeletedMessage().getOwner();
+ MessageId messageId = deletedMessage.getDeletedMessage().getMessageId();
+
+ return Mono.fromRunnable(() -> {
+ synchronized (table) {
+ Map<MessageId, DeletedMessageWithStorageInformation> userVault = userVault(bucketName, owner);
+ userVault.put(messageId, deletedMessage);
+ table.put(bucketName, owner, userVault);
+ }
+ });
}
@Override
public Publisher<Void> removeBucket(BucketName bucketName) {
- throw new NotImplementedException("Not yet implemented");
+ return Mono.fromRunnable(() -> {
+ synchronized (table) {
+ table.row(bucketName).clear();
+ }
+ });
}
@Override
public Publisher<Void> remove(BucketName bucketName, User user, MessageId messageId) {
- throw new NotImplementedException("Not yet implemented");
+ return Mono.fromRunnable(() -> {
+ synchronized (table) {
+ userVault(bucketName, user).remove(messageId);
+ }
+ });
}
@Override
public Publisher<StorageInformation> retrieveStorageInformation(User user, MessageId messageId) {
- throw new NotImplementedException("Not yet implemented");
+ return Flux.from(listBuckets())
+ .concatMap(bucket -> {
+ synchronized (table) {
+ return Mono.justOrEmpty(userVault(bucket, user).get(messageId));
+ }
+ })
+ .map(DeletedMessageWithStorageInformation::getStorageInformation)
+ .next();
}
@Override
public Publisher<DeletedMessageWithStorageInformation> listMessages(BucketName bucketName, User user) {
- throw new NotImplementedException("Not yet implemented");
+ synchronized (table) {
+ return Flux.fromIterable(Optional.ofNullable(table.get(bucketName, user))
+ .map(Map::values)
+ .map(ImmutableList::copyOf)
+ .orElse(ImmutableList.of()));
+ }
}
@Override
public Publisher<BucketName> listBuckets() {
- throw new NotImplementedException("Not yet implemented");
+ synchronized (table) {
+ return Flux.fromIterable(ImmutableSet.copyOf(table.rowKeySet()));
+ }
+ }
+
+ private Map<MessageId, DeletedMessageWithStorageInformation> userVault(BucketName bucketName, User owner) {
+ return Optional.ofNullable(table.get(bucketName, owner))
+ .orElse(new HashMap<>());
}
}
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java b/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/test/java/org/apache/james/vault/MemoryDeletedMessageMetadataVaultTest.java
similarity index 71%
copy from mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java
copy to mailbox/plugin/deleted-messages-vault-blobstore-memory/src/test/java/org/apache/james/vault/MemoryDeletedMessageMetadataVaultTest.java
index a7a4db8..5a5cb5a 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java
+++ b/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/test/java/org/apache/james/vault/MemoryDeletedMessageMetadataVaultTest.java
@@ -19,12 +19,18 @@
package org.apache.james.vault;
-import org.apache.james.blob.api.BlobId;
-import org.apache.james.blob.api.BucketName;
-import org.apache.james.blob.api.HashBlobId;
+import org.junit.jupiter.api.BeforeEach;
-public interface DeletedMessageVaultMetadataFixture {
- BlobId BLOB_ID = new HashBlobId.Factory().from("05dcb33b-8382-4744-923a-bc593ad84d23");
- BucketName BUCKET_NAME = BucketName.of("bucket-2019-06-01");
- StorageInformation STORAGE_INFORMATION = new StorageInformation(BUCKET_NAME, BLOB_ID);
-}
+public class MemoryDeletedMessageMetadataVaultTest implements DeletedMessageMetadataVaultContract {
+ private MemoryDeletedMessageMetadataVault memoryDeletedMessageMetadataVault;
+
+ @BeforeEach
+ void setUp() {
+ memoryDeletedMessageMetadataVault = new MemoryDeletedMessageMetadataVault();
+ }
+
+ @Override
+ public DeletedMessageMetadataVault metadataVault() {
+ return memoryDeletedMessageMetadataVault;
+ }
+}
\ No newline at end of file
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java b/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java
index 669b3a6..1c17a38 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java
@@ -24,19 +24,19 @@ import java.util.Objects;
import com.google.common.base.Preconditions;
public class DeletedMessageWithStorageInformation {
- private final DeletedMessage deletedmessage;
+ private final DeletedMessage deletedMessage;
private final StorageInformation storageInformation;
- public DeletedMessageWithStorageInformation(DeletedMessage deletedmessage, StorageInformation storageInformation) {
- Preconditions.checkNotNull(deletedmessage);
+ public DeletedMessageWithStorageInformation(DeletedMessage deletedMessage, StorageInformation storageInformation) {
+ Preconditions.checkNotNull(deletedMessage);
Preconditions.checkNotNull(storageInformation);
- this.deletedmessage = deletedmessage;
+ this.deletedMessage = deletedMessage;
this.storageInformation = storageInformation;
}
- public DeletedMessage getDeletedmessage() {
- return deletedmessage;
+ public DeletedMessage getDeletedMessage() {
+ return deletedMessage;
}
public StorageInformation getStorageInformation() {
@@ -48,7 +48,7 @@ public class DeletedMessageWithStorageInformation {
if (o instanceof DeletedMessageWithStorageInformation) {
DeletedMessageWithStorageInformation that = (DeletedMessageWithStorageInformation) o;
- return Objects.equals(this.deletedmessage, that.deletedmessage)
+ return Objects.equals(this.deletedMessage, that.deletedMessage)
&& Objects.equals(this.storageInformation, that.storageInformation);
}
return false;
@@ -56,6 +56,6 @@ public class DeletedMessageWithStorageInformation {
@Override
public final int hashCode() {
- return Objects.hash(deletedmessage, storageInformation);
+ return Objects.hash(deletedMessage, storageInformation);
}
}
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageMetadataVaultContract.java b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageMetadataVaultContract.java
new file mode 100644
index 0000000..714c911
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageMetadataVaultContract.java
@@ -0,0 +1,198 @@
+/****************************************************************
+ * 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.vault;
+
+import static org.apache.james.vault.DeletedMessageFixture.USER;
+import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.BLOB_ID_2;
+import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.BUCKET_NAME;
+import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.STORAGE_INFORMATION;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import org.apache.james.blob.api.BucketName;
+import org.junit.jupiter.api.Test;
+
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+public interface DeletedMessageMetadataVaultContract {
+ DeletedMessageWithStorageInformation DELETED_MESSAGE = new DeletedMessageWithStorageInformation(DeletedMessageFixture.DELETED_MESSAGE, STORAGE_INFORMATION);
+ DeletedMessageWithStorageInformation DELETED_MESSAGE_2 = new DeletedMessageWithStorageInformation(DeletedMessageFixture.DELETED_MESSAGE_2, STORAGE_INFORMATION);
+ BucketName OTHER_BUCKET_NAME = BucketName.of("other");
+ DeletedMessageWithStorageInformation DELETED_MESSAGE_2_OTHER_BUCKET = new DeletedMessageWithStorageInformation(DeletedMessageFixture.DELETED_MESSAGE_2,
+ new StorageInformation(OTHER_BUCKET_NAME, BLOB_ID_2));
+
+ DeletedMessageMetadataVault metadataVault();
+
+ @Test
+ default void listMessagesShouldBeEmptyWhenNoMessageInserted() {
+ Stream<DeletedMessageWithStorageInformation> messages = Flux.from(metadataVault().listMessages(BUCKET_NAME, USER)).toStream();
+ assertThat(messages).isEmpty();
+ }
+
+ @Test
+ default void listMessagesShouldContainPreviouslyInsertedMessage() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+
+ Stream<DeletedMessageWithStorageInformation> messages = Flux.from(metadataVault().listMessages(BUCKET_NAME, USER)).toStream();
+ assertThat(messages).containsOnly(DELETED_MESSAGE);
+ }
+
+ @Test
+ default void listMessagesShouldContainAllPreviouslyInsertedMessages() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
+
+ Stream<DeletedMessageWithStorageInformation> messages = Flux.from(metadataVault().listMessages(BUCKET_NAME, USER)).toStream();
+ assertThat(messages).containsOnly(DELETED_MESSAGE, DELETED_MESSAGE_2);
+ }
+
+ @Test
+ default void listMessagesShouldNotReturnMessagesOfOtherBuckets() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2_OTHER_BUCKET)).block();
+
+ Stream<DeletedMessageWithStorageInformation> messages = Flux.from(metadataVault().listMessages(BUCKET_NAME, USER)).toStream();
+ assertThat(messages).containsOnly(DELETED_MESSAGE);
+ }
+
+ @Test
+ default void listBucketsShouldBeEmptyWhenNoMessageInserted() {
+ Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ assertThat(messages).isEmpty();
+ }
+
+ @Test
+ default void listBucketsShouldReturnAllUsedBuckets() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2_OTHER_BUCKET)).block();
+
+ Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ assertThat(messages).containsOnly(BUCKET_NAME, OTHER_BUCKET_NAME);
+ }
+
+ @Test
+ default void listBucketsShouldNotReturnDuplicates() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
+
+ Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ assertThat(messages).containsExactly(BUCKET_NAME);
+ }
+
+ @Test
+ default void listBucketsShouldStillListNotYetDeletedBuckets() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2_OTHER_BUCKET)).block();
+
+ Mono.from(metadataVault().removeBucket(BUCKET_NAME)).block();
+
+ Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ assertThat(messages).containsOnly(OTHER_BUCKET_NAME);
+ }
+
+ @Test
+ default void listBucketsShouldNotReturnDeletedBuckets() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
+
+ Mono.from(metadataVault().removeBucket(BUCKET_NAME)).block();
+
+ Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ assertThat(messages).isEmpty();
+ }
+
+ @Test
+ default void removeBucketShouldOnlyRemoveEntriesOfTheGivenBucket() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2_OTHER_BUCKET)).block();
+
+ Mono.from(metadataVault().removeBucket(BUCKET_NAME)).block();
+
+ Stream<DeletedMessageWithStorageInformation> messages = Flux.from(metadataVault().listMessages(OTHER_BUCKET_NAME, USER)).toStream();
+ assertThat(messages).containsOnly(DELETED_MESSAGE_2_OTHER_BUCKET);
+ }
+
+ @Test
+ default void removeBucketShouldRemoveAllEntriesOfTheGivenBucket() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
+
+ Mono.from(metadataVault().removeBucket(BUCKET_NAME)).block();
+
+ Stream<DeletedMessageWithStorageInformation> messages = Flux.from(metadataVault().listMessages(BUCKET_NAME, USER)).toStream();
+ assertThat(messages).isEmpty();
+ }
+
+ @Test
+ default void listMessagesShouldNotReturnRemovedItems() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
+
+ Mono.from(metadataVault().remove(BUCKET_NAME, USER, DELETED_MESSAGE.getDeletedMessage().getMessageId())).block();
+
+ Stream<DeletedMessageWithStorageInformation> messages = Flux.from(metadataVault().listMessages(BUCKET_NAME, USER)).toStream();
+ assertThat(messages).containsExactly(DELETED_MESSAGE_2);
+ }
+
+ @Test
+ default void removeShouldNotFailWhenTheMessageDoesNotExist() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
+
+ assertThatCode(() -> Mono.from(metadataVault()
+ .remove(BUCKET_NAME, USER, DELETED_MESSAGE.getDeletedMessage().getMessageId()))
+ .block())
+ .doesNotThrowAnyException();
+ }
+
+ @Test
+ default void retrieveStorageInformationShouldReturnStoredValue() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
+
+ StorageInformation storageInformation = Mono.from(metadataVault()
+ .retrieveStorageInformation(USER, DELETED_MESSAGE.getDeletedMessage().getMessageId()))
+ .block();
+
+ assertThat(storageInformation).isEqualTo(DELETED_MESSAGE.getStorageInformation());
+ }
+
+ @Test
+ default void retrieveStorageInformationShouldReturnEmptyWhenNotStored() {
+ Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
+
+ Optional<StorageInformation> storageInformation = Mono.from(metadataVault()
+ .retrieveStorageInformation(USER, DELETED_MESSAGE.getDeletedMessage().getMessageId()))
+ .blockOptional();
+
+ assertThat(storageInformation).isEmpty();
+ }
+
+ @Test
+ default void retrieveStorageInformationShouldReturnEmptyWhenUserVaultIsEmpty() {
+ Optional<StorageInformation> storageInformation = Mono.from(metadataVault()
+ .retrieveStorageInformation(USER, DELETED_MESSAGE.getDeletedMessage().getMessageId()))
+ .blockOptional();
+
+ assertThat(storageInformation).isEmpty();
+ }
+}
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java
index a7a4db8..8bc4ec4 100644
--- a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java
@@ -25,6 +25,7 @@ import org.apache.james.blob.api.HashBlobId;
public interface DeletedMessageVaultMetadataFixture {
BlobId BLOB_ID = new HashBlobId.Factory().from("05dcb33b-8382-4744-923a-bc593ad84d23");
+ BlobId BLOB_ID_2 = new HashBlobId.Factory().from("05dcb33b-8382-4744-923a-bc593ad84d24");
BucketName BUCKET_NAME = BucketName.of("bucket-2019-06-01");
StorageInformation STORAGE_INFORMATION = new StorageInformation(BUCKET_NAME, BLOB_ID);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 05/13: JAMES-2806 add a metric for deleteBucket
method and test in its contract
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6ec43fb87bd37317da03574c3a5939aa50263563
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue Jul 2 10:35:48 2019 +0700
JAMES-2806 add a metric for deleteBucket method and test in its contract
---
.../org/apache/james/blob/api/MetricableBlobStore.java | 4 +++-
.../apache/james/blob/api/MetricableBlobStoreContract.java | 14 ++++++++++++++
.../apache/james/blob/cassandra/CassandraBlobsDAOTest.java | 7 +++++++
.../blob/objectstorage/ObjectStorageBlobsDAOTest.java | 7 +++++++
4 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java
index 89548d8..11fd997 100644
--- a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java
+++ b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java
@@ -36,6 +36,7 @@ public class MetricableBlobStore implements BlobStore {
static final String SAVE_INPUT_STREAM_TIMER_NAME = BLOB_STORE_METRIC_PREFIX + "saveInputStream";
static final String READ_BYTES_TIMER_NAME = BLOB_STORE_METRIC_PREFIX + "readBytes";
static final String READ_TIMER_NAME = BLOB_STORE_METRIC_PREFIX + "read";
+ static final String DELETE_TIMER_NAME = BLOB_STORE_METRIC_PREFIX + "delete";
private final MetricFactory metricFactory;
private final BlobStore blobStoreImpl;
@@ -73,6 +74,7 @@ public class MetricableBlobStore implements BlobStore {
@Override
public Mono<Void> deleteBucket(BucketName bucketName) {
- return blobStoreImpl.deleteBucket(bucketName);
+ return metricFactory
+ .runPublishingTimerMetric(DELETE_TIMER_NAME, () -> blobStoreImpl.deleteBucket(bucketName));
}
}
diff --git a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java
index 74a30ff..983c516 100644
--- a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java
+++ b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java
@@ -19,6 +19,7 @@
package org.apache.james.blob.api;
+import static org.apache.james.blob.api.MetricableBlobStore.DELETE_TIMER_NAME;
import static org.apache.james.blob.api.MetricableBlobStore.READ_BYTES_TIMER_NAME;
import static org.apache.james.blob.api.MetricableBlobStore.READ_TIMER_NAME;
import static org.apache.james.blob.api.MetricableBlobStore.SAVE_BYTES_TIMER_NAME;
@@ -101,4 +102,17 @@ public interface MetricableBlobStoreContract extends BlobStoreContract {
assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(READ_TIMER_NAME))
.hasSize(2);
}
+
+ @Test
+ default void deleteBucketShouldPublishDeleteTimerMetrics() {
+ BucketName bucketName = BucketName.of("custom");
+ testee().save(BucketName.DEFAULT, BYTES_CONTENT).block();
+ testee().save(bucketName, BYTES_CONTENT).block();
+
+ testee().deleteBucket(BucketName.DEFAULT);
+ testee().deleteBucket(bucketName);
+
+ assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(DELETE_TIMER_NAME))
+ .hasSize(2);
+ }
}
\ No newline at end of file
diff --git a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java
index 758ad7e..23e3375 100644
--- a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java
+++ b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java
@@ -35,6 +35,7 @@ import org.apache.james.blob.api.MetricableBlobStore;
import org.apache.james.blob.api.MetricableBlobStoreContract;
import org.apache.james.util.ZeroedInputStream;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -70,6 +71,12 @@ public class CassandraBlobsDAOTest implements MetricableBlobStoreContract {
return new HashBlobId.Factory();
}
+ @Override
+ @Disabled("JAMES-2806: delete bucket not implemented yet for Cassandra")
+ public void deleteBucketShouldPublishDeleteTimerMetrics() {
+
+ }
+
@Test
void readBytesShouldReturnSplitSavedDataByChunk() {
String longString = Strings.repeat("0123456789\n", MULTIPLE_CHUNK_SIZE);
diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
index e0214ee..1164af5 100644
--- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
+++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
@@ -45,6 +45,7 @@ import org.apache.james.blob.objectstorage.swift.UserHeaderName;
import org.apache.james.blob.objectstorage.swift.UserName;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -110,6 +111,12 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract {
return new HashBlobId.Factory();
}
+ @Override
+ @Disabled("JAMES-2806: delete bucket not implemented yet for ObjectStorage")
+ public void deleteBucketShouldPublishDeleteTimerMetrics() {
+
+ }
+
@Test
void createContainerShouldMakeTheContainerToExist() {
ContainerName containerName = ContainerName.of(UUID.randomUUID().toString());
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 06/13: JAMES-2806 add tests for deleteBucket with
UnionBlobStore
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2a2af7101ec83fa49173412499ea569f84200b36
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue Jul 2 10:39:04 2019 +0700
JAMES-2806 add tests for deleteBucket with UnionBlobStore
---
.../james/blob/union/UnionBlobStoreTest.java | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java b/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java
index a44fd0d..1789129 100644
--- a/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java
+++ b/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java
@@ -489,4 +489,43 @@ class UnionBlobStoreTest implements BlobStoreContract {
assertThat(pushBackIS)
.hasSameContentAs(new ByteArrayInputStream(new byte[0]));
}
+
+ @Test
+ void deleteBucketShouldDeleteBothCurrentAndLegacyBuckets() {
+ BlobId legacyBlobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block();
+ BlobId currentBlobId = currentBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block();
+
+ unionBlobStore.deleteBucket(BucketName.DEFAULT).block();
+
+ assertThatThrownBy(() -> legacyBlobStore.readBytes(BucketName.DEFAULT, legacyBlobId).block())
+ .isInstanceOf(ObjectStoreException.class);
+ assertThatThrownBy(() -> currentBlobStore.readBytes(BucketName.DEFAULT, currentBlobId).block())
+ .isInstanceOf(ObjectStoreException.class);
+ }
+
+ @Test
+ void deleteBucketShouldDeleteCurrentBucketEvenWhenLegacyDoesNotExist() {
+ BlobId currentBlobId = currentBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block();
+
+ unionBlobStore.deleteBucket(BucketName.DEFAULT).block();
+
+ assertThatThrownBy(() -> currentBlobStore.readBytes(BucketName.DEFAULT, currentBlobId).block())
+ .isInstanceOf(ObjectStoreException.class);
+ }
+
+ @Test
+ void deleteBucketShouldDeleteLegacyBucketEvenWhenCurrentDoesNotExist() {
+ BlobId legacyBlobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block();
+
+ unionBlobStore.deleteBucket(BucketName.DEFAULT).block();
+
+ assertThatThrownBy(() -> legacyBlobStore.readBytes(BucketName.DEFAULT, legacyBlobId).block())
+ .isInstanceOf(ObjectStoreException.class);
+ }
+
+ @Test
+ void deleteBucketShouldNotThrowWhenCurrentAndLegacyBucketsDoNotExist() {
+ assertThatCode(() -> unionBlobStore.deleteBucket(BucketName.DEFAULT).block())
+ .doesNotThrowAnyException();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 12/13: Merge remote-tracking branch
'rcordier/james-2806-bucket-name-memory'
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 40292bec751517ba5c64a0026dea219a9e939e43
Merge: 9d244d5 2a2af71
Author: Antoine DUPRAT <ad...@linagora.com>
AuthorDate: Thu Jul 4 10:32:39 2019 +0200
Merge remote-tracking branch 'rcordier/james-2806-bucket-name-memory'
.../java/org/apache/james/blob/api/BlobStore.java | 2 +
.../apache/james/blob/api/MetricableBlobStore.java | 7 +
.../james/blob/api/BucketBlobStoreContract.java | 142 +++++++++++++++++++++
.../blob/api/MetricableBlobStoreContract.java | 14 ++
.../james/blob/cassandra/CassandraBlobsDAO.java | 6 +
.../blob/cassandra/CassandraBlobsDAOTest.java | 7 +
.../apache/james/blob/memory/MemoryBlobStore.java | 44 +++++--
.../james/blob/memory/MemoryBlobStoreTest.java | 3 +-
.../blob/objectstorage/ObjectStorageBlobsDAO.java | 6 +
.../objectstorage/ObjectStorageBlobsDAOTest.java | 7 +
.../apache/james/blob/union/UnionBlobStore.java | 7 +
.../james/blob/union/UnionBlobStoreTest.java | 49 +++++++
12 files changed, 282 insertions(+), 12 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 07/13: JAMES-2807 Create POJOs for
DeletedMessageMetadataVault API
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 9ebaa14a0ace03e0b2b19b7cee18b15e95376183
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Jun 25 11:21:36 2019 +0700
JAMES-2807 Create POJOs for DeletedMessageMetadataVault API
---
.../deleted-messages-vault-blobstore/pom.xml | 86 ++++++++++++++++++++++
.../DeletedMessageWithStorageInformation.java | 61 +++++++++++++++
.../org/apache/james/vault/StorageInformation.java | 64 ++++++++++++++++
.../vault/DeletedMessageVaultMetadataFixture.java | 30 ++++++++
.../DeletedMessageWithStorageInformationTest.java | 47 ++++++++++++
.../apache/james/vault/StorageInformationTest.java | 47 ++++++++++++
mailbox/pom.xml | 4 +
7 files changed, 339 insertions(+)
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/pom.xml b/mailbox/plugin/deleted-messages-vault-blobstore/pom.xml
new file mode 100644
index 0000000..5575f57
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/pom.xml
@@ -0,0 +1,86 @@
+<?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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>apache-james-mailbox</artifactId>
+ <groupId>org.apache.james</groupId>
+ <version>3.4.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
+ <name>Apache James :: Mailbox :: Plugin :: Deleted Messages Vault :: BlobStore</name>
+ <description>Apache James Mailbox Deleted Messages Vault implementation on top of BlobStore</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-deleted-messages-vault</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-deleted-messages-vault</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>blob-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>nl.jqno.equalsverifier</groupId>
+ <artifactId>equalsverifier</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-launcher</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java b/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java
new file mode 100644
index 0000000..669b3a6
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageWithStorageInformation.java
@@ -0,0 +1,61 @@
+/****************************************************************
+ * 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.vault;
+
+import java.util.Objects;
+
+import com.google.common.base.Preconditions;
+
+public class DeletedMessageWithStorageInformation {
+ private final DeletedMessage deletedmessage;
+ private final StorageInformation storageInformation;
+
+ public DeletedMessageWithStorageInformation(DeletedMessage deletedmessage, StorageInformation storageInformation) {
+ Preconditions.checkNotNull(deletedmessage);
+ Preconditions.checkNotNull(storageInformation);
+
+ this.deletedmessage = deletedmessage;
+ this.storageInformation = storageInformation;
+ }
+
+ public DeletedMessage getDeletedmessage() {
+ return deletedmessage;
+ }
+
+ public StorageInformation getStorageInformation() {
+ return storageInformation;
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+ if (o instanceof DeletedMessageWithStorageInformation) {
+ DeletedMessageWithStorageInformation that = (DeletedMessageWithStorageInformation) o;
+
+ return Objects.equals(this.deletedmessage, that.deletedmessage)
+ && Objects.equals(this.storageInformation, that.storageInformation);
+ }
+ return false;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(deletedmessage, storageInformation);
+ }
+}
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/StorageInformation.java b/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/StorageInformation.java
new file mode 100644
index 0000000..4ebc6ca
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/StorageInformation.java
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.vault;
+
+import java.util.Objects;
+
+import org.apache.james.blob.api.BlobId;
+import org.apache.james.blob.api.BucketName;
+
+import com.google.common.base.Preconditions;
+
+public class StorageInformation {
+ private final BucketName bucketName;
+ private final BlobId blobId;
+
+ public StorageInformation(BucketName bucketName, BlobId blobId) {
+ Preconditions.checkNotNull(bucketName);
+ Preconditions.checkNotNull(blobId);
+
+ this.bucketName = bucketName;
+ this.blobId = blobId;
+ }
+
+ public BucketName getBucketName() {
+ return bucketName;
+ }
+
+ public BlobId getBlobId() {
+ return blobId;
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+ if (o instanceof StorageInformation) {
+ StorageInformation that = (StorageInformation) o;
+
+ return Objects.equals(this.bucketName, that.bucketName)
+ && Objects.equals(this.blobId, that.blobId);
+ }
+ return false;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(bucketName, blobId);
+ }
+}
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java
new file mode 100644
index 0000000..a7a4db8
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageVaultMetadataFixture.java
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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.vault;
+
+import org.apache.james.blob.api.BlobId;
+import org.apache.james.blob.api.BucketName;
+import org.apache.james.blob.api.HashBlobId;
+
+public interface DeletedMessageVaultMetadataFixture {
+ BlobId BLOB_ID = new HashBlobId.Factory().from("05dcb33b-8382-4744-923a-bc593ad84d23");
+ BucketName BUCKET_NAME = BucketName.of("bucket-2019-06-01");
+ StorageInformation STORAGE_INFORMATION = new StorageInformation(BUCKET_NAME, BLOB_ID);
+}
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageWithStorageInformationTest.java b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageWithStorageInformationTest.java
new file mode 100644
index 0000000..a79a67f
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/DeletedMessageWithStorageInformationTest.java
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.vault;
+
+import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.STORAGE_INFORMATION;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+class DeletedMessageWithStorageInformationTest {
+
+ @Test
+ void shouldRespectBeanContract() {
+ EqualsVerifier.forClass(DeletedMessageWithStorageInformation.class).verify();
+ }
+
+ @Test
+ void constructorShouldThrowOnNullDeletedMessage() {
+ assertThatThrownBy(() -> new DeletedMessageWithStorageInformation(null, STORAGE_INFORMATION))
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ void constructorShouldThrowOnNullStorageInformation() {
+ assertThatThrownBy(() -> new DeletedMessageWithStorageInformation(DeletedMessageFixture.DELETED_MESSAGE, null))
+ .isInstanceOf(NullPointerException.class);
+ }
+}
\ No newline at end of file
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/StorageInformationTest.java b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/StorageInformationTest.java
new file mode 100644
index 0000000..b55cf55
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/src/test/java/org/apache/james/vault/StorageInformationTest.java
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.vault;
+
+import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.BLOB_ID;
+import static org.apache.james.vault.DeletedMessageVaultMetadataFixture.BUCKET_NAME;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+class StorageInformationTest {
+ @Test
+ void shouldRespectBeanContract() {
+ EqualsVerifier.forClass(StorageInformation.class).verify();
+ }
+
+ @Test
+ void constructorShouldThrowOnNullBucketName() {
+ assertThatThrownBy(() -> new StorageInformation(null, BLOB_ID))
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ void constructorShouldThrowOnNullBlobId() {
+ assertThatThrownBy(() -> new StorageInformation(BUCKET_NAME, null))
+ .isInstanceOf(NullPointerException.class);
+ }
+}
\ No newline at end of file
diff --git a/mailbox/pom.xml b/mailbox/pom.xml
index 7e3dcd2..b191407 100644
--- a/mailbox/pom.xml
+++ b/mailbox/pom.xml
@@ -52,12 +52,16 @@
<module>memory</module>
<module>plugin/deleted-messages-vault</module>
+ <module>plugin/deleted-messages-vault-blobstore</module>
+
<module>plugin/quota-mailing</module>
<module>plugin/quota-mailing-cassandra</module>
<module>plugin/quota-mailing-memory</module>
+
<module>plugin/quota-search</module>
<module>plugin/quota-search-elasticsearch</module>
<module>plugin/quota-search-scanning</module>
+
<module>plugin/spamassassin</module>
<module>scanning-search</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 08/13: JAMES-2807 DeletedMessageMetadataVault API
and memory skeleton
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit c7177df2f5be728270516db4580cba6e4acefa13
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Jun 25 11:31:16 2019 +0700
JAMES-2807 DeletedMessageMetadataVault API and memory skeleton
---
.../pom.xml | 40 +++++++++++++++
.../vault/MemoryDeletedMessageMetadataVault.java | 58 ++++++++++++++++++++++
.../james/vault/DeletedMessageMetadataVault.java | 39 +++++++++++++++
mailbox/pom.xml | 1 +
pom.xml | 11 ++++
5 files changed, 149 insertions(+)
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml b/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml
new file mode 100644
index 0000000..d5ae54e
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore-memory/pom.xml
@@ -0,0 +1,40 @@
+<?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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>apache-james-mailbox</artifactId>
+ <groupId>org.apache.james</groupId>
+ <version>3.4.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore-memory</artifactId>
+ <name>Apache James :: Mailbox :: Plugin :: Deleted Messages Vault :: BlobStore :: Memory</name>
+ <description>Memory implementation of the metadata storage API required by the Deleted Messages Vault implementation on top of BlobStore</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java b/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java
new file mode 100644
index 0000000..33f11f6
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore-memory/src/main/java/org/apache/james/vault/MemoryDeletedMessageMetadataVault.java
@@ -0,0 +1,58 @@
+/****************************************************************
+ * 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.vault;
+
+import org.apache.commons.lang3.NotImplementedException;
+import org.apache.james.blob.api.BucketName;
+import org.apache.james.core.User;
+import org.apache.james.mailbox.model.MessageId;
+import org.reactivestreams.Publisher;
+
+public class MemoryDeletedMessageMetadataVault implements DeletedMessageMetadataVault {
+ @Override
+ public Publisher<Void> store(DeletedMessageWithStorageInformation deletedMessage) {
+ throw new NotImplementedException("Not yet implemented");
+ }
+
+ @Override
+ public Publisher<Void> removeBucket(BucketName bucketName) {
+ throw new NotImplementedException("Not yet implemented");
+ }
+
+ @Override
+ public Publisher<Void> remove(BucketName bucketName, User user, MessageId messageId) {
+ throw new NotImplementedException("Not yet implemented");
+ }
+
+ @Override
+ public Publisher<StorageInformation> retrieveStorageInformation(User user, MessageId messageId) {
+ throw new NotImplementedException("Not yet implemented");
+ }
+
+ @Override
+ public Publisher<DeletedMessageWithStorageInformation> listMessages(BucketName bucketName, User user) {
+ throw new NotImplementedException("Not yet implemented");
+ }
+
+ @Override
+ public Publisher<BucketName> listBuckets() {
+ throw new NotImplementedException("Not yet implemented");
+ }
+}
diff --git a/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageMetadataVault.java b/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageMetadataVault.java
new file mode 100644
index 0000000..809a34b
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault-blobstore/src/main/java/org/apache/james/vault/DeletedMessageMetadataVault.java
@@ -0,0 +1,39 @@
+/****************************************************************
+ * 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.vault;
+
+import org.apache.james.blob.api.BucketName;
+import org.apache.james.core.User;
+import org.apache.james.mailbox.model.MessageId;
+import org.reactivestreams.Publisher;
+
+public interface DeletedMessageMetadataVault {
+ Publisher<Void> store(DeletedMessageWithStorageInformation deletedMessage);
+
+ Publisher<Void> removeBucket(BucketName bucketName);
+
+ Publisher<Void> remove(BucketName bucketName, User user, MessageId messageId);
+
+ Publisher<StorageInformation> retrieveStorageInformation(User user, MessageId messageId);
+
+ Publisher<DeletedMessageWithStorageInformation> listMessages(BucketName bucketName, User user);
+
+ Publisher<BucketName> listBuckets();
+}
diff --git a/mailbox/pom.xml b/mailbox/pom.xml
index b191407..ef22a91 100644
--- a/mailbox/pom.xml
+++ b/mailbox/pom.xml
@@ -53,6 +53,7 @@
<module>plugin/deleted-messages-vault</module>
<module>plugin/deleted-messages-vault-blobstore</module>
+ <module>plugin/deleted-messages-vault-blobstore-memory</module>
<module>plugin/quota-mailing</module>
<module>plugin/quota-mailing-cassandra</module>
diff --git a/pom.xml b/pom.xml
index 52b56ab..de07d51 100644
--- a/pom.xml
+++ b/pom.xml
@@ -775,6 +775,17 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-deleted-messages-vault-blobstore</artifactId>
+ <type>test-jar</type>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>apache-james-mailbox-elasticsearch</artifactId>
<version>${project.version}</version>
</dependency>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 04/13: JAMES-2806 Add deleteBucket implementation
for memory and its contract
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 1a7e0588d24a86728dd04289c899fead15c78355
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Mon Jul 1 10:55:21 2019 +0700
JAMES-2806 Add deleteBucket implementation for memory and its contract
---
.../james/blob/api/BucketBlobStoreContract.java | 36 ++++++++++++++++++++++
.../apache/james/blob/memory/MemoryBlobStore.java | 11 ++++---
2 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BucketBlobStoreContract.java b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BucketBlobStoreContract.java
index 4655bb0..d52d703 100644
--- a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BucketBlobStoreContract.java
+++ b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BucketBlobStoreContract.java
@@ -20,6 +20,7 @@
package org.apache.james.blob.api;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.io.ByteArrayInputStream;
@@ -39,6 +40,30 @@ public interface BucketBlobStoreContract {
BlobId.Factory blobIdFactory();
@Test
+ default void deleteBucketShouldThrowWhenNullBucketName() {
+ assertThatThrownBy(() -> testee().deleteBucket(null).block())
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ default void deleteBucketShouldDeleteExistingBucketWithItsData() {
+ BlobId blobId = testee().save(CUSTOM, SHORT_BYTEARRAY).block();
+ testee().deleteBucket(CUSTOM).block();
+
+ assertThatThrownBy(() -> testee().read(CUSTOM, blobId))
+ .isInstanceOf(ObjectStoreException.class);
+ }
+
+ @Test
+ default void deleteBucketShouldBeIdempotent(){
+ testee().save(CUSTOM, SHORT_BYTEARRAY).block();
+ testee().deleteBucket(CUSTOM).block();
+
+ assertThatCode(() -> testee().deleteBucket(CUSTOM).block())
+ .doesNotThrowAnyException();
+ }
+
+ @Test
default void saveBytesShouldThrowWhenNullBucketName() {
assertThatThrownBy(() -> testee().save(null, SHORT_BYTEARRAY).block())
.isInstanceOf(NullPointerException.class);
@@ -103,4 +128,15 @@ public interface BucketBlobStoreContract {
.operationCount(10)
.runSuccessfullyWithin(Duration.ofMinutes(1));
}
+
+ @Test
+ default void deleteBucketConcurrentlyShouldNotFail() throws Exception {
+ testee().save(CUSTOM, SHORT_BYTEARRAY).block();
+
+ ConcurrentTestRunner.builder()
+ .operation(((threadNumber, step) -> testee().deleteBucket(CUSTOM).block()))
+ .threadCount(10)
+ .operationCount(10)
+ .runSuccessfullyWithin(Duration.ofMinutes(1));
+ }
}
diff --git a/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java b/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
index b7f907a..812ea3d 100644
--- a/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
+++ b/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
@@ -27,7 +27,6 @@ import java.util.Optional;
import javax.inject.Inject;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.NotImplementedException;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BlobStore;
import org.apache.james.blob.api.BucketName;
@@ -35,10 +34,8 @@ import org.apache.james.blob.api.ObjectStoreException;
import com.google.common.base.Preconditions;
import com.google.common.collect.HashBasedTable;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Table;
-import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public class MemoryBlobStore implements BlobStore {
@@ -92,7 +89,13 @@ public class MemoryBlobStore implements BlobStore {
@Override
public Mono<Void> deleteBucket(BucketName bucketName) {
- throw new NotImplementedException("not implemented");
+ Preconditions.checkNotNull(bucketName);
+
+ return Mono.fromRunnable(() -> {
+ synchronized (blobs) {
+ blobs.row(bucketName).clear();
+ }
+ });
}
private byte[] retrieveStoredValue(BucketName bucketName, BlobId blobId) {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 11/13: JAMES-2807 Make it clear that
DeletedMessageMetadataVault do not actually store buckets
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit e7b56830237716782a7dac3dc2476a44452f379f
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jul 1 16:00:12 2019 +0700
JAMES-2807 Make it clear that DeletedMessageMetadataVault do not actually store buckets
It only exposes primitives to take actions on metadata related to a bucket used for the
DeletedMessageVault
---
.../metadata/MemoryDeletedMessageMetadataVault.java | 6 +++---
.../vault/metadata/DeletedMessageMetadataVault.java | 4 ++--
.../metadata/DeletedMessageMetadataVaultContract.java | 18 +++++++++---------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVault.java b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVault.java
index ccf5fc6..59ede6d 100644
--- a/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVault.java
+++ b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/memory/metadata/MemoryDeletedMessageMetadataVault.java
@@ -62,7 +62,7 @@ public class MemoryDeletedMessageMetadataVault implements DeletedMessageMetadata
}
@Override
- public Publisher<Void> removeBucket(BucketName bucketName) {
+ public Publisher<Void> removeMetadataRelatedToBucket(BucketName bucketName) {
return Mono.fromRunnable(() -> {
synchronized (table) {
table.row(bucketName).clear();
@@ -81,7 +81,7 @@ public class MemoryDeletedMessageMetadataVault implements DeletedMessageMetadata
@Override
public Publisher<StorageInformation> retrieveStorageInformation(User user, MessageId messageId) {
- return Flux.from(listBuckets())
+ return Flux.from(listRelatedBuckets())
.concatMap(bucket -> {
synchronized (table) {
return Mono.justOrEmpty(userVault(bucket, user).get(messageId));
@@ -102,7 +102,7 @@ public class MemoryDeletedMessageMetadataVault implements DeletedMessageMetadata
}
@Override
- public Publisher<BucketName> listBuckets() {
+ public Publisher<BucketName> listRelatedBuckets() {
synchronized (table) {
return Flux.fromIterable(ImmutableSet.copyOf(table.rowKeySet()));
}
diff --git a/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageMetadataVault.java b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageMetadataVault.java
index 25b5a4a..3aab7aa 100644
--- a/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageMetadataVault.java
+++ b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/metadata/DeletedMessageMetadataVault.java
@@ -27,7 +27,7 @@ import org.reactivestreams.Publisher;
public interface DeletedMessageMetadataVault {
Publisher<Void> store(DeletedMessageWithStorageInformation deletedMessage);
- Publisher<Void> removeBucket(BucketName bucketName);
+ Publisher<Void> removeMetadataRelatedToBucket(BucketName bucketName);
Publisher<Void> remove(BucketName bucketName, User user, MessageId messageId);
@@ -35,5 +35,5 @@ public interface DeletedMessageMetadataVault {
Publisher<DeletedMessageWithStorageInformation> listMessages(BucketName bucketName, User user);
- Publisher<BucketName> listBuckets();
+ Publisher<BucketName> listRelatedBuckets();
}
diff --git a/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageMetadataVaultContract.java b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageMetadataVaultContract.java
index 3b85bc5..0052f0e 100644
--- a/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageMetadataVaultContract.java
+++ b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/metadata/DeletedMessageMetadataVaultContract.java
@@ -79,7 +79,7 @@ public interface DeletedMessageMetadataVaultContract {
@Test
default void listBucketsShouldBeEmptyWhenNoMessageInserted() {
- Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ Stream<BucketName> messages = Flux.from(metadataVault().listRelatedBuckets()).toStream();
assertThat(messages).isEmpty();
}
@@ -88,7 +88,7 @@ public interface DeletedMessageMetadataVaultContract {
Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
Mono.from(metadataVault().store(DELETED_MESSAGE_2_OTHER_BUCKET)).block();
- Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ Stream<BucketName> messages = Flux.from(metadataVault().listRelatedBuckets()).toStream();
assertThat(messages).containsOnly(BUCKET_NAME, OTHER_BUCKET_NAME);
}
@@ -97,7 +97,7 @@ public interface DeletedMessageMetadataVaultContract {
Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
- Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ Stream<BucketName> messages = Flux.from(metadataVault().listRelatedBuckets()).toStream();
assertThat(messages).containsExactly(BUCKET_NAME);
}
@@ -106,9 +106,9 @@ public interface DeletedMessageMetadataVaultContract {
Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
Mono.from(metadataVault().store(DELETED_MESSAGE_2_OTHER_BUCKET)).block();
- Mono.from(metadataVault().removeBucket(BUCKET_NAME)).block();
+ Mono.from(metadataVault().removeMetadataRelatedToBucket(BUCKET_NAME)).block();
- Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ Stream<BucketName> messages = Flux.from(metadataVault().listRelatedBuckets()).toStream();
assertThat(messages).containsOnly(OTHER_BUCKET_NAME);
}
@@ -117,9 +117,9 @@ public interface DeletedMessageMetadataVaultContract {
Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
- Mono.from(metadataVault().removeBucket(BUCKET_NAME)).block();
+ Mono.from(metadataVault().removeMetadataRelatedToBucket(BUCKET_NAME)).block();
- Stream<BucketName> messages = Flux.from(metadataVault().listBuckets()).toStream();
+ Stream<BucketName> messages = Flux.from(metadataVault().listRelatedBuckets()).toStream();
assertThat(messages).isEmpty();
}
@@ -128,7 +128,7 @@ public interface DeletedMessageMetadataVaultContract {
Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
Mono.from(metadataVault().store(DELETED_MESSAGE_2_OTHER_BUCKET)).block();
- Mono.from(metadataVault().removeBucket(BUCKET_NAME)).block();
+ Mono.from(metadataVault().removeMetadataRelatedToBucket(BUCKET_NAME)).block();
Stream<DeletedMessageWithStorageInformation> messages = Flux.from(metadataVault().listMessages(OTHER_BUCKET_NAME, USER)).toStream();
assertThat(messages).containsOnly(DELETED_MESSAGE_2_OTHER_BUCKET);
@@ -139,7 +139,7 @@ public interface DeletedMessageMetadataVaultContract {
Mono.from(metadataVault().store(DELETED_MESSAGE)).block();
Mono.from(metadataVault().store(DELETED_MESSAGE_2)).block();
- Mono.from(metadataVault().removeBucket(BUCKET_NAME)).block();
+ Mono.from(metadataVault().removeMetadataRelatedToBucket(BUCKET_NAME)).block();
Stream<DeletedMessageWithStorageInformation> messages = Flux.from(metadataVault().listMessages(BUCKET_NAME, USER)).toStream();
assertThat(messages).isEmpty();
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 01/13: JAMES-2806 add deleteBucket method in
BlobStore
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 7257bc83bb487a22f96449fa48ae7696d83bf322
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Wed Jun 26 15:55:31 2019 +0700
JAMES-2806 add deleteBucket method in BlobStore
---
.../src/main/java/org/apache/james/blob/api/BlobStore.java | 2 ++
.../java/org/apache/james/blob/api/MetricableBlobStore.java | 5 +++++
.../org/apache/james/blob/cassandra/CassandraBlobsDAO.java | 6 ++++++
.../java/org/apache/james/blob/memory/MemoryBlobStore.java | 6 ++++++
.../apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java | 6 ++++++
.../main/java/org/apache/james/blob/union/UnionBlobStore.java | 7 +++++++
.../java/org/apache/james/blob/union/UnionBlobStoreTest.java | 10 ++++++++++
7 files changed, 42 insertions(+)
diff --git a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/BlobStore.java b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/BlobStore.java
index ed7f6f7..3302203 100644
--- a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/BlobStore.java
+++ b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/BlobStore.java
@@ -36,4 +36,6 @@ public interface BlobStore {
default Mono<BlobId> save(BucketName bucketName, String data) {
return save(bucketName, data.getBytes(StandardCharsets.UTF_8));
}
+
+ Mono<Void> deleteBucket(BucketName bucketName);
}
diff --git a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java
index 3976bcd..89548d8 100644
--- a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java
+++ b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java
@@ -70,4 +70,9 @@ public class MetricableBlobStore implements BlobStore {
return metricFactory
.runPublishingTimerMetric(READ_TIMER_NAME, () -> blobStoreImpl.read(bucketName, blobId));
}
+
+ @Override
+ public Mono<Void> deleteBucket(BucketName bucketName) {
+ return blobStoreImpl.deleteBucket(bucketName);
+ }
}
diff --git a/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/CassandraBlobsDAO.java b/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/CassandraBlobsDAO.java
index 23be4e5..38edc21 100644
--- a/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/CassandraBlobsDAO.java
+++ b/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/CassandraBlobsDAO.java
@@ -34,6 +34,7 @@ import java.util.stream.Stream;
import javax.inject.Inject;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
@@ -218,4 +219,9 @@ public class CassandraBlobsDAO implements BlobStore {
return Mono.fromCallable(() -> IOUtils.toByteArray(data))
.flatMap(this::saveAsMono);
}
+
+ @Override
+ public Mono<Void> deleteBucket(BucketName bucketName) {
+ throw new NotImplementedException("not implemented");
+ }
}
diff --git a/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java b/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
index 173ce78..154a9b5 100644
--- a/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
+++ b/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
@@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.NotImplementedException;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BlobStore;
import org.apache.james.blob.api.BucketName;
@@ -78,6 +79,11 @@ public class MemoryBlobStore implements BlobStore {
return new ByteArrayInputStream(retrieveStoredValue(blobId));
}
+ @Override
+ public Mono<Void> deleteBucket(BucketName bucketName) {
+ throw new NotImplementedException("not implemented");
+ }
+
private byte[] retrieveStoredValue(BlobId blobId) {
return Optional.ofNullable(blobs.get(blobId))
.orElseThrow(() -> new ObjectStoreException("unable to find blob with id " + blobId));
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
index 7bbd2da..48840f8 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
@@ -25,6 +25,7 @@ import java.io.InputStream;
import java.util.Optional;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.NotImplementedException;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BlobStore;
import org.apache.james.blob.api.BucketName;
@@ -148,6 +149,11 @@ public class ObjectStorageBlobsDAO implements BlobStore {
}
+ @Override
+ public Mono<Void> deleteBucket(BucketName bucketName) {
+ throw new NotImplementedException("not implemented");
+ }
+
public void deleteContainer() {
blobStore.deleteContainer(containerName.value());
}
diff --git a/server/blob/blob-union/src/main/java/org/apache/james/blob/union/UnionBlobStore.java b/server/blob/blob-union/src/main/java/org/apache/james/blob/union/UnionBlobStore.java
index 3f14fd0..444c185 100644
--- a/server/blob/blob-union/src/main/java/org/apache/james/blob/union/UnionBlobStore.java
+++ b/server/blob/blob-union/src/main/java/org/apache/james/blob/union/UnionBlobStore.java
@@ -137,6 +137,13 @@ public class UnionBlobStore implements BlobStore {
}
}
+ @Override
+ public Mono<Void> deleteBucket(BucketName bucketName) {
+ return Mono.defer(() -> currentBlobStore.deleteBucket(bucketName))
+ .and(legacyBlobStore.deleteBucket(bucketName))
+ .onErrorResume(this::logAndReturnEmpty);
+ }
+
private InputStream readFallBackIfEmptyResult(BucketName bucketName, BlobId blobId) {
return Optional.ofNullable(currentBlobStore.read(bucketName, blobId))
.map(PushbackInputStream::new)
diff --git a/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java b/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java
index cba98da..a44fd0d 100644
--- a/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java
+++ b/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java
@@ -82,6 +82,11 @@ class UnionBlobStoreTest implements BlobStoreContract {
}
@Override
+ public Mono<Void> deleteBucket(BucketName bucketName) {
+ return Mono.error(new RuntimeException("broken everywhere"));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(this)
.toString();
@@ -116,6 +121,11 @@ class UnionBlobStoreTest implements BlobStoreContract {
}
@Override
+ public Mono<Void> deleteBucket(BucketName bucketName) {
+ return Mono.error(new RuntimeException("broken everywhere"));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(this)
.toString();
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 02/13: JAMES-2806 implement buckets with memory
BlobStore
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 53d3ed7317abf7f541f2fa01c1b6d0d8473da996
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue Jun 25 14:50:54 2019 +0700
JAMES-2806 implement buckets with memory BlobStore
---
.../apache/james/blob/memory/MemoryBlobStore.java | 35 +++++++++++++++-------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java b/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
index 154a9b5..b7f907a 100644
--- a/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
+++ b/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
@@ -23,7 +23,6 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
@@ -35,31 +34,41 @@ import org.apache.james.blob.api.BucketName;
import org.apache.james.blob.api.ObjectStoreException;
import com.google.common.base.Preconditions;
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Table;
+import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public class MemoryBlobStore implements BlobStore {
- private final ConcurrentHashMap<BlobId, byte[]> blobs;
private final BlobId.Factory factory;
+ private final Table<BucketName, BlobId, byte[]> blobs;
@Inject
public MemoryBlobStore(BlobId.Factory factory) {
this.factory = factory;
- blobs = new ConcurrentHashMap<>();
+ blobs = HashBasedTable.create();
}
@Override
public Mono<BlobId> save(BucketName bucketName, byte[] data) {
+ Preconditions.checkNotNull(bucketName);
Preconditions.checkNotNull(data);
- BlobId blobId = factory.forPayload(data);
- blobs.put(blobId, data);
+ BlobId blobId = factory.forPayload(data);
- return Mono.just(blobId);
+ return Mono.fromCallable(() -> {
+ synchronized (blobs) {
+ blobs.put(bucketName, blobId, data);
+ return blobId;
+ }
+ });
}
@Override
public Mono<BlobId> save(BucketName bucketName, InputStream data) {
+ Preconditions.checkNotNull(bucketName);
Preconditions.checkNotNull(data);
try {
byte[] bytes = IOUtils.toByteArray(data);
@@ -71,12 +80,14 @@ public class MemoryBlobStore implements BlobStore {
@Override
public Mono<byte[]> readBytes(BucketName bucketName, BlobId blobId) {
- return Mono.fromCallable(() -> retrieveStoredValue(blobId));
+ Preconditions.checkNotNull(bucketName);
+ return Mono.fromCallable(() -> retrieveStoredValue(bucketName, blobId));
}
@Override
public InputStream read(BucketName bucketName, BlobId blobId) {
- return new ByteArrayInputStream(retrieveStoredValue(blobId));
+ Preconditions.checkNotNull(bucketName);
+ return new ByteArrayInputStream(retrieveStoredValue(bucketName, blobId));
}
@Override
@@ -84,8 +95,10 @@ public class MemoryBlobStore implements BlobStore {
throw new NotImplementedException("not implemented");
}
- private byte[] retrieveStoredValue(BlobId blobId) {
- return Optional.ofNullable(blobs.get(blobId))
- .orElseThrow(() -> new ObjectStoreException("unable to find blob with id " + blobId));
+ private byte[] retrieveStoredValue(BucketName bucketName, BlobId blobId) {
+ synchronized (blobs) {
+ return Optional.ofNullable(blobs.get(bucketName, blobId))
+ .orElseThrow(() -> new ObjectStoreException("Unable to find blob with id " + blobId + " in bucket " + bucketName.asString()));
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 13/13: Merge remote-tracking branch
'btellier/JAMES-2807'
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit aec776ebb4bce831dd4ae08ab38e28b0b9d6c4e7
Merge: 40292be e7b5683
Author: Antoine DUPRAT <ad...@linagora.com>
AuthorDate: Thu Jul 4 10:33:15 2019 +0200
Merge remote-tracking branch 'btellier/JAMES-2807'
mailbox/plugin/deleted-messages-vault/pom.xml | 4 +
.../MemoryDeletedMessageMetadataVault.java | 115 ++++++++++++
.../metadata/DeletedMessageMetadataVault.java | 39 ++++
.../DeletedMessageWithStorageInformation.java | 63 +++++++
.../james/vault/metadata/StorageInformation.java | 64 +++++++
.../MemoryDeletedMessageMetadataVaultTest.java | 38 ++++
.../DeletedMessageMetadataVaultContract.java | 199 +++++++++++++++++++++
.../DeletedMessageVaultMetadataFixture.java | 31 ++++
.../DeletedMessageWithStorageInformationTest.java | 48 +++++
.../vault/metadata/StorageInformationTest.java | 47 +++++
mailbox/pom.xml | 3 +
11 files changed, 651 insertions(+)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 03/13: JAMES-2806 add contract for BlobStore with
custom buckets
Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2672ea9c839bbaca795ebe0146bcfdaab7014a75
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue Jun 25 16:49:46 2019 +0700
JAMES-2806 add contract for BlobStore with custom buckets
---
.../james/blob/api/BucketBlobStoreContract.java | 106 +++++++++++++++++++++
.../james/blob/memory/MemoryBlobStoreTest.java | 3 +-
2 files changed, 108 insertions(+), 1 deletion(-)
diff --git a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BucketBlobStoreContract.java b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BucketBlobStoreContract.java
new file mode 100644
index 0000000..4655bb0
--- /dev/null
+++ b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BucketBlobStoreContract.java
@@ -0,0 +1,106 @@
+/****************************************************************
+ * 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.blob.api;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+
+import org.apache.james.util.concurrency.ConcurrentTestRunner;
+import org.junit.jupiter.api.Test;
+
+public interface BucketBlobStoreContract {
+ String SHORT_STRING = "toto";
+ byte[] SHORT_BYTEARRAY = SHORT_STRING.getBytes(StandardCharsets.UTF_8);
+ BucketName CUSTOM = BucketName.of("custom");
+
+ BlobStore testee();
+
+ BlobId.Factory blobIdFactory();
+
+ @Test
+ default void saveBytesShouldThrowWhenNullBucketName() {
+ assertThatThrownBy(() -> testee().save(null, SHORT_BYTEARRAY).block())
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ default void saveStringShouldThrowWhenNullBucketName() {
+ assertThatThrownBy(() -> testee().save(null, SHORT_STRING).block())
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ default void saveInputStreamShouldThrowWhenNullBucketName() {
+ assertThatThrownBy(() -> testee().save(null, new ByteArrayInputStream(SHORT_BYTEARRAY)).block())
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ default void readShouldThrowWhenNullBucketName() {
+ BlobId blobId = testee().save(BucketName.DEFAULT, SHORT_BYTEARRAY).block();
+ assertThatThrownBy(() -> testee().read(null, blobId))
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ default void readBytesStreamShouldThrowWhenNullBucketName() {
+ BlobId blobId = testee().save(BucketName.DEFAULT, SHORT_BYTEARRAY).block();
+ assertThatThrownBy(() -> testee().readBytes(null, blobId).block())
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ default void readStringShouldThrowWhenBucketDoesNotExist() {
+ BlobId blobId = testee().save(BucketName.DEFAULT, SHORT_BYTEARRAY).block();
+ assertThatThrownBy(() -> testee().read(CUSTOM, blobId))
+ .isInstanceOf(ObjectStoreException.class);
+ }
+
+ @Test
+ default void readBytesStreamShouldThrowWhenBucketDoesNotExist() {
+ BlobId blobId = testee().save(BucketName.DEFAULT, SHORT_BYTEARRAY).block();
+ assertThatThrownBy(() -> testee().readBytes(CUSTOM, blobId).block())
+ .isInstanceOf(ObjectStoreException.class);
+ }
+
+ @Test
+ default void shouldBeAbleToSaveDataInMultipleBuckets() {
+ BlobId blobIdDefault = testee().save(BucketName.DEFAULT, SHORT_BYTEARRAY).block();
+ BlobId blobIdCustom = testee().save(CUSTOM, SHORT_BYTEARRAY).block();
+
+ byte[] bytesDefault = testee().readBytes(BucketName.DEFAULT, blobIdDefault).block();
+ byte[] bytesCustom = testee().readBytes(CUSTOM, blobIdCustom).block();
+
+ assertThat(bytesDefault).isEqualTo(bytesCustom);
+ }
+
+ @Test
+ default void saveConcurrentlyWithNonPreExistingBucketShouldNotFail() throws Exception {
+ ConcurrentTestRunner.builder()
+ .operation(((threadNumber, step) -> testee().save(CUSTOM, SHORT_STRING + threadNumber + step).block()))
+ .threadCount(10)
+ .operationCount(10)
+ .runSuccessfullyWithin(Duration.ofMinutes(1));
+ }
+}
diff --git a/server/blob/blob-memory/src/test/java/org/apache/james/blob/memory/MemoryBlobStoreTest.java b/server/blob/blob-memory/src/test/java/org/apache/james/blob/memory/MemoryBlobStoreTest.java
index 6dbac34..721c198 100644
--- a/server/blob/blob-memory/src/test/java/org/apache/james/blob/memory/MemoryBlobStoreTest.java
+++ b/server/blob/blob-memory/src/test/java/org/apache/james/blob/memory/MemoryBlobStoreTest.java
@@ -21,12 +21,13 @@ package org.apache.james.blob.memory;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BlobStore;
+import org.apache.james.blob.api.BucketBlobStoreContract;
import org.apache.james.blob.api.HashBlobId;
import org.apache.james.blob.api.MetricableBlobStore;
import org.apache.james.blob.api.MetricableBlobStoreContract;
import org.junit.jupiter.api.BeforeEach;
-public class MemoryBlobStoreTest implements MetricableBlobStoreContract {
+public class MemoryBlobStoreTest implements MetricableBlobStoreContract, BucketBlobStoreContract {
private static final HashBlobId.Factory BLOB_ID_FACTORY = new HashBlobId.Factory();
private BlobStore blobStore;
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org