embulk-output-s3v2 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/output/s3v2/PluginTask.java +8 -0
- data/src/main/java/org/embulk/output/s3v2/s3/S3ClientManager.java +18 -4
- data/src/main/java/org/embulk/output/s3v2/strategy/AbstractStrategy.java +1 -1
- data/src/test/java/org/embulk/output/s3v2/util/ThresholdComputationTests.java +43 -0
- metadata +20 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c87b938e84dcad47a5b47f65872b15d6a549877003bc1379bf9ca32c44eddb
|
4
|
+
data.tar.gz: 3505a9c76d0c385e25d8b1b11676143cca4b3c798d130a0e0c0724abd63dc1a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc999df40b640047ba878092a623b22ad25b8c975600a4615165446703b3827e823d24ed7df17b7bcc1aa64ef181847414ef72381a529b41642573a868e0c045
|
7
|
+
data.tar.gz: 3d3b4f6360528d541fff6d84963dd96b4d44360c0d9ab0f47f657ec0fee550858ff03faa64f4c0d0f2b30ee8910516a497a43b6a2ba38ae4bf67cd8272caa848
|
data/README.md
CHANGED
@@ -13,6 +13,10 @@ Files stores on Amazon S3.
|
|
13
13
|
|
14
14
|
## Configuration
|
15
15
|
- **region**: AWS region name. (string, required)
|
16
|
+
- **enable_profile**: If true, AWS credentials profile will be used when authenticating AWS. (boolean, default: `false`)
|
17
|
+
- Supported in v0.2.0 or later
|
18
|
+
- **profile**: AWS credentials profile name. If `enable_profile` is false, this parameter will be ignored. (string, default: `default`)
|
19
|
+
- Supported in v0.2.0 or later
|
16
20
|
- **bucket**: S3 bucket name. (string, required)
|
17
21
|
- **object_key_prefix**: Prefix of S3 Objects key name. (string, required)
|
18
22
|
- **enable_multi_part_upload**: If true, multipart upload will be enable. (boolean, default: `false`)
|
data/build.gradle
CHANGED
@@ -10,6 +10,14 @@ public interface PluginTask
|
|
10
10
|
@Config("region")
|
11
11
|
public String getRegion();
|
12
12
|
|
13
|
+
@Config("enable_profile")
|
14
|
+
@ConfigDefault("false")
|
15
|
+
public boolean getEnableProfile();
|
16
|
+
|
17
|
+
@Config("profile")
|
18
|
+
@ConfigDefault("\"default\"")
|
19
|
+
public String getProfile();
|
20
|
+
|
13
21
|
@Config("bucket")
|
14
22
|
public String getBucket();
|
15
23
|
|
@@ -16,9 +16,13 @@ import java.util.concurrent.ExecutorService;
|
|
16
16
|
import java.util.concurrent.Executors;
|
17
17
|
|
18
18
|
import org.embulk.output.s3v2.util.ChunksizeComputation;
|
19
|
+
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
|
20
|
+
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
|
21
|
+
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
|
19
22
|
import software.amazon.awssdk.core.sync.RequestBody;
|
20
23
|
import software.amazon.awssdk.regions.Region;
|
21
24
|
import software.amazon.awssdk.services.s3.S3Client;
|
25
|
+
import software.amazon.awssdk.services.s3.S3ClientBuilder;
|
22
26
|
import software.amazon.awssdk.services.s3.model.AbortMultipartUploadRequest;
|
23
27
|
import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest;
|
24
28
|
import software.amazon.awssdk.services.s3.model.CompletedMultipartUpload;
|
@@ -37,16 +41,26 @@ public class S3ClientManager
|
|
37
41
|
{
|
38
42
|
private final S3Client s3;
|
39
43
|
|
40
|
-
public S3ClientManager(String regionName)
|
44
|
+
public S3ClientManager(String regionName, boolean enableProfile, String profileName)
|
41
45
|
{
|
46
|
+
S3ClientBuilder builder = S3Client.builder();
|
47
|
+
|
42
48
|
Region region = Region.of(regionName);
|
43
49
|
if (Region.regions().stream().noneMatch(o -> o.equals(region))) {
|
44
50
|
throw new IllegalArgumentException("Not found aws region: " + regionName);
|
45
51
|
}
|
52
|
+
builder = builder.region(region);
|
46
53
|
|
47
|
-
|
48
|
-
|
49
|
-
|
54
|
+
AwsCredentialsProvider provider;
|
55
|
+
if (enableProfile) {
|
56
|
+
provider = ProfileCredentialsProvider.create(profileName);
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
provider = DefaultCredentialsProvider.builder().profileName("").build();
|
60
|
+
}
|
61
|
+
builder = builder.credentialsProvider(provider);
|
62
|
+
|
63
|
+
s3 = builder.build();
|
50
64
|
}
|
51
65
|
|
52
66
|
/**
|
@@ -13,7 +13,7 @@ abstract class AbstractStrategy implements TransactionalFileOutput
|
|
13
13
|
|
14
14
|
public AbstractStrategy(PluginTask task, int taskIndex)
|
15
15
|
{
|
16
|
-
s3 = new S3ClientManager(task.getRegion());
|
16
|
+
s3 = new S3ClientManager(task.getRegion(), task.getEnableProfile(), task.getProfile());
|
17
17
|
this.task = task;
|
18
18
|
this.taskIndex = taskIndex;
|
19
19
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
package org.embulk.output.s3v2.util;
|
2
|
+
|
3
|
+
import org.junit.jupiter.api.Assertions;
|
4
|
+
import org.junit.jupiter.api.DisplayName;
|
5
|
+
import org.junit.jupiter.api.Test;
|
6
|
+
import org.junit.jupiter.api.extension.ExtendWith;
|
7
|
+
import org.mockito.junit.jupiter.MockitoExtension;
|
8
|
+
|
9
|
+
import java.nio.ByteBuffer;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* @see ThresholdComputation
|
13
|
+
*/
|
14
|
+
@ExtendWith(MockitoExtension.class)
|
15
|
+
public class ThresholdComputationTests
|
16
|
+
{
|
17
|
+
@Test
|
18
|
+
@DisplayName("Threshold check returns true")
|
19
|
+
public void testThresholdCheckReturnsTrue() throws Exception
|
20
|
+
{
|
21
|
+
ByteBuffer bf = ByteBuffer.allocate(1000001);
|
22
|
+
Assertions.assertTrue(ThresholdComputation.largerThanThreshold("1MB", bf.capacity()));
|
23
|
+
}
|
24
|
+
|
25
|
+
@Test
|
26
|
+
@DisplayName("Threshold check returns false")
|
27
|
+
public void testThresholdCheckReturnsFalse() throws Exception
|
28
|
+
{
|
29
|
+
ByteBuffer bf = ByteBuffer.allocate(1000000);
|
30
|
+
Assertions.assertFalse(ThresholdComputation.largerThanThreshold("1MB", bf.capacity()));
|
31
|
+
}
|
32
|
+
|
33
|
+
@Test
|
34
|
+
@DisplayName("Invalid threshold string")
|
35
|
+
public void testInvalidThresholdString() throws Exception
|
36
|
+
{
|
37
|
+
ByteBuffer bf = ByteBuffer.allocate(1000000);
|
38
|
+
String threshold = "1MB1MB";
|
39
|
+
IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException.class,
|
40
|
+
() -> ThresholdComputation.largerThanThreshold(threshold, bf.capacity()));
|
41
|
+
Assertions.assertEquals("Unrecognized value of multipart_threshold: " + threshold, ex.getMessage());
|
42
|
+
}
|
43
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-s3v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshihiro Takushima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Stores files on Amazon S3 using aws-sdk-java-v2.
|
14
14
|
email:
|
@@ -23,45 +23,45 @@ files:
|
|
23
23
|
- LICENSE
|
24
24
|
- README.md
|
25
25
|
- build.gradle
|
26
|
-
- classpath/annotations-2.15.
|
27
|
-
- classpath/apache-client-2.15.
|
28
|
-
- classpath/arns-2.15.
|
29
|
-
- classpath/auth-2.15.
|
30
|
-
- classpath/aws-core-2.15.
|
31
|
-
- classpath/aws-query-protocol-2.15.
|
32
|
-
- classpath/aws-xml-protocol-2.15.
|
26
|
+
- classpath/annotations-2.15.61.jar
|
27
|
+
- classpath/apache-client-2.15.61.jar
|
28
|
+
- classpath/arns-2.15.61.jar
|
29
|
+
- classpath/auth-2.15.61.jar
|
30
|
+
- classpath/aws-core-2.15.61.jar
|
31
|
+
- classpath/aws-query-protocol-2.15.61.jar
|
32
|
+
- classpath/aws-xml-protocol-2.15.61.jar
|
33
33
|
- classpath/commons-codec-1.11.jar
|
34
34
|
- classpath/commons-logging-1.2.jar
|
35
|
-
- classpath/embulk-output-s3v2-0.
|
35
|
+
- classpath/embulk-output-s3v2-0.2.0.jar
|
36
36
|
- classpath/eventstream-1.0.1.jar
|
37
|
-
- classpath/http-client-spi-2.15.
|
37
|
+
- classpath/http-client-spi-2.15.61.jar
|
38
38
|
- classpath/httpclient-4.5.13.jar
|
39
39
|
- classpath/httpcore-4.4.13.jar
|
40
40
|
- classpath/jackson-annotations-2.10.5.jar
|
41
41
|
- classpath/jackson-core-2.10.5.jar
|
42
42
|
- classpath/jackson-databind-2.10.5.1.jar
|
43
|
-
- classpath/metrics-spi-2.15.
|
43
|
+
- classpath/metrics-spi-2.15.61.jar
|
44
44
|
- classpath/netty-buffer-4.1.53.Final.jar
|
45
45
|
- classpath/netty-codec-4.1.53.Final.jar
|
46
46
|
- classpath/netty-codec-http-4.1.53.Final.jar
|
47
47
|
- classpath/netty-codec-http2-4.1.53.Final.jar
|
48
48
|
- classpath/netty-common-4.1.53.Final.jar
|
49
49
|
- classpath/netty-handler-4.1.53.Final.jar
|
50
|
-
- classpath/netty-nio-client-2.15.
|
50
|
+
- classpath/netty-nio-client-2.15.61.jar
|
51
51
|
- classpath/netty-reactive-streams-2.0.4.jar
|
52
52
|
- classpath/netty-reactive-streams-http-2.0.4.jar
|
53
53
|
- classpath/netty-resolver-4.1.53.Final.jar
|
54
54
|
- classpath/netty-transport-4.1.53.Final.jar
|
55
55
|
- classpath/netty-transport-native-epoll-4.1.53.Final-linux-x86_64.jar
|
56
56
|
- classpath/netty-transport-native-unix-common-4.1.53.Final.jar
|
57
|
-
- classpath/profiles-2.15.
|
58
|
-
- classpath/protocol-core-2.15.
|
57
|
+
- classpath/profiles-2.15.61.jar
|
58
|
+
- classpath/protocol-core-2.15.61.jar
|
59
59
|
- classpath/reactive-streams-1.0.3.jar
|
60
|
-
- classpath/regions-2.15.
|
61
|
-
- classpath/s3-2.15.
|
62
|
-
- classpath/sdk-core-2.15.
|
60
|
+
- classpath/regions-2.15.61.jar
|
61
|
+
- classpath/s3-2.15.61.jar
|
62
|
+
- classpath/sdk-core-2.15.61.jar
|
63
63
|
- classpath/slf4j-api-1.7.28.jar
|
64
|
-
- classpath/utils-2.15.
|
64
|
+
- classpath/utils-2.15.61.jar
|
65
65
|
- config/checkstyle/checkstyle.xml
|
66
66
|
- config/checkstyle/default.xml
|
67
67
|
- gradle/wrapper/gradle-wrapper.jar
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- src/main/java/org/embulk/output/s3v2/util/ThresholdComputation.java
|
83
83
|
- src/test/java/org/embulk/output/s3v2/strategy/BufferedStrategyTests.java
|
84
84
|
- src/test/java/org/embulk/output/s3v2/util/ChunksizeComputationTests.java
|
85
|
+
- src/test/java/org/embulk/output/s3v2/util/ThresholdComputationTests.java
|
85
86
|
- src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
|
86
87
|
homepage: https://github.com/ttksm/embulk-output-s3v2
|
87
88
|
licenses:
|