Skip to content

Commit

Permalink
RDB Shredder: remove auto-creation of event manifests table (close #62)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuwy committed Apr 29, 2018
1 parent 64487d8 commit bfc52cc
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ object DuplicateStorage {

/**
* Indempotent action to create duplicates table
* If table with name already exists - do nothing and just return name
* If table doesn't exist - create table with predefined structure and return name
* This is blocking operation as opposed to `DynamoDB#createTable`
* If table with name already exists - block until is available and return name
* If table doesn't exist - throw exception
*
* @param client AWS DynamoDB client with established connection
* @param name DynamoDB table name
* @return same table name or throw exception
*/
def getOrCreateTable(client: AmazonDynamoDB, name: String): String = {
@throws[IllegalStateException]
private[spark] def getOrCreateTable(client: AmazonDynamoDB, name: String): String = {
val request = new DescribeTableRequest().withTableName(name)
val result = try {
Option(client.describeTable(request).getTable)
Expand All @@ -242,7 +242,8 @@ object DuplicateStorage {
case Some(description) =>
waitForActive(client, name, description)
name
case None => createTable(client, name).getTableName
case None =>
throw new IllegalStateException("Amazon DynamoDB table for event manifest is unavailable")
}
}

Expand All @@ -261,7 +262,7 @@ object DuplicateStorage {
val schema = List(
new KeySchemaElement(eventIdColumn, KeyType.HASH),
new KeySchemaElement(fingerprintColumn, KeyType.RANGE))

val request = new CreateTableRequest()
.withTableName(name)
.withAttributeDefinitions(pks.asJava)
Expand Down

0 comments on commit bfc52cc

Please sign in to comment.