embulk-output-dynamodb 0.1.3 → 0.1.5

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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -1
  3. data/README.md +2 -2
  4. data/build.gradle +2 -2
  5. data/classpath/aws-java-sdk-core-1.11.16.jar +0 -0
  6. data/classpath/aws-java-sdk-dynamodb-1.11.16.jar +0 -0
  7. data/classpath/aws-java-sdk-kms-1.11.16.jar +0 -0
  8. data/classpath/aws-java-sdk-s3-1.11.16.jar +0 -0
  9. data/classpath/commons-codec-1.9.jar +0 -0
  10. data/classpath/commons-logging-1.2.jar +0 -0
  11. data/classpath/embulk-output-dynamodb-0.1.5.jar +0 -0
  12. data/classpath/httpclient-4.5.2.jar +0 -0
  13. data/classpath/httpcore-4.4.4.jar +0 -0
  14. data/classpath/jackson-annotations-2.6.0.jar +0 -0
  15. data/classpath/jackson-core-2.6.6.jar +0 -0
  16. data/classpath/jackson-databind-2.6.6.jar +0 -0
  17. data/classpath/jackson-dataformat-cbor-2.6.6.jar +0 -0
  18. data/gradle/wrapper/gradle-wrapper.jar +0 -0
  19. data/gradle/wrapper/gradle-wrapper.properties +2 -2
  20. data/gradlew.bat +90 -90
  21. data/src/main/java/org/embulk/output/dynamodb/AwsCredentials.java +2 -2
  22. data/src/main/java/org/embulk/output/dynamodb/DynamodbOutputPlugin.java +3 -3
  23. data/src/main/java/org/embulk/output/dynamodb/DynamodbUtils.java +42 -7
  24. metadata +15 -11
  25. data/classpath/aws-java-sdk-core-1.10.50.jar +0 -0
  26. data/classpath/aws-java-sdk-dynamodb-1.10.50.jar +0 -0
  27. data/classpath/aws-java-sdk-kms-1.10.50.jar +0 -0
  28. data/classpath/aws-java-sdk-s3-1.10.50.jar +0 -0
  29. data/classpath/commons-codec-1.6.jar +0 -0
  30. data/classpath/commons-logging-1.1.3.jar +0 -0
  31. data/classpath/embulk-output-dynamodb-0.1.3.jar +0 -0
  32. data/classpath/httpclient-4.3.6.jar +0 -0
  33. data/classpath/httpcore-4.3.3.jar +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65c351383c9859353bc121a5f054b63de4876773
4
- data.tar.gz: e171f2369c6582ef90c8fb7d4a6acc0a0300061b
3
+ metadata.gz: 82cba589f5f74209f19cff43e295c2c6fb48fb20
4
+ data.tar.gz: b0645e814a4937376ac7f9a10b06f29cf4b5873f
5
5
  SHA512:
6
- metadata.gz: 862214066e48cb94be626d68b9a014dcdccf1a4a74f1808e4ff87b43beef2115f55b0d5547aa8d3460404bf85856ab9ed64488190bf1dbdde71ce7f44c07dd47
7
- data.tar.gz: 8466fe13984980117b6a7bba30efbafca953ad8011758fcfd4b6a0eb6589efc45389051ed2de2e7c2eeb11342a5abf2e5be9b9c82a188d28f28652c5b7b5e5c6
6
+ metadata.gz: 25b60a3454c49cb41e10a633ff55b7dc80637d35766a69d56994a29541e06283a47b310e99240ef02b30f7b376c0a7cefface78ed20b29b52601dc05e796d575
7
+ data.tar.gz: af0c6c9e88343be88c1c010e48d197f3f7c1f41c269754ebc2615e0611bced90694149ea2ae67810d99c7606c115ee3517c9669868f4b28c4a8f446997f5b3dc
data/CHANGELOG.md CHANGED
@@ -1 +1,27 @@
1
- ## 0.1.3 - 2016-07-11
1
+ ## 0.1.5 - 2022-11-09
2
+
3
+ [new feature] Support both ECS task role and EC2 instance profile in auth_method 'instance' [#12](https://github.com/sakama/embulk-output-dynamodb/pull/12) @grass-fed thanks!
4
+
5
+ ## 0.1.4 - 2017-06-21
6
+
7
+ [new feature] HashKey/RangeKey table support at upsert_with_expression mode [#9](https://github.com/sakama/embulk-output-dynamodb/pull/9) @takasick thanks!
8
+
9
+ ## 0.1.3 - 2016-07-11
10
+
11
+ [maintenance] Fix JSON column handling(Array type) [#7](https://github.com/sakama/embulk-output-dynamodb/pull/7) @joker1007 thanks!
12
+ [maintenance] Add validation for auto_create_table option [#8](https://github.com/sakama/embulk-output-dynamodb/pull/8)
13
+
14
+ ## 0.1.2 - 2016-05-24
15
+
16
+ [maintenance] Small fix
17
+
18
+ ## 0.1.1 - 2016-05-16
19
+
20
+ [maintenance] Check if table exists before creating table [#5](https://github.com/sakama/embulk-output-dynamodb/pull/5)
21
+
22
+ ## 0.1.0 - 2016-05-13
23
+
24
+ Thanks for contribution!
25
+
26
+ @joker1007 [#1](https://github.com/sakama/embulk-output-dynamodb/pull/1) [#2](https://github.com/sakama/embulk-output-dynamodb/pull/2)
27
+ @satoshihirose [#3](https://github.com/sakama/embulk-output-dynamodb/pull/3)
data/README.md CHANGED
@@ -115,7 +115,7 @@
115
115
 
116
116
  - **instance**
117
117
 
118
- Use EC2 instance profile
118
+ Use ECS task role or EC2 instance profile.
119
119
 
120
120
  ```yaml
121
121
  auth_method: instance
@@ -212,4 +212,4 @@ $ cd /path/to/dynamodb
212
212
  $ wget http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest.tar.gz
213
213
  $ tar zxvf dynamodb_local_latest.tar.gz
214
214
  $ java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
215
- ```
215
+ ```
data/build.gradle CHANGED
@@ -14,7 +14,7 @@ configurations {
14
14
  provided
15
15
  }
16
16
 
17
- version = "0.1.3"
17
+ version = "0.1.5"
18
18
 
19
19
  sourceCompatibility = 1.7
20
20
  targetCompatibility = 1.7
@@ -22,7 +22,7 @@ targetCompatibility = 1.7
22
22
  dependencies {
23
23
  compile "org.embulk:embulk-core:0.8.8"
24
24
  provided "org.embulk:embulk-core:0.8.8"
25
- compile "com.amazonaws:aws-java-sdk-dynamodb:1.10.50"
25
+ compile "com.amazonaws:aws-java-sdk-dynamodb:1.11.16"
26
26
 
27
27
  testCompile "junit:junit:4.+"
28
28
  testCompile "org.embulk:embulk-core:0.8.8:tests"
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,6 +1,6 @@
1
- #Wed Jan 13 12:41:02 JST 2016
1
+ #Sun Jan 08 00:35:58 PST 2017
2
2
  distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip
data/gradlew.bat CHANGED
@@ -1,90 +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
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
@@ -7,8 +7,8 @@ import com.amazonaws.auth.AWSSessionCredentialsProvider;
7
7
  import com.amazonaws.auth.AnonymousAWSCredentials;
8
8
  import com.amazonaws.auth.BasicAWSCredentials;
9
9
  import com.amazonaws.auth.BasicSessionCredentials;
10
+ import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper;
10
11
  import com.amazonaws.auth.EnvironmentVariableCredentialsProvider;
11
- import com.amazonaws.auth.InstanceProfileCredentialsProvider;
12
12
  import com.amazonaws.auth.SystemPropertiesCredentialsProvider;
13
13
  import com.amazonaws.auth.profile.ProfileCredentialsProvider;
14
14
  import com.amazonaws.auth.profile.ProfilesConfigFile;
@@ -85,7 +85,7 @@ public abstract class AwsCredentials
85
85
  reject(task.getSessionToken(), "session_token");
86
86
  reject(task.getProfileFile(), "profile_file");
87
87
  reject(task.getProfileName(), "profile_name");
88
- return new InstanceProfileCredentialsProvider();
88
+ return new EC2ContainerCredentialsProviderWrapper();
89
89
 
90
90
  case "profile":
91
91
  {
@@ -199,7 +199,7 @@ public class DynamodbOutputPlugin
199
199
  private final String table;
200
200
  private final Mode mode;
201
201
  private final Optional<String> updateExpression;
202
- private final String primaryKey;
202
+ private final List primaryKeyElements;
203
203
  private final int maxPutItems;
204
204
 
205
205
  public DynamodbPageOutput(PluginTask task, DynamoDB dynamoDB)
@@ -210,7 +210,7 @@ public class DynamodbOutputPlugin
210
210
  this.table = task.getTable();
211
211
  this.mode = task.getMode();
212
212
  this.updateExpression = task.getUpdateExpression();
213
- this.primaryKey = (mode.equals(Mode.UPSERT_WITH_EXPRESSION)) ? dynamodbUtils.getPrimaryKeyName(dynamoDB, table) : null;
213
+ this.primaryKeyElements = (mode.equals(Mode.UPSERT_WITH_EXPRESSION)) ? dynamodbUtils.getPrimaryKey(dynamoDB, table) : null;
214
214
  this.maxPutItems = task.getMaxPutItems();
215
215
  }
216
216
 
@@ -400,7 +400,7 @@ public class DynamodbOutputPlugin
400
400
  public void updateItem(Item item)
401
401
  {
402
402
  try {
403
- dynamodbUtils.updateItem(dynamoDB, table, item, primaryKey, updateExpression);
403
+ dynamodbUtils.updateItem(dynamoDB, table, item, primaryKeyElements, updateExpression);
404
404
  totalWroteItemSize++;
405
405
  if (totalWroteItemSize % 1000 == 0) {
406
406
  log.info(String.format("Updated %s items", totalWroteItemSize));
@@ -143,17 +143,34 @@ public class DynamodbUtils
143
143
  }
144
144
  }
145
145
 
146
- protected void updateItem(DynamoDB dynamoDB, String tableName, Item item, String primaryKey, Optional<String> expression)
146
+ protected void updateItem(DynamoDB dynamoDB, String tableName, Item item, List primaryKeyelements, Optional<String> expression)
147
147
  {
148
- Object primaryKeyValue = null;
148
+ String hashKeyname = null;
149
+ String rangeKeyname = null;
150
+ Object hashKeyValue = null;
151
+ Object rangeKeyValue = null;
149
152
  Map<String, String> attributeNames = new HashMap<>();
150
153
  Map<String, Object> attributeValues = new HashMap<>();
151
154
 
155
+ Iterator it = primaryKeyelements.iterator();
156
+ while (it.hasNext()) {
157
+ KeySchemaElement element = (KeySchemaElement) it.next();
158
+ if (element.getKeyType().equals(KeyType.HASH.toString())) {
159
+ hashKeyname = element.getAttributeName();
160
+ }
161
+ else if (element.getKeyType().equals(KeyType.RANGE.toString())) {
162
+ rangeKeyname = element.getAttributeName();
163
+ }
164
+ }
165
+
152
166
  Map<String, Object> itemMap = item.asMap();
153
167
  for (Map.Entry<String, Object> e : itemMap.entrySet()) {
154
168
  String keyName = e.getKey();
155
- if (keyName.equals(primaryKey)) {
156
- primaryKeyValue = e.getValue();
169
+ if (keyName.equals(hashKeyname)) {
170
+ hashKeyValue = e.getValue();
171
+ }
172
+ else if (keyName.equals(rangeKeyname)) {
173
+ rangeKeyValue = e.getValue();
157
174
  }
158
175
  else {
159
176
  if (expression.get().indexOf(keyName) > 0) {
@@ -164,9 +181,17 @@ public class DynamodbUtils
164
181
  }
165
182
  log.debug("attribute names: " + attributeNames.toString());
166
183
  log.debug("attribute values: " + attributeValues.toString());
167
- log.debug(String.format("primary key %s:%s", primaryKey, primaryKeyValue));
184
+
168
185
  Table table = dynamoDB.getTable(tableName);
169
- table.updateItem(primaryKey, primaryKeyValue, expression.get(), attributeNames, attributeValues);
186
+
187
+ log.debug(String.format("hash key %s:%s", hashKeyname, hashKeyValue));
188
+ if (rangeKeyValue == null) {
189
+ table.updateItem(hashKeyname, hashKeyValue, expression.get(), attributeNames, attributeValues);
190
+ }
191
+ else {
192
+ log.debug(String.format("range key %s:%s", rangeKeyname, rangeKeyValue));
193
+ table.updateItem(hashKeyname, hashKeyValue, rangeKeyname, rangeKeyValue, expression.get(), attributeNames, attributeValues);
194
+ }
170
195
  }
171
196
 
172
197
  protected String getPrimaryKeyName(DynamoDB dynamoDB, String tableName)
@@ -178,11 +203,21 @@ public class DynamodbUtils
178
203
  String primaryKey = null;
179
204
  while (schema.hasNext()) {
180
205
  KeySchemaElement element = schema.next();
181
- primaryKey = element.getAttributeName();
206
+ if (element.getKeyType().equals(KeyType.HASH.toString())) {
207
+ primaryKey = element.getAttributeName();
208
+ }
182
209
  }
183
210
  return primaryKey;
184
211
  }
185
212
 
213
+ protected List getPrimaryKey(DynamoDB dynamoDB, String tableName)
214
+ {
215
+ Table table = dynamoDB.getTable(tableName);
216
+ TableDescription description = table.describe();
217
+ List<KeySchemaElement> keyelements = description.getKeySchema();
218
+ return keyelements;
219
+ }
220
+
186
221
  protected void createTable(DynamoDB dynamoDB, DynamodbOutputPlugin.PluginTask task)
187
222
  throws InterruptedException
188
223
  {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-dynamodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Akama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2022-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -65,15 +65,19 @@ files:
65
65
  - src/test/java/org/embulk/output/dynamodb/TestDynamodbOutputPlugin.java
66
66
  - src/test/java/org/embulk/output/dynamodb/TestDynamodbUtils.java
67
67
  - src/test/resources/sample_01.csv
68
- - classpath/aws-java-sdk-core-1.10.50.jar
69
- - classpath/aws-java-sdk-dynamodb-1.10.50.jar
70
- - classpath/aws-java-sdk-kms-1.10.50.jar
71
- - classpath/aws-java-sdk-s3-1.10.50.jar
72
- - classpath/commons-codec-1.6.jar
73
- - classpath/commons-logging-1.1.3.jar
74
- - classpath/embulk-output-dynamodb-0.1.3.jar
75
- - classpath/httpclient-4.3.6.jar
76
- - classpath/httpcore-4.3.3.jar
68
+ - classpath/commons-logging-1.2.jar
69
+ - classpath/aws-java-sdk-s3-1.11.16.jar
70
+ - classpath/embulk-output-dynamodb-0.1.5.jar
71
+ - classpath/aws-java-sdk-dynamodb-1.11.16.jar
72
+ - classpath/jackson-databind-2.6.6.jar
73
+ - classpath/jackson-core-2.6.6.jar
74
+ - classpath/httpclient-4.5.2.jar
75
+ - classpath/commons-codec-1.9.jar
76
+ - classpath/aws-java-sdk-core-1.11.16.jar
77
+ - classpath/aws-java-sdk-kms-1.11.16.jar
78
+ - classpath/jackson-dataformat-cbor-2.6.6.jar
79
+ - classpath/httpcore-4.4.4.jar
80
+ - classpath/jackson-annotations-2.6.0.jar
77
81
  homepage: https://github.com/sakama/embulk-output-dynamodb
78
82
  licenses:
79
83
  - Apache-2.0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file