embulk-output-sftp 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +59 -0
- data/build.gradle +77 -0
- data/classpath/commons-logging-1.2.jar +0 -0
- data/classpath/commons-vfs2-2.1.1660580.2.jar +0 -0
- data/classpath/embulk-output-sftp-0.0.2.jar +0 -0
- data/classpath/jsch-0.1.53.jar +0 -0
- data/example/data.csv +100 -0
- data/example/sample.yml +39 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/gradlew +164 -0
- data/gradlew.bat +90 -0
- data/lib/embulk/output/sftp.rb +3 -0
- data/src/main/java/org/embulk/output/sftp/SftpFileOutput.java +209 -0
- data/src/main/java/org/embulk/output/sftp/SftpFileOutputPlugin.java +103 -0
- data/src/test/java/org/embulk/output/sftp/TestSftpFileOutputPlugin.java +5 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 694b901dce5a8bb71bb6e91fec4e43bb522ad9f9
|
4
|
+
data.tar.gz: b0e8215fa6b83e825678ab12473a23c63335bea0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8cae6bd750dac296ece0bb96772850666056ac08b623470c3084e3b4a24db6631a31d0fdcff8be5bcb94833d5497f26d620daa29503c9a7ce5fc8530f80c3dd
|
7
|
+
data.tar.gz: 37d6e31ee01606551db9fd6d102857bb15781acd8ec1612577ab88502170a7e9bf17d12c612bb2ce51e994a71c6619dc872e4956cae86cbb75f9d63ff66f6dca
|
data/.gitignore
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Sftp file output plugin for Embulk
|
2
|
+
|
3
|
+
Stores files on a SFTP Server
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
* **Plugin type**: file output
|
8
|
+
* **Load all or nothing**: no
|
9
|
+
* **Resume supported**: no
|
10
|
+
* **Cleanup supported**: no
|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
|
14
|
+
- **host**: (string, required)
|
15
|
+
- **port**: (string, default: `22`)
|
16
|
+
- **user**: (string, required)
|
17
|
+
- **password**: (string, default: `null`)
|
18
|
+
- **secret_key_file**: (string, default: `null`)
|
19
|
+
- **secret_key_passphrase**: (string, default: `""`)
|
20
|
+
- **user_directory_is_root**: (boolean, default: `true`)
|
21
|
+
- **timeout**: sftp connection timeout seconds (integer, default: `600`)
|
22
|
+
- **path_prefix**: Prefix of output paths (string, required)
|
23
|
+
- **file_ext**: Extension of output files (string, required)
|
24
|
+
- **sequence_format**: Format for sequence part of output files (string, default: `".%03d.%02d"`)
|
25
|
+
|
26
|
+
## Example
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
out:
|
30
|
+
type: sftp
|
31
|
+
host: 127.0.0.1
|
32
|
+
port: 22
|
33
|
+
user: civitaspo
|
34
|
+
secret_key_file: /Users/civitaspo/.ssh/id_rsa
|
35
|
+
secret_key_passphrase: secret_pass
|
36
|
+
user_directory_is_root: false
|
37
|
+
timeout: 600
|
38
|
+
path_prefix: /data/sftp
|
39
|
+
file_ext: _20151020.tsv
|
40
|
+
sequence_format: ".%01d%01d"
|
41
|
+
```
|
42
|
+
|
43
|
+
## Run Example
|
44
|
+
replace settings in `example/sample.yml` before running.
|
45
|
+
|
46
|
+
```
|
47
|
+
$ ./gradlew classpath
|
48
|
+
$ embulk run -Ilib example/sample.yml
|
49
|
+
```
|
50
|
+
|
51
|
+
## Build
|
52
|
+
|
53
|
+
```
|
54
|
+
$ ./gradlew gem # -t to watch change of files and rebuild continuously
|
55
|
+
```
|
56
|
+
|
57
|
+
## Note
|
58
|
+
|
59
|
+
This plugin uses "org.apache.commons:commons-vfs" and the library uses the logger "org.apache.commons.logging.Log". So, this plugin suppress the logger's message except when embulk log level is debug.
|
data/build.gradle
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
plugins {
|
2
|
+
id "com.jfrog.bintray" version "1.1"
|
3
|
+
id "com.github.jruby-gradle.base" version "0.1.5"
|
4
|
+
id "java"
|
5
|
+
}
|
6
|
+
import com.github.jrubygradle.JRubyExec
|
7
|
+
repositories {
|
8
|
+
mavenCentral()
|
9
|
+
jcenter()
|
10
|
+
}
|
11
|
+
configurations {
|
12
|
+
provided
|
13
|
+
}
|
14
|
+
|
15
|
+
version = "0.0.2"
|
16
|
+
sourceCompatibility = 1.7
|
17
|
+
targetCompatibility = 1.7
|
18
|
+
|
19
|
+
dependencies {
|
20
|
+
compile "org.embulk:embulk-core:0.7.4"
|
21
|
+
provided "org.embulk:embulk-core:0.7.4"
|
22
|
+
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
|
23
|
+
compile "org.apache.commons:commons-vfs2:2.+"
|
24
|
+
compile "com.jcraft:jsch:0.1.53"
|
25
|
+
testCompile "junit:junit:4.+"
|
26
|
+
}
|
27
|
+
|
28
|
+
task classpath(type: Copy, dependsOn: ["jar"]) {
|
29
|
+
doFirst { file("classpath").deleteDir() }
|
30
|
+
from (configurations.runtime - configurations.provided + files(jar.archivePath))
|
31
|
+
into "classpath"
|
32
|
+
}
|
33
|
+
clean { delete "classpath" }
|
34
|
+
|
35
|
+
task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
|
36
|
+
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
|
37
|
+
script "${project.name}.gemspec"
|
38
|
+
doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
|
39
|
+
}
|
40
|
+
|
41
|
+
task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
|
42
|
+
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "push"
|
43
|
+
script "pkg/${project.name}-${project.version}.gem"
|
44
|
+
}
|
45
|
+
|
46
|
+
task "package"(dependsOn: ["gemspec", "classpath"]) << {
|
47
|
+
println "> Build succeeded."
|
48
|
+
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
|
49
|
+
}
|
50
|
+
|
51
|
+
task gemspec {
|
52
|
+
ext.gemspecFile = file("${project.name}.gemspec")
|
53
|
+
inputs.file "build.gradle"
|
54
|
+
outputs.file gemspecFile
|
55
|
+
doLast { gemspecFile.write($/
|
56
|
+
Gem::Specification.new do |spec|
|
57
|
+
spec.name = "${project.name}"
|
58
|
+
spec.version = "${project.version}"
|
59
|
+
spec.authors = ["Civitaspo"]
|
60
|
+
spec.summary = %[Sftp file output plugin for Embulk]
|
61
|
+
spec.description = %[Stores files on Sftp.]
|
62
|
+
spec.email = ["civitaspo@gmail.com"]
|
63
|
+
spec.licenses = ["MIT"]
|
64
|
+
spec.homepage = "https://github.com/civitaspo/embulk-output-sftp"
|
65
|
+
|
66
|
+
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
67
|
+
spec.test_files = spec.files.grep(%r"^(test|spec)/")
|
68
|
+
spec.require_paths = ["lib"]
|
69
|
+
|
70
|
+
#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
|
71
|
+
spec.add_development_dependency 'bundler', ['~> 1.0']
|
72
|
+
spec.add_development_dependency 'rake', ['>= 10.0']
|
73
|
+
end
|
74
|
+
/$)
|
75
|
+
}
|
76
|
+
}
|
77
|
+
clean { delete "${project.name}.gemspec" }
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/example/data.csv
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
time,id,name,score
|
2
|
+
2015-07-13,0,Vqjht6YEUBsMPXmoW1iOGFROZF27pBzz0TUkOKeDXEY,1370
|
3
|
+
2015-07-13,1,VmjbjAA0tOoSEPv_vKAGMtD_0aXZji0abGe7_VXHmUQ,3962
|
4
|
+
2015-07-13,2,C40P5H1WcBx-aWFDJCI8th6QPEI2DOUgupt_gB8UutE,7323
|
5
|
+
2015-07-13,3,Prr0_u_T1ts4myUofBorOJFpCYcOTLOmNBMuRmKIPJU,5905
|
6
|
+
2015-07-13,4,AEGIhHVW5cV6Xlb62uvx3TVl3kmh3Do8AvvtLDS7MDw,8378
|
7
|
+
2015-07-13,5,eupqWLrnCHr_1UaX4dUInLRxx5Q_cyQ4t0oSJBcw0MA,275
|
8
|
+
2015-07-13,6,BN8cQ47EXRb_oCGOoN96bhBldoiyoCp5O_vGHwg0XCg,9303
|
9
|
+
2015-07-13,7,RvV35-6jY6MC9_Wnm4nPsmyyfqcr-hlnBt88sXtn1nU,6130
|
10
|
+
2015-07-13,8,6OZiuPiJKjWNLMPgiEbJarB0F80lTPYkkePP8LMliv0,6652
|
11
|
+
2015-07-13,9,13CgEU_ApAMVE6Ll6Y-mSu-aubskNgHbynj2rj8f8oE,6822
|
12
|
+
2015-07-13,10,j1evoWRzKrJR0sfo014ZxhZtKigWDkRip5FwpAHAsmU,1311
|
13
|
+
2015-07-13,11,4vBBBcArfMGhediXV5Sn80hj4KkI4nUCllECNKxNgnI,4748
|
14
|
+
2015-07-13,12,6LSLQGjv46TWsvXrxYCfM5yIz4JGiGd1eEQI4TC-4yc,43
|
15
|
+
2015-07-13,13,bgLJeacIPOMH6sDb5tEmca1oYyaMdfqZomGEI2uby7k,1214
|
16
|
+
2015-07-13,14,bRHc-42RqKVv3ORxhVCA4T4dLEXyBzBCQoed8VOrDCo,7048
|
17
|
+
2015-07-13,15,ysiB3w-K5jb3FxpQY61OHYTlK9qklz3nW84RLvBnh9s,8795
|
18
|
+
2015-07-13,16,Rvn7-tMbQM3q0yWQD8AUdURhFB0ZkzLGdIiDg-AJokM,7838
|
19
|
+
2015-07-13,17,FDEI99QVJ8xRTOiQ-UDVlPMOBfuA0IwIAbJ872XnKOo,9507
|
20
|
+
2015-07-13,18,lZUazYHDEGbQbzN7vEFeLjmnzp1wsjR0D8r8f7Cs6x0,3378
|
21
|
+
2015-07-13,19,WmDFEQsDPSnVs8AiAdO3QJqlSFer1K0I8z7F0cl_WRk,1661
|
22
|
+
2015-07-13,20,OEDSi7YIj4OjMNqTw12EA04BNtNuVWva6YRhokxL4xQ,5934
|
23
|
+
2015-07-13,21,fXYhm19m2FsbWcRQGqJvVOSl2ZIRSNhWTfke-iG8e7Q,680
|
24
|
+
2015-07-13,22,LK59zfxizCwr5CI2Wu88B8gY8-G4OeyAXZobplwGzKk,8758
|
25
|
+
2015-07-13,23,8i5TVZorCp4YATsaxgybkdOHcmDywvb35Sf-Eb-sl9E,8392
|
26
|
+
2015-07-13,24,MrM9vy1U-9_OEYOQAxbshenvvUGdCZfqjx7l3KKBQ2I,8708
|
27
|
+
2015-07-13,25,miVWwEwur_7baTxIBHUT9y351AU3tnAcCXgBzvyUR5I,2843
|
28
|
+
2015-07-13,26,_vxViqC02KVb7RRBeDGYs9VZ52KB8QmvguzSXUYGfwI,6681
|
29
|
+
2015-07-13,27,Ui6BqkQDipo5kQEeVUuC2OFFIB1O4T8ALlM2GI_zvtk,7542
|
30
|
+
2015-07-13,28,OT3VLH-RdK0sIgQM3f6LIbBa_rt0YzCD5YOw4qpu6p8,5791
|
31
|
+
2015-07-13,29,vassmNeEo_jbn88g7QP58mTxH-b1jhHfwFhy-FL6T8c,9613
|
32
|
+
2015-07-13,30,VjzTphngC6V5fphi9fkGeYGCPIQNpDajfkHxrJopF6k,3064
|
33
|
+
2015-07-13,31,aqw27tMVvSsLJ8EEY3hphHMb0BRLm-LZysjVV3aX7pQ,7862
|
34
|
+
2015-07-13,32,ZXepGbCv7Yw_ejNQyAPjrqG_VwNH_RZoG8lKODl-f9c,397
|
35
|
+
2015-07-13,33,-yRoubVSa0oPfg0E1Gh7zYBQfBO8dIxZvQH9c5OsZAU,5003
|
36
|
+
2015-07-13,34,UkhBEKU7G0rV58Urs6JTAgC0UF5Y2kP-dffmE6H4nGs,6514
|
37
|
+
2015-07-13,35,ktLO3RTpHLZon7AhE9XMwPPh0t_GiOpS8vwCCqoPPnk,8634
|
38
|
+
2015-07-13,36,3ktjc_W87j3S8qLOJ0CVEVSSpz_nUAEQVBsqOMabrp0,3679
|
39
|
+
2015-07-13,37,KscV-oPqhG_CZXYUgdCmekKdR9FIT5tSt7rd3wpQDcU,1013
|
40
|
+
2015-07-13,38,VFiC8YyBk6zZk5bpfZG8s1a3kYfMA1zvnbs6DDSplGY,1556
|
41
|
+
2015-07-13,39,s0bxCQyW048GkhEAoEzXYGcTV8BZo6MLnRhL62nepYk,2844
|
42
|
+
2015-07-13,40,aWbMyvSxxTqrVONKAeQVvqi_bGqROu9UeR5NqPPlI4A,8035
|
43
|
+
2015-07-13,41,qfjEvEY8XSgMEmc-vIZLinOeIdIz6xprQbsYAe0i2WU,3205
|
44
|
+
2015-07-13,42,NK2ddaghTrUTS6Y7U1e-l57922ccVOKnqlODcA6lyBQ,302
|
45
|
+
2015-07-13,43,JRQpF1luRmNk2stUaZzDQDj93hy4RSW_iWybVgsgzJA,6534
|
46
|
+
2015-07-13,44,lz7bs1xZi4qdWLE7fQwpykWDNgp_o9oUuCZXipSLSqw,9250
|
47
|
+
2015-07-13,45,TxcwVGwelHKJws_6Q0Nk6I4Eeo9sSThM7M9KorqIGhA,5549
|
48
|
+
2015-07-13,46,u_uy6k3TgUIp3NWMFJ8EOH1mKtFhozGBD208z9um88s,3624
|
49
|
+
2015-07-13,47,RaI9xr82f0D7Jjuc4QY8Rz-UlCg3V5tw7KgJtczEo44,5278
|
50
|
+
2015-07-13,48,u6Nqudxl6vrbKGemO8xXgYojhtBGK3SQkTRPSYcaZuI,9588
|
51
|
+
2015-07-13,49,r-IgfD4fE9TiQWarsVxO_4AdieYIUZ9cczPD44_snQ4,4795
|
52
|
+
2015-07-13,50,KIiUpd04d3zYDul1mFlcJ3934AYvA_YeXDYG089ub-M,4344
|
53
|
+
2015-07-13,51,zZs0iuqm7liPKKHHn8wz-kNvd2zLCqRdXAng4B3gL0A,2116
|
54
|
+
2015-07-13,52,Rg7T2IsH0-HIvhgq0mNRC-4q5JoZ5Rcjq4tP7dz_3Ew,5323
|
55
|
+
2015-07-13,53,uBNgdXPL6kZGXP-gTic2N-uDRCxAtmI-KixkJWgrObA,9
|
56
|
+
2015-07-13,54,fQ_TLG3oByt3sDqM3Kruo69fBd1qLMXbbg10myfFXkQ,2471
|
57
|
+
2015-07-13,55,0uNd4TrRpEA1lY_zWikyELZ3MmCTzON_5ftfi-45wic,9831
|
58
|
+
2015-07-13,56,Jfp4VCtsFElA6UzzZyPxOwegfGqsYwrimSFp59YshTs,3177
|
59
|
+
2015-07-13,57,KAHSwcCwblbPRysuImbzUxx0SLAMIMb6LmMAXJBjUww,1182
|
60
|
+
2015-07-13,58,wuyDbV5ljr5275eGWhAe8wkElCzd2d_gRW3SpBkLIyY,183
|
61
|
+
2015-07-13,59,R3KTTvKRvPn6vu4qtooBbqYmwdOCC9vjmcsnf_fyu5g,5001
|
62
|
+
2015-07-13,60,Pgsf32JIv2cUMdTE9Vydh2Y36B_Xi4T1ufIy7QiKFSU,6182
|
63
|
+
2015-07-13,61,EZmz-tWhPPAsXsDZms_HHsDLKBOuZisUDotr72xXQnI,5228
|
64
|
+
2015-07-13,62,mk4y32O73DU2z65dFuW1PvIokdB7bB7btUnCoDlSVxM,8094
|
65
|
+
2015-07-13,63,fs1HvYjpOvAHnT5W1rCPU9A3k8_Px2XwfprrLrkQibM,5849
|
66
|
+
2015-07-13,64,x8WAAde6AqG2YaOEIpCFMzItRrfUXqgc8bwcoWSiMEo,6076
|
67
|
+
2015-07-13,65,zuvlwNyn8AgPEvg6qIxzkUp_ClPkMn5A__YyksWbxTo,6439
|
68
|
+
2015-07-13,66,ZWWjbJAqVtZz3AzCpacgEabm7SMloLHPBTlS3NMk7GA,6531
|
69
|
+
2015-07-13,67,wdHfAVpHp9rFaGhZOC81AusTsZX0KHxTf5RkFBw6gpI,8088
|
70
|
+
2015-07-13,68,hw8HUkIQMSS-2gAT7rvA2kgdhXfhHlySxKtssINvcFc,7808
|
71
|
+
2015-07-13,69,x1_SLENL6-M1y0n5qmfBF1-GCslEHpVM4Fo1Rdz9Ofg,3617
|
72
|
+
2015-07-13,70,E2Uj3TGAwd_B3FOS6KQ1Gjyql2YpoNtbdzWBTUOWmxY,8401
|
73
|
+
2015-07-13,71,WkpwSIP4fA42gYd1H3ohw7EmtqdQSqh4ooA7aX8v_7o,1309
|
74
|
+
2015-07-13,72,xDdMCHpSKFSZWQBJJgNzNh1R4hXouCsUfKFZpio5cgY,7867
|
75
|
+
2015-07-13,73,l0QVMlih2NmGSajDXytku9Em9p61erNKe1LEyk1VZ-Q,7964
|
76
|
+
2015-07-13,74,R8G5juHaD9sit1oujjp4FoXzXJT7hdIjEY3Lhu-ep6o,5680
|
77
|
+
2015-07-13,75,Ckpy3y166odB33VVWb27XNG_Wi65_qyikeL7dGHceSE,8603
|
78
|
+
2015-07-13,76,elFu5tPgUNzhuyswgr3QS7TXR2fInI4PWVZIEffxq6c,4972
|
79
|
+
2015-07-13,77,kz663CgkMh9VfcJrfMZb735vJJWYUPAuaskNeg7xRDk,8396
|
80
|
+
2015-07-13,78,evuBVl0RR1XQfJHN4jxSBpLcKxjZ7RtpDGYrU2ONYZA,6433
|
81
|
+
2015-07-13,79,ZbIJwmWRWscOurtrCam-iLB2mIqREwQwGFRfVYzGxwk,2917
|
82
|
+
2015-07-13,80,mzCWiiJFzo1R_anxGFALosK0eKvGfv_RT7iRGZnL790,3162
|
83
|
+
2015-07-13,81,JyrXoXLq5RpRwwXNpiW1NFK6ZkVmS55hJsNBGsuY7xY,2385
|
84
|
+
2015-07-13,82,fO7A_MQGh3Zojp6HlVZayvJHLu_RQ082ix3Y6BlRCu0,5965
|
85
|
+
2015-07-13,83,ib-pOMBLU1sN5fyyJbAElIdWEJgkoqRcBuwo6CVVYsk,3265
|
86
|
+
2015-07-13,84,X_6Ren6P7TpqyiWViO72kEwIulMqbTU_v8eAGfEo8k0,8049
|
87
|
+
2015-07-13,85,hNI30i9IYx7EreMyG7rI56Y-ZtrRe4sBYjzKMnSrL5I,9222
|
88
|
+
2015-07-13,86,kzokOacUOXELAeIHfPbnl-Er8rnHYq2JnksqN1roOSQ,2972
|
89
|
+
2015-07-13,87,qKIfkhQObWMadIi5vshcDRv95je4TYcAPSYITfwVTRk,5390
|
90
|
+
2015-07-13,88,9xKf3bfWj8Gr1NNocYHZuL0kIkAVD750LCMYDZ-R1tA,4759
|
91
|
+
2015-07-13,89,ohbmpvNy7aaaIVZ74SlHSfm0ffdwV-AqJP1bfDSjNUU,2279
|
92
|
+
2015-07-13,90,l6lTsvxdlcTfcqx2c0lQSd9HejVQg40W25f0wGNQViY,9034
|
93
|
+
2015-07-13,91,XoALSEQg9ycuGqrEWHOb8vdrLbheZSgFO53Wr3mciXY,3945
|
94
|
+
2015-07-13,92,0hgDRI_mijs5w7rkiLIe__LEayOOLxL0qVT1IHa5QBw,8109
|
95
|
+
2015-07-13,93,KjCRAc-AVcS-R13toBUR6pK_7d9Y8Gl4TRdYYMaSirc,4774
|
96
|
+
2015-07-13,94,fyQVGlT8Bqmu_LiajPlgfbmavoNyAqXaBsBP_e4OnN8,7253
|
97
|
+
2015-07-13,95,FpBYRPWKu6DmLpx5tsB25URWfj3sNCbcydNAXULaiD8,3166
|
98
|
+
2015-07-13,96,9ikvnUqp1Rf2yVwLvs5bBvxQP-KyqxGi4gZRSZ8c1d4,3695
|
99
|
+
2015-07-13,97,RRNYDAzKaq4Trtt96Bxgk3N0fXLIV8hXoK0qQ7uw_Wc,5065
|
100
|
+
,,,9170
|
data/example/sample.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
in:
|
2
|
+
type: file
|
3
|
+
path_prefix: example/data.csv
|
4
|
+
parser:
|
5
|
+
type: csv
|
6
|
+
charset: UTF-8
|
7
|
+
newline: CRLF
|
8
|
+
null_string: 'NULL'
|
9
|
+
skip_header_lines: 1
|
10
|
+
comment_line_marker: '#'
|
11
|
+
columns:
|
12
|
+
- {name: time, type: timestamp, format: "%Y-%m-%d"}
|
13
|
+
- {name: id, type: long}
|
14
|
+
- {name: name, type: string}
|
15
|
+
- {name: score, type: double}
|
16
|
+
out:
|
17
|
+
type: sftp
|
18
|
+
host: 127.0.0.1
|
19
|
+
port: 22
|
20
|
+
user: your_name
|
21
|
+
password: your_password
|
22
|
+
secret_key_file: your_secret_key_file
|
23
|
+
secret_key_passphrase: your_secret_key_passphrase
|
24
|
+
user_directory_is_root: true
|
25
|
+
path_prefix: /tmp/embulk_output_sftp/data
|
26
|
+
file_ext: .tsv
|
27
|
+
sequence_format: ".%01d%01d"
|
28
|
+
formatter:
|
29
|
+
type: csv
|
30
|
+
delimiter: "\t"
|
31
|
+
newline: CRLF
|
32
|
+
newline_in_field: LF
|
33
|
+
header_line: true
|
34
|
+
charset: UTF-8
|
35
|
+
quote_policy: NONE
|
36
|
+
quote: "\""
|
37
|
+
escape: "\\"
|
38
|
+
null_string: ""
|
39
|
+
default_timezone: 'UTC'
|
Binary file
|
data/gradlew
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
##############################################################################
|
4
|
+
##
|
5
|
+
## Gradle start up script for UN*X
|
6
|
+
##
|
7
|
+
##############################################################################
|
8
|
+
|
9
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
10
|
+
DEFAULT_JVM_OPTS=""
|
11
|
+
|
12
|
+
APP_NAME="Gradle"
|
13
|
+
APP_BASE_NAME=`basename "$0"`
|
14
|
+
|
15
|
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
16
|
+
MAX_FD="maximum"
|
17
|
+
|
18
|
+
warn ( ) {
|
19
|
+
echo "$*"
|
20
|
+
}
|
21
|
+
|
22
|
+
die ( ) {
|
23
|
+
echo
|
24
|
+
echo "$*"
|
25
|
+
echo
|
26
|
+
exit 1
|
27
|
+
}
|
28
|
+
|
29
|
+
# OS specific support (must be 'true' or 'false').
|
30
|
+
cygwin=false
|
31
|
+
msys=false
|
32
|
+
darwin=false
|
33
|
+
case "`uname`" in
|
34
|
+
CYGWIN* )
|
35
|
+
cygwin=true
|
36
|
+
;;
|
37
|
+
Darwin* )
|
38
|
+
darwin=true
|
39
|
+
;;
|
40
|
+
MINGW* )
|
41
|
+
msys=true
|
42
|
+
;;
|
43
|
+
esac
|
44
|
+
|
45
|
+
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
46
|
+
if $cygwin ; then
|
47
|
+
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
48
|
+
fi
|
49
|
+
|
50
|
+
# Attempt to set APP_HOME
|
51
|
+
# Resolve links: $0 may be a link
|
52
|
+
PRG="$0"
|
53
|
+
# Need this for relative symlinks.
|
54
|
+
while [ -h "$PRG" ] ; do
|
55
|
+
ls=`ls -ld "$PRG"`
|
56
|
+
link=`expr "$ls" : '.*-> \(.*\)$'`
|
57
|
+
if expr "$link" : '/.*' > /dev/null; then
|
58
|
+
PRG="$link"
|
59
|
+
else
|
60
|
+
PRG=`dirname "$PRG"`"/$link"
|
61
|
+
fi
|
62
|
+
done
|
63
|
+
SAVED="`pwd`"
|
64
|
+
cd "`dirname \"$PRG\"`/" >&-
|
65
|
+
APP_HOME="`pwd -P`"
|
66
|
+
cd "$SAVED" >&-
|
67
|
+
|
68
|
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
69
|
+
|
70
|
+
# Determine the Java command to use to start the JVM.
|
71
|
+
if [ -n "$JAVA_HOME" ] ; then
|
72
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
73
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
74
|
+
JAVACMD="$JAVA_HOME/jre/sh/java"
|
75
|
+
else
|
76
|
+
JAVACMD="$JAVA_HOME/bin/java"
|
77
|
+
fi
|
78
|
+
if [ ! -x "$JAVACMD" ] ; then
|
79
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
80
|
+
|
81
|
+
Please set the JAVA_HOME variable in your environment to match the
|
82
|
+
location of your Java installation."
|
83
|
+
fi
|
84
|
+
else
|
85
|
+
JAVACMD="java"
|
86
|
+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
87
|
+
|
88
|
+
Please set the JAVA_HOME variable in your environment to match the
|
89
|
+
location of your Java installation."
|
90
|
+
fi
|
91
|
+
|
92
|
+
# Increase the maximum file descriptors if we can.
|
93
|
+
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
94
|
+
MAX_FD_LIMIT=`ulimit -H -n`
|
95
|
+
if [ $? -eq 0 ] ; then
|
96
|
+
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
97
|
+
MAX_FD="$MAX_FD_LIMIT"
|
98
|
+
fi
|
99
|
+
ulimit -n $MAX_FD
|
100
|
+
if [ $? -ne 0 ] ; then
|
101
|
+
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
102
|
+
fi
|
103
|
+
else
|
104
|
+
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
105
|
+
fi
|
106
|
+
fi
|
107
|
+
|
108
|
+
# For Darwin, add options to specify how the application appears in the dock
|
109
|
+
if $darwin; then
|
110
|
+
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
111
|
+
fi
|
112
|
+
|
113
|
+
# For Cygwin, switch paths to Windows format before running java
|
114
|
+
if $cygwin ; then
|
115
|
+
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
116
|
+
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
117
|
+
|
118
|
+
# We build the pattern for arguments to be converted via cygpath
|
119
|
+
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
120
|
+
SEP=""
|
121
|
+
for dir in $ROOTDIRSRAW ; do
|
122
|
+
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
123
|
+
SEP="|"
|
124
|
+
done
|
125
|
+
OURCYGPATTERN="(^($ROOTDIRS))"
|
126
|
+
# Add a user-defined pattern to the cygpath arguments
|
127
|
+
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
128
|
+
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
129
|
+
fi
|
130
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
131
|
+
i=0
|
132
|
+
for arg in "$@" ; do
|
133
|
+
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
134
|
+
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
135
|
+
|
136
|
+
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
137
|
+
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
138
|
+
else
|
139
|
+
eval `echo args$i`="\"$arg\""
|
140
|
+
fi
|
141
|
+
i=$((i+1))
|
142
|
+
done
|
143
|
+
case $i in
|
144
|
+
(0) set -- ;;
|
145
|
+
(1) set -- "$args0" ;;
|
146
|
+
(2) set -- "$args0" "$args1" ;;
|
147
|
+
(3) set -- "$args0" "$args1" "$args2" ;;
|
148
|
+
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
149
|
+
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
150
|
+
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
151
|
+
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
152
|
+
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
153
|
+
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
154
|
+
esac
|
155
|
+
fi
|
156
|
+
|
157
|
+
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
158
|
+
function splitJvmOpts() {
|
159
|
+
JVM_OPTS=("$@")
|
160
|
+
}
|
161
|
+
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
162
|
+
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
163
|
+
|
164
|
+
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
data/gradlew.bat
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
@if "%DEBUG%" == "" @echo off
|
2
|
+
@rem ##########################################################################
|
3
|
+
@rem
|
4
|
+
@rem Gradle startup script for Windows
|
5
|
+
@rem
|
6
|
+
@rem ##########################################################################
|
7
|
+
|
8
|
+
@rem Set local scope for the variables with windows NT shell
|
9
|
+
if "%OS%"=="Windows_NT" setlocal
|
10
|
+
|
11
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
12
|
+
set DEFAULT_JVM_OPTS=
|
13
|
+
|
14
|
+
set DIRNAME=%~dp0
|
15
|
+
if "%DIRNAME%" == "" set DIRNAME=.
|
16
|
+
set APP_BASE_NAME=%~n0
|
17
|
+
set APP_HOME=%DIRNAME%
|
18
|
+
|
19
|
+
@rem Find java.exe
|
20
|
+
if defined JAVA_HOME goto findJavaFromJavaHome
|
21
|
+
|
22
|
+
set JAVA_EXE=java.exe
|
23
|
+
%JAVA_EXE% -version >NUL 2>&1
|
24
|
+
if "%ERRORLEVEL%" == "0" goto init
|
25
|
+
|
26
|
+
echo.
|
27
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
28
|
+
echo.
|
29
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
30
|
+
echo location of your Java installation.
|
31
|
+
|
32
|
+
goto fail
|
33
|
+
|
34
|
+
:findJavaFromJavaHome
|
35
|
+
set JAVA_HOME=%JAVA_HOME:"=%
|
36
|
+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
37
|
+
|
38
|
+
if exist "%JAVA_EXE%" goto init
|
39
|
+
|
40
|
+
echo.
|
41
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
42
|
+
echo.
|
43
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
44
|
+
echo location of your Java installation.
|
45
|
+
|
46
|
+
goto fail
|
47
|
+
|
48
|
+
:init
|
49
|
+
@rem Get command-line arguments, handling Windowz variants
|
50
|
+
|
51
|
+
if not "%OS%" == "Windows_NT" goto win9xME_args
|
52
|
+
if "%@eval[2+2]" == "4" goto 4NT_args
|
53
|
+
|
54
|
+
:win9xME_args
|
55
|
+
@rem Slurp the command line arguments.
|
56
|
+
set CMD_LINE_ARGS=
|
57
|
+
set _SKIP=2
|
58
|
+
|
59
|
+
:win9xME_args_slurp
|
60
|
+
if "x%~1" == "x" goto execute
|
61
|
+
|
62
|
+
set CMD_LINE_ARGS=%*
|
63
|
+
goto execute
|
64
|
+
|
65
|
+
:4NT_args
|
66
|
+
@rem Get arguments from the 4NT Shell from JP Software
|
67
|
+
set CMD_LINE_ARGS=%$
|
68
|
+
|
69
|
+
:execute
|
70
|
+
@rem Setup the command line
|
71
|
+
|
72
|
+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
73
|
+
|
74
|
+
@rem Execute Gradle
|
75
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
76
|
+
|
77
|
+
:end
|
78
|
+
@rem End local scope for the variables with windows NT shell
|
79
|
+
if "%ERRORLEVEL%"=="0" goto mainEnd
|
80
|
+
|
81
|
+
:fail
|
82
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
83
|
+
rem the _cmd.exe /c_ return code!
|
84
|
+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
85
|
+
exit /b 1
|
86
|
+
|
87
|
+
:mainEnd
|
88
|
+
if "%OS%"=="Windows_NT" endlocal
|
89
|
+
|
90
|
+
:omega
|
@@ -0,0 +1,209 @@
|
|
1
|
+
package org.embulk.output.sftp;
|
2
|
+
|
3
|
+
import com.google.common.base.Throwables;
|
4
|
+
import org.apache.commons.vfs2.FileObject;
|
5
|
+
import org.apache.commons.vfs2.FileSystemException;
|
6
|
+
import org.apache.commons.vfs2.FileSystemOptions;
|
7
|
+
import org.apache.commons.vfs2.Selectors;
|
8
|
+
import org.apache.commons.vfs2.impl.StandardFileSystemManager;
|
9
|
+
import org.apache.commons.vfs2.provider.sftp.IdentityInfo;
|
10
|
+
import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder;
|
11
|
+
import org.embulk.config.TaskReport;
|
12
|
+
import org.embulk.spi.Buffer;
|
13
|
+
import org.embulk.spi.Exec;
|
14
|
+
import org.embulk.spi.FileOutput;
|
15
|
+
import org.embulk.spi.TransactionalFileOutput;
|
16
|
+
import org.slf4j.Logger;
|
17
|
+
|
18
|
+
import java.io.File;
|
19
|
+
import java.io.IOException;
|
20
|
+
import java.io.OutputStream;
|
21
|
+
import java.net.URI;
|
22
|
+
import java.net.URISyntaxException;
|
23
|
+
|
24
|
+
import static org.embulk.output.sftp.SftpFileOutputPlugin.PluginTask;
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Created by takahiro.nakayama on 10/20/15.
|
28
|
+
*/
|
29
|
+
public class SftpFileOutput
|
30
|
+
implements FileOutput, TransactionalFileOutput
|
31
|
+
{
|
32
|
+
private final Logger logger = Exec.getLogger(SftpFileOutput.class);
|
33
|
+
private final StandardFileSystemManager manager;
|
34
|
+
private final FileSystemOptions fsOptions;
|
35
|
+
private final String userInfo;
|
36
|
+
private final String host;
|
37
|
+
private final int port;
|
38
|
+
private final String pathPrefix;
|
39
|
+
private final String sequenceFormat;
|
40
|
+
private final String fileNameExtension;
|
41
|
+
|
42
|
+
private final int taskIndex;
|
43
|
+
private int fileIndex = 0;
|
44
|
+
private FileObject currentFile;
|
45
|
+
private OutputStream currentFileOutputStream;
|
46
|
+
|
47
|
+
private StandardFileSystemManager initializeStandardFileSystemManager()
|
48
|
+
{
|
49
|
+
if (!logger.isDebugEnabled()) {
|
50
|
+
// TODO: change logging format: org.apache.commons.logging.Log
|
51
|
+
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
|
52
|
+
}
|
53
|
+
StandardFileSystemManager manager = new StandardFileSystemManager();
|
54
|
+
try {
|
55
|
+
manager.init();
|
56
|
+
}
|
57
|
+
catch (FileSystemException e) {
|
58
|
+
logger.error(e.getMessage());
|
59
|
+
throw new RuntimeException(e);
|
60
|
+
}
|
61
|
+
|
62
|
+
return manager;
|
63
|
+
}
|
64
|
+
|
65
|
+
private String initializeUserInfo(PluginTask task)
|
66
|
+
{
|
67
|
+
String userInfo = task.getUser();
|
68
|
+
if (task.getPassword().isPresent()) {
|
69
|
+
userInfo += ":" + task.getPassword().get();
|
70
|
+
}
|
71
|
+
return userInfo;
|
72
|
+
}
|
73
|
+
|
74
|
+
private FileSystemOptions initializeFsOptions(PluginTask task)
|
75
|
+
{
|
76
|
+
FileSystemOptions fsOptions = new FileSystemOptions();
|
77
|
+
|
78
|
+
try {
|
79
|
+
SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(fsOptions, task.getUserDirIsRoot());
|
80
|
+
SftpFileSystemConfigBuilder.getInstance().setTimeout(fsOptions, task.getSftpConnectionTimeout());
|
81
|
+
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(fsOptions, "no");
|
82
|
+
if (task.getSecretKeyFilePath().isPresent()) {
|
83
|
+
IdentityInfo identityInfo = new IdentityInfo(new File((task.getSecretKeyFilePath().get())), task.getSecretKeyPassphrase().getBytes());
|
84
|
+
SftpFileSystemConfigBuilder.getInstance().setIdentityInfo(fsOptions, identityInfo);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
catch (FileSystemException e) {
|
88
|
+
logger.error(e.getMessage());
|
89
|
+
throw new RuntimeException(e);
|
90
|
+
}
|
91
|
+
|
92
|
+
return fsOptions;
|
93
|
+
}
|
94
|
+
|
95
|
+
SftpFileOutput(PluginTask task, int taskIndex)
|
96
|
+
{
|
97
|
+
this.manager = initializeStandardFileSystemManager();
|
98
|
+
this.userInfo = initializeUserInfo(task);
|
99
|
+
this.fsOptions = initializeFsOptions(task);
|
100
|
+
this.host = task.getHost();
|
101
|
+
this.port = task.getPort();
|
102
|
+
this.pathPrefix = task.getPathPrefix();
|
103
|
+
this.sequenceFormat = task.getSequenceFormat();
|
104
|
+
this.fileNameExtension = task.getFileNameExtension();
|
105
|
+
this.taskIndex = taskIndex;
|
106
|
+
}
|
107
|
+
|
108
|
+
@Override
|
109
|
+
public void nextFile()
|
110
|
+
{
|
111
|
+
closeCurrentFile();
|
112
|
+
|
113
|
+
try {
|
114
|
+
currentFile = newSftpFile(getSftpFileUri(getOutputFilePath()));
|
115
|
+
currentFileOutputStream = currentFile.getContent().getOutputStream();
|
116
|
+
logger.info("new sftp file: {}", currentFile.getPublicURIString());
|
117
|
+
}
|
118
|
+
catch (FileSystemException e) {
|
119
|
+
logger.error(e.getMessage());
|
120
|
+
Throwables.propagate(e);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
@Override
|
125
|
+
public void add(Buffer buffer)
|
126
|
+
{
|
127
|
+
if (currentFile == null) {
|
128
|
+
throw new IllegalStateException("nextFile() must be called before poll()");
|
129
|
+
}
|
130
|
+
|
131
|
+
try {
|
132
|
+
currentFileOutputStream.write(buffer.array(), buffer.offset(), buffer.limit());
|
133
|
+
}
|
134
|
+
catch (IOException e) {
|
135
|
+
logger.error(e.getMessage());
|
136
|
+
Throwables.propagate(e);
|
137
|
+
}
|
138
|
+
buffer.release();
|
139
|
+
}
|
140
|
+
|
141
|
+
@Override
|
142
|
+
public void finish()
|
143
|
+
{
|
144
|
+
closeCurrentFile();
|
145
|
+
}
|
146
|
+
|
147
|
+
@Override
|
148
|
+
public void close()
|
149
|
+
{
|
150
|
+
closeCurrentFile();
|
151
|
+
manager.close();
|
152
|
+
}
|
153
|
+
|
154
|
+
@Override
|
155
|
+
public void abort()
|
156
|
+
{
|
157
|
+
}
|
158
|
+
|
159
|
+
@Override
|
160
|
+
public TaskReport commit()
|
161
|
+
{
|
162
|
+
return null;
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
private void closeCurrentFile()
|
167
|
+
{
|
168
|
+
if (currentFile == null) {
|
169
|
+
return;
|
170
|
+
}
|
171
|
+
|
172
|
+
try {
|
173
|
+
currentFileOutputStream.close();
|
174
|
+
currentFile.getContent().close();
|
175
|
+
currentFile.close();
|
176
|
+
}
|
177
|
+
catch (IOException e) {
|
178
|
+
logger.error(e.getMessage());
|
179
|
+
Throwables.propagate(e);
|
180
|
+
}
|
181
|
+
finally {
|
182
|
+
fileIndex++;
|
183
|
+
currentFile = null;
|
184
|
+
currentFileOutputStream = null;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
private URI getSftpFileUri(String remoteFilePath)
|
189
|
+
{
|
190
|
+
try {
|
191
|
+
return new URI("sftp", userInfo, host, port, remoteFilePath, null, null);
|
192
|
+
}
|
193
|
+
catch (URISyntaxException e) {
|
194
|
+
logger.error(e.getMessage());
|
195
|
+
throw new RuntimeException(e);
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
private String getOutputFilePath()
|
200
|
+
{
|
201
|
+
return pathPrefix + String.format(sequenceFormat, taskIndex, fileIndex) + fileNameExtension;
|
202
|
+
}
|
203
|
+
|
204
|
+
private FileObject newSftpFile(URI sftpUri)
|
205
|
+
throws FileSystemException
|
206
|
+
{
|
207
|
+
return manager.resolveFile(sftpUri.toString(), fsOptions);
|
208
|
+
}
|
209
|
+
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
package org.embulk.output.sftp;
|
2
|
+
|
3
|
+
import com.google.common.base.Optional;
|
4
|
+
import org.embulk.config.Config;
|
5
|
+
import org.embulk.config.ConfigDefault;
|
6
|
+
import org.embulk.config.ConfigDiff;
|
7
|
+
import org.embulk.config.ConfigSource;
|
8
|
+
import org.embulk.config.Task;
|
9
|
+
import org.embulk.config.TaskReport;
|
10
|
+
import org.embulk.config.TaskSource;
|
11
|
+
import org.embulk.spi.Exec;
|
12
|
+
import org.embulk.spi.FileOutputPlugin;
|
13
|
+
import org.embulk.spi.TransactionalFileOutput;
|
14
|
+
import org.slf4j.Logger;
|
15
|
+
|
16
|
+
import java.util.List;
|
17
|
+
|
18
|
+
public class SftpFileOutputPlugin
|
19
|
+
implements FileOutputPlugin
|
20
|
+
{
|
21
|
+
private Logger logger = Exec.getLogger(SftpFileOutputPlugin.class);
|
22
|
+
|
23
|
+
public interface PluginTask
|
24
|
+
extends Task
|
25
|
+
{
|
26
|
+
@Config("host")
|
27
|
+
public String getHost();
|
28
|
+
|
29
|
+
@Config("port")
|
30
|
+
@ConfigDefault("22")
|
31
|
+
public int getPort();
|
32
|
+
|
33
|
+
@Config("user")
|
34
|
+
public String getUser();
|
35
|
+
|
36
|
+
@Config("password")
|
37
|
+
@ConfigDefault("null")
|
38
|
+
public Optional<String> getPassword();
|
39
|
+
|
40
|
+
@Config("secret_key_file")
|
41
|
+
@ConfigDefault("null")
|
42
|
+
public Optional<String> getSecretKeyFilePath();
|
43
|
+
|
44
|
+
@Config("secret_key_passphrase")
|
45
|
+
@ConfigDefault("\"\"")
|
46
|
+
public String getSecretKeyPassphrase();
|
47
|
+
|
48
|
+
@Config("user_directory_is_root")
|
49
|
+
@ConfigDefault("true")
|
50
|
+
public Boolean getUserDirIsRoot();
|
51
|
+
|
52
|
+
@Config("timeout")
|
53
|
+
@ConfigDefault("600") // 10 minutes
|
54
|
+
public int getSftpConnectionTimeout();
|
55
|
+
|
56
|
+
@Config("path_prefix")
|
57
|
+
public String getPathPrefix();
|
58
|
+
|
59
|
+
@Config("file_ext")
|
60
|
+
public String getFileNameExtension();
|
61
|
+
|
62
|
+
@Config("sequence_format")
|
63
|
+
@ConfigDefault("\"%03d.%02d.\"")
|
64
|
+
public String getSequenceFormat();
|
65
|
+
|
66
|
+
}
|
67
|
+
|
68
|
+
@Override
|
69
|
+
public ConfigDiff transaction(ConfigSource config, int taskCount,
|
70
|
+
FileOutputPlugin.Control control)
|
71
|
+
{
|
72
|
+
PluginTask task = config.loadConfig(PluginTask.class);
|
73
|
+
|
74
|
+
// retryable (idempotent) output:
|
75
|
+
// return resume(task.dump(), taskCount, control);
|
76
|
+
|
77
|
+
// non-retryable (non-idempotent) output:
|
78
|
+
control.run(task.dump());
|
79
|
+
return Exec.newConfigDiff();
|
80
|
+
}
|
81
|
+
|
82
|
+
@Override
|
83
|
+
public ConfigDiff resume(TaskSource taskSource,
|
84
|
+
int taskCount,
|
85
|
+
FileOutputPlugin.Control control)
|
86
|
+
{
|
87
|
+
throw new UnsupportedOperationException("sftp output plugin does not support resuming");
|
88
|
+
}
|
89
|
+
|
90
|
+
@Override
|
91
|
+
public void cleanup(TaskSource taskSource,
|
92
|
+
int taskCount,
|
93
|
+
List<TaskReport> successTaskReports)
|
94
|
+
{
|
95
|
+
}
|
96
|
+
|
97
|
+
@Override
|
98
|
+
public TransactionalFileOutput open(TaskSource taskSource, final int taskIndex)
|
99
|
+
{
|
100
|
+
final PluginTask task = taskSource.loadTask(PluginTask.class);
|
101
|
+
return new SftpFileOutput(task, taskIndex);
|
102
|
+
}
|
103
|
+
}
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-output-sftp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Civitaspo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '1.0'
|
25
|
+
prerelease: false
|
26
|
+
type: :development
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '10.0'
|
39
|
+
prerelease: false
|
40
|
+
type: :development
|
41
|
+
description: Stores files on Sftp.
|
42
|
+
email:
|
43
|
+
- civitaspo@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- build.gradle
|
52
|
+
- example/data.csv
|
53
|
+
- example/sample.yml
|
54
|
+
- gradle/wrapper/gradle-wrapper.jar
|
55
|
+
- gradle/wrapper/gradle-wrapper.properties
|
56
|
+
- gradlew
|
57
|
+
- gradlew.bat
|
58
|
+
- lib/embulk/output/sftp.rb
|
59
|
+
- src/main/java/org/embulk/output/sftp/SftpFileOutput.java
|
60
|
+
- src/main/java/org/embulk/output/sftp/SftpFileOutputPlugin.java
|
61
|
+
- src/test/java/org/embulk/output/sftp/TestSftpFileOutputPlugin.java
|
62
|
+
- classpath/commons-logging-1.2.jar
|
63
|
+
- classpath/commons-vfs2-2.1.1660580.2.jar
|
64
|
+
- classpath/embulk-output-sftp-0.0.2.jar
|
65
|
+
- classpath/jsch-0.1.53.jar
|
66
|
+
homepage: https://github.com/civitaspo/embulk-output-sftp
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.1.9
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Sftp file output plugin for Embulk
|
90
|
+
test_files: []
|