use of software.amazon.awssdk.services.applicationautoscaling.model.DeleteScalingPolicyRequest in project scalardb by scalar-labs.
the class DynamoAdmin method disableAutoScaling.
private void disableAutoScaling(String namespace, String table) throws ExecutionException {
TableMetadata tableMetadata = getTableMetadata(namespace, table);
if (tableMetadata == null) {
return;
}
List<DeleteScalingPolicyRequest> deleteScalingPolicyRequestList = new ArrayList<>();
List<DeregisterScalableTargetRequest> deregisterScalableTargetRequestList = new ArrayList<>();
// write, read scaling of table
for (String scalingType : TABLE_SCALING_TYPE_SET) {
deleteScalingPolicyRequestList.add(buildDeleteScalingPolicyRequest(getTableResourceID(namespace, table), scalingType));
deregisterScalableTargetRequestList.add(buildDeregisterScalableTargetRequest(getTableResourceID(namespace, table), scalingType));
}
// write, read scaling of global indexes (secondary indexes)
Set<String> secondaryIndexes = tableMetadata.getSecondaryIndexNames();
for (String secondaryIndex : secondaryIndexes) {
for (String scalingType : SECONDARY_INDEX_SCALING_TYPE_SET) {
deleteScalingPolicyRequestList.add(buildDeleteScalingPolicyRequest(getGlobalIndexResourceID(namespace, table, secondaryIndex), scalingType));
deregisterScalableTargetRequestList.add(buildDeregisterScalableTargetRequest(getGlobalIndexResourceID(namespace, table, secondaryIndex), scalingType));
}
}
deleteScalingPolicy(deleteScalingPolicyRequestList);
deregisterScalableTarget(deregisterScalableTargetRequestList);
}
use of software.amazon.awssdk.services.applicationautoscaling.model.DeleteScalingPolicyRequest in project scalardb by scalar-labs.
the class DynamoAdmin method dropIndex.
@Override
public void dropIndex(String namespace, String table, String columnName) throws ExecutionException {
try {
client.updateTable(UpdateTableRequest.builder().tableName(getFullTableName(namespace, table)).globalSecondaryIndexUpdates(GlobalSecondaryIndexUpdate.builder().delete(DeleteGlobalSecondaryIndexAction.builder().indexName(getGlobalIndexName(namespace, table, columnName)).build()).build()).build());
} catch (Exception e) {
throw new ExecutionException("dropping the secondary index failed", e);
}
waitForIndexDeletion(namespace, table, columnName);
// disable auto scaling
List<DeleteScalingPolicyRequest> deleteScalingPolicyRequestList = new ArrayList<>();
List<DeregisterScalableTargetRequest> deregisterScalableTargetRequestList = new ArrayList<>();
for (String scalingType : SECONDARY_INDEX_SCALING_TYPE_SET) {
deleteScalingPolicyRequestList.add(buildDeleteScalingPolicyRequest(getGlobalIndexResourceID(namespace, table, columnName), scalingType));
deregisterScalableTargetRequestList.add(buildDeregisterScalableTargetRequest(getGlobalIndexResourceID(namespace, table, columnName), scalingType));
}
deleteScalingPolicy(deleteScalingPolicyRequestList);
deregisterScalableTarget(deregisterScalableTargetRequestList);
// update metadata
TableMetadata tableMetadata = getTableMetadata(namespace, table);
putTableMetadata(namespace, table, TableMetadata.newBuilder(tableMetadata).removeSecondaryIndex(columnName).build());
}
Aggregations