Merge e7ea3bb537 into dd14bac4e3
This commit is contained in:
commit
52eb1f8253
2 changed files with 17 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +1,4 @@
|
||||||
|
*.iml
|
||||||
|
.idea/
|
||||||
target/
|
target/
|
||||||
AwsCredentials.properties
|
AwsCredentials.properties
|
||||||
|
|
|
||||||
|
|
@ -99,11 +99,25 @@ public class LeaseManager<T extends Lease> implements ILeaseManager<T> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createLeaseTableIfNotExists(Long readCapacity, Long writeCapacity)
|
public boolean createLeaseTableIfNotExists(Long readCapacity, Long writeCapacity)
|
||||||
throws ProvisionedThroughputException, DependencyException {
|
throws ProvisionedThroughputException, DependencyException {
|
||||||
verifyNotNull(readCapacity, "readCapacity cannot be null");
|
verifyNotNull(readCapacity, "readCapacity cannot be null");
|
||||||
verifyNotNull(writeCapacity, "writeCapacity cannot be null");
|
verifyNotNull(writeCapacity, "writeCapacity cannot be null");
|
||||||
|
|
||||||
boolean tableDidNotExist = true;
|
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();
|
CreateTableRequest request = new CreateTableRequest();
|
||||||
request.setTableName(table);
|
request.setTableName(table);
|
||||||
request.setKeySchema(serializer.getKeySchema());
|
request.setKeySchema(serializer.getKeySchema());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue