james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [19/19] james-project git commit: JAMES-2525 Use a separate Cached ThreadPool for ObjectStorage execution
Date Fri, 07 Dec 2018 01:10:42 GMT
JAMES-2525 Use a separate Cached ThreadPool for ObjectStorage execution


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

Branch: refs/heads/master
Commit: 8c99d0d9e3a86922ef4e426b574e23b1fe017d1c
Parents: 4734f2d
Author: tran tien duc <dtran@linagora.com>
Authored: Tue Nov 27 16:51:53 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Dec 7 08:01:17 2018 +0700

----------------------------------------------------------------------
 .../james/blob/objectstorage/ObjectStorageBlobsDAO.java  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8c99d0d9/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
----------------------------------------------------------------------
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 00b9b97..1409aaf 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
@@ -23,6 +23,8 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.blob.api.BlobId;
@@ -31,6 +33,7 @@ import org.apache.james.blob.api.ObjectStoreException;
 import org.apache.james.blob.objectstorage.swift.SwiftKeystone2ObjectStorage;
 import org.apache.james.blob.objectstorage.swift.SwiftKeystone3ObjectStorage;
 import org.apache.james.blob.objectstorage.swift.SwiftTempAuthObjectStorage;
+import org.apache.james.util.concurrent.NamedThreadFactory;
 import org.jclouds.blobstore.domain.Blob;
 import org.jclouds.blobstore.options.CopyOptions;
 import org.jclouds.domain.Location;
@@ -54,6 +57,7 @@ public class ObjectStorageBlobsDAO implements BlobStore {
     private final ContainerName containerName;
     private final org.jclouds.blobstore.BlobStore blobStore;
     private final PayloadCodec payloadCodec;
+    private final Executor executor;
 
     ObjectStorageBlobsDAO(ContainerName containerName, BlobId.Factory blobIdFactory,
                           org.jclouds.blobstore.BlobStore blobStore, PayloadCodec payloadCodec)
{
@@ -61,6 +65,7 @@ public class ObjectStorageBlobsDAO implements BlobStore {
         this.containerName = containerName;
         this.blobStore = blobStore;
         this.payloadCodec = payloadCodec;
+        this.executor = Executors.newCachedThreadPool(NamedThreadFactory.withClassName(getClass()));
     }
 
     public static ObjectStorageBlobsDAOBuilder.RequireContainerName builder(SwiftTempAuthObjectStorage.Configuration
testConfig) {
@@ -102,7 +107,7 @@ public class ObjectStorageBlobsDAO implements BlobStore {
     private CompletableFuture<BlobId> updateBlobId(BlobId from, BlobId to) {
         String containerName = this.containerName.value();
         return CompletableFuture
-            .supplyAsync(() -> blobStore.copyBlob(containerName, from.asString(), containerName,
to.asString(), CopyOptions.NONE))
+            .supplyAsync(() -> blobStore.copyBlob(containerName, from.asString(), containerName,
to.asString(), CopyOptions.NONE), executor)
             .thenAcceptAsync(any -> blobStore.removeBlob(containerName, from.asString()))
             .thenApply(any -> to);
     }
@@ -114,14 +119,14 @@ public class ObjectStorageBlobsDAO implements BlobStore {
         Blob blob = blobStore.blobBuilder(id.asString()).payload(payload).build();
 
         return CompletableFuture
-            .supplyAsync(() -> blobStore.putBlob(containerName, blob))
+            .supplyAsync(() -> blobStore.putBlob(containerName, blob), executor)
             .thenApply(any -> blobIdFactory.from(hashingInputStream.hash().toString()));
     }
 
     @Override
     public CompletableFuture<byte[]> readBytes(BlobId blobId) {
         return CompletableFuture
-            .supplyAsync(Throwing.supplier(() -> IOUtils.toByteArray(read(blobId))).sneakyThrow());
+            .supplyAsync(Throwing.supplier(() -> IOUtils.toByteArray(read(blobId))).sneakyThrow(),
executor);
     }
 
     @Override


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


Mime
View raw message