Java Code Examples for com.amazonaws.services.dynamodbv2.document.Table#waitForDelete()

The following examples show how to use com.amazonaws.services.dynamodbv2.document.Table#waitForDelete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoviesDeleteTable.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
            .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2"))
            .build();

        DynamoDB dynamoDB = new DynamoDB(client);

        Table table = dynamoDB.getTable("Movies");

        try {
            System.out.println("Attempting to delete table; please wait...");
            table.delete();
            table.waitForDelete();
            System.out.print("Success.");

        }
        catch (Exception e) {
            System.err.println("Unable to delete table: ");
            System.err.println(e.getMessage());
        }
    }
 
Example 2
Source File: DocumentAPITableExample.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
static void deleteExampleTable() {

        Table table = dynamoDB.getTable(tableName);
        try {
            System.out.println("Issuing DeleteTable request for " + tableName);
            table.delete();

            System.out.println("Waiting for " + tableName + " to be deleted...this may take a while...");

            table.waitForDelete();
        }
        catch (Exception e) {
            System.err.println("DeleteTable request failed for " + tableName);
            System.err.println(e.getMessage());
        }
    }
 
Example 3
Source File: DocumentAPIGlobalSecondaryIndexExample.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void deleteTable(String tableName) {

        System.out.println("Deleting table " + tableName + "...");

        Table table = dynamoDB.getTable(tableName);
        table.delete();

        // Wait for table to be deleted
        System.out.println("Waiting for " + tableName + " to be deleted...");
        try {
            table.waitForDelete();
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
 
Example 4
Source File: DocumentAPITableExample.java    From aws-dynamodb-examples with Apache License 2.0 6 votes vote down vote up
static void deleteExampleTable() {

        Table table = dynamoDB.getTable(tableName);
        try {
            System.out.println("Issuing DeleteTable request for " + tableName);
            table.delete();

            System.out.println("Waiting for " + tableName
                + " to be deleted...this may take a while...");

            table.waitForDelete();
        } catch (Exception e) {
            System.err.println("DeleteTable request failed for " + tableName);
            System.err.println(e.getMessage());
        }
    }
 
Example 5
Source File: IntegrationTest.java    From dynamodb-transactions with Apache License 2.0 6 votes vote down vote up
@AfterClass
public static void deleteTables() throws InterruptedException {
    try {
        Table hashTable = documentDynamoDB.getTable(INTEG_HASH_TABLE_NAME);
        Table lockTable = documentDynamoDB.getTable(INTEG_LOCK_TABLE_NAME);
        Table imagesTable = documentDynamoDB.getTable(INTEG_IMAGES_TABLE_NAME);

        System.out.println("Issuing DeleteTable request for " + INTEG_HASH_TABLE_NAME);
        hashTable.delete();
        System.out.println("Issuing DeleteTable request for " + INTEG_LOCK_TABLE_NAME);
        lockTable.delete();
        System.out.println("Issuing DeleteTable request for " + INTEG_IMAGES_TABLE_NAME);
        imagesTable.delete();

        System.out.println("Waiting for " + INTEG_HASH_TABLE_NAME + " to be deleted...this may take a while...");
        hashTable.waitForDelete();
        System.out.println("Waiting for " + INTEG_LOCK_TABLE_NAME + " to be deleted...this may take a while...");
        lockTable.waitForDelete();
        System.out.println("Waiting for " + INTEG_IMAGES_TABLE_NAME + " to be deleted...this may take a while...");
        imagesTable.waitForDelete();
    } catch (Exception e) {
        System.err.println("DeleteTable request failed for some table");
        System.err.println(e.getMessage());
    }
}
 
Example 6
Source File: TryDaxHelper.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
void deleteTable(String tableName, DynamoDB client) {
    Table table = client.getTable(tableName);
    try {
        System.out.println("\nAttempting to delete table; please wait...");
        table.delete();
        table.waitForDelete();
        System.out.println("Successfully deleted table.");

    } catch (Exception e) {
        System.err.println("Unable to delete table: ");
        e.printStackTrace();
    }
}
 
Example 7
Source File: CreateTablesLoadData.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
private static void deleteTable(String tableName) {
    Table table = dynamoDB.getTable(tableName);
    try {
        System.out.println("Issuing DeleteTable request for " + tableName);
        table.delete();
        System.out.println("Waiting for " + tableName + " to be deleted...this may take a while...");
        table.waitForDelete();

    }
    catch (Exception e) {
        System.err.println("DeleteTable request failed for " + tableName);
        System.err.println(e.getMessage());
    }
}
 
Example 8
Source File: DocumentAPIParallelScan.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
private static void deleteTable(String tableName) {
    try {

        Table table = dynamoDB.getTable(tableName);
        table.delete();
        System.out.println("Waiting for " + tableName + " to be deleted...this may take a while...");
        table.waitForDelete();

    }
    catch (Exception e) {
        System.err.println("Failed to delete table " + tableName);
        e.printStackTrace(System.err);
    }
}
 
Example 9
Source File: DocumentAPILocalSecondaryIndexExample.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
public static void deleteTable(String tableName) {

        Table table = dynamoDB.getTable(tableName);
        System.out.println("Deleting table " + tableName + "...");
        table.delete();

        // Wait for table to be deleted
        System.out.println("Waiting for " + tableName + " to be deleted...");
        try {
            table.waitForDelete();
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
 
Example 10
Source File: CreateTablesLoadData.java    From aws-dynamodb-examples with Apache License 2.0 5 votes vote down vote up
private static void deleteTable(String tableName) {
    Table table = dynamoDB.getTable(tableName);
    try {
        System.out.println("Issuing DeleteTable request for " + tableName);
        table.delete();
        System.out.println("Waiting for " + tableName
            + " to be deleted...this may take a while...");
        table.waitForDelete();

    } catch (Exception e) {
        System.err.println("DeleteTable request failed for " + tableName);
        System.err.println(e.getMessage());
    }
}
 
Example 11
Source File: DocumentAPIParallelScan.java    From aws-dynamodb-examples with Apache License 2.0 5 votes vote down vote up
private static void deleteTable(String tableName){
    try {
        
        Table table = dynamoDB.getTable(tableName);
        table.delete();
        System.out.println("Waiting for " + tableName
            + " to be deleted...this may take a while...");
        table.waitForDelete();
           
    } catch (Exception e) {
        System.err.println("Failed to delete table " + tableName);
        e.printStackTrace(System.err);
    }
}
 
Example 12
Source File: DocumentAPILocalSecondaryIndexExample.java    From aws-dynamodb-examples with Apache License 2.0 5 votes vote down vote up
public static void deleteTable(String tableName) {

        Table table = dynamoDB.getTable(tableName);
        System.out.println("Deleting table " + tableName + "...");
        table.delete();

        // Wait for table to be deleted
        System.out.println("Waiting for " + tableName + " to be deleted...");
        try {
            table.waitForDelete();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
 
Example 13
Source File: DocumentAPIGlobalSecondaryIndexExample.java    From aws-dynamodb-examples with Apache License 2.0 5 votes vote down vote up
public static void deleteTable(String tableName) {

        System.out.println("Deleting table " + tableName + "...");
        
        Table table = dynamoDB.getTable(tableName);
        table.delete();

        // Wait for table to be deleted
        System.out.println("Waiting for " + tableName + " to be deleted...");
        try {
            table.waitForDelete();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
 
Example 14
Source File: RedshiftIT.java    From digdag with Apache License 2.0 4 votes vote down vote up
@Test
public void loadFromDynamoDB()
        throws Exception
{
    DynamoDB dynamoDB = new DynamoDB(dynamoClient);

    ArrayList<AttributeDefinition> attributeDefinitions= new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition().withAttributeName("Id").withAttributeType("N"));

    ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
    keySchema.add(new KeySchemaElement().withAttributeName("Id").withKeyType(KeyType.HASH));

    CreateTableRequest request = new CreateTableRequest()
            .withTableName(dynamoTableName)
            .withKeySchema(keySchema)
            .withAttributeDefinitions(attributeDefinitions)
            .withProvisionedThroughput(new ProvisionedThroughput()
                    .withReadCapacityUnits(1L)
                    .withWriteCapacityUnits(1L));

    ImmutableList<Item> items = ImmutableList.of(
            new Item().withPrimaryKey("Id", 0).withString("Name", "foo").withNumber("Score", 3.14f),
            new Item().withPrimaryKey("Id", 1).withString("Name", "bar").withNumber("Score", 1.23f),
            new Item().withPrimaryKey("Id", 2).withString("Name", "baz").withNumber("Score", 5.0f)
    );

    ImmutableList<Map<String, Object>> expected = ImmutableList.of(
            ImmutableMap.of("id", 0, "name", "foo", "score", 3.14f),
            ImmutableMap.of("id", 1, "name", "bar", "score", 1.23f),
            ImmutableMap.of("id", 2, "name", "baz", "score", 5.0f),
            ImmutableMap.of("id", 9, "name", "zzz", "score", 9.99f)
    );

    Table table = null;
    try {
        table = dynamoDB.createTable(request);
        table.waitForActive();

        items.forEach(table::putItem);

        runDigdagWithDynamoDB(configFile, "acceptance/redshift/load_from_dynamodb.dig", redshiftUser, Optional.absent());

        assertTableContents(DEST_TABLE, expected);
    }
    finally {
        if (table != null) {
            table.delete();
            table.waitForDelete();
        }
    }
}