embulk-input-sftp 0.1.2 → 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/.travis.yml +10 -0
- data/CHANGELOG.md +8 -2
- data/README.md +2 -0
- data/build.gradle +3 -3
- data/classpath/commons-vfs2-2.1.jar +0 -0
- data/classpath/embulk-input-sftp-0.2.0.jar +0 -0
- data/src/main/java/org/embulk/input/sftp/FileList.java +0 -1
- data/src/main/java/org/embulk/input/sftp/PluginTask.java +4 -0
- data/src/main/java/org/embulk/input/sftp/SftpFileInput.java +15 -11
- data/src/main/java/org/embulk/input/sftp/SftpFileInputPlugin.java +3 -1
- data/src/main/java/org/embulk/input/sftp/SingleFileProvider.java +0 -1
- data/src/test/java/org/embulk/input/sftp/TestSftpFileInputPlugin.java +18 -0
- metadata +6 -5
- data/classpath/commons-vfs2-2.1.1660580.2.jar +0 -0
- data/classpath/embulk-input-sftp-0.1.2.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2afbf35e073d8e31985a7c797395c796828aa675
|
4
|
+
data.tar.gz: 73667da5ec1be837b3c5811969dc5c4ba4014731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bb521683b3668ef39f71233755eaabc3f2b67578e711efe942e095dbf97969f1b7aeeb72bb5cbb422a7eeb3d4dc9384e549e0a9f94a331a3829c0d5d779bb8a
|
7
|
+
data.tar.gz: cbb3f79afc30b70fca469bd6012653d13e58983d03934a48d76e474c277e9cc7b79161a03eaf48b38c2ce7389048545cd0dfa77c7d373a216eec556e84941aee
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
+
## 0.2.0 - 2016-08-19
|
2
|
+
|
3
|
+
* [new feature] Support incremental option [#11](https://github.com/sakama/embulk-input-sftp/pull/11)
|
4
|
+
* [maintenance] Mask password in the log [#12](https://github.com/sakama/embulk-input-sftp/pull/12)
|
5
|
+
* [maintenance] Fix file listing order and handling of last_path [#14](https://github.com/sakama/embulk-input-sftp/pull/14)
|
6
|
+
|
1
7
|
## 0.1.2 - 2015-03-23
|
2
8
|
|
3
9
|
* [maintenance] Use RetryExecutor when retrying that is provide by embulk-core [#9](https://github.com/sakama/embulk-input-sftp/pull/9)
|
4
10
|
|
5
11
|
## 0.1.1 - 2015-03-18
|
6
12
|
|
7
|
-
* [feature] Support last_path_ option [#2](https://github.com/sakama/embulk-input-sftp/pull/2)[#4](https://github.com/sakama/embulk-input-sftp/pull/4)[#7](https://github.com/sakama/embulk-input-sftp/pull/7)
|
8
|
-
* [feature] Support path_match_pattern option [#6](https://github.com/sakama/embulk-input-sftp/pull/6)
|
13
|
+
* [new feature] Support last_path_ option [#2](https://github.com/sakama/embulk-input-sftp/pull/2)[#4](https://github.com/sakama/embulk-input-sftp/pull/4)[#7](https://github.com/sakama/embulk-input-sftp/pull/7)
|
14
|
+
* [new feature] Support path_match_pattern option [#6](https://github.com/sakama/embulk-input-sftp/pull/6)
|
9
15
|
* [maintenance] Add unit test [#3](https://github.com/sakama/embulk-input-sftp/pull/3)
|
10
16
|
* [maintenance] Skip retry of file downloading when permission denied error happens [#1](https://github.com/sakama/embulk-input-sftp/pull/1)
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# SFTP file input plugin for Embulk
|
2
|
+
[](https://travis-ci.org/embulk/embulk-input-sftp)
|
2
3
|
|
3
4
|
Reads files stored on remote server using SFTP
|
4
5
|
|
@@ -19,6 +20,7 @@ Reads files stored on remote server using SFTP
|
|
19
20
|
- **user_directory_is_root**: (boolean, default: `true`)
|
20
21
|
- **timeout**: sftp connection timeout seconds (integer, default: `600`)
|
21
22
|
- **path_prefix**: Prefix of output paths (string, required)
|
23
|
+
- **incremental**: enables incremental loading(boolean, optional. default: `true`). If incremental loading is enabled, config diff for the next execution will include `last_path` parameter so that next execution skips files before the path. Otherwise, `last_path` will not be included.
|
22
24
|
- **path_match_pattern**: regexp to match file paths. If a file path doesn't match with this pattern, the file will be skipped (regexp string, optional)
|
23
25
|
- **total_file_count_limit**: maximum number of files to read (integer, optional)
|
24
26
|
- **min_task_size (experimental)**: minimum size of a task. If this is larger than 0, one task includes multiple input files. This is useful if too many number of tasks impacts performance of output or executor plugins badly. (integer, optional)
|
data/build.gradle
CHANGED
@@ -14,7 +14,7 @@ configurations {
|
|
14
14
|
provided
|
15
15
|
}
|
16
16
|
|
17
|
-
version = "0.
|
17
|
+
version = "0.2.0"
|
18
18
|
|
19
19
|
sourceCompatibility = 1.7
|
20
20
|
targetCompatibility = 1.7
|
@@ -22,7 +22,7 @@ targetCompatibility = 1.7
|
|
22
22
|
dependencies {
|
23
23
|
compile "org.embulk:embulk-core:0.8.6"
|
24
24
|
provided "org.embulk:embulk-core:0.8.6"
|
25
|
-
compile "org.apache.commons:commons-vfs2:2
|
25
|
+
compile "org.apache.commons:commons-vfs2:2.1"
|
26
26
|
compile "org.apache.commons:commons-io:1.3.2"
|
27
27
|
compile "com.jcraft:jsch:0.1.53"
|
28
28
|
testCompile "junit:junit:4.+"
|
@@ -82,7 +82,7 @@ Gem::Specification.new do |spec|
|
|
82
82
|
spec.description = %[Reads files stored on remote server using SFTP.]
|
83
83
|
spec.email = ["satoshiakama@gmail.com"]
|
84
84
|
spec.licenses = ["Apache-2.0"]
|
85
|
-
spec.homepage = "https://github.com/
|
85
|
+
spec.homepage = "https://github.com/embulk/embulk-input-sftp"
|
86
86
|
|
87
87
|
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
88
88
|
spec.test_files = spec.files.grep(%r"^(test|spec)/")
|
Binary file
|
Binary file
|
@@ -158,7 +158,6 @@ public class FileList
|
|
158
158
|
|
159
159
|
int index = entries.size();
|
160
160
|
entries.add(new Entry(index, size));
|
161
|
-
log.info("add file to the request list: {}", path);
|
162
161
|
|
163
162
|
byte[] data = path.getBytes(StandardCharsets.UTF_8);
|
164
163
|
castBuffer.putInt(0, data.length);
|
@@ -25,6 +25,7 @@ import java.io.File;
|
|
25
25
|
import java.io.IOException;
|
26
26
|
import java.net.URI;
|
27
27
|
import java.net.URISyntaxException;
|
28
|
+
import java.util.Arrays;
|
28
29
|
|
29
30
|
public class SftpFileInput
|
30
31
|
extends InputStreamFileInput
|
@@ -107,6 +108,7 @@ public class SftpFileInput
|
|
107
108
|
if (proxy.getHost().isPresent()) {
|
108
109
|
builder.setProxyHost(fsOptions, proxy.getHost().get());
|
109
110
|
builder.setProxyPort(fsOptions, proxy.getPort());
|
111
|
+
log.info("Using proxy {}:{} proxy_type:{}", proxy.getHost().get(), proxy.getPort(), proxy.getType().toString());
|
110
112
|
}
|
111
113
|
|
112
114
|
if (proxy.getUser().isPresent()) {
|
@@ -132,7 +134,9 @@ public class SftpFileInput
|
|
132
134
|
public static String getSftpFileUri(PluginTask task, String path)
|
133
135
|
{
|
134
136
|
try {
|
135
|
-
|
137
|
+
String uri = new URI("sftp", initializeUserInfo(task), task.getHost(), task.getPort(), path, null, null).toString();
|
138
|
+
log.info("Connecting to sftp://{}:***@{}:{}/", task.getUser(), task.getHost(), task.getPort());
|
139
|
+
return uri;
|
136
140
|
}
|
137
141
|
catch (URISyntaxException ex) {
|
138
142
|
throw new ConfigException(ex);
|
@@ -180,7 +184,9 @@ public class SftpFileInput
|
|
180
184
|
FileObject files = manager.resolveFile(getSftpFileUri(task, task.getPathPrefix()), fsOptions);
|
181
185
|
String basename = FilenameUtils.getBaseName(task.getPathPrefix());
|
182
186
|
if (files.isFolder()) {
|
183
|
-
|
187
|
+
FileObject[] children = files.getChildren();
|
188
|
+
Arrays.sort(children);
|
189
|
+
for (FileObject f : children) {
|
184
190
|
if (f.isFile()) {
|
185
191
|
addFileToList(builder, f.toString(), f.getContent().getSize(), "", lastKey);
|
186
192
|
}
|
@@ -188,7 +194,9 @@ public class SftpFileInput
|
|
188
194
|
}
|
189
195
|
else {
|
190
196
|
FileObject parent = files.getParent();
|
191
|
-
|
197
|
+
FileObject[] children = parent.getChildren();
|
198
|
+
Arrays.sort(children);
|
199
|
+
for (FileObject f : children) {
|
192
200
|
if (f.isFile()) {
|
193
201
|
addFileToList(builder, f.toString(), f.getContent().getSize(), basename, lastKey);
|
194
202
|
}
|
@@ -238,24 +246,20 @@ public class SftpFileInput
|
|
238
246
|
String remoteBasename = FilenameUtils.getBaseName(fileName);
|
239
247
|
if (remoteBasename.startsWith(basename)) {
|
240
248
|
if (lastKey != null && !isMatchLastKey) {
|
241
|
-
if (
|
242
|
-
return;
|
243
|
-
}
|
244
|
-
else {
|
249
|
+
if (fileName.equals(lastKey)) {
|
245
250
|
isMatchLastKey = true;
|
246
251
|
}
|
252
|
+
return;
|
247
253
|
}
|
248
254
|
builder.add(fileName, fileSize);
|
249
255
|
}
|
250
256
|
}
|
251
257
|
else {
|
252
258
|
if (lastKey != null && !isMatchLastKey) {
|
253
|
-
if (
|
254
|
-
return;
|
255
|
-
}
|
256
|
-
else {
|
259
|
+
if (fileName.equals(lastKey)) {
|
257
260
|
isMatchLastKey = true;
|
258
261
|
}
|
262
|
+
return;
|
259
263
|
}
|
260
264
|
builder.add(fileName, fileSize);
|
261
265
|
}
|
@@ -33,7 +33,9 @@ public class SftpFileInputPlugin
|
|
33
33
|
control.run(taskSource, taskCount);
|
34
34
|
|
35
35
|
ConfigDiff configDiff = Exec.newConfigDiff();
|
36
|
-
|
36
|
+
if (task.getIncremental()) {
|
37
|
+
configDiff.set("last_path", SftpFileInput.getRelativePath(task.getFiles().getLastPath(task.getLastPath())));
|
38
|
+
}
|
37
39
|
|
38
40
|
return configDiff;
|
39
41
|
}
|
@@ -53,7 +53,6 @@ public class SingleFileProvider
|
|
53
53
|
@Override
|
54
54
|
public InputStream call() throws FileSystemException
|
55
55
|
{
|
56
|
-
log.info("Starting to download file {}", key);
|
57
56
|
FileObject file = manager.resolveFile(key, fsOptions);
|
58
57
|
return file.getContent().getInputStream();
|
59
58
|
}
|
@@ -124,6 +124,7 @@ public class TestSftpFileInputPlugin
|
|
124
124
|
|
125
125
|
PluginTask task = config.loadConfig(PluginTask.class);
|
126
126
|
assertEquals(22, task.getPort());
|
127
|
+
assertEquals(true, task.getIncremental());
|
127
128
|
assertEquals(true, task.getUserDirIsRoot());
|
128
129
|
assertEquals(600, task.getSftpConnectionTimeout());
|
129
130
|
assertEquals(5, task.getMaxConnectionRetry());
|
@@ -173,6 +174,23 @@ public class TestSftpFileInputPlugin
|
|
173
174
|
assertEquals("in/aa/a", configDiff.get(String.class, "last_path"));
|
174
175
|
}
|
175
176
|
|
177
|
+
@Test
|
178
|
+
public void testResumeIncrementalFalse()
|
179
|
+
{
|
180
|
+
ConfigSource newConfig = config.deepCopy().set("incremental", false);
|
181
|
+
PluginTask task = newConfig.loadConfig(PluginTask.class);
|
182
|
+
task.setFiles(createFileList(Arrays.asList("in/aa/a"), task));
|
183
|
+
ConfigDiff configDiff = plugin.resume(task.dump(), 0, new FileInputPlugin.Control()
|
184
|
+
{
|
185
|
+
@Override
|
186
|
+
public List<TaskReport> run(TaskSource taskSource, int taskCount)
|
187
|
+
{
|
188
|
+
return emptyTaskReports(taskCount);
|
189
|
+
}
|
190
|
+
});
|
191
|
+
assertEquals("{}", configDiff.toString());
|
192
|
+
}
|
193
|
+
|
176
194
|
@Test
|
177
195
|
public void testCleanup()
|
178
196
|
{
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-sftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satoshi Akama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
|
+
- .travis.yml
|
49
50
|
- CHANGELOG.md
|
50
51
|
- README.md
|
51
52
|
- build.gradle
|
@@ -70,10 +71,10 @@ files:
|
|
70
71
|
- src/test/resources/sample_02.csv
|
71
72
|
- classpath/commons-io-1.3.2.jar
|
72
73
|
- classpath/commons-logging-1.2.jar
|
73
|
-
- classpath/commons-vfs2-2.1.
|
74
|
-
- classpath/embulk-input-sftp-0.
|
74
|
+
- classpath/commons-vfs2-2.1.jar
|
75
|
+
- classpath/embulk-input-sftp-0.2.0.jar
|
75
76
|
- classpath/jsch-0.1.53.jar
|
76
|
-
homepage: https://github.com/
|
77
|
+
homepage: https://github.com/embulk/embulk-input-sftp
|
77
78
|
licenses:
|
78
79
|
- Apache-2.0
|
79
80
|
metadata: {}
|
Binary file
|
Binary file
|