Skip to content
This repository was archived by the owner on Jun 18, 2020. It is now read-only.

Commit bbcaf78

Browse files
author
Alexander Patrikalakis
committed
moved classes into different packages. upgraded SDK. tested table create request factory
1 parent ba3c751 commit bbcaf78

31 files changed

+676
-305
lines changed

README.md

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,31 @@ The CLI's usage follows with required parameters marked by asterisks.
1717
Use this flag to use strongly consistent scan. If the flag is not used
1818
it will default to eventually consistent scan
1919
Default: false
20-
--createDestination
21-
Create destination table if it does not exist
22-
Default: false
2320
--copyStreamSpecificationWhenCreating
2421
Use the source table stream specification for the destination table
2522
during its creation.
2623
Default: false
24+
--createAllGsi
25+
Create all GSI in destination table
26+
Default: false
27+
--createAllLsi
28+
Create all LSI in destination table
29+
Default: false
30+
--createDestination
31+
Create destination table if it does not exist
32+
Default: false
2733
--destinationEndpoint
2834
Endpoint of the destination table
29-
* --destinationRegion
35+
* --destinationSigningRegion
3036
Signing region for the destination endpoint
3137
* --destinationTable
3238
Name of the destination table
3339
--help
3440
Display usage information
41+
--includeGsi
42+
Include the following GSI in the destination table
43+
--includeLsi
44+
Include the following LSI in the destination table
3545
--maxWriteThreads
3646
Number of max threads to write to destination table
3747
Default: 1024
@@ -44,7 +54,7 @@ The CLI's usage follows with required parameters marked by asterisks.
4454
Default: 0
4555
--sourceEndpoint
4656
Endpoint of the source table
47-
* --sourceRegion
57+
* --sourceSigningRegion
4858
Signing region for the source endpoint
4959
* --sourceTable
5060
Name of the source table
@@ -87,8 +97,8 @@ To transfer to a different region, create two AmazonDynamoDBClients
8797
with different endpoints to pass into the DynamoDBBootstrapWorker and the DynamoDBConsumer.
8898
8999
```java
90-
import com.amazonaws.dynamodb.bootstrap.DynamoDBBootstrapWorker;
91-
import com.amazonaws.dynamodb.bootstrap.DynamoDBConsumer;
100+
import DynamoDBBootstrapWorker;
101+
import com.amazonaws.dynamodb.bootstrap.consumer.DynamoDBConsumer;
92102
import com.amazonaws.dynamodb.bootstrap.exception.NullReadCapacityException;
93103
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
94104
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
@@ -98,28 +108,22 @@ import java.util.concurrent.Executors;
98108
99109
class TransferDataFromOneTableToAnother {
100110
public static void main(String[] args) {
101-
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
111+
final AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
102112
.withRegion(com.amazonaws.regions.Regions.US_WEST_1).build();
103-
DynamoDBBootstrapWorker worker = null;
104113
try {
105114
// 100.0 read operations per second. 4 threads to scan the table.
106-
worker = new DynamoDBBootstrapWorker(client,
115+
final DynamoDBBootstrapWorker worker = new DynamoDBBootstrapWorker(client,
107116
100.0, "mySourceTable", 4);
117+
// 50.0 write operations per second. 8 threads to scan the table.
118+
final DynamoDBConsumer consumer = new DynamoDBConsumer(client, "myDestinationTable",
119+
50.0, Executors.newFixedThreadPool(8));
120+
worker.pipe(consumer);
108121
} catch (NullReadCapacityException e) {
109122
System.err.println("The DynamoDB source table returned a null read capacity.");
110123
System.exit(1);
111-
}
112-
// 50.0 write operations per second. 8 threads to scan the table.
113-
DynamoDBConsumer consumer = new DynamoDBConsumer(client, "myDestinationTable", 50.0,
114-
Executors.newFixedThreadPool(8));
115-
try {
116-
worker.pipe(consumer);
117-
} catch (ExecutionException e) {
124+
} catch (ExecutionException | InterruptedException e) {
118125
System.err.println("Encountered exception when executing transfer: " + e.getMessage());
119126
System.exit(1);
120-
} catch (InterruptedException e){
121-
System.err.println("Interrupted when executing transfer: " + e.getMessage());
122-
System.exit(1);
123127
}
124128
}
125129
}
@@ -128,13 +132,15 @@ class TransferDataFromOneTableToAnother {
128132
129133
### 2. Transfer Data From one DynamoDB Table to a Blocking Queue.
130134
131-
The below example will read from a DynamoDB table and export to an array blocking queue. This is useful for when another application would like to consume
132-
the DynamoDB entries but does not have a setup application for it. They can just retrieve the queue (consumer.getQueue()) and then continually pop() from it
135+
The below example will read from a DynamoDB table and export to an array blocking queue.
136+
This is useful for when another application would like to consume
137+
the DynamoDB entries but does not have a setup application for it.
138+
They can just retrieve the queue (consumer.getQueue()) and then continually pop() from it
133139
to then process the new entries.
134140
135141
```java
136-
import com.amazonaws.dynamodb.bootstrap.BlockingQueueConsumer;
137-
import com.amazonaws.dynamodb.bootstrap.DynamoDBBootstrapWorker;
142+
import com.amazonaws.dynamodb.bootstrap.consumer.BlockingQueueConsumer;
143+
import DynamoDBBootstrapWorker;
138144
import com.amazonaws.dynamodb.bootstrap.exception.NullReadCapacityException;
139145
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
140146
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
@@ -143,29 +149,20 @@ import java.util.concurrent.ExecutionException;
143149
144150
class TransferDataFromOneTableToBlockingQueue {
145151
public static void main(String[] args) {
146-
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
152+
final AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
147153
.withRegion(com.amazonaws.regions.Regions.US_WEST_1).build();
148-
149-
DynamoDBBootstrapWorker worker = null;
150-
151154
try {
152155
// 100.0 read operations per second. 4 threads to scan the table.
153-
worker = new DynamoDBBootstrapWorker(client, 100.0, "mySourceTable", 4);
156+
final DynamoDBBootstrapWorker worker = new DynamoDBBootstrapWorker(client, 100.0,
157+
"mySourceTable", 4);
158+
final BlockingQueueConsumer consumer = new BlockingQueueConsumer(8);
159+
worker.pipe(consumer);
154160
} catch (NullReadCapacityException e) {
155161
System.err.println("The DynamoDB source table returned a null read capacity.");
156162
System.exit(1);
157-
}
158-
159-
BlockingQueueConsumer consumer = new BlockingQueueConsumer(8);
160-
161-
try {
162-
worker.pipe(consumer);
163-
} catch (ExecutionException e) {
163+
} catch (ExecutionException | InterruptedException e) {
164164
System.err.println("Encountered exception when executing transfer: " + e.getMessage());
165165
System.exit(1);
166-
} catch (InterruptedException e){
167-
System.err.println("Interrupted when executing transfer: " + e.getMessage());
168-
System.exit(1);
169166
}
170167
}
171168
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<url>https://github.com/awslabs/dynamodb-import-export-tool.git</url>
1212
</scm>
1313
<properties>
14-
<jdk.version>1.7</jdk.version>
14+
<jdk.version>1.8</jdk.version>
1515
<aws.java.sdk.version>1.11.123</aws.java.sdk.version>
1616
<powermock.version>1.6.6</powermock.version>
1717
<jcommander.version>1.69</jcommander.version>

src/main/java/com/amazonaws/dynamodb/bootstrap/AbstractLogProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
*/
1515
package com.amazonaws.dynamodb.bootstrap;
1616

17-
import java.util.concurrent.ExecutionException;
18-
import java.util.concurrent.ExecutorService;
19-
import java.util.concurrent.TimeUnit;
20-
17+
import com.amazonaws.dynamodb.bootstrap.constants.BootstrapConstants;
18+
import com.amazonaws.dynamodb.bootstrap.consumer.AbstractLogConsumer;
2119
import org.apache.log4j.LogManager;
2220
import org.apache.log4j.Logger;
2321

24-
import com.amazonaws.dynamodb.bootstrap.constants.BootstrapConstants;
22+
import java.util.concurrent.ExecutionException;
23+
import java.util.concurrent.ExecutorService;
24+
import java.util.concurrent.TimeUnit;
2525

2626
/**
2727
* Abstract class to send inputs from a source to a consumer.

src/main/java/com/amazonaws/dynamodb/bootstrap/CommandLineArgs.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import com.beust.jcommander.Parameter;
1919
import lombok.Getter;
2020

21+
import java.util.List;
22+
2123
/**
2224
* This class contains the parameters to input when executing the program from
2325
* command line.
@@ -60,6 +62,22 @@ public boolean getHelp() {
6062
@Parameter(names = CREATE_DESTINATION_TABLE_IF_MISSING, description = "Create destination table if it does not exist")
6163
private boolean createDestinationTableIfMissing;
6264

65+
public static final String CREATE_ALL_LSI = "--createAllLsi";
66+
@Parameter(names = CREATE_ALL_LSI, description = "Create all LSI in destination table")
67+
private boolean createAllLsi;
68+
69+
public static final String CREATE_ALL_GSI = "--createAllGsi";
70+
@Parameter(names = CREATE_ALL_GSI, description = "Create all GSI in destination table")
71+
private boolean createAllGsi;
72+
73+
public static final String INCLUDE_LSI = "--includeLsi";
74+
@Parameter(names = INCLUDE_LSI, description = "Include the following LSI in the destination table")
75+
private List<String> includeLsi;
76+
77+
public static final String INCLUDE_GSI = "--includeGsi";
78+
@Parameter(names = INCLUDE_GSI, description = "Include the following GSI in the destination table")
79+
private List<String> includeGsi;
80+
6381
public static final String COPY_STREAM_SPECIFICATION_WHEN_CREATING = "--copyStreamSpecificationWhenCreating";
6482
@Parameter(names = COPY_STREAM_SPECIFICATION_WHEN_CREATING, description = "Use the source table stream specification for the destination table during its creation.")
6583
private boolean copyStreamSpecification;

0 commit comments

Comments
 (0)