当前位置: 首页>>代码示例>>Java>>正文


Java ProvisionedThroughput类代码示例

本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput的典型用法代码示例。如果您正苦于以下问题:Java ProvisionedThroughput类的具体用法?Java ProvisionedThroughput怎么用?Java ProvisionedThroughput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProvisionedThroughput类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了ProvisionedThroughput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constructCreateTableRequest

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
public CreateTableRequest constructCreateTableRequest() {
    ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition().withAttributeName(partitionKeyName.toString()).withAttributeType("S"));
    attributeDefinitions.add(new AttributeDefinition().withAttributeName(sortKeyName.toString()).withAttributeType("N"));

    ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
    keySchema.add(new KeySchemaElement().withAttributeName(partitionKeyName.toString()).withKeyType(KeyType.HASH));
    keySchema.add(new KeySchemaElement().withAttributeName(sortKeyName.toString()).withKeyType(KeyType.RANGE));

    ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
            .withReadCapacityUnits(1L)
            .withWriteCapacityUnits(1L);
    CreateTableRequest request = new CreateTableRequest()
            .withTableName(tableName)
            .withKeySchema(keySchema)
            .withAttributeDefinitions(attributeDefinitions)
            .withProvisionedThroughput(provisionedThroughput);
    return request;
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:20,代码来源:GenericDynamoDB.java

示例2: createRecipientTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的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);
    }
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:20,代码来源:CloudNoticeDAO.java

示例3: closeStorage

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的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));
}
 
开发者ID:orbit,项目名称:orbit-dynamodb,代码行数:21,代码来源:DynamoDBPersistenceTest.java

示例4: createTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
protected Table createTable(CreateTableRequest request) throws InterruptedException {
  DynamoDB dynamoDB = new DynamoDB(tables.getAsyncClient());
  request.withProvisionedThroughput(new ProvisionedThroughput()
    .withReadCapacityUnits(5L)
    .withWriteCapacityUnits(6L));

  if (request.getTableName() == null) {
    String tableName = tables.getTestTableName();
    tableName = tableName.replace('-', '_');
    request.setTableName(tableName);
  }

  Table table = dynamoDB.createTable(request);
  table.waitForActive();
  return table;
}
 
开发者ID:fineoio,项目名称:drill-dynamo-adapter,代码行数:17,代码来源:BaseDynamoTest.java

示例5: deploy

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的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);

    }
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:20,代码来源:DatabaseDeployer.java

示例6: setUp

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
@Before
public void setUp() {
    // Unique table for each run
    tableName = "table" + String.valueOf(tableCount++);
    dynamoDB.getDynamoDbClient().createTable(
        new CreateTableRequest()
            .withTableName(tableName)
            .withKeySchema(new KeySchemaElement("id", "HASH"))
            .withAttributeDefinitions(
                new AttributeDefinition("id", "S")
            )
            .withProvisionedThroughput(
                new ProvisionedThroughput(1L, 1L)
            )
    );

    locker = new DynamoDbLocker(
        new DynamoDB(dynamoDB.getDynamoDbClient()),
        tableName,
        Clock.systemUTC()
    );
}
 
开发者ID:vvondra,项目名称:fleet-cron,代码行数:23,代码来源:DynamoDbLockerTest.java

示例7: scaleTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
private String scaleTable(String tableName, Long readCapacity, Long writeCapacity)
{
    Table table = dynamoDB.getTable(tableName);
    ProvisionedThroughput tp = new ProvisionedThroughput();
    tp.setReadCapacityUnits(readCapacity);
    tp.setWriteCapacityUnits(writeCapacity);
    TableDescription d = table.describe();
    if (!Objects.equals(d.getProvisionedThroughput().getReadCapacityUnits(), readCapacity)
        || !Objects.equals(d.getProvisionedThroughput().getWriteCapacityUnits(), writeCapacity))
    {
        d = table.updateTable(tp);
        return tableName + "\nRequested read/write : " + readCapacity + "/" + writeCapacity
               + "\nCurrent read/write :" + d.getProvisionedThroughput().getReadCapacityUnits() + "/" + d.getProvisionedThroughput().getWriteCapacityUnits()
               + "\nStatus : " + d.getTableStatus() + "\n";
    }
    else
    {
        return tableName + "\n Requested throughput equals current throughput\n";
    }
}
 
开发者ID:dhorions,项目名称:lambdaDynamodbScaler,代码行数:21,代码来源:Scaler.java

示例8: createIdentityTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
/**
 * Used to create the Identity Table. This function only needs to be called
 * once.
 */
protected void createIdentityTable() throws DataAccessException {
    ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
            .withReadCapacityUnits(10L)
            .withWriteCapacityUnits(5L);

    ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions
            .add(new AttributeDefinition().withAttributeName(ATTRIBUTE_USERNAME).withAttributeType("S"));

    ArrayList<KeySchemaElement> tableKeySchema = new ArrayList<KeySchemaElement>();
    tableKeySchema.add(new KeySchemaElement().withAttributeName(ATTRIBUTE_USERNAME).withKeyType(KeyType.HASH));

    CreateTableRequest createTableRequest = new CreateTableRequest()
            .withTableName(USER_TABLE)
            .withProvisionedThroughput(provisionedThroughput)
            .withAttributeDefinitions(attributeDefinitions)
            .withKeySchema(tableKeySchema);

    try {
        ddb.createTable(createTableRequest);
    } catch (AmazonClientException e) {
        throw new DataAccessException("Failed to create table: " + USER_TABLE, e);
    }
}
 
开发者ID:awslabs,项目名称:amazon-cognito-developer-authentication-sample,代码行数:29,代码来源:UserAuthentication.java

示例9: createDeviceTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
/**
 * Used to create the device table. This function only needs to be called
 * once.
 */
protected void createDeviceTable() throws DataAccessException {
    ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
            .withReadCapacityUnits(10L)
            .withWriteCapacityUnits(5L);

    ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions.add(new AttributeDefinition().withAttributeName(
            ATTRIBUTE_UID).withAttributeType("S"));

    ArrayList<KeySchemaElement> tableKeySchema = new ArrayList<KeySchemaElement>();
    tableKeySchema.add(new KeySchemaElement().withAttributeName(ATTRIBUTE_UID)
            .withKeyType(KeyType.HASH));

    CreateTableRequest createTableRequest = new CreateTableRequest()
            .withTableName(DEVICE_TABLE)
            .withProvisionedThroughput(provisionedThroughput)
            .withAttributeDefinitions(attributeDefinitions)
            .withKeySchema(tableKeySchema);

    try {
        ddb.createTable(createTableRequest);
    } catch (AmazonClientException e) {
        throw new DataAccessException("Failed to create table: " + DEVICE_TABLE, e);
    }
}
 
开发者ID:awslabs,项目名称:amazon-cognito-developer-authentication-sample,代码行数:30,代码来源:DeviceAuthentication.java

示例10: createTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
public void createTable(Class<? extends IDomain> domain){
    CreateTableRequest tableRequest = dynamoDBMapper.generateCreateTableRequest(domain);
    tableRequest = tableRequest.withProvisionedThroughput(new ProvisionedThroughput(5L,5L));

    //check whether or not we need to add a provisioning throughput value for GSI
    for (Method method : domain.getMethods()) {
        if(method.isAnnotationPresent(DynamoDBIndexHashKey.class)){
            String tempGSI = method.getAnnotation(DynamoDBIndexHashKey.class).globalSecondaryIndexName();
            for (GlobalSecondaryIndex globalSecondaryIndex : tableRequest.getGlobalSecondaryIndexes()) {
                if(globalSecondaryIndex.getIndexName().equals(tempGSI)){
                    globalSecondaryIndex.setProvisionedThroughput(new ProvisionedThroughput(5L,5L));
                }
            }
        }
    }

    amazonDynamoDBClient.createTable(tableRequest);
}
 
开发者ID:nfscan,项目名称:nfscan,代码行数:19,代码来源:BaseDatabaseControllerTest.java

示例11: createTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
public void createTable() {
  List<KeySchemaElement> keySchema = new ArrayList<>();

  keySchema.add(
      new KeySchemaElement()
          .withAttributeName(sequenceNumber.getAttributeName())
          .withKeyType(KeyType.HASH)
  );

  ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput();
  provisionedThroughput.setReadCapacityUnits(10L);
  provisionedThroughput.setWriteCapacityUnits(10L);

  CreateTableRequest request = new CreateTableRequest()
      .withTableName("example_table")
      .withKeySchema(keySchema)
      .withAttributeDefinitions(singleton(sequenceNumber))
      .withProvisionedThroughput(provisionedThroughput);

  client.createTable(request);
}
 
开发者ID:mlk,项目名称:AssortmentOfJUnitRules,代码行数:22,代码来源:DynamoExample.java

示例12: createTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的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;
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:23,代码来源:AmazonDynamoDBStubTest.java

示例13: test_updateTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
@Test
public void test_updateTable() throws Exception {
  createTable();

  DescribeTableResult describeResult = dynamoDb.describeTable(TEST_TABLE_NAME);
  Long readUnits = describeResult.getTable().getProvisionedThroughput().getReadCapacityUnits();

  assertThat(readUnits, equalTo(UNITS));

  UpdateTableResult updateResult = dynamoDb.updateTable(TEST_TABLE_NAME, new ProvisionedThroughput()
    .withReadCapacityUnits(new Long(200))
    .withWriteCapacityUnits(new Long(200)));
  String tableName = updateResult.getTableDescription().getTableName();

  assertThat(tableName, equalTo(TEST_TABLE_NAME));

  ListTablesResult listResult = listTables();

  describeResult = dynamoDb.describeTable(TEST_TABLE_NAME);
  readUnits = describeResult.getTable().getProvisionedThroughput().getReadCapacityUnits();

  assertThat(readUnits, equalTo(new Long(200)));
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:24,代码来源:AmazonDynamoDBStubTest.java

示例14: createTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的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;
}
 
开发者ID:Erudika,项目名称:para,代码行数:31,代码来源:AWSDynamoUtils.java

示例15: updateTable

import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; //导入依赖的package包/类
/**
 * Updates the table settings (read and write capacities).
 * @param appid name of the {@link com.erudika.para.core.App}
 * @param readCapacity read capacity
 * @param writeCapacity write capacity
 * @return true if updated
 */
public static boolean updateTable(String appid, long readCapacity, long writeCapacity) {
	if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid)) {
		return false;
	}
	String table = getTableNameForAppid(appid);
	try {
		// AWS throws an exception if the new read/write capacity values are the same as the current ones
		getClient().updateTable(new UpdateTableRequest().withTableName(table).
				withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity)));
		return true;
	} catch (Exception e) {
		logger.error("Could not update table '{}' - table is not active or no change to capacity: {}",
				table, e.getMessage());
	}
	return false;
}
 
开发者ID:Erudika,项目名称:para,代码行数:24,代码来源:AWSDynamoUtils.java


注:本文中的com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。