Search in sources :

Example 1 with DeleteScalingPolicyRequest

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);
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata) DeregisterScalableTargetRequest(software.amazon.awssdk.services.applicationautoscaling.model.DeregisterScalableTargetRequest) ArrayList(java.util.ArrayList) DeleteScalingPolicyRequest(software.amazon.awssdk.services.applicationautoscaling.model.DeleteScalingPolicyRequest)

Example 2 with DeleteScalingPolicyRequest

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());
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata) DeregisterScalableTargetRequest(software.amazon.awssdk.services.applicationautoscaling.model.DeregisterScalableTargetRequest) ArrayList(java.util.ArrayList) DeleteScalingPolicyRequest(software.amazon.awssdk.services.applicationautoscaling.model.DeleteScalingPolicyRequest) ExecutionException(com.scalar.db.exception.storage.ExecutionException) ExecutionException(com.scalar.db.exception.storage.ExecutionException) ObjectNotFoundException(software.amazon.awssdk.services.applicationautoscaling.model.ObjectNotFoundException) ResourceNotFoundException(software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException) DynamoDbException(software.amazon.awssdk.services.dynamodb.model.DynamoDbException)

Aggregations

TableMetadata (com.scalar.db.api.TableMetadata)2 ArrayList (java.util.ArrayList)2 DeleteScalingPolicyRequest (software.amazon.awssdk.services.applicationautoscaling.model.DeleteScalingPolicyRequest)2 DeregisterScalableTargetRequest (software.amazon.awssdk.services.applicationautoscaling.model.DeregisterScalableTargetRequest)2 ExecutionException (com.scalar.db.exception.storage.ExecutionException)1 ObjectNotFoundException (software.amazon.awssdk.services.applicationautoscaling.model.ObjectNotFoundException)1 DynamoDbException (software.amazon.awssdk.services.dynamodb.model.DynamoDbException)1 ResourceNotFoundException (software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException)1