Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.iml
.idea/
target/
AwsCredentials.properties
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,25 @@ public LeaseManager(String table, AmazonDynamoDB dynamoDBClient, ILeaseSerialize
*/
@Override
public boolean createLeaseTableIfNotExists(Long readCapacity, Long writeCapacity)
throws ProvisionedThroughputException, DependencyException {
throws ProvisionedThroughputException, DependencyException {
verifyNotNull(readCapacity, "readCapacity cannot be null");
verifyNotNull(writeCapacity, "writeCapacity cannot be null");

boolean tableDidNotExist = true;

// First, attempt to describe the table and short-circuit if it already existed
try {
dynamoDBClient.describeTable(table);
return false;
} catch (ResourceNotFoundException e) {
tableDidNotExist = true;
} catch (AmazonClientException e) {
// In order to insulate ourselves from failures specific to DescribeTable, we swallow this exception;
// we can still rely on CreateTable request failing if present.
LOG.error("Failed to retrieve table description for table " + table, e);
}

// We believe the table does not exist, so we proceed to creating it
CreateTableRequest request = new CreateTableRequest();
request.setTableName(table);
request.setKeySchema(serializer.getKeySchema());
Expand Down