embulk-output-trafodion 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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/build.gradle +96 -0
- data/config/checkstyle/checkstyle.xml +128 -0
- data/config/checkstyle/default.xml +108 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/gradlew +160 -0
- data/gradlew.bat +90 -0
- data/lib/embulk/output/trafodion.rb +3 -0
- data/src/main/java/org/embulk/output/trafodion/TrafodionBatchInsert.java +37 -0
- data/src/main/java/org/embulk/output/trafodion/TrafodionOutputConnection.java +222 -0
- data/src/main/java/org/embulk/output/trafodion/TrafodionOutputConnector.java +36 -0
- data/src/main/java/org/embulk/output/trafodion/TrafodionOutputPlugin.java +132 -0
- data/src/test/java/org/embulk/output/trafodion/TestTrafodionOutputPlugin.java +5 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4d89d2510cedb9c60648ae973509085578fe85fb
|
4
|
+
data.tar.gz: bca7798f62192221b979e2fb89d8853490273039
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7af5c12de52a7cc78916a22dcbddfa83fbd40febbeac902cb7f3bd24942f465aac2e0345bbd9f5a1a0b7fe80bb3297ce356246e14a71cd8fb4fb0b4215f65626
|
7
|
+
data.tar.gz: d7d8cc8b26a48b35cc77511d767e7b58981a08e733cb3598dcfb37304f509ee5f2fac8296c6ea475f42cbb8a8b1c692ffdeaf63700f18e1e102edd9ada7f00fc
|
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,32 @@
|
|
1
|
+
# Trafodion output plugin for Embulk
|
2
|
+
|
3
|
+
TODO: Write short description here and build.gradle file.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
* **Plugin type**: output
|
8
|
+
* **Load all or nothing**: no
|
9
|
+
* **Resume supported**: no
|
10
|
+
* **Cleanup supported**: yes
|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
|
14
|
+
- **option1**: description (integer, required)
|
15
|
+
- **option2**: description (string, default: `"myvalue"`)
|
16
|
+
- **option3**: description (string, default: `null`)
|
17
|
+
|
18
|
+
## Example
|
19
|
+
|
20
|
+
```yaml
|
21
|
+
out:
|
22
|
+
type: trafodion
|
23
|
+
option1: example1
|
24
|
+
option2: example2
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
## Build
|
29
|
+
|
30
|
+
```
|
31
|
+
$ ./gradlew gem # -t to watch change of files and rebuild continuously
|
32
|
+
```
|
data/build.gradle
ADDED
@@ -0,0 +1,96 @@
|
|
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 "checkstyle"
|
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.13"
|
23
|
+
compile files('../lib/embulk-output-jdbc-0.6.3.jar')
|
24
|
+
compile files('../lib/jdbcT4-2.2.0.jar')
|
25
|
+
provided "org.embulk:embulk-core:0.8.13"
|
26
|
+
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
|
27
|
+
testCompile "junit:junit:4.+"
|
28
|
+
}
|
29
|
+
|
30
|
+
task classpath(type: Copy, dependsOn: ["jar"]) {
|
31
|
+
doFirst { file("classpath").deleteDir() }
|
32
|
+
from (configurations.runtime - configurations.provided + files(jar.archivePath))
|
33
|
+
into "classpath"
|
34
|
+
}
|
35
|
+
clean { delete "classpath" }
|
36
|
+
|
37
|
+
checkstyle {
|
38
|
+
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
|
39
|
+
toolVersion = '6.14.1'
|
40
|
+
}
|
41
|
+
checkstyleMain {
|
42
|
+
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
|
43
|
+
ignoreFailures = true
|
44
|
+
}
|
45
|
+
checkstyleTest {
|
46
|
+
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
|
47
|
+
ignoreFailures = true
|
48
|
+
}
|
49
|
+
task checkstyle(type: Checkstyle) {
|
50
|
+
classpath = sourceSets.main.output + sourceSets.test.output
|
51
|
+
source = sourceSets.main.allJava + sourceSets.test.allJava
|
52
|
+
}
|
53
|
+
|
54
|
+
task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
|
55
|
+
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
|
56
|
+
script "${project.name}.gemspec"
|
57
|
+
doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
|
58
|
+
}
|
59
|
+
|
60
|
+
task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
|
61
|
+
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "push"
|
62
|
+
script "pkg/${project.name}-${project.version}.gem"
|
63
|
+
}
|
64
|
+
|
65
|
+
task "package"(dependsOn: ["gemspec", "classpath"]) << {
|
66
|
+
println "> Build succeeded."
|
67
|
+
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
|
68
|
+
}
|
69
|
+
|
70
|
+
task gemspec {
|
71
|
+
ext.gemspecFile = file("${project.name}.gemspec")
|
72
|
+
inputs.file "build.gradle"
|
73
|
+
outputs.file gemspecFile
|
74
|
+
doLast { gemspecFile.write($/
|
75
|
+
Gem::Specification.new do |spec|
|
76
|
+
spec.name = "${project.name}"
|
77
|
+
spec.version = "${project.version}"
|
78
|
+
spec.authors = ["Alex Peng"]
|
79
|
+
spec.summary = %[Trafodion output plugin for Embulk]
|
80
|
+
spec.description = %[Dumps records to Trafodion.]
|
81
|
+
spec.email = ["alex_peng1986@hotmail.com"]
|
82
|
+
spec.licenses = ["MIT"]
|
83
|
+
spec.homepage = "https://github.com/AlexPeng19/embulk-output-trafodion"
|
84
|
+
|
85
|
+
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
86
|
+
spec.test_files = spec.files.grep(%r"^(test|spec)/")
|
87
|
+
spec.require_paths = ["lib"]
|
88
|
+
|
89
|
+
#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
|
90
|
+
spec.add_development_dependency 'bundler', ['~> 1.0']
|
91
|
+
spec.add_development_dependency 'rake', ['>= 10.0']
|
92
|
+
end
|
93
|
+
/$)
|
94
|
+
}
|
95
|
+
}
|
96
|
+
clean { delete "${project.name}.gemspec" }
|
@@ -0,0 +1,128 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE module PUBLIC
|
3
|
+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
4
|
+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
5
|
+
<module name="Checker">
|
6
|
+
<!-- https://github.com/facebook/presto/blob/master/src/checkstyle/checks.xml -->
|
7
|
+
<module name="FileTabCharacter"/>
|
8
|
+
<module name="NewlineAtEndOfFile">
|
9
|
+
<property name="lineSeparator" value="lf"/>
|
10
|
+
</module>
|
11
|
+
<module name="RegexpMultiline">
|
12
|
+
<property name="format" value="\r"/>
|
13
|
+
<property name="message" value="Line contains carriage return"/>
|
14
|
+
</module>
|
15
|
+
<module name="RegexpMultiline">
|
16
|
+
<property name="format" value=" \n"/>
|
17
|
+
<property name="message" value="Line has trailing whitespace"/>
|
18
|
+
</module>
|
19
|
+
<module name="RegexpMultiline">
|
20
|
+
<property name="format" value="\{\n\n"/>
|
21
|
+
<property name="message" value="Blank line after opening brace"/>
|
22
|
+
</module>
|
23
|
+
<module name="RegexpMultiline">
|
24
|
+
<property name="format" value="\n\n\s*\}"/>
|
25
|
+
<property name="message" value="Blank line before closing brace"/>
|
26
|
+
</module>
|
27
|
+
<module name="RegexpMultiline">
|
28
|
+
<property name="format" value="\n\n\n"/>
|
29
|
+
<property name="message" value="Multiple consecutive blank lines"/>
|
30
|
+
</module>
|
31
|
+
<module name="RegexpMultiline">
|
32
|
+
<property name="format" value="\n\n\Z"/>
|
33
|
+
<property name="message" value="Blank line before end of file"/>
|
34
|
+
</module>
|
35
|
+
<module name="RegexpMultiline">
|
36
|
+
<property name="format" value="Preconditions\.checkNotNull"/>
|
37
|
+
<property name="message" value="Use of checkNotNull"/>
|
38
|
+
</module>
|
39
|
+
|
40
|
+
<module name="TreeWalker">
|
41
|
+
<module name="EmptyBlock">
|
42
|
+
<property name="option" value="text"/>
|
43
|
+
<property name="tokens" value="
|
44
|
+
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
|
45
|
+
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
|
46
|
+
</module>
|
47
|
+
<module name="EmptyStatement"/>
|
48
|
+
<module name="EmptyForInitializerPad"/>
|
49
|
+
<module name="EmptyForIteratorPad">
|
50
|
+
<property name="option" value="space"/>
|
51
|
+
</module>
|
52
|
+
<module name="MethodParamPad">
|
53
|
+
<property name="allowLineBreaks" value="true"/>
|
54
|
+
<property name="option" value="nospace"/>
|
55
|
+
</module>
|
56
|
+
<module name="ParenPad"/>
|
57
|
+
<module name="TypecastParenPad"/>
|
58
|
+
<module name="NeedBraces"/>
|
59
|
+
<module name="LeftCurly">
|
60
|
+
<property name="option" value="nl"/>
|
61
|
+
<property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
|
62
|
+
</module>
|
63
|
+
<module name="LeftCurly">
|
64
|
+
<property name="option" value="eol"/>
|
65
|
+
<property name="tokens" value="
|
66
|
+
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
|
67
|
+
LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
|
68
|
+
</module>
|
69
|
+
<module name="RightCurly">
|
70
|
+
<property name="option" value="alone"/>
|
71
|
+
</module>
|
72
|
+
<module name="GenericWhitespace"/>
|
73
|
+
<module name="WhitespaceAfter"/>
|
74
|
+
<module name="NoWhitespaceBefore"/>
|
75
|
+
|
76
|
+
<module name="UpperEll"/>
|
77
|
+
<module name="DefaultComesLast"/>
|
78
|
+
<module name="ArrayTypeStyle"/>
|
79
|
+
<module name="MultipleVariableDeclarations"/>
|
80
|
+
<module name="ModifierOrder"/>
|
81
|
+
<module name="OneStatementPerLine"/>
|
82
|
+
<module name="StringLiteralEquality"/>
|
83
|
+
<module name="MutableException"/>
|
84
|
+
<module name="EqualsHashCode"/>
|
85
|
+
<module name="InnerAssignment"/>
|
86
|
+
<module name="InterfaceIsType"/>
|
87
|
+
<module name="HideUtilityClassConstructor"/>
|
88
|
+
|
89
|
+
<module name="MemberName"/>
|
90
|
+
<module name="LocalVariableName"/>
|
91
|
+
<module name="LocalFinalVariableName"/>
|
92
|
+
<module name="TypeName"/>
|
93
|
+
<module name="PackageName"/>
|
94
|
+
<module name="ParameterName"/>
|
95
|
+
<module name="StaticVariableName"/>
|
96
|
+
<module name="ClassTypeParameterName">
|
97
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
98
|
+
</module>
|
99
|
+
<module name="MethodTypeParameterName">
|
100
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
101
|
+
</module>
|
102
|
+
|
103
|
+
<module name="AvoidStarImport"/>
|
104
|
+
<module name="RedundantImport"/>
|
105
|
+
<module name="UnusedImports"/>
|
106
|
+
<module name="ImportOrder">
|
107
|
+
<property name="groups" value="*,javax,java"/>
|
108
|
+
<property name="separated" value="true"/>
|
109
|
+
<property name="option" value="bottom"/>
|
110
|
+
<property name="sortStaticImportsAlphabetically" value="true"/>
|
111
|
+
</module>
|
112
|
+
|
113
|
+
<module name="WhitespaceAround">
|
114
|
+
<property name="allowEmptyConstructors" value="true"/>
|
115
|
+
<property name="allowEmptyMethods" value="true"/>
|
116
|
+
<property name="ignoreEnhancedForColon" value="false"/>
|
117
|
+
<property name="tokens" value="
|
118
|
+
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
|
119
|
+
BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
|
120
|
+
LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
121
|
+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
122
|
+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
|
123
|
+
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
|
124
|
+
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
|
125
|
+
STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
|
126
|
+
</module>
|
127
|
+
</module>
|
128
|
+
</module>
|
@@ -0,0 +1,108 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE module PUBLIC
|
3
|
+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
4
|
+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
5
|
+
<!--
|
6
|
+
This is a subset of ./checkstyle.xml which allows some loose styles
|
7
|
+
-->
|
8
|
+
<module name="Checker">
|
9
|
+
<module name="FileTabCharacter"/>
|
10
|
+
<module name="NewlineAtEndOfFile">
|
11
|
+
<property name="lineSeparator" value="lf"/>
|
12
|
+
</module>
|
13
|
+
<module name="RegexpMultiline">
|
14
|
+
<property name="format" value="\r"/>
|
15
|
+
<property name="message" value="Line contains carriage return"/>
|
16
|
+
</module>
|
17
|
+
<module name="RegexpMultiline">
|
18
|
+
<property name="format" value=" \n"/>
|
19
|
+
<property name="message" value="Line has trailing whitespace"/>
|
20
|
+
</module>
|
21
|
+
<module name="RegexpMultiline">
|
22
|
+
<property name="format" value="\n\n\n"/>
|
23
|
+
<property name="message" value="Multiple consecutive blank lines"/>
|
24
|
+
</module>
|
25
|
+
<module name="RegexpMultiline">
|
26
|
+
<property name="format" value="\n\n\Z"/>
|
27
|
+
<property name="message" value="Blank line before end of file"/>
|
28
|
+
</module>
|
29
|
+
|
30
|
+
<module name="TreeWalker">
|
31
|
+
<module name="EmptyBlock">
|
32
|
+
<property name="option" value="text"/>
|
33
|
+
<property name="tokens" value="
|
34
|
+
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
|
35
|
+
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
|
36
|
+
</module>
|
37
|
+
<module name="EmptyStatement"/>
|
38
|
+
<module name="EmptyForInitializerPad"/>
|
39
|
+
<module name="EmptyForIteratorPad">
|
40
|
+
<property name="option" value="space"/>
|
41
|
+
</module>
|
42
|
+
<module name="MethodParamPad">
|
43
|
+
<property name="allowLineBreaks" value="true"/>
|
44
|
+
<property name="option" value="nospace"/>
|
45
|
+
</module>
|
46
|
+
<module name="ParenPad"/>
|
47
|
+
<module name="TypecastParenPad"/>
|
48
|
+
<module name="NeedBraces"/>
|
49
|
+
<module name="LeftCurly">
|
50
|
+
<property name="option" value="nl"/>
|
51
|
+
<property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
|
52
|
+
</module>
|
53
|
+
<module name="LeftCurly">
|
54
|
+
<property name="option" value="eol"/>
|
55
|
+
<property name="tokens" value="
|
56
|
+
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
|
57
|
+
LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
|
58
|
+
</module>
|
59
|
+
<module name="RightCurly">
|
60
|
+
<property name="option" value="alone"/>
|
61
|
+
</module>
|
62
|
+
<module name="GenericWhitespace"/>
|
63
|
+
<module name="WhitespaceAfter"/>
|
64
|
+
<module name="NoWhitespaceBefore"/>
|
65
|
+
|
66
|
+
<module name="UpperEll"/>
|
67
|
+
<module name="DefaultComesLast"/>
|
68
|
+
<module name="ArrayTypeStyle"/>
|
69
|
+
<module name="MultipleVariableDeclarations"/>
|
70
|
+
<module name="ModifierOrder"/>
|
71
|
+
<module name="OneStatementPerLine"/>
|
72
|
+
<module name="StringLiteralEquality"/>
|
73
|
+
<module name="MutableException"/>
|
74
|
+
<module name="EqualsHashCode"/>
|
75
|
+
<module name="InnerAssignment"/>
|
76
|
+
<module name="InterfaceIsType"/>
|
77
|
+
<module name="HideUtilityClassConstructor"/>
|
78
|
+
|
79
|
+
<module name="MemberName"/>
|
80
|
+
<module name="LocalVariableName"/>
|
81
|
+
<module name="LocalFinalVariableName"/>
|
82
|
+
<module name="TypeName"/>
|
83
|
+
<module name="PackageName"/>
|
84
|
+
<module name="ParameterName"/>
|
85
|
+
<module name="StaticVariableName"/>
|
86
|
+
<module name="ClassTypeParameterName">
|
87
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
88
|
+
</module>
|
89
|
+
<module name="MethodTypeParameterName">
|
90
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
91
|
+
</module>
|
92
|
+
|
93
|
+
<module name="WhitespaceAround">
|
94
|
+
<property name="allowEmptyConstructors" value="true"/>
|
95
|
+
<property name="allowEmptyMethods" value="true"/>
|
96
|
+
<property name="ignoreEnhancedForColon" value="false"/>
|
97
|
+
<property name="tokens" value="
|
98
|
+
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
|
99
|
+
BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
|
100
|
+
LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
101
|
+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
102
|
+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
|
103
|
+
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
|
104
|
+
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
|
105
|
+
STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
|
106
|
+
</module>
|
107
|
+
</module>
|
108
|
+
</module>
|
Binary file
|
data/gradlew
ADDED
@@ -0,0 +1,160 @@
|
|
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
|
+
# Attempt to set APP_HOME
|
46
|
+
# Resolve links: $0 may be a link
|
47
|
+
PRG="$0"
|
48
|
+
# Need this for relative symlinks.
|
49
|
+
while [ -h "$PRG" ] ; do
|
50
|
+
ls=`ls -ld "$PRG"`
|
51
|
+
link=`expr "$ls" : '.*-> \(.*\)$'`
|
52
|
+
if expr "$link" : '/.*' > /dev/null; then
|
53
|
+
PRG="$link"
|
54
|
+
else
|
55
|
+
PRG=`dirname "$PRG"`"/$link"
|
56
|
+
fi
|
57
|
+
done
|
58
|
+
SAVED="`pwd`"
|
59
|
+
cd "`dirname \"$PRG\"`/" >/dev/null
|
60
|
+
APP_HOME="`pwd -P`"
|
61
|
+
cd "$SAVED" >/dev/null
|
62
|
+
|
63
|
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
64
|
+
|
65
|
+
# Determine the Java command to use to start the JVM.
|
66
|
+
if [ -n "$JAVA_HOME" ] ; then
|
67
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
68
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
69
|
+
JAVACMD="$JAVA_HOME/jre/sh/java"
|
70
|
+
else
|
71
|
+
JAVACMD="$JAVA_HOME/bin/java"
|
72
|
+
fi
|
73
|
+
if [ ! -x "$JAVACMD" ] ; then
|
74
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
75
|
+
|
76
|
+
Please set the JAVA_HOME variable in your environment to match the
|
77
|
+
location of your Java installation."
|
78
|
+
fi
|
79
|
+
else
|
80
|
+
JAVACMD="java"
|
81
|
+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
82
|
+
|
83
|
+
Please set the JAVA_HOME variable in your environment to match the
|
84
|
+
location of your Java installation."
|
85
|
+
fi
|
86
|
+
|
87
|
+
# Increase the maximum file descriptors if we can.
|
88
|
+
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
89
|
+
MAX_FD_LIMIT=`ulimit -H -n`
|
90
|
+
if [ $? -eq 0 ] ; then
|
91
|
+
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
92
|
+
MAX_FD="$MAX_FD_LIMIT"
|
93
|
+
fi
|
94
|
+
ulimit -n $MAX_FD
|
95
|
+
if [ $? -ne 0 ] ; then
|
96
|
+
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
97
|
+
fi
|
98
|
+
else
|
99
|
+
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
100
|
+
fi
|
101
|
+
fi
|
102
|
+
|
103
|
+
# For Darwin, add options to specify how the application appears in the dock
|
104
|
+
if $darwin; then
|
105
|
+
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
106
|
+
fi
|
107
|
+
|
108
|
+
# For Cygwin, switch paths to Windows format before running java
|
109
|
+
if $cygwin ; then
|
110
|
+
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
111
|
+
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
112
|
+
JAVACMD=`cygpath --unix "$JAVACMD"`
|
113
|
+
|
114
|
+
# We build the pattern for arguments to be converted via cygpath
|
115
|
+
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
116
|
+
SEP=""
|
117
|
+
for dir in $ROOTDIRSRAW ; do
|
118
|
+
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
119
|
+
SEP="|"
|
120
|
+
done
|
121
|
+
OURCYGPATTERN="(^($ROOTDIRS))"
|
122
|
+
# Add a user-defined pattern to the cygpath arguments
|
123
|
+
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
124
|
+
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
125
|
+
fi
|
126
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
127
|
+
i=0
|
128
|
+
for arg in "$@" ; do
|
129
|
+
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
130
|
+
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
131
|
+
|
132
|
+
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
133
|
+
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
134
|
+
else
|
135
|
+
eval `echo args$i`="\"$arg\""
|
136
|
+
fi
|
137
|
+
i=$((i+1))
|
138
|
+
done
|
139
|
+
case $i in
|
140
|
+
(0) set -- ;;
|
141
|
+
(1) set -- "$args0" ;;
|
142
|
+
(2) set -- "$args0" "$args1" ;;
|
143
|
+
(3) set -- "$args0" "$args1" "$args2" ;;
|
144
|
+
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
145
|
+
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
146
|
+
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
147
|
+
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
148
|
+
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
149
|
+
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
150
|
+
esac
|
151
|
+
fi
|
152
|
+
|
153
|
+
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
154
|
+
function splitJvmOpts() {
|
155
|
+
JVM_OPTS=("$@")
|
156
|
+
}
|
157
|
+
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
158
|
+
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
159
|
+
|
160
|
+
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,37 @@
|
|
1
|
+
package org.embulk.output.trafodion;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
import java.sql.Types;
|
5
|
+
import java.sql.SQLException;
|
6
|
+
import com.google.common.base.Optional;
|
7
|
+
import org.embulk.output.jdbc.MergeConfig;
|
8
|
+
import org.embulk.output.jdbc.StandardBatchInsert;
|
9
|
+
|
10
|
+
public class TrafodionBatchInsert
|
11
|
+
extends StandardBatchInsert
|
12
|
+
{
|
13
|
+
public TrafodionBatchInsert(TrafodionOutputConnector connector, Optional<MergeConfig> mergeConfig) throws IOException, SQLException
|
14
|
+
{
|
15
|
+
super(connector, mergeConfig);
|
16
|
+
}
|
17
|
+
|
18
|
+
@Override
|
19
|
+
public void setFloat(float v) throws IOException, SQLException
|
20
|
+
{
|
21
|
+
if (Float.isNaN(v) || Float.isInfinite(v)) {
|
22
|
+
setNull(Types.REAL); // TODO get through argument
|
23
|
+
} else {
|
24
|
+
super.setFloat(v);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
@Override
|
29
|
+
public void setDouble(double v) throws IOException, SQLException
|
30
|
+
{
|
31
|
+
if (Double.isNaN(v) || Double.isInfinite(v)) {
|
32
|
+
setNull(Types.DOUBLE); // TODO get through argument
|
33
|
+
} else {
|
34
|
+
super.setDouble(v);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,222 @@
|
|
1
|
+
package org.embulk.output.trafodion;
|
2
|
+
|
3
|
+
import java.util.List;
|
4
|
+
import java.sql.Connection;
|
5
|
+
import java.sql.SQLException;
|
6
|
+
import java.sql.Statement;
|
7
|
+
|
8
|
+
import org.embulk.output.jdbc.JdbcColumn;
|
9
|
+
import org.embulk.output.jdbc.JdbcSchema;
|
10
|
+
import org.embulk.output.jdbc.JdbcOutputConnection;
|
11
|
+
import org.embulk.output.jdbc.MergeConfig;
|
12
|
+
|
13
|
+
public class TrafodionOutputConnection
|
14
|
+
extends JdbcOutputConnection
|
15
|
+
{
|
16
|
+
public TrafodionOutputConnection(Connection connection, boolean autoCommit)
|
17
|
+
throws SQLException
|
18
|
+
{
|
19
|
+
super(connection,null);
|
20
|
+
setSearchPath("alex");
|
21
|
+
connection.setAutoCommit(autoCommit);
|
22
|
+
}
|
23
|
+
/*@Override
|
24
|
+
public void createTableIfNotExists(String tableName, JdbcSchema schema) throws SQLException
|
25
|
+
{
|
26
|
+
if (!tableExists(tableName)) {
|
27
|
+
createTable(tableName, schema);
|
28
|
+
}
|
29
|
+
}*/
|
30
|
+
@Override
|
31
|
+
protected void setSearchPath(String schema) throws SQLException {
|
32
|
+
Statement stmt = connection.createStatement();
|
33
|
+
try {
|
34
|
+
String sql = "SET SCHEMA " + schema;
|
35
|
+
executeUpdate(stmt, sql);
|
36
|
+
commitIfNecessary(connection);
|
37
|
+
} finally {
|
38
|
+
stmt.close();
|
39
|
+
}
|
40
|
+
}
|
41
|
+
@Override
|
42
|
+
protected String buildPreparedInsertSql(String toTable, JdbcSchema toTableSchema) throws SQLException
|
43
|
+
{
|
44
|
+
StringBuilder sb = new StringBuilder();
|
45
|
+
|
46
|
+
sb.append("UPSERT USING LOAD INTO ");
|
47
|
+
quoteIdentifierString(sb, toTable);
|
48
|
+
|
49
|
+
sb.append(" (");
|
50
|
+
for (int i=0; i < toTableSchema.getCount(); i++) {
|
51
|
+
if(i != 0) { sb.append(", "); }
|
52
|
+
quoteIdentifierString(sb, toTableSchema.getColumnName(i));
|
53
|
+
}
|
54
|
+
sb.append(") VALUES (");
|
55
|
+
for(int i=0; i < toTableSchema.getCount(); i++) {
|
56
|
+
if(i != 0) { sb.append(", "); }
|
57
|
+
sb.append("?");
|
58
|
+
}
|
59
|
+
sb.append(")");
|
60
|
+
|
61
|
+
return sb.toString();
|
62
|
+
}
|
63
|
+
@Override
|
64
|
+
protected String buildCollectInsertSql(List<String> fromTables, JdbcSchema schema, String toTable)
|
65
|
+
{
|
66
|
+
StringBuilder sb = new StringBuilder();
|
67
|
+
|
68
|
+
sb.append("UPSERT USING LOAD INTO ");
|
69
|
+
quoteIdentifierString(sb, toTable);
|
70
|
+
sb.append(" (");
|
71
|
+
for (int i=0; i < schema.getCount(); i++) {
|
72
|
+
if (i != 0) { sb.append(", "); }
|
73
|
+
quoteIdentifierString(sb, schema.getColumnName(i));
|
74
|
+
}
|
75
|
+
sb.append(") ");
|
76
|
+
for (int i=0; i < fromTables.size(); i++) {
|
77
|
+
if (i != 0) { sb.append(" UNION ALL "); }
|
78
|
+
sb.append("SELECT ");
|
79
|
+
for (int j=0; j < schema.getCount(); j++) {
|
80
|
+
if (j != 0) { sb.append(", "); }
|
81
|
+
quoteIdentifierString(sb, schema.getColumnName(j));
|
82
|
+
}
|
83
|
+
sb.append(" FROM ");
|
84
|
+
quoteIdentifierString(sb, fromTables.get(i));
|
85
|
+
}
|
86
|
+
|
87
|
+
return sb.toString();
|
88
|
+
}
|
89
|
+
protected int executeUpdate(Statement stmt, String sql) throws SQLException
|
90
|
+
{
|
91
|
+
System.out.println("SQL: " + sql);
|
92
|
+
long startTime = System.currentTimeMillis();
|
93
|
+
int count = stmt.executeUpdate(sql);
|
94
|
+
double seconds = (System.currentTimeMillis() - startTime) / 1000.0;
|
95
|
+
if (count == 0) {
|
96
|
+
System.out.println(String.format("> %.2f seconds", seconds));
|
97
|
+
} else {
|
98
|
+
System.out.println(String.format("> %.2f seconds (%,d rows)", seconds, count));
|
99
|
+
}
|
100
|
+
return count;
|
101
|
+
}
|
102
|
+
|
103
|
+
/*public void createTable(String tableName, JdbcSchema schema) throws SQLException
|
104
|
+
{
|
105
|
+
Statement stmt = connection.createStatement();
|
106
|
+
try {
|
107
|
+
String sql = buildCreateTableSql(tableName, schema);
|
108
|
+
executeUpdate(stmt, sql);
|
109
|
+
commitIfNecessary(connection);
|
110
|
+
} catch (SQLException ex) {
|
111
|
+
throw safeRollback(connection, ex);
|
112
|
+
} finally {
|
113
|
+
stmt.close();
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
protected String buildCreateTableSql(String name, JdbcSchema schema)
|
118
|
+
{
|
119
|
+
StringBuilder sb = new StringBuilder();
|
120
|
+
|
121
|
+
sb.append("CREATE TABLE ");
|
122
|
+
quoteIdentifierString(sb, name);
|
123
|
+
sb.append(buildCreateTableSchemaSql(schema));
|
124
|
+
return sb.toString();
|
125
|
+
}*/
|
126
|
+
@Override
|
127
|
+
protected String buildPreparedMergeSql(String toTable, JdbcSchema toTableSchema, MergeConfig mergeConfig) throws SQLException
|
128
|
+
{
|
129
|
+
StringBuilder sb = new StringBuilder();
|
130
|
+
|
131
|
+
sb.append("UPSERT USING LOAD INTO ");
|
132
|
+
quoteIdentifierString(sb, toTable);
|
133
|
+
sb.append(" (");
|
134
|
+
for (int i = 0; i < toTableSchema.getCount(); i++) {
|
135
|
+
if(i != 0) { sb.append(", "); }
|
136
|
+
quoteIdentifierString(sb, toTableSchema.getColumnName(i));
|
137
|
+
}
|
138
|
+
sb.append(") VALUES (");
|
139
|
+
for(int i = 0; i < toTableSchema.getCount(); i++) {
|
140
|
+
if(i != 0) { sb.append(", "); }
|
141
|
+
sb.append("?");
|
142
|
+
}
|
143
|
+
sb.append(")");
|
144
|
+
sb.append(" ON DUPLICATE KEY UPDATE ");
|
145
|
+
if (mergeConfig.getMergeRule().isPresent()) {
|
146
|
+
List<String> rule = mergeConfig.getMergeRule().get();
|
147
|
+
for (int i = 0; i < rule.size(); i++) {
|
148
|
+
if (i != 0) {
|
149
|
+
sb.append(", ");
|
150
|
+
}
|
151
|
+
sb.append(rule.get(i));
|
152
|
+
}
|
153
|
+
} else {
|
154
|
+
for (int i = 0; i < toTableSchema.getCount(); i++) {
|
155
|
+
if(i != 0) { sb.append(", "); }
|
156
|
+
String columnName = quoteIdentifierString(toTableSchema.getColumnName(i));
|
157
|
+
sb.append(columnName).append(" = VALUES(").append(columnName).append(")");
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
return sb.toString();
|
162
|
+
}
|
163
|
+
|
164
|
+
@Override
|
165
|
+
protected String buildCollectMergeSql(List<String> fromTables, JdbcSchema schema, String toTable, MergeConfig mergeConfig) throws SQLException
|
166
|
+
{
|
167
|
+
StringBuilder sb = new StringBuilder();
|
168
|
+
|
169
|
+
sb.append("UPSERT USING LOAD INTO ");
|
170
|
+
quoteIdentifierString(sb, toTable);
|
171
|
+
sb.append(" (");
|
172
|
+
for (int i = 0; i < schema.getCount(); i++) {
|
173
|
+
if (i != 0) { sb.append(", "); }
|
174
|
+
quoteIdentifierString(sb, schema.getColumnName(i));
|
175
|
+
}
|
176
|
+
sb.append(") ");
|
177
|
+
for (int i = 0; i < fromTables.size(); i++) {
|
178
|
+
if (i != 0) { sb.append(" UNION ALL "); }
|
179
|
+
sb.append("SELECT ");
|
180
|
+
for (int j = 0; j < schema.getCount(); j++) {
|
181
|
+
if (j != 0) { sb.append(", "); }
|
182
|
+
quoteIdentifierString(sb, schema.getColumnName(j));
|
183
|
+
}
|
184
|
+
sb.append(" FROM ");
|
185
|
+
quoteIdentifierString(sb, fromTables.get(i));
|
186
|
+
}
|
187
|
+
sb.append(" ON DUPLICATE KEY UPDATE ");
|
188
|
+
if (mergeConfig.getMergeRule().isPresent()) {
|
189
|
+
List<String> rule = mergeConfig.getMergeRule().get();
|
190
|
+
for (int i = 0; i < rule.size(); i++) {
|
191
|
+
if (i != 0) {
|
192
|
+
sb.append(", ");
|
193
|
+
}
|
194
|
+
sb.append(rule.get(i));
|
195
|
+
}
|
196
|
+
} else {
|
197
|
+
for (int i = 0; i < schema.getCount(); i++) {
|
198
|
+
if(i != 0) { sb.append(", "); }
|
199
|
+
String columnName = quoteIdentifierString(schema.getColumnName(i));
|
200
|
+
sb.append(columnName).append(" = VALUES(").append(columnName).append(")");
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
return sb.toString();
|
205
|
+
}
|
206
|
+
/*@Override
|
207
|
+
protected String buildPreparedInsertSql(String toTable, JdbcSchema toTableSchema) throws SQLException
|
208
|
+
{
|
209
|
+
String sql = super.buildPreparedInsertSql(toTable, toTableSchema);
|
210
|
+
return sql;
|
211
|
+
}*/
|
212
|
+
@Override
|
213
|
+
protected String buildColumnTypeName(JdbcColumn c)
|
214
|
+
{
|
215
|
+
switch(c.getSimpleTypeName()) {
|
216
|
+
case "CLOB":
|
217
|
+
return "varchar(1000)";
|
218
|
+
default:
|
219
|
+
return super.buildColumnTypeName(c);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
package org.embulk.output.trafodion;
|
2
|
+
|
3
|
+
import java.util.Properties;
|
4
|
+
import java.sql.Driver;
|
5
|
+
import java.sql.Connection;
|
6
|
+
import java.sql.SQLException;
|
7
|
+
import org.embulk.output.jdbc.JdbcOutputConnector;
|
8
|
+
|
9
|
+
public class TrafodionOutputConnector
|
10
|
+
implements JdbcOutputConnector
|
11
|
+
{
|
12
|
+
private final Driver driver;
|
13
|
+
private final String url;
|
14
|
+
private final Properties properties;
|
15
|
+
|
16
|
+
public TrafodionOutputConnector(String url, Properties properties)
|
17
|
+
{
|
18
|
+
this.driver=new org.trafodion.jdbc.t4.T4Driver();
|
19
|
+
this.url = url;
|
20
|
+
this.properties = properties;
|
21
|
+
}
|
22
|
+
|
23
|
+
public TrafodionOutputConnection connect(boolean autoCommit) throws SQLException
|
24
|
+
{
|
25
|
+
Connection c = driver.connect(url, properties);
|
26
|
+
try {
|
27
|
+
TrafodionOutputConnection con = new TrafodionOutputConnection(c,autoCommit);
|
28
|
+
c = null;
|
29
|
+
return con;
|
30
|
+
} finally {
|
31
|
+
if (c != null) {
|
32
|
+
c.close();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,132 @@
|
|
1
|
+
package org.embulk.output.trafodion;
|
2
|
+
import java.io.IOException;
|
3
|
+
import java.sql.SQLException;
|
4
|
+
import java.util.Properties;
|
5
|
+
|
6
|
+
import org.embulk.config.Config;
|
7
|
+
import org.embulk.config.ConfigDefault;
|
8
|
+
import org.embulk.output.jdbc.AbstractJdbcOutputPlugin;
|
9
|
+
import org.embulk.output.jdbc.AbstractJdbcOutputPlugin.Features;
|
10
|
+
import org.embulk.output.jdbc.AbstractJdbcOutputPlugin.PluginTask;
|
11
|
+
import org.embulk.output.jdbc.BatchInsert;
|
12
|
+
import org.embulk.output.jdbc.MergeConfig;
|
13
|
+
|
14
|
+
import com.google.common.base.Optional;
|
15
|
+
|
16
|
+
import org.embulk.output.trafodion.TrafodionOutputPlugin.TrafodionPluginTask;
|
17
|
+
public class TrafodionOutputPlugin
|
18
|
+
extends AbstractJdbcOutputPlugin
|
19
|
+
{
|
20
|
+
public interface TrafodionPluginTask
|
21
|
+
extends PluginTask
|
22
|
+
{
|
23
|
+
@Config("host")
|
24
|
+
public String getHost();
|
25
|
+
|
26
|
+
@Config("port")
|
27
|
+
@ConfigDefault("23400")
|
28
|
+
public int getPort();
|
29
|
+
|
30
|
+
@Config("user")
|
31
|
+
public String getUser();
|
32
|
+
|
33
|
+
@Config("password")
|
34
|
+
@ConfigDefault("\"\"")
|
35
|
+
public String getPassword();
|
36
|
+
|
37
|
+
@Config("database")
|
38
|
+
@ConfigDefault("trafodion")
|
39
|
+
public String getDatabase();
|
40
|
+
|
41
|
+
// @Config("schema")
|
42
|
+
//public String getSchema();
|
43
|
+
|
44
|
+
}
|
45
|
+
|
46
|
+
@Override
|
47
|
+
protected Class<? extends PluginTask> getTaskClass()
|
48
|
+
{
|
49
|
+
return TrafodionPluginTask.class;
|
50
|
+
}
|
51
|
+
|
52
|
+
@Override
|
53
|
+
protected Features getFeatures(PluginTask task)
|
54
|
+
{
|
55
|
+
return new Features()
|
56
|
+
.setMaxTableNameLength(64)
|
57
|
+
.setIgnoreMergeKeys(true);
|
58
|
+
}
|
59
|
+
|
60
|
+
@Override
|
61
|
+
protected TrafodionOutputConnector getConnector(PluginTask task, boolean retryableMetadataOperation)
|
62
|
+
{
|
63
|
+
TrafodionPluginTask trafodionTask = (TrafodionPluginTask) task;
|
64
|
+
|
65
|
+
String url = String.format("jdbc:t4jdbc://%s:%d/:",
|
66
|
+
trafodionTask.getHost(), trafodionTask.getPort());
|
67
|
+
|
68
|
+
Properties props = new Properties();
|
69
|
+
|
70
|
+
props.setProperty("rewriteBatchedStatements", "true");
|
71
|
+
props.setProperty("useCompression", "true");
|
72
|
+
|
73
|
+
props.setProperty("connectTimeout", "300000"); // milliseconds
|
74
|
+
props.setProperty("socketTimeout", "1800000"); // smillieconds
|
75
|
+
|
76
|
+
// Enable keepalive based on tcp_keepalive_time, tcp_keepalive_intvl and tcp_keepalive_probes kernel parameters.
|
77
|
+
// Socket options TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL are not configurable.
|
78
|
+
props.setProperty("tcpKeepAlive", "true");
|
79
|
+
//props.setProperty("schema", trafodionTask.getSchema());
|
80
|
+
// TODO
|
81
|
+
//switch t.getSssl() {
|
82
|
+
//when "disable":
|
83
|
+
// break;
|
84
|
+
//when "enable":
|
85
|
+
// props.setProperty("useSSL", "true");
|
86
|
+
// props.setProperty("requireSSL", "false");
|
87
|
+
// props.setProperty("verifyServerCertificate", "false");
|
88
|
+
// break;
|
89
|
+
//when "verify":
|
90
|
+
// props.setProperty("useSSL", "true");
|
91
|
+
// props.setProperty("requireSSL", "true");
|
92
|
+
// props.setProperty("verifyServerCertificate", "true");
|
93
|
+
// break;
|
94
|
+
//}
|
95
|
+
|
96
|
+
if (!retryableMetadataOperation) {
|
97
|
+
// non-retryable batch operation uses longer timeout
|
98
|
+
props.setProperty("connectTimeout", "300000"); // milliseconds
|
99
|
+
props.setProperty("socketTimeout", "2700000"); // milliseconds
|
100
|
+
}
|
101
|
+
|
102
|
+
props.putAll(trafodionTask.getOptions());
|
103
|
+
|
104
|
+
// TODO validate task.getMergeKeys is null
|
105
|
+
|
106
|
+
props.setProperty("user", trafodionTask.getUser());
|
107
|
+
logger.info("Connecting to {} options {}", url, props);
|
108
|
+
props.setProperty("password", trafodionTask.getPassword());
|
109
|
+
logger.info("url--------:"+url+"props-------:"+props);
|
110
|
+
return new TrafodionOutputConnector(url, props);
|
111
|
+
}
|
112
|
+
|
113
|
+
@Override
|
114
|
+
protected BatchInsert newBatchInsert(PluginTask task, Optional<MergeConfig> mergeConfig) throws IOException, SQLException
|
115
|
+
{
|
116
|
+
return new TrafodionBatchInsert(getConnector(task, true), mergeConfig);
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
@Override
|
121
|
+
protected boolean isRetryableException(String sqlState, int errorCode)
|
122
|
+
{
|
123
|
+
switch (errorCode) {
|
124
|
+
case 1213: // ER_LOCK_DEADLOCK (Message: Deadlock found when trying to get lock; try restarting transaction)
|
125
|
+
return true;
|
126
|
+
case 1205: // ER_LOCK_WAIT_TIMEOUT (Message: Lock wait timeout exceeded; try restarting transaction)
|
127
|
+
return true;
|
128
|
+
default:
|
129
|
+
return false;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
}
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-output-trafodion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Peng
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-31 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: Dumps records to Trafodion.
|
42
|
+
email:
|
43
|
+
- alex_peng1986@hotmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- build.gradle
|
52
|
+
- config/checkstyle/checkstyle.xml
|
53
|
+
- config/checkstyle/default.xml
|
54
|
+
- gradle/wrapper/gradle-wrapper.jar
|
55
|
+
- gradle/wrapper/gradle-wrapper.properties
|
56
|
+
- gradlew
|
57
|
+
- gradlew.bat
|
58
|
+
- lib/embulk/output/trafodion.rb
|
59
|
+
- src/main/java/org/embulk/output/trafodion/TrafodionBatchInsert.java
|
60
|
+
- src/main/java/org/embulk/output/trafodion/TrafodionOutputConnection.java
|
61
|
+
- src/main/java/org/embulk/output/trafodion/TrafodionOutputConnector.java
|
62
|
+
- src/main/java/org/embulk/output/trafodion/TrafodionOutputPlugin.java
|
63
|
+
- src/test/java/org/embulk/output/trafodion/TestTrafodionOutputPlugin.java
|
64
|
+
- classpath/embulk-output-trafodion-0.1.0.jar
|
65
|
+
- classpath/embulk-output-jdbc-0.6.3.jar
|
66
|
+
- classpath/jdbcT4-2.2.0.jar
|
67
|
+
homepage: https://github.com/AlexPeng19/embulk-output-trafodion
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.1.9
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Trafodion output plugin for Embulk
|
91
|
+
test_files: []
|