embulk-output-sftp 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2b11bf7261d43608476053f62b5425f45643c1a
4
- data.tar.gz: dc84dd6e807ae8d0b6736eaa485ced869e8c83c2
3
+ metadata.gz: 3d9834eb7ff92d71bfd153216229ad010c7449d4
4
+ data.tar.gz: ab85abd9efaca6457c57e1349c0b0494f8a769e1
5
5
  SHA512:
6
- metadata.gz: 0025aef591b2cdb982df7d09a5b2225f1855b2e7ab97966d34cd61b74eaa1e1dcab848af0881a5f4a2159d5d6d9d39f99fd064a0ed9cf3cc686a4e9359b398e0
7
- data.tar.gz: 5bb8ab885d48fb2e3a4af7a5db9e850d7c185e0d2d4de8897abaf5c2580fba1ec4e16c3a5c60be91239cb4db280420f1dcdb8f863bc0132e0ac0ba0a8f62ce20
6
+ metadata.gz: 28fe14dde5b881475e5145272343ca6582072a29233c06871d4d24a94333c414ae1aed1643749d46c22bfc7c585dedc917d1714f11b35dfe8db8619ad08a00e5
7
+ data.tar.gz: 029de058c1e7167329c3d4bcfa95fd58d9a2b7e26319cf3365a91f4a7563999697d2476b91858fa8557d9362068484760e2c269e6eea05d7405bb5d44d858ef0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.1.5 (2018-03-13)
2
+ - Fix: Fix random hanging and log transfer progress
3
+ - https://github.com/embulk/embulk-output-sftp/pull/45
4
+
1
5
  0.1.4 (2017-12-21)
2
6
  - Fix: Disable remote temporary file rename logic
3
7
  - https://github.com/embulk/embulk-output-sftp/pull/41
data/build.gradle CHANGED
@@ -17,7 +17,7 @@ configurations {
17
17
  }
18
18
 
19
19
  group = "org.embulk.output.sftp"
20
- version = "0.1.4"
20
+ version = "0.1.5"
21
21
  sourceCompatibility = 1.7
22
22
  targetCompatibility = 1.7
23
23
 
@@ -2,7 +2,6 @@ package org.embulk.output.sftp;
2
2
 
3
3
  import com.google.common.base.Function;
4
4
  import com.google.common.base.Throwables;
5
- import org.apache.commons.io.IOUtils;
6
5
  import org.apache.commons.vfs2.FileObject;
7
6
  import org.apache.commons.vfs2.FileSystemException;
8
7
  import org.apache.commons.vfs2.FileSystemOptions;
@@ -16,11 +15,11 @@ import org.embulk.spi.util.RetryExecutor.RetryGiveupException;
16
15
  import org.embulk.spi.util.RetryExecutor.Retryable;
17
16
  import org.slf4j.Logger;
18
17
 
19
- import java.io.BufferedInputStream;
20
18
  import java.io.BufferedOutputStream;
21
19
  import java.io.File;
22
20
  import java.io.FileInputStream;
23
21
  import java.io.IOException;
22
+ import java.io.InputStream;
24
23
  import java.net.URI;
25
24
  import java.net.URISyntaxException;
26
25
 
@@ -143,12 +142,32 @@ public class SftpUtils
143
142
  @Override
144
143
  public Void call() throws IOException
145
144
  {
145
+ long size = localTempFile.length();
146
+ int step = 10; // 10% each step
147
+ long bytesPerStep = size / step;
148
+ long startTime = System.nanoTime();
149
+
146
150
  try (FileObject remoteFile = newSftpFile(getSftpFileUri(remotePath));
147
- BufferedOutputStream outputStream = new BufferedOutputStream(remoteFile.getContent().getOutputStream());
148
- BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(localTempFile))
151
+ InputStream inputStream = new FileInputStream(localTempFile);
152
+ BufferedOutputStream outputStream = new BufferedOutputStream(remoteFile.getContent().getOutputStream());
149
153
  ) {
150
- logger.info("new sftp file: {}", remoteFile.getPublicURIString());
151
- IOUtils.copy(inputStream, outputStream);
154
+ logger.info("Uploading to remote sftp file ({} KB): {}", size / 1024, remoteFile.getPublicURIString());
155
+ byte[] buffer = new byte[8 * 1024]; // 8KB ~ default buffer size of BufferedOutputStream
156
+ int len = inputStream.read(buffer);
157
+ long total = 0;
158
+ int progress = 0;
159
+ while (len != -1) {
160
+ outputStream.write(buffer, 0, len);
161
+ len = inputStream.read(buffer);
162
+ total += len;
163
+ if (total / bytesPerStep > progress) {
164
+ progress = (int) (total / bytesPerStep);
165
+ long transferRate = (long) (total / ((System.nanoTime() - startTime) / 1e9));
166
+ logger.info("Upload progress: {}% - {} KB - {} KB/s",
167
+ progress * step, total / 1024, transferRate / 1024);
168
+ }
169
+ }
170
+ logger.info("Upload completed.");
152
171
  }
153
172
  return null;
154
173
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-sftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Civitaspo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-21 00:00:00.000000000 Z
12
+ date: 2018-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +73,7 @@ files:
73
73
  - classpath/commons-io-2.6.jar
74
74
  - classpath/commons-logging-1.2.jar
75
75
  - classpath/commons-vfs2-2.2.jar
76
- - classpath/embulk-output-sftp-0.1.4.jar
76
+ - classpath/embulk-output-sftp-0.1.5.jar
77
77
  - classpath/jsch-0.1.54.jar
78
78
  homepage: https://github.com/embulk/embulk-output-sftp
79
79
  licenses:
Binary file