List of usage examples for com.amazonaws.services.dynamodbv2.model GlobalSecondaryIndex setProvisionedThroughput
public void setProvisionedThroughput(ProvisionedThroughput provisionedThroughput)
Represents the provisioned throughput settings for the specified global secondary index.
From source file:org.openhab.persistence.dynamodb.internal.DynamoDBPersistenceService.java
License:Open Source License
/** * Create table (if not present) and wait for table to become active. * * Synchronized in order to ensure that at most single thread is creating the table at a time * * @param mapper// w w w . j a va 2 s. c om * @param dtoClass * @return whether table creation succeeded. */ private synchronized boolean createTable(DynamoDBMapper mapper, Class<?> dtoClass) { if (db == null) { return false; } String tableName; try { ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput(dbConfig.getReadCapacityUnits(), dbConfig.getWriteCapacityUnits()); CreateTableRequest request = mapper.generateCreateTableRequest(dtoClass); request.setProvisionedThroughput(provisionedThroughput); if (request.getGlobalSecondaryIndexes() != null) { for (GlobalSecondaryIndex index : request.getGlobalSecondaryIndexes()) { index.setProvisionedThroughput(provisionedThroughput); } } tableName = request.getTableName(); try { db.getDynamoClient().describeTable(tableName); } catch (ResourceNotFoundException e) { // No table present, continue with creation db.getDynamoClient().createTable(request); } catch (AmazonClientException e) { logger.error("Table creation failed due to error in describeTable operation", e); return false; } // table found or just created, wait return waitForTableToBecomeActive(tableName); } catch (AmazonClientException e) { logger.error("Exception when creating table", e); return false; } }
From source file:org.xmlsh.aws.util.AWSDDBCommand.java
License:BSD License
protected GlobalSecondaryIndex parseGlobalSecondaryIndex(XValue xv) throws InvalidArgumentException, UnexpectedException { if (!xv.isXdmNode()) throw new InvalidArgumentException( "Unexpected argument type for global secondary index: " + xv.describe()); GlobalSecondaryIndex gi = new GlobalSecondaryIndex(); gi.setIndexName(xv.xpath(getShell(), "./@name").toString()); gi.setKeySchema(parseKeySchemaList(xv.xpath(getShell(), "./key-schema"))); gi.setProjection(parseProjection(xv.xpath(getShell(), "./projection"))); gi.setProvisionedThroughput(parseProvisionedThroughput(xv.xpath(getShell(), "./provisioned-throughput"))); return gi;/* www. j av a 2 s . co m*/ }