embulk-output-fluentd 0.1.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.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +27 -0
  3. data/.gitignore +80 -0
  4. data/.scalafmt.conf +2 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +59 -0
  7. data/build.gradle +83 -0
  8. data/build.sbt +32 -0
  9. data/gradle/wrapper/gradle-wrapper.jar +0 -0
  10. data/gradle/wrapper/gradle-wrapper.properties +6 -0
  11. data/gradlew +169 -0
  12. data/gradlew.bat +84 -0
  13. data/lib/embulk/output/fluentd.rb +3 -0
  14. data/project/build.properties +1 -0
  15. data/project/plugins.sbt +2 -0
  16. data/settings.gradle +1 -0
  17. data/src/main/resources/application.conf +8 -0
  18. data/src/main/scala/org/embulk/output/fluentd/ColumnVisitor.scala +43 -0
  19. data/src/main/scala/org/embulk/output/fluentd/FluentdOutputPlugin.scala +55 -0
  20. data/src/main/scala/org/embulk/output/fluentd/FluentdTransactionalPageOutput.scala +52 -0
  21. data/src/main/scala/org/embulk/output/fluentd/PluginTask.scala +36 -0
  22. data/src/main/scala/org/embulk/output/fluentd/sender/ActorManager.scala +29 -0
  23. data/src/main/scala/org/embulk/output/fluentd/sender/Sender.scala +131 -0
  24. data/src/main/scala/org/embulk/output/fluentd/sender/SenderBuilder.scala +40 -0
  25. data/src/main/scala/org/embulk/output/fluentd/sender/SenderFlow.scala +36 -0
  26. data/src/main/scala/org/embulk/output/fluentd/sender/SuperVisor.scala +46 -0
  27. data/src/test/scala/org/embulk/output/fluentd/TestActorManager.scala +42 -0
  28. data/src/test/scala/org/embulk/output/fluentd/sender/SenderFlowImplTest.scala +87 -0
  29. data/src/test/scala/org/embulk/output/fluentd/sender/SenderImplTest.scala +119 -0
  30. metadata +118 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 814cfc5414b7c2ec68f86f5a55497cb6804cbc16
4
+ data.tar.gz: 3807f6c4bf5d43db0731f6c5bc6eddcf0da97e89
5
+ SHA512:
6
+ metadata.gz: 7d48fb066b478310a752f9a093ca60fc9fc254be5a8155b11f352111c054e63f2f71d59ba229c40ae4d91c5423d8f261a2daa65a632da0678c27f6d5472dc1e3
7
+ data.tar.gz: d56863b6181d87f7f37e73775680906f07536dadd3092c585196aa6853c574b3671fae4de1d0daa0fb89c3e306ddfd41c39e44981398c4ca1feae0ff27472598
@@ -0,0 +1,27 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ executorType: docker
5
+ docker:
6
+ - image: hseeberger/scala-sbt
7
+ working_directory: /root/embulk-output-fluentd/
8
+ steps:
9
+ - checkout
10
+ - restore_cache:
11
+ name: Restoring Cache
12
+ keys:
13
+ - sbt
14
+ - setup_remote_docker
15
+ - run:
16
+ name: prepare
17
+ command: sbt update exit
18
+ - save_cache:
19
+ name: Saving Cache sbt
20
+ key: sbt
21
+ paths:
22
+ - "/root/.sbt"
23
+ - "/root/.ivy2"
24
+ - run:
25
+ name: compile
26
+ command: |
27
+ sbt compile test scalafmt::test exit
@@ -0,0 +1,80 @@
1
+ /pkg/
2
+ /tmp/
3
+ *.gemspec
4
+ .gradle/
5
+ /classpath/
6
+ build/
7
+ .idea
8
+ /.settings/
9
+ /.metadata/
10
+ .classpath
11
+ .project
12
+
13
+ .settings
14
+ .classpath
15
+ .project
16
+ *.iml
17
+ *.ipr
18
+ *.iws
19
+ dist/
20
+ lib_managed/
21
+ project/boot/
22
+ project/plugins/project/
23
+ target/
24
+
25
+ # use glob syntax.
26
+ syntax: glob
27
+ *.ser
28
+ *.class
29
+ *~
30
+ *.bak
31
+ #*.off
32
+ *.old
33
+
34
+ # eclipse conf file
35
+ .settings
36
+ .classpath
37
+ .project
38
+ .manager
39
+ .scala_dependencies
40
+
41
+ # idea
42
+ .idea
43
+ *.iml
44
+
45
+ # building
46
+ target
47
+ build
48
+ null
49
+ tmp*
50
+ temp*
51
+ !templates/
52
+ dist
53
+ test-output
54
+ build.log
55
+
56
+ # other scm
57
+ .svn
58
+ .CVS
59
+ .hg*
60
+
61
+ # switch to regexp syntax.
62
+ # syntax: regexp
63
+ # ^\.pc/
64
+
65
+ #SHITTY output not in target directory
66
+ build.log
67
+ .DS_Store
68
+ derby.log
69
+
70
+ *.db
71
+
72
+ .lib
73
+ sbt
74
+
75
+ logs
76
+ sandbox/db
77
+
78
+
79
+ .ensime*⏎
80
+ project/project/
@@ -0,0 +1,2 @@
1
+ style = defaultWithAlign
2
+ maxColumn = 120
@@ -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.
@@ -0,0 +1,59 @@
1
+ # Fluentd output plugin for Embulk
2
+
3
+ ## Notice
4
+ This plugin is support only Java8.
5
+
6
+ ## Overview
7
+
8
+ * **Plugin type**: output
9
+ * **Load all or nothing**: no
10
+ * **Resume supported**: no
11
+ * **Cleanup supported**: no
12
+
13
+ ## Configuration
14
+
15
+ | name | type | required? | default | description |
16
+ |:-------------------------------------|:------------|:-----------|:-------------------------|:-----------------------|
17
+ | host | string | optional | "127.0.0.1" | fluentd servers host |
18
+ | port | integer | optional | "24224" | fluentd servers port |
19
+ | tag | string | required | | tag of logs |
20
+ | time_key | string | optional | | To use the name of value as time key. The value must set unixtime of seconds. (if empty parameter then using current unixtime) |
21
+ | async_size | integer | optional | "1" | asynchronous parallelism size |
22
+ | request_grouping_size | integer | optional | "100" | sending request grouping size (*1) |
23
+ | request_per_seconds | integer | optional | "0" | Sending throttle requests in per seconds. (default 0 is non throttle) (*2) |
24
+ | default_timezone | string | optional | UTC | |
25
+ | default_timestamp_format | string | optional | %Y-%m-%d %H:%M:%S.%6N | |
26
+
27
+ *1: Grouping Request of sending fluentd in a single time. (e.f. 100 is about 2750 records in single time.)
28
+ *2: Throttling single request of requestGroupingSize(just 100 of 2750 records) of bulk requests.
29
+
30
+ If your fluentd server is overloading, adjustment parameters(asyncSize,requestGroupingSize,requestPerSeconds) .
31
+
32
+ ## Example
33
+
34
+ ```yaml
35
+ out:
36
+ type: fluentd
37
+ tag: fluentd.tag
38
+ asyncSize: 4
39
+ requestPerSeconds: 30
40
+ ```
41
+
42
+ ```
43
+ $ embulk gem install embulk-output-fluentd
44
+ ```
45
+
46
+ ## Build
47
+
48
+ ```
49
+ $ ./gradlew gem # -t to watch change of files and rebuild continuously
50
+ ```
51
+
52
+ ## Developing or Testing
53
+
54
+ This plug-in is written by Scala. You could use sbt.
55
+
56
+ ```
57
+ $ ./sbt
58
+ $ ./sbt test
59
+ ```
@@ -0,0 +1,83 @@
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
+ id "scala"
6
+ }
7
+ import com.github.jrubygradle.JRubyExec
8
+ repositories {
9
+ mavenCentral()
10
+ jcenter()
11
+ }
12
+ configurations {
13
+ provided
14
+ }
15
+
16
+ version = "0.1.0"
17
+
18
+ sourceCompatibility = 1.7
19
+ targetCompatibility = 1.7
20
+
21
+ dependencies {
22
+ compile "org.embulk:embulk-core:0.8.25"
23
+ compile "org.scala-lang:scala-library:2.11.11"
24
+ compile group: 'com.typesafe.akka', name: 'akka-stream_2.11', version:'2.5.3'
25
+ compile group: 'com.typesafe.akka', name: 'akka-actor_2.11', version:'2.5.3'
26
+ compile group: 'com.typesafe.akka', name: 'akka-slf4j_2.11', version:'2.5.3'
27
+ compile 'org.velvia:msgpack4s_2.11:0.6.0'
28
+ compile 'org.wvlet:airframe_2.11:0.15'
29
+ provided "org.embulk:embulk-core:0.8.24"
30
+ }
31
+
32
+ task classpath(type: Copy, dependsOn: ["jar"]) {
33
+ doFirst { file("classpath").deleteDir() }
34
+ from (configurations.runtime - configurations.provided + files(jar.archivePath))
35
+ into "classpath"
36
+ }
37
+ clean { delete "classpath" }
38
+
39
+ task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
40
+ jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
41
+ script "${project.name}.gemspec"
42
+ doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
43
+ }
44
+
45
+ task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
46
+ jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "push"
47
+ script "pkg/${project.name}-${project.version}.gem"
48
+ }
49
+
50
+ task "package"(dependsOn: ["gemspec", "classpath"]) {
51
+ doLast {
52
+ println "> Build succeeded."
53
+ println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
54
+ }
55
+ }
56
+
57
+ task gemspec {
58
+ ext.gemspecFile = file("${project.name}.gemspec")
59
+ inputs.file "build.gradle"
60
+ outputs.file gemspecFile
61
+ doLast { gemspecFile.write($/
62
+ Gem::Specification.new do |spec|
63
+ spec.name = "${project.name}"
64
+ spec.version = "${project.version}"
65
+ spec.authors = ["smdmts"]
66
+ spec.summary = %[Fluentd output plugin for Embulk]
67
+ spec.description = %[Dumps records to Fluentd.]
68
+ spec.email = ["smdmts@gmail.com"]
69
+ spec.licenses = ["MIT"]
70
+ spec.homepage = "https://github.com/smdmts/embulk-output-fluentd"
71
+
72
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
73
+ spec.test_files = spec.files.grep(%r"^(test|spec)/")
74
+ spec.require_paths = ["lib"]
75
+
76
+ #spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
77
+ spec.add_development_dependency 'bundler', ['~> 1.0']
78
+ spec.add_development_dependency 'rake', ['>= 10.0']
79
+ end
80
+ /$)
81
+ }
82
+ }
83
+ clean { delete "${project.name}.gemspec" }
@@ -0,0 +1,32 @@
1
+ enablePlugins(ScalafmtPlugin)
2
+
3
+ lazy val root = (project in file(".")).settings(
4
+ inThisBuild(
5
+ List(
6
+ organization := "com.example",
7
+ scalaVersion := "2.11.11",
8
+ version := "0.1.0-SNAPSHOT"
9
+ )),
10
+ name := "embulk-output-fluentd",
11
+ scalafmtOnCompile in ThisBuild := true,
12
+ scalafmtTestOnCompile in ThisBuild := true
13
+ )
14
+
15
+ resolvers += Resolver.jcenterRepo
16
+ resolvers += Resolver.sonatypeRepo("releases")
17
+ resolvers += "velvia maven" at "http://dl.bintray.com/velvia/maven"
18
+
19
+ libraryDependencies ++= Seq(
20
+ "org.jruby" % "jruby-complete" % "1.6.5",
21
+ "org.embulk" % "embulk-core" % "0.8.25",
22
+ "com.typesafe.akka" %% "akka-actor" % "2.5.3",
23
+ "com.typesafe.akka" %% "akka-stream" % "2.5.3",
24
+ "com.typesafe.akka" %% "akka-slf4j" % "2.5.3",
25
+ "org.velvia" %% "msgpack4s" % "0.6.0",
26
+ "org.wvlet" %% "airframe" % "0.15",
27
+ "com.typesafe.akka" %% "akka-stream-testkit" % "2.5.3" % Test,
28
+ "org.scalacheck" %% "scalacheck" % "1.13.4" % Test,
29
+ "org.scalatest" %% "scalatest" % "3.0.1" % Test,
30
+ "org.scalamock" %% "scalamock-scalatest-support" % "3.6.0" % Test,
31
+ "com.github.alexarchambault" %% "scalacheck-shapeless_1.13" % "1.1.5" % Test
32
+ )
@@ -0,0 +1,6 @@
1
+ #Mon Jun 19 14:41:12 JST 2017
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-3.2.1-all.zip
data/gradlew ADDED
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ##############################################################################
4
+ ##
5
+ ## Gradle start up script for UN*X
6
+ ##
7
+ ##############################################################################
8
+
9
+ # Attempt to set APP_HOME
10
+ # Resolve links: $0 may be a link
11
+ PRG="$0"
12
+ # Need this for relative symlinks.
13
+ while [ -h "$PRG" ] ; do
14
+ ls=`ls -ld "$PRG"`
15
+ link=`expr "$ls" : '.*-> \(.*\)$'`
16
+ if expr "$link" : '/.*' > /dev/null; then
17
+ PRG="$link"
18
+ else
19
+ PRG=`dirname "$PRG"`"/$link"
20
+ fi
21
+ done
22
+ SAVED="`pwd`"
23
+ cd "`dirname \"$PRG\"`/" >/dev/null
24
+ APP_HOME="`pwd -P`"
25
+ cd "$SAVED" >/dev/null
26
+
27
+ APP_NAME="Gradle"
28
+ APP_BASE_NAME=`basename "$0"`
29
+
30
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31
+ DEFAULT_JVM_OPTS=""
32
+
33
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
34
+ MAX_FD="maximum"
35
+
36
+ warn ( ) {
37
+ echo "$*"
38
+ }
39
+
40
+ die ( ) {
41
+ echo
42
+ echo "$*"
43
+ echo
44
+ exit 1
45
+ }
46
+
47
+ # OS specific support (must be 'true' or 'false').
48
+ cygwin=false
49
+ msys=false
50
+ darwin=false
51
+ nonstop=false
52
+ case "`uname`" in
53
+ CYGWIN* )
54
+ cygwin=true
55
+ ;;
56
+ Darwin* )
57
+ darwin=true
58
+ ;;
59
+ MINGW* )
60
+ msys=true
61
+ ;;
62
+ NONSTOP* )
63
+ nonstop=true
64
+ ;;
65
+ esac
66
+
67
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68
+
69
+ # Determine the Java command to use to start the JVM.
70
+ if [ -n "$JAVA_HOME" ] ; then
71
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72
+ # IBM's JDK on AIX uses strange locations for the executables
73
+ JAVACMD="$JAVA_HOME/jre/sh/java"
74
+ else
75
+ JAVACMD="$JAVA_HOME/bin/java"
76
+ fi
77
+ if [ ! -x "$JAVACMD" ] ; then
78
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79
+
80
+ Please set the JAVA_HOME variable in your environment to match the
81
+ location of your Java installation."
82
+ fi
83
+ else
84
+ JAVACMD="java"
85
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86
+
87
+ Please set the JAVA_HOME variable in your environment to match the
88
+ location of your Java installation."
89
+ fi
90
+
91
+ # Increase the maximum file descriptors if we can.
92
+ if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93
+ MAX_FD_LIMIT=`ulimit -H -n`
94
+ if [ $? -eq 0 ] ; then
95
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96
+ MAX_FD="$MAX_FD_LIMIT"
97
+ fi
98
+ ulimit -n $MAX_FD
99
+ if [ $? -ne 0 ] ; then
100
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
101
+ fi
102
+ else
103
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104
+ fi
105
+ fi
106
+
107
+ # For Darwin, add options to specify how the application appears in the dock
108
+ if $darwin; then
109
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110
+ fi
111
+
112
+ # For Cygwin, switch paths to Windows format before running java
113
+ if $cygwin ; then
114
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116
+ JAVACMD=`cygpath --unix "$JAVACMD"`
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
+ # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
165
+ if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
166
+ cd "$(dirname "$0")"
167
+ fi
168
+
169
+ exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"