use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput in project nifi by apache.
the class ITAbstractDynamoDBTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
FileInputStream fis = new FileInputStream(CREDENTIALS_FILE);
final PropertiesCredentials credentials = new PropertiesCredentials(fis);
amazonDynamoDBClient = new AmazonDynamoDBClient(credentials);
dynamoDB = new DynamoDB(amazonDynamoDBClient);
amazonDynamoDBClient.setRegion(Region.getRegion(Regions.US_WEST_2));
ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition().withAttributeName("hashS").withAttributeType("S"));
attributeDefinitions.add(new AttributeDefinition().withAttributeName("rangeS").withAttributeType("S"));
ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
keySchema.add(new KeySchemaElement().withAttributeName("hashS").withKeyType(KeyType.HASH));
keySchema.add(new KeySchemaElement().withAttributeName("rangeS").withKeyType(KeyType.RANGE));
CreateTableRequest request = new CreateTableRequest().withTableName(stringHashStringRangeTableName).withKeySchema(keySchema).withAttributeDefinitions(attributeDefinitions).withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(5L).withWriteCapacityUnits(6L));
Table stringHashStringRangeTable = dynamoDB.createTable(request);
stringHashStringRangeTable.waitForActive();
attributeDefinitions = new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition().withAttributeName("hashN").withAttributeType("N"));
attributeDefinitions.add(new AttributeDefinition().withAttributeName("rangeN").withAttributeType("N"));
keySchema = new ArrayList<KeySchemaElement>();
keySchema.add(new KeySchemaElement().withAttributeName("hashN").withKeyType(KeyType.HASH));
keySchema.add(new KeySchemaElement().withAttributeName("rangeN").withKeyType(KeyType.RANGE));
request = new CreateTableRequest().withTableName(numberHashNumberRangeTableName).withKeySchema(keySchema).withAttributeDefinitions(attributeDefinitions).withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(5L).withWriteCapacityUnits(6L));
Table numberHashNumberRangeTable = dynamoDB.createTable(request);
numberHashNumberRangeTable.waitForActive();
attributeDefinitions = new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition().withAttributeName("hashN").withAttributeType("N"));
keySchema = new ArrayList<KeySchemaElement>();
keySchema.add(new KeySchemaElement().withAttributeName("hashN").withKeyType(KeyType.HASH));
request = new CreateTableRequest().withTableName(numberHashOnlyTableName).withKeySchema(keySchema).withAttributeDefinitions(attributeDefinitions).withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(5L).withWriteCapacityUnits(6L));
Table numberHashOnlyTable = dynamoDB.createTable(request);
numberHashOnlyTable.waitForActive();
}
use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput in project amos-ss17-alexa by c-i-ber.
the class DynamoDbMapper method createTable.
/**
* creates a new table by a pojo class
*
* @param cl class which will be mapped to the new table
*/
public void createTable(Class cl) throws InterruptedException {
CreateTableRequest tableRequest = mapper.generateCreateTableRequest(cl);
tableRequest.setProvisionedThroughput(new ProvisionedThroughput(1L, 1L));
Table table = dynamoDB.createTable(tableRequest);
table.waitForActive();
}
use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput in project wildfly-camel by wildfly-extras.
the class DynamoDBUtils method createTable.
public static TableDescription createTable(AmazonDynamoDB client, String tableName) throws InterruptedException {
CreateTableRequest tableReq = new CreateTableRequest().withTableName(tableName).withKeySchema(new KeySchemaElement("Id", KeyType.HASH)).withAttributeDefinitions(new AttributeDefinition("Id", ScalarAttributeType.N)).withProvisionedThroughput(new ProvisionedThroughput(10L, 10L)).withStreamSpecification(new StreamSpecification().withStreamEnabled(true).withStreamViewType(StreamViewType.NEW_AND_OLD_IMAGES));
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.createTable(tableReq);
return table.waitForActive();
}
use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput in project tutorials by eugenp.
the class ProductInfoRepositoryIntegrationTest method setup.
@Before
public void setup() {
try {
repository = new ProductInfoRepository();
repository.setMapper(dynamoDBMapper);
CreateTableRequest tableRequest = dynamoDBMapper.generateCreateTableRequest(ProductInfo.class);
tableRequest.setProvisionedThroughput(new ProvisionedThroughput(1L, 1L));
amazonDynamoDB.createTable(tableRequest);
} catch (ResourceInUseException e) {
// Do nothing, table already created
}
// TODO How to handle different environments. i.e. AVOID deleting all entries in ProductInfo on table
dynamoDBMapper.batchDelete((List<ProductInfo>) repository.findAll());
}
use of com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput in project spring-integration-aws by spring-projects.
the class DynamoDbMetaDataStore method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
try {
this.table.describe();
this.createTableLatch.countDown();
return;
} catch (ResourceNotFoundException e) {
if (logger.isInfoEnabled()) {
logger.info("No table '" + this.table.getTableName() + "'. Creating one...");
}
}
CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(this.table.getTableName()).withKeySchema(new KeySchemaElement(KEY, KeyType.HASH)).withAttributeDefinitions(new AttributeDefinition(KEY, ScalarAttributeType.S)).withProvisionedThroughput(new ProvisionedThroughput(this.readCapacity, this.writeCapacity));
this.dynamoDB.createTableAsync(createTableRequest, new AsyncHandler<CreateTableRequest, CreateTableResult>() {
@Override
public void onError(Exception e) {
logger.error("Cannot create DynamoDb table: " + DynamoDbMetaDataStore.this.table.getTableName(), e);
DynamoDbMetaDataStore.this.createTableLatch.countDown();
}
@Override
public void onSuccess(CreateTableRequest request, CreateTableResult createTableResult) {
Waiter<DescribeTableRequest> waiter = DynamoDbMetaDataStore.this.dynamoDB.waiters().tableExists();
WaiterParameters<DescribeTableRequest> waiterParameters = new WaiterParameters<>(new DescribeTableRequest(DynamoDbMetaDataStore.this.table.getTableName())).withPollingStrategy(new PollingStrategy(new MaxAttemptsRetryStrategy(DynamoDbMetaDataStore.this.createTableRetries), new FixedDelayStrategy(DynamoDbMetaDataStore.this.createTableDelay)));
waiter.runAsync(waiterParameters, new WaiterHandler<DescribeTableRequest>() {
@Override
public void onWaitSuccess(DescribeTableRequest request) {
DynamoDbMetaDataStore.this.createTableLatch.countDown();
DynamoDbMetaDataStore.this.table.describe();
}
@Override
public void onWaitFailure(Exception e) {
logger.error("Cannot describe DynamoDb table: " + DynamoDbMetaDataStore.this.table.getTableName(), e);
DynamoDbMetaDataStore.this.createTableLatch.countDown();
}
});
}
});
}
Aggregations