Skip to content

Commit 6b61c6e

Browse files
authored
Merge pull request #50 from tvhung83/add_local_buffering_config
Add `local_buffering` & `temp_file_threshold` configs
2 parents 6572e1a + 8b8ca77 commit 6b61c6e

File tree

13 files changed

+1098
-281
lines changed

13 files changed

+1098
-281
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
dist: precise
1+
dist: trusty
22
language: java
33
jdk:
4-
- openjdk7
5-
- oraclejdk7
4+
- openjdk8
65
- oraclejdk8
76
script:
87
- ./gradlew test

build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ sourceCompatibility = 1.7
2222
targetCompatibility = 1.7
2323

2424
dependencies {
25-
compile "org.embulk:embulk-core:0.8.6"
26-
provided "org.embulk:embulk-core:0.8.6"
25+
compile "org.embulk:embulk-core:0.9.7"
26+
provided "org.embulk:embulk-core:0.9.7"
2727
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
2828
compile "org.apache.commons:commons-vfs2:2.2"
2929
compile "commons-io:commons-io:2.6"
3030
compile "com.jcraft:jsch:0.1.54"
3131
testCompile "junit:junit:4.+"
32-
testCompile "org.embulk:embulk-core:0.8.6:tests"
33-
testCompile "org.embulk:embulk-standards:0.8.6"
32+
testCompile "org.embulk:embulk-core:0.9.7:tests"
33+
testCompile "org.embulk:embulk-standards:0.9.7"
3434
testCompile "org.apache.sshd:apache-sshd:1.1.0+"
3535
testCompile "org.littleshoot:littleproxy:1.1.0-beta1"
3636
testCompile "io.netty:netty-all:4.0.34.Final"
37+
testCompile "org.mockito:mockito-core:2.+"
3738
}
3839

3940
jacocoTestReport {

src/main/java/org/embulk/output/sftp/SftpFileOutput.java

Lines changed: 0 additions & 140 deletions
This file was deleted.

src/main/java/org/embulk/output/sftp/SftpFileOutputPlugin.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import org.embulk.spi.TransactionalFileOutput;
1414
import org.embulk.spi.unit.LocalFile;
1515

16+
import javax.validation.constraints.Max;
17+
import javax.validation.constraints.Min;
18+
1619
import java.util.List;
1720
import java.util.Map;
1821

@@ -47,7 +50,7 @@ public interface PluginTask
4750

4851
@Config("user_directory_is_root")
4952
@ConfigDefault("true")
50-
public Boolean getUserDirIsRoot();
53+
public boolean getUserDirIsRoot();
5154

5255
@Config("timeout")
5356
@ConfigDefault("600") // 10 minutes
@@ -73,7 +76,18 @@ public interface PluginTask
7376

7477
@Config("rename_file_after_upload")
7578
@ConfigDefault("false")
76-
public Boolean getRenameFileAfterUpload();
79+
public boolean getRenameFileAfterUpload();
80+
81+
// if `false`, plugin will use remote file as buffer
82+
@Config("local_buffering")
83+
@ConfigDefault("true")
84+
public boolean getLocalBuffering();
85+
86+
@Min(50L * 1024 * 1024) // 50MiB
87+
@Max(10L * 1024 * 1024 * 1024) // 10GiB
88+
@Config("temp_file_threshold")
89+
@ConfigDefault("5368709120") // 5GiB
90+
public long getTempFileThreshold();
7791
}
7892

7993
@Override
@@ -141,6 +155,9 @@ public void cleanup(TaskSource taskSource,
141155
public TransactionalFileOutput open(TaskSource taskSource, final int taskIndex)
142156
{
143157
final PluginTask task = taskSource.loadTask(PluginTask.class);
144-
return new SftpFileOutput(task, taskIndex);
158+
if (task.getLocalBuffering()) {
159+
return new SftpLocalFileOutput(task, taskIndex);
160+
}
161+
return new SftpRemoteFileOutput(task, taskIndex);
145162
}
146163
}

0 commit comments

Comments
 (0)