From 22364efa66f6c5d4325f86c8bed923b187ae6dcf Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 2 Oct 2023 14:08:46 +0200 Subject: [PATCH] Cleanup IBM COS --- afs/ibm/pom.xml | 18 ++++++------------ .../afs/ibm/cos/types/CosConnector.java | 19 +++++++++++++++---- .../ibm/cos/types/CosFileSystemCreator.java | 2 +- .../afs/ibm/cos/types/CosPathValidator.java | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/afs/ibm/pom.xml b/afs/ibm/pom.xml index cd5727279..7a810ef66 100644 --- a/afs/ibm/pom.xml +++ b/afs/ibm/pom.xml @@ -16,26 +16,20 @@ microstream-afs-ibm-cos https://microstream.one + + 2.13.2 + + com.ibm.cos ibm-cos-java-sdk-core - 2.13.2 + ${ibm.java.sdk.version} com.ibm.cos ibm-cos-java-sdk-s3 - 2.13.2 - - - com.ibm.cos - ibm-cos-java-sdk-core - - - com.ibm.cos - ibm-cos-java-sdk-kms - - + ${ibm.java.sdk.version} diff --git a/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosConnector.java b/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosConnector.java index 63b1caf81..7660da8e7 100644 --- a/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosConnector.java +++ b/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosConnector.java @@ -2,7 +2,7 @@ /*- * #%L - * microstream-afs-ibm-ocs + * microstream-afs-ibm-cos * %% * Copyright (C) 2019 - 2022 MicroStream Software * %% @@ -26,6 +26,7 @@ import com.ibm.cloud.objectstorage.services.s3.model.GetObjectRequest; import com.ibm.cloud.objectstorage.services.s3.model.ListObjectsV2Request; import com.ibm.cloud.objectstorage.services.s3.model.ObjectMetadata; +import com.ibm.cloud.objectstorage.services.s3.model.PutObjectRequest; import com.ibm.cloud.objectstorage.services.s3.model.S3ObjectInputStream; import com.ibm.cloud.objectstorage.services.s3.model.S3ObjectSummary; import one.microstream.afs.blobstore.types.BlobStoreConnector; @@ -41,7 +42,7 @@ import java.util.List; import java.util.regex.Pattern; import java.util.stream.Stream; - +import java.util.stream.StreamSupport; /** @@ -97,6 +98,7 @@ public static class Default extends BlobStoreConnector.Abstract implements CosConnector { + public static final int READ_LIMIT = Integer.MAX_VALUE; private final AmazonS3 s3; Default( @@ -227,12 +229,21 @@ protected long internalWriteData( ByteBufferInputStream.New(sourceBuffers) )) { - this.s3.putObject( + int bufferSum = StreamSupport.stream(sourceBuffers.spliterator(), false).mapToInt( + buffer -> buffer.limit() + ).sum(); + + ObjectMetadata objectMetadata = new ObjectMetadata(); + objectMetadata.setContentLength(bufferSum); + PutObjectRequest putObjectRequest = new PutObjectRequest( file.container(), toBlobKey(file, nextBlobNumber), inputStream, - new ObjectMetadata() + objectMetadata ); + putObjectRequest.getRequestClientOptions().setReadLimit(READ_LIMIT); + + this.s3.putObject(putObjectRequest); } catch(final IOException e) { diff --git a/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosFileSystemCreator.java b/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosFileSystemCreator.java index e6c34f1ba..0e98afb82 100644 --- a/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosFileSystemCreator.java +++ b/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosFileSystemCreator.java @@ -2,7 +2,7 @@ /*- * #%L - * microstream-afs-ibm-ocs + * microstream-afs-ibm-cos * %% * Copyright (C) 2019 - 2022 MicroStream Software * %% diff --git a/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosPathValidator.java b/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosPathValidator.java index 2357d1e9c..79c7a77da 100644 --- a/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosPathValidator.java +++ b/afs/ibm/src/main/java/one/microstream/afs/ibm/cos/types/CosPathValidator.java @@ -2,7 +2,7 @@ /*- * #%L - * microstream-afs-ibm-ocs + * microstream-afs-ibm-cos * %% * Copyright (C) 2019 - 2022 MicroStream Software * %%