Example usage for com.amazonaws.services.dynamodbv2.model ProvisionedThroughputDescription getReadCapacityUnits

List of usage examples for com.amazonaws.services.dynamodbv2.model ProvisionedThroughputDescription getReadCapacityUnits

Introduction

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

Prototype


public Long getReadCapacityUnits() 

Source Link

Document

The maximum number of strongly consistent reads consumed per second before DynamoDB returns a ThrottlingException.

Usage

From source file:aws.example.dynamodb.DescribeTable.java

License:Open Source License

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    DescribeTable <table>\n\n" + "Where:\n"
            + "    table - the table to get information about.\n\n" + "Example:\n"
            + "    DescribeTable HelloTable\n";

    if (args.length < 1) {
        System.out.println(USAGE);
        System.exit(1);/*ww w  . j a  v  a 2 s .c  om*/
    }

    String table_name = args[0];
    System.out.format("Getting description for %s\n\n", table_name);

    final AmazonDynamoDBClient ddb = new AmazonDynamoDBClient();

    try {
        TableDescription table_info = ddb.describeTable(table_name).getTable();

        if (table_info != null) {
            System.out.format("Table name  : %s\n", table_info.getTableName());
            System.out.format("Table ARN   : %s\n", table_info.getTableArn());
            System.out.format("Status      : %s\n", table_info.getTableStatus());
            System.out.format("Item count  : %d\n", table_info.getItemCount().longValue());
            System.out.format("Size (bytes): %d\n", table_info.getTableSizeBytes().longValue());

            ProvisionedThroughputDescription throughput_info = table_info.getProvisionedThroughput();
            System.out.println("Throughput");
            System.out.format("  Read Capacity : %d\n", throughput_info.getReadCapacityUnits().longValue());
            System.out.format("  Write Capacity: %d\n", throughput_info.getWriteCapacityUnits().longValue());

            List<AttributeDefinition> attributes = table_info.getAttributeDefinitions();
            System.out.println("Attributes");
            for (AttributeDefinition a : attributes) {
                System.out.format("  %s (%s)\n", a.getAttributeName(), a.getAttributeType());
            }
        }
    } catch (AmazonServiceException e) {
        System.err.println(e.getErrorMessage());
        System.exit(1);
    }
    System.out.println("\nDone!");
}

From source file:com.cfelde.aws.ddb.management.TableThroughput.java

License:Open Source License

public void initCapacityValues() {
    synchronized (lock) {
        try {/*from  ww w  . java2 s . com*/
            ProvisionedThroughputDescription ptd = ddb.describeTable(new DescribeTableRequest(tableName))
                    .getTable().getProvisionedThroughput();

            requestedReadCapacity.compareAndSet(0, ptd.getReadCapacityUnits());
            requestedWriteCapacity.compareAndSet(0, ptd.getWriteCapacityUnits());

            LOG.info("Initial capacity on " + tableName + ": reads: " + ptd.getReadCapacityUnits()
                    + ", writes: " + ptd.getWriteCapacityUnits());
        } catch (Throwable t) {
            LOG.error("Exception in initCapacityValues: " + t.getMessage(), t);
            exceptionCounter.incrementAndGet();
        }
    }
}

From source file:com.cfelde.aws.ddb.management.TableThroughput.java

License:Open Source License

public void updateCapacity() {
    synchronized (lock) {
        try {/*from ww w. j a va  2  s. c  om*/
            if (lastTableChange.plusMinutes(3).isAfter(new DateTime()))
                return;

            long readCapacity = requestedReadCapacity.get();
            long writeCapacity = requestedWriteCapacity.get();

            if (readCapacity > maxReadLimit)
                readCapacity = maxReadLimit;
            if (readCapacity < minReadLimit)
                readCapacity = minReadLimit;

            if (writeCapacity > maxWriteLimit)
                writeCapacity = maxWriteLimit;
            if (writeCapacity < minWriteLimit)
                writeCapacity = minWriteLimit;

            ProvisionedThroughputDescription ptd = ddb.describeTable(new DescribeTableRequest(tableName))
                    .getTable().getProvisionedThroughput();

            downscaleCounter.set(ptd.getNumberOfDecreasesToday());

            final long currentReadCapacity = ptd.getReadCapacityUnits();
            final long currentWriteCapacity = ptd.getWriteCapacityUnits();

            // Make sure we don't try to scale up more than 100%
            if (readCapacity > currentReadCapacity * 2)
                readCapacity = currentReadCapacity * 2;

            if (writeCapacity > currentWriteCapacity * 2)
                writeCapacity = currentWriteCapacity * 2;

            if (!isDownscaleAllowed() && readCapacity < currentReadCapacity)
                readCapacity = currentReadCapacity;
            if (!isDownscaleAllowed() && writeCapacity < currentWriteCapacity)
                writeCapacity = currentWriteCapacity;

            // Check if no change
            if (readCapacity == currentReadCapacity && writeCapacity == currentWriteCapacity)
                return;

            /*
            if (readCapacity < currentReadCapacity || writeCapacity < currentWriteCapacity)
            downscaleAllowed.set(false);
            */

            ProvisionedThroughput throughput = new ProvisionedThroughput();
            throughput.withReadCapacityUnits(readCapacity);
            throughput.withWriteCapacityUnits(writeCapacity);

            UpdateTableRequest request = new UpdateTableRequest(tableName, throughput);

            LOG.info("Changing throughput on " + tableName + " to: reads: " + throughput.getReadCapacityUnits()
                    + ", writes: " + throughput.getWriteCapacityUnits());
            ddb.updateTable(request);

            lastTableChange = new DateTime();
        } catch (Throwable t) {
            LOG.error("Exception in updateCapacity: " + t.getMessage(), t);
            exceptionCounter.incrementAndGet();
        }
    }
}

From source file:jp.classmethod.aws.dynamodb.DynamoDbRepository.java

License:Open Source License

private ProvisionedThroughput convert(ProvisionedThroughputDescription d) {
    return new ProvisionedThroughput(d.getReadCapacityUnits(), d.getWriteCapacityUnits());
}

From source file:org.apache.hadoop.dynamodb.read.ReadIopsCalculator.java

License:Open Source License

private double getThroughput() {
    ProvisionedThroughputDescription provisionedThroughput = dynamoDBClient.describeTable(tableName)
            .getProvisionedThroughput();
    return provisionedThroughput.getReadCapacityUnits();
}

From source file:org.xmlsh.aws.util.AWSDDBCommand.java

License:BSD License

private void writeProvisionedThroughput(ProvisionedThroughputDescription provisionedThroughput)
        throws XMLStreamException {
    startElement("provisioned-throughput");
    attribute("last-decrease", provisionedThroughput.getLastDecreaseDateTime());
    attribute("last-increase", provisionedThroughput.getLastIncreaseDateTime());
    attribute("decreases-today", provisionedThroughput.getNumberOfDecreasesToday());
    attribute("read-capacity", provisionedThroughput.getReadCapacityUnits());
    attribute("write-capacity", provisionedThroughput.getWriteCapacityUnits());
    endElement();/* w w  w  . j a v a 2  s.co  m*/

}