embulk-output-s3_per_record 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df24af87908ca267e9a6518308f0bfb319d14808
4
- data.tar.gz: 1f9f6af566dff9c786c1f9531b7527d039eadcf2
3
+ metadata.gz: 59291fd824e6db4a6f56e4e3b107f1be43a71dfa
4
+ data.tar.gz: 0cb03ee9ae9d61130c53c5a0f5b80e5bd4ae34d7
5
5
  SHA512:
6
- metadata.gz: 083299386ca77263932553aaab9bb0e735f73b24ebe502328568ab70e4d7d0ff5c9711792c7a4758a0a3daeb5c74f2b5567473cc9310b325f78f6d8fe25f333e
7
- data.tar.gz: 38912a1f91df7c26d1db2a023babd24b7a696b8f132f8218add7b59890bd668fd172205fff76105fd851d7ed346a22314502176703861983a37a7aff73824605
6
+ metadata.gz: 7c446fa5ddc162c53763695e8b36d5ca6ec213d5e677ecf5df0fe31097e5aae445ae34176642dcdfbe51b05085d5fc82d771a1572588386c9587c22c9f3b2b8a
7
+ data.tar.gz: 7c7e563beeede3252e82ed481a9e4bba1785bf4e6f1abfb508d602041a8ad37df6db7a6f5d6b61ba78c042274d2a8b5abc13a3423f75edda8cdbbe4c05624220
data/.gitignore CHANGED
@@ -10,3 +10,4 @@ build/
10
10
  /.metadata/
11
11
  .classpath
12
12
  .project
13
+ *.iml
data/build.gradle CHANGED
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.2"
16
+ version = "0.2.0"
17
17
 
18
18
  sourceCompatibility = 1.7
19
19
  targetCompatibility = 1.7
@@ -6,6 +6,7 @@ import java.io.InputStream;
6
6
  import java.nio.charset.StandardCharsets;
7
7
  import java.util.ArrayList;
8
8
  import java.util.List;
9
+ import java.util.concurrent.atomic.AtomicLong;
9
10
 
10
11
  import javax.validation.constraints.NotNull;
11
12
 
@@ -32,6 +33,7 @@ import com.amazonaws.services.s3.transfer.TransferManager;
32
33
  import com.amazonaws.services.s3.transfer.Upload;
33
34
  import com.amazonaws.util.Base64;
34
35
  import com.google.common.base.Optional;
36
+ import org.slf4j.Logger;
35
37
 
36
38
 
37
39
  public class S3PerRecordOutputPlugin
@@ -41,6 +43,11 @@ public class S3PerRecordOutputPlugin
41
43
  public static final String KEY_COLUMN_START_MARKER = "${";
42
44
  public static final String KEY_COLUMN_END_MARKER = "}";
43
45
 
46
+ private static final Logger logger = Exec.getLogger(S3PerRecordOutputPlugin.class);
47
+ private static volatile long nextLoggingRowCount = 1000;
48
+ private static AtomicLong processedRows = new AtomicLong(0);
49
+ private static long startTime = System.currentTimeMillis();
50
+
44
51
  public interface PluginTask
45
52
  extends Task
46
53
  {
@@ -129,6 +136,7 @@ public class S3PerRecordOutputPlugin
129
136
  credentials = new DefaultAWSCredentialsProviderChain().getCredentials();
130
137
  }
131
138
  transferManager = new TransferManager(credentials);
139
+ logger.info("Start Upload to bucket \"{}\"", bucket);
132
140
  }
133
141
 
134
142
  private List<KeyPart> makeKeyPattern(final String key) {
@@ -175,6 +183,12 @@ public class S3PerRecordOutputPlugin
175
183
  try (InputStream is = new ByteArrayInputStream(payloadBytes)) {
176
184
  Upload upload = transferManager.upload(bucket, key, is, metadata);
177
185
  upload.waitForUploadResult();
186
+ long rows = processedRows.incrementAndGet();
187
+ if (rows == nextLoggingRowCount) {
188
+ double seconds = (System.currentTimeMillis() - startTime) / 1000.0;
189
+ logger.info(String.format("> Uploaded %,d rows in %.2f seconds", rows, seconds));
190
+ nextLoggingRowCount *= 2;
191
+ }
178
192
  } catch (InterruptedException | IOException e) {
179
193
  throw new RuntimeException(e);
180
194
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-s3_per_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tomykaira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-22 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -63,8 +63,8 @@ files:
63
63
  - classpath/commons-logging-1.1.3.jar
64
64
  - classpath/commons-codec-1.6.jar
65
65
  - classpath/aws-java-sdk-s3-1.10.71.jar
66
- - classpath/embulk-output-s3_per_record-0.1.2.jar
67
66
  - classpath/aws-java-sdk-core-1.10.71.jar
67
+ - classpath/embulk-output-s3_per_record-0.2.0.jar
68
68
  - classpath/httpcore-4.3.3.jar
69
69
  - classpath/aws-java-sdk-kms-1.10.71.jar
70
70
  homepage: https://github.com/tomykaira/embulk-output-s3_per_record