Search in sources :

Example 1 with UpdateShardCountRequest

use of com.amazonaws.services.kinesis.model.UpdateShardCountRequest in project druid by druid-io.

the class KinesisAdminClient method updatePartitionCount.

/**
 * This method updates the shard count of {@param streamName} to have a final shard count of {@param newShardCount}
 * If {@param blocksUntilStarted} is set to true, then this method will blocks until the resharding
 * started (but not nessesary finished), otherwise, the method will returns right after issue the reshard command
 */
@Override
public void updatePartitionCount(String streamName, int newShardCount, boolean blocksUntilStarted) {
    int originalShardCount = getStreamPartitionCount(streamName);
    if (originalShardCount == newShardCount) {
        return;
    }
    UpdateShardCountRequest updateShardCountRequest = new UpdateShardCountRequest();
    updateShardCountRequest.setStreamName(streamName);
    updateShardCountRequest.setTargetShardCount(newShardCount);
    updateShardCountRequest.setScalingType(ScalingType.UNIFORM_SCALING);
    UpdateShardCountResult updateShardCountResult = amazonKinesis.updateShardCount(updateShardCountRequest);
    if (updateShardCountResult.getSdkHttpMetadata().getHttpStatusCode() != 200) {
        throw new ISE("Cannot update stream's shard count for integration test");
    }
    if (blocksUntilStarted) {
        // Wait until the resharding started (or finished)
        ITRetryUtil.retryUntil(() -> {
            int updatedShardCount = getStreamPartitionCount(streamName);
            return verifyStreamStatus(streamName, StreamStatus.ACTIVE, StreamStatus.UPDATING) && updatedShardCount != originalShardCount;
        }, true, // higher value to avoid exceeding kinesis TPS limit
        300, 100, "Kinesis stream resharding to start (or finished)");
    }
}
Also used : UpdateShardCountResult(com.amazonaws.services.kinesis.model.UpdateShardCountResult) ISE(org.apache.druid.java.util.common.ISE) UpdateShardCountRequest(com.amazonaws.services.kinesis.model.UpdateShardCountRequest)

Aggregations

UpdateShardCountRequest (com.amazonaws.services.kinesis.model.UpdateShardCountRequest)1 UpdateShardCountResult (com.amazonaws.services.kinesis.model.UpdateShardCountResult)1 ISE (org.apache.druid.java.util.common.ISE)1