chibenwa commented on a change in pull request #436:
URL: https://github.com/apache/james-project/pull/436#discussion_r634209706
##########
File path: server/blob/blob-cassandra/pom.xml
##########
@@ -65,6 +65,10 @@
<groupId>${james.groupId}</groupId>
<artifactId>james-server-util</artifactId>
</dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>metrics-logger</artifactId>
Review comment:
Why? MetricFactory API is not enough?
##########
File path:
server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobStoreClOneTest.java
##########
@@ -0,0 +1,216 @@
+package org.apache.james.blob.cassandra;
+
+import static org.apache.james.blob.api.BlobStore.StoragePolicy.LOW_COST;
+import static
org.apache.james.blob.cassandra.CassandraBlobStoreDAO.CASSANDRA_BLOBSTORE_CL_ONE_HIT_COUNT_METRIC_NAME;
+import static
org.apache.james.blob.cassandra.CassandraBlobStoreDAO.CASSANDRA_BLOBSTORE_CL_ONE_MISS_COUNT_METRIC_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.awaitility.Awaitility.await;
+import static org.awaitility.Durations.FIVE_SECONDS;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
+import
org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
+import org.apache.james.blob.api.BlobId;
+import org.apache.james.blob.api.BlobStore;
+import org.apache.james.blob.api.BucketName;
+import org.apache.james.blob.api.HashBlobId;
+import org.apache.james.blob.api.MetricableBlobStore;
+import org.apache.james.blob.api.ObjectStoreException;
+import org.apache.james.metrics.api.MetricFactory;
+import org.apache.james.server.blob.deduplication.BlobStoreFactory;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import com.google.common.base.Strings;
+
+import reactor.core.publisher.Mono;
+
+class CassandraBlobStoreClOneTest implements CassandraBlobStoreContract {
+ @RegisterExtension
+ static CassandraClusterExtension cassandraCluster = new
CassandraClusterExtension(CassandraBlobModule.MODULE);
+
+ private BlobStore testee;
+ private CassandraDefaultBucketDAO defaultBucketDAO;
+
+ @BeforeEach
+ void setUp(CassandraCluster cassandra) {
+ HashBlobId.Factory blobIdFactory = new HashBlobId.Factory();
+ CassandraBucketDAO bucketDAO = new CassandraBucketDAO(blobIdFactory,
cassandra.getConf());
+ defaultBucketDAO = spy(new
CassandraDefaultBucketDAO(cassandra.getConf()));
+ CassandraConfiguration cassandraConfiguration =
CassandraConfiguration.builder()
+ .blobPartSize(CHUNK_SIZE)
+ .optimisticConsistencyLevel(true)
+ .build();
+ MetricFactory metricFactory = metricsTestExtension.getMetricFactory();
+ testee = new MetricableBlobStore(
+ metricFactory,
+ BlobStoreFactory.builder()
+ .blobStoreDAO(new CassandraBlobStoreDAO(defaultBucketDAO,
bucketDAO, cassandraConfiguration, BucketName.DEFAULT, metricFactory))
+ .blobIdFactory(blobIdFactory)
+ .defaultBucketName()
+ .deduplication());
+ }
+
+ @Override
+ public BlobStore testee() {
+ return testee;
+ }
+
+ @Override
+ public BlobId.Factory blobIdFactory() {
+ return new HashBlobId.Factory();
+ }
+
+ @Override
+ public CassandraDefaultBucketDAO defaultBucketDAO() {
+ return defaultBucketDAO;
+ }
+
+ @Override
+ @Test
+ public void readShouldNotReturnInvalidResultsWhenPartialDataPresent() {
+ int repeatCount = MULTIPLE_CHUNK_SIZE * CHUNK_SIZE;
+ String longString = Strings.repeat("0123456789\n", repeatCount);
+ BlobId blobId =
Mono.from(testee().save(testee().getDefaultBucketName(), longString,
LOW_COST)).block();
+
+ when(defaultBucketDAO().readPartClOne(blobId,
1)).thenReturn(Mono.empty());
+ when(defaultBucketDAO().readPart(blobId, 1)).thenReturn(Mono.empty());
+
+ assertThatThrownBy(() ->
IOUtils.toString(testee().read(testee().getDefaultBucketName(), blobId),
StandardCharsets.UTF_8))
+ .isInstanceOf(ObjectStoreException.class)
+ .hasMessageContaining("Missing blob part for blobId");
Review comment:
No then we should fallback to CL QUORUM...
##########
File path:
server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobStoreClOneTest.java
##########
@@ -0,0 +1,216 @@
+package org.apache.james.blob.cassandra;
Review comment:
Oups
##########
File path:
server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobStoreClOneTest.java
##########
@@ -0,0 +1,216 @@
+package org.apache.james.blob.cassandra;
+
+import static org.apache.james.blob.api.BlobStore.StoragePolicy.LOW_COST;
+import static
org.apache.james.blob.cassandra.CassandraBlobStoreDAO.CASSANDRA_BLOBSTORE_CL_ONE_HIT_COUNT_METRIC_NAME;
+import static
org.apache.james.blob.cassandra.CassandraBlobStoreDAO.CASSANDRA_BLOBSTORE_CL_ONE_MISS_COUNT_METRIC_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.awaitility.Awaitility.await;
+import static org.awaitility.Durations.FIVE_SECONDS;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
+import
org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
+import org.apache.james.blob.api.BlobId;
+import org.apache.james.blob.api.BlobStore;
+import org.apache.james.blob.api.BucketName;
+import org.apache.james.blob.api.HashBlobId;
+import org.apache.james.blob.api.MetricableBlobStore;
+import org.apache.james.blob.api.ObjectStoreException;
+import org.apache.james.metrics.api.MetricFactory;
+import org.apache.james.server.blob.deduplication.BlobStoreFactory;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import com.google.common.base.Strings;
+
+import reactor.core.publisher.Mono;
+
+class CassandraBlobStoreClOneTest implements CassandraBlobStoreContract {
+ @RegisterExtension
+ static CassandraClusterExtension cassandraCluster = new
CassandraClusterExtension(CassandraBlobModule.MODULE);
+
+ private BlobStore testee;
+ private CassandraDefaultBucketDAO defaultBucketDAO;
+
+ @BeforeEach
+ void setUp(CassandraCluster cassandra) {
+ HashBlobId.Factory blobIdFactory = new HashBlobId.Factory();
+ CassandraBucketDAO bucketDAO = new CassandraBucketDAO(blobIdFactory,
cassandra.getConf());
+ defaultBucketDAO = spy(new
CassandraDefaultBucketDAO(cassandra.getConf()));
+ CassandraConfiguration cassandraConfiguration =
CassandraConfiguration.builder()
+ .blobPartSize(CHUNK_SIZE)
+ .optimisticConsistencyLevel(true)
+ .build();
+ MetricFactory metricFactory = metricsTestExtension.getMetricFactory();
+ testee = new MetricableBlobStore(
+ metricFactory,
+ BlobStoreFactory.builder()
+ .blobStoreDAO(new CassandraBlobStoreDAO(defaultBucketDAO,
bucketDAO, cassandraConfiguration, BucketName.DEFAULT, metricFactory))
+ .blobIdFactory(blobIdFactory)
+ .defaultBucketName()
+ .deduplication());
+ }
+
+ @Override
+ public BlobStore testee() {
+ return testee;
+ }
+
+ @Override
+ public BlobId.Factory blobIdFactory() {
+ return new HashBlobId.Factory();
+ }
+
+ @Override
+ public CassandraDefaultBucketDAO defaultBucketDAO() {
+ return defaultBucketDAO;
+ }
+
+ @Override
+ @Test
+ public void readShouldNotReturnInvalidResultsWhenPartialDataPresent() {
+ int repeatCount = MULTIPLE_CHUNK_SIZE * CHUNK_SIZE;
+ String longString = Strings.repeat("0123456789\n", repeatCount);
+ BlobId blobId =
Mono.from(testee().save(testee().getDefaultBucketName(), longString,
LOW_COST)).block();
+
+ when(defaultBucketDAO().readPartClOne(blobId,
1)).thenReturn(Mono.empty());
+ when(defaultBucketDAO().readPart(blobId, 1)).thenReturn(Mono.empty());
+
+ assertThatThrownBy(() ->
IOUtils.toString(testee().read(testee().getDefaultBucketName(), blobId),
StandardCharsets.UTF_8))
+ .isInstanceOf(ObjectStoreException.class)
+ .hasMessageContaining("Missing blob part for blobId");
+ }
+
+ @Override
+ @Test
+ public void readBytesShouldNotReturnInvalidResultsWhenPartialDataPresent()
{
+ int repeatCount = MULTIPLE_CHUNK_SIZE * CHUNK_SIZE;
+ String longString = Strings.repeat("0123456789\n", repeatCount);
+ BlobId blobId =
Mono.from(testee().save(testee().getDefaultBucketName(), longString,
LOW_COST)).block();
+
+ when(defaultBucketDAO().readPartClOne(blobId,
1)).thenReturn(Mono.empty());
+ when(defaultBucketDAO().readPart(blobId, 1)).thenReturn(Mono.empty());
+
+ assertThatThrownBy(() ->
Mono.from(testee().readBytes(testee().getDefaultBucketName(), blobId)).block())
+ .isInstanceOf(ObjectStoreException.class)
+ .hasMessageContaining("Missing blob part for blobId");
Review comment:
No then we should fallback to CL QUORUM...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]