embulk-output-gcs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7774879832609dc7f15ce3025ebef7ac4d2ee127
4
+ data.tar.gz: 0a00dc3980dcd45c4be65a93bade838aeb1bc1b5
5
+ SHA512:
6
+ metadata.gz: a199e472278173b7b65363da88660a116c78175cf7b7ef0c5509939e66b240411316643877ec03a10b897be72ca57ce6cc1ae93ccb241d82550076c990f0d5d4
7
+ data.tar.gz: a33c9a64410730e7a96bee350774bbbbe36a279feb30ed4c498d4244c695bc745e41f8d6f5eb399c6f879f537c2b5531a4ea284e9532238064e0e495722f2759
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *~
2
+ /pkg/
3
+ /tmp/
4
+ .gradle/
5
+ /classpath/
6
+ build/
7
+ .idea
8
+ *.iml
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,41 @@
1
+ # Google Cloud Storage output plugin for Embulk
2
+
3
+ Google Cloud Storage output plugin for [Embulk](https://github.com/embulk/embulk).
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: file output
8
+ * **Load all or nothing**: no
9
+ * **Resume supported**: yes
10
+ * **Cleanup supported**: no
11
+
12
+ ## Configuration
13
+
14
+ - **bucket**: Google Cloud Storage bucket name (string, required)
15
+ - **path_prefix**: Prefix of output keys (string, required)
16
+ - **file_ext**: Extention of output file (string, required)
17
+ - **content_type**: content type of output file (string, optional, default value is "application/octet-stream")
18
+ - **service_account_email**: Google Cloud Platform service account email (string, required)
19
+ - **p12_keyfile_path**: Private key file fullpath of Google Cloud Platform service account (string, required)
20
+ - **application_name**: Application name, anything you like (string, optional, default value is "embulk-output-gcs")
21
+
22
+ ## Example
23
+
24
+ ```yaml
25
+ out:
26
+ type: gcs
27
+ bucket: your-gcs-bucket-name
28
+ path_prefix: logs/out
29
+ file_ext: .csv
30
+ service_account_email: 'XYZ@developer.gserviceaccount.com'
31
+ p12_keyfile_path: '/path/to/private/key.p12'
32
+ formatter:
33
+ type: csv
34
+ encoding: UTF-8
35
+ ```
36
+
37
+ ## Build
38
+
39
+ ```
40
+ $ ./gradlew gem
41
+ ```
data/build.gradle ADDED
@@ -0,0 +1,59 @@
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.1.0"
16
+
17
+ dependencies {
18
+ compile "org.embulk:embulk-core:0.5.1"
19
+ provided "org.embulk:embulk-core:0.5.1"
20
+
21
+ compile "com.google.http-client:google-http-client-jackson2:1.19.0"
22
+ compile ("com.google.apis:google-api-services-storage:v1-rev28-1.19.1") {exclude module: "guava-jdk5"}
23
+
24
+ testCompile "junit:junit:4.+"
25
+ }
26
+
27
+ task classpath(type: Copy, dependsOn: ["jar"]) {
28
+ doFirst { file("classpath").deleteDir() }
29
+ from (configurations.runtime - configurations.provided + files(jar.archivePath))
30
+ into "classpath"
31
+ }
32
+ clean { delete 'classpath' }
33
+
34
+ task gem(type: JRubyExec, dependsOn: ["build", "gemspec", "classpath"]) {
35
+ jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
36
+ script "build/gemspec"
37
+ doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
38
+ }
39
+
40
+ task gemspec << { file("build/gemspec").write($/
41
+ Gem::Specification.new do |spec|
42
+ spec.name = "${project.name}"
43
+ spec.version = "${project.version}"
44
+ spec.authors = ["Kazuyuki Honda"]
45
+ spec.summary = %[Google Cloud Storage output plugin for Embulk]
46
+ spec.description = %["Dumps records to Google Cloud Storage."]
47
+ spec.email = ["hakobera@gmail.com"]
48
+ spec.licenses = ["MIT"]
49
+ spec.homepage = "https://github.com/hakobera/embulk-output-gcs"
50
+
51
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
52
+ spec.test_files = spec.files.grep(%r"^(test|spec)/")
53
+ spec.require_paths = ["lib"]
54
+
55
+ spec.add_development_dependency 'bundler', ['~> 1.0']
56
+ spec.add_development_dependency 'rake', ['>= 10.0']
57
+ end
58
+ /$)
59
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
data/gradle/gradle.iml ADDED
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module external.linked.project.id="gradle" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
4
+ <output url="file://$MODULE_DIR$/build" />
5
+ <output-test url="file://$MODULE_DIR$/build" />
6
+ <exclude-output />
7
+ <content url="file://$MODULE_DIR$">
8
+ <excludeFolder url="file://$MODULE_DIR$/.gradle" />
9
+ <excludeFolder url="file://$MODULE_DIR$/build" />
10
+ </content>
11
+ <orderEntry type="inheritedJdk" />
12
+ <orderEntry type="sourceFolder" forTests="false" />
13
+ </component>
14
+ </module>
@@ -0,0 +1,6 @@
1
+ #Tue Mar 10 13:52:23 JST 2015
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ zipStoreBase=GRADLE_USER_HOME
5
+ zipStorePath=wrapper/dists
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip
data/gradle/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 "$@"
@@ -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
Binary file
@@ -0,0 +1,6 @@
1
+ #Wed Feb 04 13:46:12 PST 2015
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ zipStoreBase=GRADLE_USER_HOME
5
+ zipStorePath=wrapper/dists
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip
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,3 @@
1
+ Embulk::JavaPlugin.register_output(
2
+ "gcs", "org.embulk.output.GcsOutputPlugin",
3
+ File.expand_path('../../../../classpath', __FILE__))
@@ -0,0 +1,253 @@
1
+ package org.embulk.output;
2
+
3
+ import com.google.api.client.auth.oauth2.Credential;
4
+ import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
5
+ import com.google.api.client.http.HttpTransport;
6
+ import com.google.api.client.http.InputStreamContent;
7
+ import com.google.api.client.http.apache.ApacheHttpTransport;
8
+ import com.google.api.client.json.JsonFactory;
9
+ import com.google.api.client.json.jackson2.JacksonFactory;
10
+ import com.google.api.services.storage.Storage;
11
+ import com.google.api.services.storage.StorageScopes;
12
+ import com.google.api.services.storage.model.StorageObject;
13
+ import com.google.common.base.Throwables;
14
+ import com.google.common.collect.ImmutableList;
15
+ import org.embulk.config.CommitReport;
16
+ import org.embulk.config.Config;
17
+ import org.embulk.config.ConfigDefault;
18
+ import org.embulk.config.ConfigDiff;
19
+ import org.embulk.config.ConfigSource;
20
+ import org.embulk.config.Task;
21
+ import org.embulk.config.TaskSource;
22
+ import org.embulk.spi.Buffer;
23
+ import org.embulk.spi.Exec;
24
+ import org.embulk.spi.FileOutputPlugin;
25
+ import org.embulk.spi.TransactionalFileOutput;
26
+ import org.slf4j.Logger;
27
+
28
+ import java.io.File;
29
+ import java.io.IOException;
30
+ import java.io.PipedInputStream;
31
+ import java.io.PipedOutputStream;
32
+ import java.security.GeneralSecurityException;
33
+ import java.util.ArrayList;
34
+ import java.util.List;
35
+ import java.util.concurrent.Callable;
36
+ import java.util.concurrent.ExecutionException;
37
+ import java.util.concurrent.ExecutorService;
38
+ import java.util.concurrent.Executors;
39
+ import java.util.concurrent.Future;
40
+
41
+ public class GcsOutputPlugin implements FileOutputPlugin {
42
+ private static final Logger logger = Exec.getLogger(GcsOutputPlugin.class);
43
+ private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
44
+
45
+ public interface PluginTask extends Task {
46
+ @Config("bucket")
47
+ public String getBucket();
48
+
49
+ @Config("path_prefix")
50
+ public String getPathPrefix();
51
+
52
+ @Config("file_ext")
53
+ public String getFileNameExtension();
54
+
55
+ @Config("sequence_format")
56
+ @ConfigDefault("\".%03d.%02d\"")
57
+ public String getSequenceFormat();
58
+
59
+ @Config("content_type")
60
+ @ConfigDefault("\"application/octet-stream\"")
61
+ public String getContentType();
62
+
63
+ @Config("service_account_email")
64
+ public String getServiceAccountEmail();
65
+
66
+ @Config("p12_keyfile_path")
67
+ public String getP12KeyfilePath();
68
+
69
+ @Config("application_name")
70
+ @ConfigDefault("\"embulk-output-gcs\"")
71
+ public String getApplicationName();
72
+ }
73
+
74
+ @Override
75
+ public ConfigDiff transaction(ConfigSource config,
76
+ int taskCount,
77
+ FileOutputPlugin.Control control) {
78
+ PluginTask task = config.loadConfig(PluginTask.class);
79
+ return resume(task.dump(), taskCount, control);
80
+ }
81
+
82
+ @Override
83
+ public ConfigDiff resume(TaskSource taskSource,
84
+ int taskCount,
85
+ FileOutputPlugin.Control control) {
86
+ control.run(taskSource);
87
+ return Exec.newConfigDiff();
88
+ }
89
+
90
+ @Override
91
+ public void cleanup(TaskSource taskSource,
92
+ int taskCount,
93
+ List<CommitReport> successCommitReports) {
94
+ }
95
+
96
+ @Override
97
+ public TransactionalFileOutput open(TaskSource taskSource, final int taskIndex) {
98
+ PluginTask task = taskSource.loadTask(PluginTask.class);
99
+
100
+ Storage client = createClient(task);
101
+ return new TransactionalGcsFileOutput(task, client, taskIndex);
102
+ }
103
+
104
+ private GoogleCredential createCredential(final PluginTask task, final HttpTransport httpTransport) {
105
+ try {
106
+ // @see https://developers.google.com/accounts/docs/OAuth2ServiceAccount#authorizingrequests
107
+ // @see https://cloud.google.com/compute/docs/api/how-tos/authorization
108
+ // @see https://developers.google.com/resources/api-libraries/documentation/storage/v1/java/latest/com/google/api/services/storage/STORAGE_SCOPE.html
109
+ GoogleCredential cred = new GoogleCredential.Builder()
110
+ .setTransport(httpTransport)
111
+ .setJsonFactory(JSON_FACTORY)
112
+ .setServiceAccountId(task.getServiceAccountEmail())
113
+ .setServiceAccountScopes(ImmutableList.of(StorageScopes.DEVSTORAGE_READ_WRITE))
114
+ .setServiceAccountPrivateKeyFromP12File(new File(task.getP12KeyfilePath()))
115
+ .build();
116
+ return cred;
117
+ } catch (IOException ex) {
118
+ logger.error(String.format("Could not load client secrets file %s", task.getP12KeyfilePath()));
119
+ throw Throwables.propagate(ex);
120
+ } catch (GeneralSecurityException ex) {
121
+ logger.error("Google Authentication was failed");
122
+ throw Throwables.propagate(ex);
123
+ }
124
+ }
125
+
126
+ private Storage createClient(final PluginTask task) {
127
+ HttpTransport httpTransport = new ApacheHttpTransport.Builder().build();
128
+ Credential credential = createCredential(task, httpTransport);
129
+ Storage client = new Storage.Builder(httpTransport, JSON_FACTORY, credential)
130
+ .setApplicationName(task.getApplicationName())
131
+ .build();
132
+ return client;
133
+ }
134
+
135
+ static class TransactionalGcsFileOutput implements TransactionalFileOutput {
136
+ private final int taskIndex;
137
+ private final Storage client;
138
+ private final String bucket;
139
+ private final String pathPrefix;
140
+ private final String pathSuffix;
141
+ private final String sequenceFormat;
142
+ private final String contentType;
143
+ private final List<StorageObject> storageObjects = new ArrayList<>();
144
+
145
+ private int fileIndex = 0;
146
+ private int callCount = 0;
147
+ private PipedOutputStream currentStream = null;
148
+ private Future<StorageObject> currentUpload = null;
149
+
150
+ TransactionalGcsFileOutput(PluginTask task, Storage client, int taskIndex) {
151
+ this.taskIndex = taskIndex;
152
+ this.client = client;
153
+ this.bucket = task.getBucket();
154
+ this.pathPrefix = task.getPathPrefix();
155
+ this.pathSuffix = task.getFileNameExtension();
156
+ this.sequenceFormat = task.getSequenceFormat();
157
+ this.contentType = task.getContentType();
158
+ }
159
+
160
+ public void nextFile() {
161
+ closeCurrentUpload();
162
+ currentStream = new PipedOutputStream();
163
+ String path = pathPrefix + String.format(sequenceFormat, taskIndex, fileIndex) + pathSuffix;
164
+ logger.info("Uploading '{}/{}'", bucket, path);
165
+ currentUpload = startUpload(path, contentType, currentStream);
166
+ fileIndex++;
167
+ }
168
+
169
+ @Override
170
+ public void add(Buffer buffer) {
171
+ try {
172
+ logger.debug("#add called {} times for taskIndex {}", callCount, taskIndex);
173
+ currentStream.write(buffer.array(), buffer.offset(), buffer.limit());
174
+ callCount++;
175
+ } catch (IOException ex) {
176
+ throw new RuntimeException(ex);
177
+ } finally {
178
+ buffer.release();
179
+ }
180
+ }
181
+
182
+ @Override
183
+ public void finish() {
184
+ closeCurrentUpload();
185
+ }
186
+
187
+ @Override
188
+ public void close() {
189
+ closeCurrentUpload();
190
+ }
191
+
192
+ @Override
193
+ public void abort() {
194
+ }
195
+
196
+ @Override
197
+ public CommitReport commit() {
198
+ CommitReport report = Exec.newCommitReport();
199
+ report.set("files", storageObjects);
200
+ return report;
201
+ }
202
+
203
+ private void closeCurrentUpload() {
204
+ try {
205
+ if (currentStream != null) {
206
+ currentStream.close();
207
+ currentStream = null;
208
+ }
209
+
210
+ if (currentUpload != null) {
211
+ StorageObject obj = currentUpload.get();
212
+ storageObjects.add(obj);
213
+ logger.info("Uploaded '{}/{}' to {}bytes", obj.getBucket(), obj.getName(), obj.getSize());
214
+ currentUpload = null;
215
+ }
216
+
217
+ callCount = 0;
218
+ } catch (InterruptedException | ExecutionException | IOException ex) {
219
+ throw Throwables.propagate(ex);
220
+ }
221
+ }
222
+
223
+ private Future<StorageObject> startUpload(String path, String contentType, PipedOutputStream output) {
224
+ try {
225
+ final ExecutorService executor = Executors.newCachedThreadPool();
226
+
227
+ PipedInputStream inputStream = new PipedInputStream(output);
228
+ InputStreamContent mediaContent = new InputStreamContent(contentType, inputStream);
229
+ mediaContent.setCloseInputStream(true);
230
+
231
+ StorageObject objectMetadata = new StorageObject();
232
+ objectMetadata.setName(path);
233
+
234
+ final Storage.Objects.Insert insert = client.objects().insert(bucket, objectMetadata, mediaContent);
235
+ insert.setDisableGZipContent(true);
236
+ return executor.submit(new Callable<StorageObject>() {
237
+ @Override
238
+ public StorageObject call() throws InterruptedException {
239
+ try {
240
+ return insert.execute();
241
+ } catch (IOException ex) {
242
+ throw Throwables.propagate(ex);
243
+ } finally {
244
+ executor.shutdown();
245
+ }
246
+ }
247
+ });
248
+ } catch (IOException ex) {
249
+ throw Throwables.propagate(ex);
250
+ }
251
+ }
252
+ }
253
+ }
@@ -0,0 +1,5 @@
1
+ package org.embulk.output;
2
+
3
+ public class TestGcsOutputPlugin
4
+ {
5
+ }
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-output-gcs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kazuyuki Honda
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ~>
17
+ - !ruby/object:Gem::Version
18
+ version: '1.0'
19
+ name: bundler
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '10.0'
33
+ name: rake
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: '"Dumps records to Google Cloud Storage."'
42
+ email:
43
+ - hakobera@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - LICENSE.txt
50
+ - README.md
51
+ - build.gradle
52
+ - gradle/gradle.iml
53
+ - gradle/gradle/wrapper/gradle-wrapper.jar
54
+ - gradle/gradle/wrapper/gradle-wrapper.properties
55
+ - gradle/gradlew
56
+ - gradle/gradlew.bat
57
+ - gradle/wrapper/gradle-wrapper.jar
58
+ - gradle/wrapper/gradle-wrapper.properties
59
+ - gradlew
60
+ - gradlew.bat
61
+ - lib/embulk/output/gcs.rb
62
+ - src/main/java/org/embulk/output/GcsOutputPlugin.java
63
+ - src/test/java/org/embulk/output/TestGcsOutputPlugin.java
64
+ - classpath/commons-codec-1.3.jar
65
+ - classpath/commons-logging-1.1.1.jar
66
+ - classpath/embulk-output-gcs-0.1.0.jar
67
+ - classpath/google-api-client-1.19.1.jar
68
+ - classpath/google-api-services-storage-v1-rev28-1.19.1.jar
69
+ - classpath/google-http-client-1.19.0.jar
70
+ - classpath/google-http-client-jackson2-1.19.0.jar
71
+ - classpath/google-oauth-client-1.19.0.jar
72
+ - classpath/httpclient-4.0.1.jar
73
+ - classpath/httpcore-4.0.1.jar
74
+ - classpath/jsr305-1.3.9.jar
75
+ homepage: https://github.com/hakobera/embulk-output-gcs
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.1.9
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Google Cloud Storage output plugin for Embulk
99
+ test_files: []