com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription Java Examples

The following examples show how to use com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputDescription. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WriteIopsCalculatorTest.java    From emr-dynamodb-connector with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
  when(dynamoDBClient.describeTable(TABLE_NAME)).thenReturn(new TableDescription()
      .withBillingModeSummary(
          new BillingModeSummary().withBillingMode(DynamoDBConstants.BILLING_MODE_PROVISIONED))
      .withProvisionedThroughput(
          new ProvisionedThroughputDescription().withWriteCapacityUnits(WRITE_CAPACITY_UNITS)));

  JobConf jobConf = new JobConf();
  jobConf.setNumMapTasks(TOTAL_MAP_TASKS);
  jobConf.set("mapreduce.task.attempt.id", "attempt_m_1");
  jobConf.set(DynamoDBConstants.THROUGHPUT_WRITE_PERCENT, String.valueOf
      (THROUGHPUT_WRITE_PERCENT));
  when(jobClient.getConf()).thenReturn(jobConf);

  writeIopsCalculator = new WriteIopsCalculator(jobClient, dynamoDBClient, TABLE_NAME) {
    @Override
    int calculateMaxMapTasks(int totalMapTasks) {
      return MAX_CONCURRENT_MAP_TASKS;
    }
  };
}
 
Example #2
Source File: DynamoDBRecordReaderTest.java    From emr-dynamodb-connector with Apache License 2.0 6 votes vote down vote up
private TableDescription getTableDescription(String hashType, String rangeType) {
  List<KeySchemaElement> keySchema = new ArrayList<>();
  List<AttributeDefinition> definitions = new ArrayList<>();

  keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH));
  definitions.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType
      (hashType));

  if (rangeType != null) {
    keySchema.add(new KeySchemaElement().withAttributeName("rangeKey").withKeyType(KeyType
        .RANGE));
    definitions.add(new AttributeDefinition().withAttributeName("rangeKey").withAttributeType
        (rangeType));
  }

  TableDescription description = new TableDescription().withKeySchema(keySchema)
      .withAttributeDefinitions(definitions).withProvisionedThroughput(new
          ProvisionedThroughputDescription().withReadCapacityUnits(1000L)
          .withWriteCapacityUnits(1000L));
  return description;
}
 
Example #3
Source File: DynamoDBBootstrapWorker.java    From dynamodb-import-export-tool with Apache License 2.0 6 votes vote down vote up
/**
 * returns the approximate number of segments a table should be broken up
 * when parallel scanning. This function is based off of either read and
 * write capacity, with which you can scan much faster, or the size of your
 * table, which should need many more segments in order to scan the table
 * fast enough in parallel so that one worker does not finish long before
 * other workers.
 * 
 * @throws NullReadCapacityException
 *             if the table returns a null readCapacity units.
 */
public static int getNumberOfSegments(TableDescription description)
        throws NullReadCapacityException {
    ProvisionedThroughputDescription provisionedThroughput = description
            .getProvisionedThroughput();
    double tableSizeInGigabytes = Math.ceil(description.getTableSizeBytes()
            / BootstrapConstants.GIGABYTE);
    Long readCapacity = provisionedThroughput.getReadCapacityUnits();
    Long writeCapacity = provisionedThroughput.getWriteCapacityUnits();
    if (writeCapacity == null) {
        writeCapacity = 1L;
    }
    if (readCapacity == null) {
        throw new NullReadCapacityException(
                "Cannot scan with a null readCapacity provisioned throughput");
    }
    double throughput = (readCapacity + 3 * writeCapacity) / 3000.0;
    return (int) (10 * Math.max(Math.ceil(throughput),
            Math.ceil(tableSizeInGigabytes) / 10));
}
 
Example #4
Source File: WriteIopsCalculator.java    From emr-dynamodb-connector with Apache License 2.0 5 votes vote down vote up
private double getThroughput() {
  TableDescription tableDescription = dynamoDBClient.describeTable(tableName);
  if (tableDescription.getBillingModeSummary() == null || tableDescription.getBillingModeSummary()
      .getBillingMode().equalsIgnoreCase(DynamoDBConstants.BILLING_MODE_PROVISIONED)) {
    ProvisionedThroughputDescription provisionedThroughput =
        tableDescription.getProvisionedThroughput();
    return provisionedThroughput.getWriteCapacityUnits();
  }
  return DynamoDBConstants.DEFAULT_CAPACITY_FOR_ON_DEMAND;
}
 
Example #5
Source File: ReadIopsCalculator.java    From emr-dynamodb-connector with Apache License 2.0 5 votes vote down vote up
private double getThroughput() {
  TableDescription tableDescription = dynamoDBClient.describeTable(tableName);
  if (tableDescription.getBillingModeSummary() == null ||
      tableDescription.getBillingModeSummary().getBillingMode()
          .equalsIgnoreCase(DynamoDBConstants.BILLING_MODE_PROVISIONED)) {
    ProvisionedThroughputDescription provisionedThroughput = tableDescription
        .getProvisionedThroughput();
    return provisionedThroughput.getReadCapacityUnits();
  }
  return DynamoDBConstants.DEFAULT_CAPACITY_FOR_ON_DEMAND;
}
 
Example #6
Source File: ReadIopsCalculatorTest.java    From emr-dynamodb-connector with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
  when(dynamoDBClient.describeTable(TABLE_NAME)).thenReturn(new TableDescription()
      .withBillingModeSummary(
          new BillingModeSummary().withBillingMode(DynamoDBConstants.BILLING_MODE_PROVISIONED))
      .withProvisionedThroughput(
          new ProvisionedThroughputDescription().withReadCapacityUnits(READ_CAPACITY_UNITS)));

  JobConf jobConf = new JobConf();
  jobConf.set(DynamoDBConstants.THROUGHPUT_READ_PERCENT, String.valueOf(THROUGHPUT_READ_PERCENT));
  when(jobClient.getConf()).thenReturn(jobConf);

  readIopsCalculator = new ReadIopsCalculator(jobClient, dynamoDBClient, TABLE_NAME,
      TOTAL_SEGMETNS, LOCAL_SEGMENTS);
}
 
Example #7
Source File: DescribeTable.java    From aws-doc-sdk-examples with Apache License 2.0 4 votes vote down vote up
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);
    }

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

    final AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();

    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!");
}