Skip to content

Commit

Permalink
Cleanup IBM COS
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesRabauer committed Oct 2, 2023
1 parent c40b4d4 commit 22364ef
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
18 changes: 6 additions & 12 deletions afs/ibm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,20 @@
<artifactId>microstream-afs-ibm-cos</artifactId>
<url>https://microstream.one</url>

<properties>
<ibm.java.sdk.version>2.13.2</ibm.java.sdk.version>
</properties>

<dependencies>
<dependency>
<groupId>com.ibm.cos</groupId>
<artifactId>ibm-cos-java-sdk-core</artifactId>
<version>2.13.2</version>
<version>${ibm.java.sdk.version}</version>
</dependency>
<dependency>
<groupId>com.ibm.cos</groupId>
<artifactId>ibm-cos-java-sdk-s3</artifactId>
<version>2.13.2</version>
<exclusions>
<exclusion>
<groupId>com.ibm.cos</groupId>
<artifactId>ibm-cos-java-sdk-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.ibm.cos</groupId>
<artifactId>ibm-cos-java-sdk-kms</artifactId>
</exclusion>
</exclusions>
<version>${ibm.java.sdk.version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/*-
* #%L
* microstream-afs-ibm-ocs
* microstream-afs-ibm-cos
* %%
* Copyright (C) 2019 - 2022 MicroStream Software
* %%
Expand All @@ -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;
Expand All @@ -41,7 +42,7 @@
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import java.util.stream.StreamSupport;


/**
Expand Down Expand Up @@ -97,6 +98,7 @@ public static class Default
extends BlobStoreConnector.Abstract<S3ObjectSummary>
implements CosConnector
{
public static final int READ_LIMIT = Integer.MAX_VALUE;
private final AmazonS3 s3;

Default(
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/*-
* #%L
* microstream-afs-ibm-ocs
* microstream-afs-ibm-cos
* %%
* Copyright (C) 2019 - 2022 MicroStream Software
* %%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/*-
* #%L
* microstream-afs-ibm-ocs
* microstream-afs-ibm-cos
* %%
* Copyright (C) 2019 - 2022 MicroStream Software
* %%
Expand Down

0 comments on commit 22364ef

Please sign in to comment.