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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d9834eb7ff92d71bfd153216229ad010c7449d4
|
4
|
+
data.tar.gz: ab85abd9efaca6457c57e1349c0b0494f8a769e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28fe14dde5b881475e5145272343ca6582072a29233c06871d4d24a94333c414ae1aed1643749d46c22bfc7c585dedc917d1714f11b35dfe8db8619ad08a00e5
|
7
|
+
data.tar.gz: 029de058c1e7167329c3d4bcfa95fd58d9a2b7e26319cf3365a91f4a7563999697d2476b91858fa8557d9362068484760e2c269e6eea05d7405bb5d44d858ef0
|
data/CHANGELOG.md
CHANGED
data/build.gradle
CHANGED
Binary file
|
@@ -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
|
-
|
148
|
-
|
151
|
+
InputStream inputStream = new FileInputStream(localTempFile);
|
152
|
+
BufferedOutputStream outputStream = new BufferedOutputStream(remoteFile.getContent().getOutputStream());
|
149
153
|
) {
|
150
|
-
logger.info("
|
151
|
-
|
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
|
+
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:
|
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.
|
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
|