private String enableStreamForTable(AmazonDynamoDBClient client, StreamViewType viewType, String tableName) { DescribeTableRequest describeTableRequest = new DescribeTableRequest() .withTableName(tableName); DescribeTableResult describeResult = client.describeTable(describeTableRequest); if (describeResult.getTable().getStreamSpecification().isStreamEnabled()) { //TODO: what if the viewtype doesn't match return describeResult.getTable().getLatestStreamId(); } StreamSpecification streamSpecification = new StreamSpecification(); streamSpecification.setStreamEnabled(true); streamSpecification.setStreamViewType(viewType); UpdateTableRequest updateTableRequest = new UpdateTableRequest() .withTableName(tableName) .withStreamSpecification(streamSpecification); UpdateTableResult result = client.updateTable(updateTableRequest); return result.getTableDescription().getLatestStreamId(); }
public static String enableStreamForTable(AmazonDynamoDBClient client, StreamViewType viewType, String tableName) { DescribeTableRequest describeTableRequest = new DescribeTableRequest() .withTableName(tableName); DescribeTableResult describeResult = client.describeTable(describeTableRequest); if (describeResult.getTable().getStreamSpecification().isStreamEnabled()) { //TODO: what if the viewtype doesn't match return describeResult.getTable().getLatestStreamId(); } StreamSpecification streamSpecification = new StreamSpecification(); streamSpecification.setStreamEnabled(true); streamSpecification.setStreamViewType(viewType); UpdateTableRequest updateTableRequest = new UpdateTableRequest() .withTableName(tableName) .withStreamSpecification(streamSpecification); UpdateTableResult result = client.updateTable(updateTableRequest); return result.getTableDescription().getLatestStreamId(); }
/** * Updates the table settings (read and write capacities). * @param appid name of the {@link com.erudika.para.core.App} * @param readCapacity read capacity * @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; } String table = getTableNameForAppid(appid); try { // AWS throws an exception if the new read/write capacity values are the same as the current ones getClient().updateTable(new UpdateTableRequest().withTableName(table). withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity))); return true; } catch (Exception e) { logger.error("Could not update table '{}' - table is not active or no change to capacity: {}", table, e.getMessage()); } return false; }
@Override public void execute() { ddbClient.updateTable(new UpdateTableRequest() .withTableName(determineTableName()) .withProvisionedThroughput(new ProvisionedThroughput() .withReadCapacityUnits(determineReadCapacity()) .withWriteCapacityUnits(determineWriteCapacity()))); }
static void updateExampleTable() { ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput() .withReadCapacityUnits(6L) .withWriteCapacityUnits(7L); UpdateTableRequest updateTableRequest = new UpdateTableRequest() .withTableName(tableName) .withProvisionedThroughput(provisionedThroughput); client.updateTable(updateTableRequest); waitForTableToBecomeAvailable(tableName); }
@Override public UpdateTableResult updateTable(UpdateTableRequest updateTableRequest) { this.updateTableRequest = updateTableRequest; return null; }