Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I am currently using Java dynamoMapper to create and query the table. When trying to create a table with a global secondary index, I get the following error

No provisioned throughput specified for the global secondary index

My java class representing the table has this attribute for the global secondary index.

@DynamoDBIndexHashKey(globalSecondaryIndexName="sender")

    public String getSender() {

    return sender;

}

Class to create table looks like this 

public boolean createTable() {

try {

DynamoDBMapper mapper = new DynamoDBMapper(client);

CreateTableRequest tableRequest =     mapper.generateCreateTableRequest(entityClass); // 1

tableRequest.setProvisionedThroughput(new ProvisionedThroughput(1000L, 1500L)); // 2

client.createTable(tableRequest); // 3

 

    } catch (Error e) {

        e.printStackTrace();

        return false;

 

    } catch (Exception e) {

        e.printStackTrace();

        return false;

    }

    return true;

}

I have searched the Amazon site for adding annotations and configuration but nothing came up for DynamoMapper. Is there any way to do this using ORM or will I have to manually create by using a lower-level API?

1 Answer

0 votes
by (44.4k points)

On each secondary index table, you will have to set the provisioned throughput.

tableRequest.getGlobalSecondaryIndexes().get(0).setProvisionedThroughput(new ProvisionedThroughput(10l, 10l));

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...