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

Commit eafbb4c

Browse files
Alexander PatrikalakisAlexander Patrikalakis
Alexander Patrikalakis
authored and
Alexander Patrikalakis
committed
moved classes into different packages. upgraded SDK. tested table create request factory
1 parent ba3c751 commit eafbb4c

34 files changed

+786
-497
lines changed

README.md

+36-39
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

+1-1
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

+8-11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.log4j.Logger;
2323

2424
import com.amazonaws.dynamodb.bootstrap.constants.BootstrapConstants;
25+
import com.amazonaws.dynamodb.bootstrap.consumer.AbstractLogConsumer;
2526

2627
/**
2728
* Abstract class to send inputs from a source to a consumer.
@@ -31,25 +32,22 @@ public abstract class AbstractLogProvider {
3132
/**
3233
* Logger for the DynamoDBBootstrapWorker.
3334
*/
34-
private static final Logger LOGGER = LogManager
35-
.getLogger(AbstractLogProvider.class);
35+
private static final Logger LOGGER = LogManager.getLogger(AbstractLogProvider.class);
3636

3737
protected ExecutorService threadPool;
3838

3939
/**
4040
* Begins to read log results and transfer them to the consumer who will
4141
* write the results.
4242
*/
43-
public abstract void pipe(final AbstractLogConsumer consumer)
44-
throws ExecutionException, InterruptedException;
43+
public abstract void pipe(final AbstractLogConsumer consumer) throws ExecutionException, InterruptedException;
4544

4645
/**
4746
* Shuts the thread pool down.
48-
*
49-
* @param <awaitTermination>
50-
* If true, this method waits for the threads in the pool to
51-
* finish. If false, this thread pool shuts down without
52-
* finishing their current tasks.
47+
*
48+
* @param <awaitTermination> If true, this method waits for the threads in the pool to
49+
* finish. If false, this thread pool shuts down without
50+
* finishing their current tasks.
5351
*/
5452
public void shutdown(boolean awaitTermination) {
5553
if (awaitTermination) {
@@ -61,8 +59,7 @@ public void shutdown(boolean awaitTermination) {
6159
}
6260
} catch (InterruptedException e) {
6361
interrupted = true;
64-
LOGGER.warn("Threadpool was interrupted when trying to shutdown: "
65-
+ e.getMessage());
62+
LOGGER.warn("Threadpool was interrupted when trying to shutdown: " + e.getMessage());
6663
} finally {
6764
if (interrupted)
6865
Thread.currentThread().interrupt();

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

-50
This file was deleted.

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

+20-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
*/
1515
package com.amazonaws.dynamodb.bootstrap;
1616

17+
import java.util.List;
18+
1719
import com.amazonaws.dynamodb.bootstrap.constants.BootstrapConstants;
1820
import com.beust.jcommander.Parameter;
21+
1922
import lombok.Getter;
2023

2124
/**
@@ -60,6 +63,22 @@ public boolean getHelp() {
6063
@Parameter(names = CREATE_DESTINATION_TABLE_IF_MISSING, description = "Create destination table if it does not exist")
6164
private boolean createDestinationTableIfMissing;
6265

66+
public static final String CREATE_ALL_LSI = "--createAllLsi";
67+
@Parameter(names = CREATE_ALL_LSI, description = "Create all LSI in destination table")
68+
private boolean createAllLsi;
69+
70+
public static final String CREATE_ALL_GSI = "--createAllGsi";
71+
@Parameter(names = CREATE_ALL_GSI, description = "Create all GSI in destination table")
72+
private boolean createAllGsi;
73+
74+
public static final String INCLUDE_LSI = "--includeLsi";
75+
@Parameter(names = INCLUDE_LSI, description = "Include the following LSI in the destination table")
76+
private List<String> includeLsi;
77+
78+
public static final String INCLUDE_GSI = "--includeGsi";
79+
@Parameter(names = INCLUDE_GSI, description = "Include the following GSI in the destination table")
80+
private List<String> includeGsi;
81+
6382
public static final String COPY_STREAM_SPECIFICATION_WHEN_CREATING = "--copyStreamSpecificationWhenCreating";
6483
@Parameter(names = COPY_STREAM_SPECIFICATION_WHEN_CREATING, description = "Use the source table stream specification for the destination table during its creation.")
6584
private boolean copyStreamSpecification;
@@ -83,7 +102,7 @@ public boolean getHelp() {
83102
public static final String SECTION = "--section";
84103
@Parameter(names = SECTION, description = "Section number to scan when running multiple programs concurrently [0, 1... totalSections-1]", required = false)
85104
private int section = 0;
86-
105+
87106
public static final String CONSISTENT_SCAN = "--consistentScan";
88107
@Parameter(names = CONSISTENT_SCAN, description = "Use this flag to use strongly consistent scan. If the flag is not used it will default to eventually consistent scan")
89108
private boolean consistentScan = false;

0 commit comments

Comments
 (0)