embulk-output-dynamodb 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0c86de91e5c36f167f01b9a3d9510eed81d58527
4
+ data.tar.gz: 01ca2686938850340d6d6aeb166aa78833ea2603
5
+ SHA512:
6
+ metadata.gz: 3f3b54201891fb212456b7403dd45bb6a2c7037bb592b67bdba8d51cbf9dacf0097d9e27f8b08c6a4b8280e061f9e981e2c82b97870072b339aaab24b8ed03c2
7
+ data.tar.gz: 3ff9b88e413a761ff8be4e40abab6c3418a0443fcfb2dedd09e9100b640c03990c5a1dcee82db220d3dc4410a69f2fc3a619873f3606c678eb882f73cf2e7730
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ target/
2
+ build/
3
+ pkg/
4
+ *.iml
5
+ *~
6
+ ._*
7
+ .idea
8
+ tmp/
9
+ vendor/
10
+ /classpath/
11
+ /.bundle
12
+ .yardoc
13
+ /embulk-*.jar
14
+ /.gradle
data/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ ## 0.1.0 - 2016-05-13
data/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # AWS DynamoDB output plugin for Embulk
2
+
3
+ [Embulk](http://www.embulk.org/) output plugin to load/insert data into [AWS DynamoDB](http://aws.amazon.com/dynamodb/)
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: output
8
+ * **Load all or nothing**: no
9
+ * **Resume supported**: no
10
+ * **Cleanup supported**: no
11
+
12
+ ## Configuration
13
+
14
+ ### General Parameters
15
+
16
+ - **mode** (string optional, default:upsert)
17
+ - **upsert**
18
+
19
+ Creates a new item, or replaces an old item with a new item.
20
+ If an item that has the same primary key as the new item already exists in the specified table, the new item completely replaces the existing item.
21
+ This mode uses [BatchWriteItem](http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html) and you can set `max_put_items` parameter.
22
+
23
+ - **upsert_with_expression**
24
+
25
+ Edits an existing item's attributes, or adds a new item to the table if it does not already exist.
26
+ If you have data with following schema, you can set `update_expression` as follows.
27
+ ```
28
+ - col1(Number primaryKey)
29
+ - col2(Number)
30
+ - col3(String)
31
+ - col4(Number)
32
+ - col5(String)
33
+ ```
34
+
35
+ ```yaml
36
+ mode: upsert_with_expression
37
+ # update where col1 has #col1
38
+ update_expression: "add #col2 :col2 set #col3 = :col3 set #col4 = #col4 - :col4 remove #col5"
39
+ ```
40
+
41
+ - **region** (string required) Region of Amazon DynamoDB
42
+ - **auto_create_table** (boolean optional, default: false) [See below]()
43
+ - **table** (string required) Table name of Amazon DynamoDB
44
+
45
+ table and option accept [Time#strftime](http://ruby-doc.org/core-2.2.3/Time.html#method-i-strftime) format to construct table name.
46
+ Table name is formatted at runtime using the local time of the embulk server.
47
+
48
+ For example, with the configuration below, data is inserted into tables table_2015_04, table_2015_05 and so on.
49
+ ```
50
+ out:
51
+ type: dynamodb
52
+ table: table_%Y_%m
53
+ ```
54
+ - **write_capacity_units** (int optional) Provisioned write capacity units
55
+ - **normal** (int optional) value that will be set after execution
56
+ - **raise** (int optional) value that will be set before execution
57
+ - **read_capacity_units** (int optional) Provisioned read capacity units
58
+ - **normal** (int optional) value that will be set after execution
59
+ - **raise** (int optional) value that will be set before execution
60
+
61
+ - Up to 30 before execution and down to 5 after execution.
62
+ ```yaml
63
+ write_capacity_units:
64
+ normal: 5
65
+ raise: 30
66
+ ```
67
+
68
+ - Up to 30 before execution
69
+ ```yaml
70
+ write_capacity_units:
71
+ raise: 30
72
+ ```
73
+
74
+ - Down to 5 after execution
75
+ ```yaml
76
+ write_capacity_units:
77
+ normal: 5
78
+ ```
79
+
80
+ **NOTICE**: You can decrease the read_capacity_units or write_capacity_units settings for a table, but no more than [4 times per table in a single UTC calendar day](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html#d0e53216).
81
+
82
+ - **max_put_items** (int optional, default:25)
83
+ Max put items at every batch writing requests when `upsert mode`.
84
+ A single call to [BatchWriteItem](http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html) can write up to 16 MB of data, which can comprise as many as 25 put requests.
85
+ If you have exceeded data, decrease this value.
86
+
87
+ ### Authentication Parameters
88
+
89
+ 6 authentication methods are supported.
90
+
91
+ - **basic**
92
+
93
+ Use access_key_id and secret_access_key
94
+
95
+ ```yaml
96
+ auth_method: basic
97
+ access_key_id: YOUR_ACCESS_KEY_ID
98
+ secret_access_key: YOUR_SECRET_ACCESS_KEY
99
+ ```
100
+
101
+ - **access_key_id**: AWS access key ID (string, required)
102
+
103
+ - **secret_access_key**: AWS secret access key (string, required)
104
+
105
+ - **env**
106
+
107
+ Read AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY) from environment variables.
108
+
109
+ ```yaml
110
+ auth_method: env
111
+ ```
112
+
113
+ - **instance**
114
+
115
+ Use EC2 instance profile
116
+
117
+ ```yaml
118
+ auth_method: instance
119
+ ```
120
+
121
+ - **profile**
122
+
123
+ Read credentials from file. Format of the file is as following, where `[...]` is a name of profile.
124
+
125
+ ```yaml
126
+ auth_method: profile
127
+ profile_file: /path/to/profilefile
128
+ profile_name: PROFILE_NAME
129
+ ```
130
+
131
+ - **profile_file**: path to a profiles file. (string, default: given by AWS_CREDENTIAL_PROFILES_FILE environment varialbe, or ~/.aws/credentials).
132
+
133
+ - **profile_name**: name of a profile. (string, default: `"default"`)
134
+
135
+ ```
136
+ [default]
137
+ aws_access_key_id=YOUR_ACCESS_KEY_ID
138
+ aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
139
+
140
+ [profile2]
141
+ ...
142
+ ```
143
+
144
+ - **properties**
145
+
146
+ Read aws.accessKeyId and aws.secretKey from Java system properties
147
+
148
+ ```yaml
149
+ auth_method: properties
150
+ ```
151
+
152
+ - **session**
153
+
154
+ Use temporary-generated access_key_id, secret_access_key and session_token.
155
+
156
+ ```yaml
157
+ auth_method: session
158
+ access_key_id: YOUR_ACCESS_KEY_ID
159
+ secret_access_key: YOUR_SECRET_ACCESS_KEY
160
+ session_token: SESSION_TOKEN
161
+ ```
162
+
163
+ - **access_key_id**: AWS access key ID (string, required)
164
+
165
+ - **secret_access_key**: AWS secret access key (string, required)
166
+
167
+ - **session_token**: session token (string, required)
168
+
169
+ ## Example
170
+
171
+ ```yaml
172
+ out:
173
+ type: dynamodb
174
+ mode: upsert
175
+ region: us-west-2
176
+ auth_method: basic
177
+ access_key_id: ABCXYZ123ABCXYZ123
178
+ secret_access_key: ABCXYZ123ABCXYZ123
179
+ auto_create_table: true
180
+ table: dynamotable
181
+ write_capacity_units:
182
+ normal: 5
183
+ raise: 20
184
+ read_capacity_units:
185
+ normal: 6
186
+ raise: 30
187
+ ```
188
+
189
+
190
+ ## Build
191
+
192
+ ```
193
+ $ ./gradlew gem # -t to watch change of files and rebuild continuously
194
+ ```
195
+
196
+ ## Test
197
+
198
+ ```
199
+ $ ./gradlew test # -t to watch change of files and rebuild continuously
200
+ ```
201
+
202
+ To run unit tests, you need to setup DynamoDB on your local environment.
203
+ Please reference the documentation [Running DynamoDB on Your Computer](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html) on AWS Developer Guide.
204
+ ```
205
+ $ mkdir /path/to/dynamodb
206
+ $ cd /path/to/dynamodb
207
+ $ wget http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest.tar.gz
208
+ $ tar zxvf dynamodb_local_latest.tar.gz
209
+ $ java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
210
+ ```
data/build.gradle ADDED
@@ -0,0 +1,92 @@
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 "jacoco"
6
+ id "checkstyle"
7
+ }
8
+ import com.github.jrubygradle.JRubyExec
9
+ repositories {
10
+ mavenCentral()
11
+ jcenter()
12
+ }
13
+ configurations {
14
+ provided
15
+ }
16
+
17
+ version = "0.1.0"
18
+
19
+ sourceCompatibility = 1.7
20
+ targetCompatibility = 1.7
21
+
22
+ dependencies {
23
+ compile "org.embulk:embulk-core:0.8.8"
24
+ provided "org.embulk:embulk-core:0.8.8"
25
+ compile "com.amazonaws:aws-java-sdk-dynamodb:1.10.50"
26
+
27
+ testCompile "junit:junit:4.+"
28
+ testCompile "org.embulk:embulk-core:0.8.8:tests"
29
+ testCompile "org.embulk:embulk-standards:0.8.8"
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
+ checkstyle {
40
+ configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
41
+ toolVersion = '6.14.1'
42
+ }
43
+ checkstyleMain {
44
+ configFile = file("${project.rootDir}/config/checkstyle/default.xml")
45
+ ignoreFailures = true
46
+ }
47
+ checkstyleTest {
48
+ configFile = file("${project.rootDir}/config/checkstyle/default.xml")
49
+ ignoreFailures = true
50
+ }
51
+ task checkstyle(type: Checkstyle) {
52
+ classpath = sourceSets.main.output + sourceSets.test.output
53
+ source = sourceSets.main.allJava + sourceSets.test.allJava
54
+ }
55
+
56
+ task gem(type: JRubyExec, dependsOn: ["assemble", "gemspec", "classpath"]) {
57
+ jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
58
+ script "build/gemspec"
59
+ doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
60
+ }
61
+
62
+ task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
63
+ jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "push"
64
+ script "pkg/${project.name}-${project.version}.gem"
65
+ }
66
+
67
+ task "package"(dependsOn: ["gemspec", "classpath"]) << {
68
+ println "> Build succeeded."
69
+ println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
70
+ }
71
+
72
+ task gemspec << { file("build/gemspec").write($/
73
+ Gem::Specification.new do |spec|
74
+ spec.name = "${project.name}"
75
+ spec.version = "${project.version}"
76
+ spec.authors = ["Satoshi Akama"]
77
+ spec.summary = %[AWS DynamoDB output plugin for Embulk]
78
+ spec.description = %[Dumps records to AWS DynamoDB.]
79
+ spec.email = ["satoshiakama@gmail.com"]
80
+ spec.licenses = ["Apache-2.0"]
81
+ # TODO set this: spec.homepage = "https://github.com/sakama/embulk-output-dynamodb"
82
+
83
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
84
+ spec.test_files = spec.files.grep(%r"^(test|spec)/")
85
+ spec.require_paths = ["lib"]
86
+
87
+ spec.add_development_dependency 'bundler', ['~> 1.0']
88
+ spec.add_development_dependency 'rake', ['>= 10.0']
89
+ end
90
+ /$)
91
+ }
92
+ clean { delete "${project.name}.gemspec" }
@@ -0,0 +1,130 @@
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
+ <property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
97
+ </module>
98
+ <module name="ClassTypeParameterName">
99
+ <property name="format" value="^[A-Z][0-9]?$"/>
100
+ </module>
101
+ <module name="MethodTypeParameterName">
102
+ <property name="format" value="^[A-Z][0-9]?$"/>
103
+ </module>
104
+
105
+ <module name="AvoidStarImport"/>
106
+ <module name="RedundantImport"/>
107
+ <module name="UnusedImports"/>
108
+ <module name="ImportOrder">
109
+ <property name="groups" value="*,javax,java"/>
110
+ <property name="separated" value="true"/>
111
+ <property name="option" value="bottom"/>
112
+ <property name="sortStaticImportsAlphabetically" value="true"/>
113
+ </module>
114
+
115
+ <module name="WhitespaceAround">
116
+ <property name="allowEmptyConstructors" value="true"/>
117
+ <property name="allowEmptyMethods" value="true"/>
118
+ <property name="ignoreEnhancedForColon" value="false"/>
119
+ <property name="tokens" value="
120
+ ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
121
+ BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
122
+ LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
123
+ LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
124
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
125
+ LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
126
+ PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
127
+ STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
128
+ </module>
129
+ </module>
130
+ </module>