本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.ScalarAttributeType类的典型用法代码示例。如果您正苦于以下问题:Java ScalarAttributeType类的具体用法?Java ScalarAttributeType怎么用?Java ScalarAttributeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScalarAttributeType类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了ScalarAttributeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRecipientTable
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
private void createRecipientTable() {
CreateTableRequest request
= new CreateTableRequest()
.withTableName(TABLE_NAME)
.withAttributeDefinitions(
new AttributeDefinition("_id", ScalarAttributeType.S)
)
.withKeySchema(
new KeySchemaElement("_id", KeyType.HASH)
)
.withProvisionedThroughput(new ProvisionedThroughput(10L, 10L));
ddb.createTable(request);
try {
TableUtils.waitUntilActive(ddb, TABLE_NAME);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
示例2: closeStorage
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
@Override
public void closeStorage()
{
try
{
dynamoDBConnection.getDynamoClient().describeTable(getTableName());
dynamoDBConnection.getDynamoClient().deleteTable(getTableName());
}
catch(ResourceNotFoundException e)
{
}
dynamoDBConnection.getDynamoDB().createTable(getTableName(),
Collections.singletonList(
new KeySchemaElement("_id", KeyType.HASH)),
Collections.singletonList(
new AttributeDefinition("_id", ScalarAttributeType.S)),
new ProvisionedThroughput(1L, 1L));
}
示例3: createHashAndSortTable
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
protected Table createHashAndSortTable(String pk, String sort) throws InterruptedException {
ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<>();
ScalarAttributeType type = ScalarAttributeType.S;
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName(pk).withAttributeType(type));
attributeDefinitions
.add(new AttributeDefinition().withAttributeName(sort).withAttributeType(type));
ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
keySchema.add(new KeySchemaElement().withAttributeName(pk).withKeyType(KeyType.HASH));
keySchema.add(new KeySchemaElement().withAttributeName(sort).withKeyType(KeyType.RANGE));
CreateTableRequest request = new CreateTableRequest()
.withKeySchema(keySchema)
.withAttributeDefinitions(attributeDefinitions);
return createTable(request);
}
示例4: deploy
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
public void deploy() {
final AttributeDefinition idAttr = new AttributeDefinition().withAttributeName("id")
.withAttributeType(ScalarAttributeType.S);
final ProvisionedThroughput throughput = new ProvisionedThroughput().withReadCapacityUnits(5L)
.withWriteCapacityUnits(5L);
final KeySchemaElement idKey = new KeySchemaElement().withAttributeName("id").withKeyType(KeyType.HASH);
final CreateTableRequest createTableRequest = new CreateTableRequest().withTableName("TranslateSlack")
.withAttributeDefinitions(idAttr)
.withKeySchema(idKey)
.withProvisionedThroughput(throughput);
;
;
ddb.createTable(createTableRequest);
}
示例5: getTableSchema
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
@Override
public CreateTableRequest getTableSchema() {
return super.getTableSchema()
.withAttributeDefinitions(
new AttributeDefinition()
.withAttributeName(Constants.JANUSGRAPH_HASH_KEY)
.withAttributeType(ScalarAttributeType.S),
new AttributeDefinition()
.withAttributeName(Constants.JANUSGRAPH_RANGE_KEY)
.withAttributeType(ScalarAttributeType.S))
.withKeySchema(
new KeySchemaElement()
.withAttributeName(Constants.JANUSGRAPH_HASH_KEY)
.withKeyType(KeyType.HASH),
new KeySchemaElement()
.withAttributeName(Constants.JANUSGRAPH_RANGE_KEY)
.withKeyType(KeyType.RANGE));
}
示例6: createTable
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
private CreateTableResult createTable() throws Exception {
List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
AttributeDefinition attributeDefinition = new AttributeDefinition()
.withAttributeName(TEST_ATTRIBUTE)
.withAttributeType(ScalarAttributeType.S);
attributeDefinitions.add(attributeDefinition);
String tableName = TEST_TABLE_NAME;
List<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
KeySchemaElement keySchemaElement = new KeySchemaElement()
.withAttributeName(TEST_ATTRIBUTE)
.withKeyType(KeyType.HASH);
ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
.withReadCapacityUnits(UNITS)
.withWriteCapacityUnits(UNITS);
CreateTableResult result = dynamoDb.createTable(attributeDefinitions, tableName, keySchema, provisionedThroughput);
return result;
}
示例7: createTable
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
/**
* Creates a table in AWS DynamoDB.
* @param appid name of the {@link com.erudika.para.core.App}
* @param readCapacity read capacity
* @param writeCapacity write capacity
* @return true if created
*/
public static boolean createTable(String appid, long readCapacity, long writeCapacity) {
if (StringUtils.isBlank(appid)) {
return false;
} else if (StringUtils.containsWhitespace(appid)) {
logger.warn("DynamoDB table name contains whitespace. The name '{}' is invalid.", appid);
return false;
} else if (existsTable(appid)) {
logger.warn("DynamoDB table '{}' already exists.", appid);
return false;
}
try {
String table = getTableNameForAppid(appid);
getClient().createTable(new CreateTableRequest().withTableName(table).
withKeySchema(new KeySchemaElement(Config._KEY, KeyType.HASH)).
withAttributeDefinitions(new AttributeDefinition(Config._KEY, ScalarAttributeType.S)).
withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity)));
logger.info("Created DynamoDB table '{}'.", table);
} catch (Exception e) {
logger.error(null, e);
return false;
}
return true;
}
示例8: createStoreIfAbsent
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
@Override
public void createStoreIfAbsent(String storeName, boolean bBinaryValues) {
String tableName = storeToTableName(storeName);
if (!Tables.doesTableExist(m_ddbClient, tableName)) {
// Create a table with a primary hash key named '_key', which holds a string
m_logger.info("Creating table: {}", tableName);
CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName)
.withKeySchema(new KeySchemaElement()
.withAttributeName(ROW_KEY_ATTR_NAME)
.withKeyType(KeyType.HASH))
.withAttributeDefinitions(new AttributeDefinition()
.withAttributeName(ROW_KEY_ATTR_NAME)
.withAttributeType(ScalarAttributeType.S))
.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(READ_CAPACITY_UNITS)
.withWriteCapacityUnits(WRITE_CAPACITY_UNITS));
m_ddbClient.createTable(createTableRequest).getTableDescription();
try {
Tables.awaitTableToBecomeActive(m_ddbClient, tableName);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
示例9: main
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
String tableName = "Movies";
Table table = dynamoDB.createTable(tableName,
Arrays.asList(
new KeySchemaElement("year", KeyType.HASH),
new KeySchemaElement("title", KeyType.RANGE)),
Arrays.asList(
new AttributeDefinition("year", ScalarAttributeType.N),
new AttributeDefinition("title", ScalarAttributeType.S)),
new ProvisionedThroughput(10L, 10L));
try {
TableUtils.waitUntilActive(client, tableName);
System.out.println("Table status: " + table.getDescription().getTableStatus());
} catch (AmazonClientException e) {
e.printStackTrace();
System.exit(1);
}
}
示例10: createTable
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
private static CreateTableResult createTable(AmazonDynamoDB ddb, String tableName, String hashKeyName) {
List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition(hashKeyName, ScalarAttributeType.S));
List<KeySchemaElement> ks = new ArrayList<KeySchemaElement>();
ks.add(new KeySchemaElement(hashKeyName, KeyType.HASH));
ProvisionedThroughput provisionedthroughput = new ProvisionedThroughput(1000L, 1000L);
CreateTableRequest request =
new CreateTableRequest()
.withTableName(tableName)
.withAttributeDefinitions(attributeDefinitions)
.withKeySchema(ks)
.withProvisionedThroughput(provisionedthroughput);
return ddb.createTable(request);
}
示例11: initializeHashAndRangeTable
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
private void initializeHashAndRangeTable(String name, String hashName, String rangeName) {
String tableName = quartzPrefix + name;
if (!tableExists(tableName)) {
log.info(String.format("Creating table '%s' with hash and range index.", tableName));
CreateTableRequest request = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(
new KeySchemaElement().withKeyType(KeyType.HASH).withAttributeName(hashName),
new KeySchemaElement().withKeyType(KeyType.RANGE).withAttributeName(rangeName))
.withAttributeDefinitions(
new AttributeDefinition(hashName, ScalarAttributeType.S),
new AttributeDefinition(rangeName, ScalarAttributeType.S))
.withProvisionedThroughput(new ProvisionedThroughput(1L, 1L));
client.createTable(request);
waitForTable(tableName);
} else {
log.info(String.format("Table '%s' already exists.", tableName));
}
}
示例12: initializeHashTable
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
private void initializeHashTable(String name, String hashName) {
String tableName = quartzPrefix + name;
if (!tableExists(tableName)) {
log.info(String.format("Creating table '%s' with hash index.", tableName));
CreateTableRequest request = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(
new KeySchemaElement().withKeyType(KeyType.HASH).withAttributeName(hashName))
.withAttributeDefinitions(
new AttributeDefinition(hashName, ScalarAttributeType.S))
.withProvisionedThroughput(new ProvisionedThroughput(1L, 1L));
client.createTable(request);
waitForTable(tableName);
} else {
log.info(String.format("Table '%s' already exists.", tableName));
}
}
示例13: createSessionTable
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
public static void createSessionTable(AmazonDynamoDBClient dynamo,
String tableName,
long readCapacityUnits,
long writeCapacityUnits) {
CreateTableRequest request = new CreateTableRequest().withTableName(tableName);
request.withKeySchema(new KeySchemaElement().withAttributeName(DynamoSessionItem.SESSION_ID_ATTRIBUTE_NAME)
.withKeyType(KeyType.HASH));
request.withAttributeDefinitions(
new AttributeDefinition().withAttributeName(DynamoSessionItem.SESSION_ID_ATTRIBUTE_NAME)
.withAttributeType(ScalarAttributeType.S));
request.setProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(readCapacityUnits)
.withWriteCapacityUnits(writeCapacityUnits));
dynamo.createTable(request);
}
示例14: createTable
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
private CreateTableResult createTable() {
final List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
attributeDefinitions.add(new AttributeDefinition(RESOURCE_NAME_ATT, ScalarAttributeType.S));
attributeDefinitions.add(new AttributeDefinition(RDF_TRIPLE_ATT, ScalarAttributeType.S));
attributeDefinitions.add(new AttributeDefinition(RDF_PREDICATE_ATT, ScalarAttributeType.S));
attributeDefinitions.add(new AttributeDefinition(RDF_OBJECT_ATT, ScalarAttributeType.S));
final List<KeySchemaElement> keySchema = new ArrayList<>();
keySchema.add(new KeySchemaElement(RESOURCE_NAME_ATT, KeyType.HASH));
keySchema.add(new KeySchemaElement(RDF_TRIPLE_ATT, KeyType.RANGE));
final ProvisionedThroughput provisionedthroughput =
new ProvisionedThroughput(10L, 10L);
final LocalSecondaryIndex predicateIndex = new LocalSecondaryIndex()
.withIndexName(PREDICATE_INDEX_NAME)
.withKeySchema(new KeySchemaElement(RESOURCE_NAME_ATT, KeyType.HASH))
.withKeySchema(new KeySchemaElement(RDF_PREDICATE_ATT, KeyType.RANGE))
.withProjection(new Projection().withNonKeyAttributes(RDF_SUBJECT_ATT, RDF_OBJECT_ATT)
.withProjectionType(ProjectionType.INCLUDE));
final GlobalSecondaryIndex objectIndex = new GlobalSecondaryIndex()
.withIndexName(OBJECT_INDEX_NAME)
.withKeySchema(new KeySchemaElement(RDF_OBJECT_ATT, KeyType.HASH))
.withKeySchema(new KeySchemaElement(RDF_PREDICATE_ATT, KeyType.RANGE))
.withProjection(new Projection().withNonKeyAttributes(RDF_SUBJECT_ATT)
.withProjectionType(ProjectionType.INCLUDE))
.withProvisionedThroughput(new ProvisionedThroughput(10L, 10L));
final CreateTableRequest request =
new CreateTableRequest()
.withTableName(TABLE_NAME)
.withAttributeDefinitions(attributeDefinitions)
.withKeySchema(keySchema)
.withProvisionedThroughput(provisionedthroughput)
.withLocalSecondaryIndexes(predicateIndex)
.withGlobalSecondaryIndexes(objectIndex);
return dynamodbClient.createTable(request);
}
示例15: createTicketTables
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; //导入依赖的package包/类
/**
* Create ticket tables.
*
* @param deleteTables the delete tables
*/
public void createTicketTables(final boolean deleteTables) {
final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
metadata.forEach(Unchecked.consumer(r -> {
final CreateTableRequest request = new CreateTableRequest()
.withAttributeDefinitions(new AttributeDefinition(ColumnNames.ID.getName(), ScalarAttributeType.S))
.withKeySchema(new KeySchemaElement(ColumnNames.ID.getName(), KeyType.HASH))
.withProvisionedThroughput(new ProvisionedThroughput(dynamoDbProperties.getReadCapacity(),
dynamoDbProperties.getWriteCapacity()))
.withTableName(r.getProperties().getStorageName());
if (deleteTables) {
final DeleteTableRequest delete = new DeleteTableRequest(r.getProperties().getStorageName());
LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
}
LOGGER.debug("Sending delete request [{}] to create table", request);
TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);
LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());
final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);
final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
}));
}