Example usage for com.amazonaws.services.dynamodbv2.model UpdateTableRequest UpdateTableRequest

List of usage examples for com.amazonaws.services.dynamodbv2.model UpdateTableRequest UpdateTableRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model UpdateTableRequest UpdateTableRequest.

Prototype

public UpdateTableRequest() 

Source Link

Document

Default constructor for UpdateTableRequest object.

Usage

From source file:com.erudika.para.persistence.AWSDynamoUtils.java

License:Apache License

/**
 * Updates the table settings (read and write capacities).
 * @param appid name of the {@link com.erudika.para.core.App}
 * @param readCapacity read capacity/* ww w  .ja va  2 s  .  c o  m*/
 * @param writeCapacity write capacity
 * @return true if updated
 */
public static boolean updateTable(String appid, long readCapacity, long writeCapacity) {
    if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid)) {
        return false;
    }
    try {
        Map<String, Object> dbStats = getTableStatus(appid);
        String status = (String) dbStats.get("status");
        // AWS throws an exception if the new read/write capacity values are the same as the current ones
        if (!dbStats.isEmpty() && "ACTIVE".equalsIgnoreCase(status)) {
            getClient().updateTable(new UpdateTableRequest().withTableName(getTableNameForAppid(appid))
                    .withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity)));
            return true;
        }
    } catch (Exception e) {
        logger.error(null, e);
    }
    return false;
}

From source file:com.makariev.dynamodb.data.tables.ModifyTablesService.java

License:Apache License

public TableDescription updateThroughput(TableDescription tableDescription,
        ProvisionedThroughput provisionedThroughput) {
    final String tableName = tableDescription.getTableName();
    final UpdateTableRequest updateTableRequest = new UpdateTableRequest().withTableName(tableName)
            .withProvisionedThroughput(provisionedThroughput);

    final UpdateTableResult requestResult = client.updateTable(updateTableRequest);
    return requestResult.getTableDescription();
}

From source file:Database.TableFunctions.java

public static void updateTableInformation() {
        ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput().withReadCapacityUnits(6L)
                .withWriteCapacityUnits(7L);
        UpdateTableRequest updateTableRequest = new UpdateTableRequest().withTableName(tablename)
                .withProvisionedThroughput(provisionedThroughput);
        UpdateTableResult result = dynamoDB.updateTable(updateTableRequest);
        waitForTableToBecomeAvailable(tablename);
    }//from  ww  w. ja  va  2 s  .c  om