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


Java Table.waitForActive方法代码示例

本文整理汇总了Java中com.amazonaws.services.dynamodbv2.document.Table.waitForActive方法的典型用法代码示例。如果您正苦于以下问题:Java Table.waitForActive方法的具体用法?Java Table.waitForActive怎么用?Java Table.waitForActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.dynamodbv2.document.Table的用法示例。


在下文中一共展示了Table.waitForActive方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的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

示例2: createTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private void createTable(Class tableClass) {
    CreateTableRequest createTableRequest = mapper.generateCreateTableRequest(tableClass);

    createTableRequest.setProvisionedThroughput(new ProvisionedThroughput(dbReadCapacity, dbWriteCapacity));
    if (tableExists(createTableRequest.getTableName())) {
        LOG.info("Table {} already exists", createTableRequest.getTableName());
        return;
    }
    try {
        DynamoDB dynamoDB = new DynamoDB(amazonDynamoDB);
        Table table = dynamoDB.createTable(createTableRequest);
        LOG.info("Creating table {} ... ", createTableRequest.getTableName());
        table.waitForActive();
        LOG.info("Table {} was created successfully.", createTableRequest.getTableName());
    } catch (Exception e) {
        LOG.error("Failed to create table {}. ", createTableRequest.getTableName());
        LOG.error(e);
        throw new ConfigurationException("Failed to create table" + createTableRequest.getTableName(), e);
    }
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:21,代码来源:InitConfigurationServiceImpl.java

示例3: createTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private static Table createTable(final DynamoDBConnection dynamoDBConnection, final String tableName) throws InterruptedException
{
    final CreateTableRequest createTableRequest = createCreateTableRequest(tableName);

    final Table table = dynamoDBConnection.getDynamoDB().createTable(createTableRequest);

    table.waitForActive();
    return table;
}
 
开发者ID:orbit,项目名称:orbit-dynamodb,代码行数:10,代码来源:DynamoDBUtils.java

示例4: waiterMethodsShouldWorkWithWrapper

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
@Test
public void waiterMethodsShouldWorkWithWrapper() throws InterruptedException {
  DynamoDBClientWithStubbedWaiter subject = new DynamoDBClientWithStubbedWaiter(
      dynamoDbRule.getClient());

  DynamoDB db = new DynamoDB(subject);

  AttributeDefinition id = new AttributeDefinition("id", ScalarAttributeType.S);
  List<KeySchemaElement> keySchema = new ArrayList<>();

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

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

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

  Table result = db.createTable(request);
  TableDescription description = result.waitForActive();

  assertThat(description.getTableName(), is("test_table"));
}
 
开发者ID:mlk,项目名称:AssortmentOfJUnitRules,代码行数:32,代码来源:DynamoDBClientWithStubbedWaiterTest.java

示例5: createTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
@Override
public void createTable(String tableName, String primaryKey) throws Exception {
    try {
        // Create the key schema for the given primary key
        ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
        keySchema.add(new KeySchemaElement()
            .withAttributeName(primaryKey)
            .withKeyType(KeyType.HASH));
        
        // Create the attribute definitions
        ArrayList<AttributeDefinition> attrDefs = new ArrayList<AttributeDefinition>();
        attrDefs.add(new AttributeDefinition()
            .withAttributeName(primaryKey)
            .withAttributeType("N"));

        // Create the table request given the table name, the key schema and the attribute definitios
        CreateTableRequest tableRequest = new CreateTableRequest()
            .withTableName(tableName)
            .withKeySchema(keySchema)
            .withAttributeDefinitions(attrDefs)
            .withProvisionedThroughput(new ProvisionedThroughput()
                .withReadCapacityUnits(5L)
                .withWriteCapacityUnits(5L));

        // Create the table
        LOGGER.debug("Creating DynamoDB table " + tableName);
        Table table = dynamoDB.createTable(tableRequest);

        // Wait until the table is active
        LOGGER.debug("Waiting until the DynamoDB table " + tableName + " becomes active");
        table.waitForActive();
    } catch (Exception e) {
        LOGGER.error("Error while creating the DynamoDB table " + tableName
                + ". Details=" + e.getMessage());
    } // try catch
}
 
开发者ID:telefonicaid,项目名称:fiware-cygnus,代码行数:37,代码来源:DynamoDBBackendImpl.java

示例6: createExampleTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
static void createExampleTable() {

        try {

            ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
            attributeDefinitions.add(new AttributeDefinition()
                .withAttributeName("Id")
                .withAttributeType("N"));

            ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
            keySchema.add(new KeySchemaElement()
                .withAttributeName("Id")
                .withKeyType(KeyType.HASH));

            CreateTableRequest request = new CreateTableRequest()
                .withTableName(tableName)
                .withKeySchema(keySchema)
                .withAttributeDefinitions(attributeDefinitions)
                .withProvisionedThroughput(new ProvisionedThroughput()
                    .withReadCapacityUnits(5L)
                    .withWriteCapacityUnits(6L));

            System.out.println("Issuing CreateTable request for " + tableName);
            Table table = dynamoDB.createTable(request);

            System.out.println("Waiting for " + tableName
                + " to be created...this may take a while...");
            table.waitForActive();

            getTableInformation();

        } catch (Exception e) {
            System.err.println("CreateTable request failed for " + tableName);
            System.err.println(e.getMessage());
        }

    }
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:38,代码来源:DocumentAPITableExample.java

示例7: updateExampleTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
static void updateExampleTable() {

        Table table = dynamoDB.getTable(tableName);
        System.out.println("Modifying provisioned throughput for " + tableName);

        try {
            table.updateTable(new ProvisionedThroughput()
                .withReadCapacityUnits(6L).withWriteCapacityUnits(7L));

            table.waitForActive();
        } catch (Exception e) {
            System.err.println("UpdateTable request failed for " + tableName);
            System.err.println(e.getMessage());
        }
    }
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:16,代码来源:DocumentAPITableExample.java

示例8: createTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
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();
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:12,代码来源:DynamoDBUtils.java

示例9: createTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private void createTable() {
    try {
        final ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
        keySchema.add(new KeySchemaElement()
                .withAttributeName("id")
                .withKeyType(KeyType.HASH));

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

        final ArrayList<GlobalSecondaryIndex> globalSecondaryIndices = new ArrayList<>();

        if (secondaryIndexNames != null) {
            for (final String indexName : secondaryIndexNames) {
                attributeDefinitions.add(new AttributeDefinition()
                        .withAttributeName(indexName)
                        .withAttributeType("S"));

                globalSecondaryIndices.add(new GlobalSecondaryIndex()
                        .withIndexName(indexName + "-index")
                        .withKeySchema(new KeySchemaElement().withAttributeName(indexName).withKeyType(KeyType.HASH))
                        .withProjection(new Projection().withProjectionType(ProjectionType.ALL))
                        .withProvisionedThroughput(new ProvisionedThroughput()
                                .withReadCapacityUnits(readCapacityUnits)
                                .withWriteCapacityUnits(writeCapacityUnits)));
            }
        }

        final CreateTableRequest request = new CreateTableRequest()
                .withTableName(tableName)
                .withKeySchema(keySchema)
                .withProvisionedThroughput(new ProvisionedThroughput()
                        .withReadCapacityUnits(readCapacityUnits)
                        .withWriteCapacityUnits(writeCapacityUnits));

        if (!globalSecondaryIndices.isEmpty()) {
            request.withGlobalSecondaryIndexes(globalSecondaryIndices);
        }

        request.setAttributeDefinitions(attributeDefinitions);

        logger.debug("Issuing CreateTable request for " + tableName);
        final Table table = DynamoCommons.getInstance().getDb().createTable(request);
        logger.debug("Waiting for table to be created...");
        table.waitForActive();

    } catch (final Exception e) {
        logger.error("CreateTable request failed: " + e.getMessage());
    }
}
 
开发者ID:BackendButters,项目名称:AwsCommons,代码行数:53,代码来源:AbstractDynamoTable.java

示例10: loadFromDynamoDB

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
@Test
public void loadFromDynamoDB()
        throws Exception
{
    DynamoDB dynamoDB = new DynamoDB(dynamoClient);

    ArrayList<AttributeDefinition> attributeDefinitions= new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition().withAttributeName("Id").withAttributeType("N"));

    ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
    keySchema.add(new KeySchemaElement().withAttributeName("Id").withKeyType(KeyType.HASH));

    CreateTableRequest request = new CreateTableRequest()
            .withTableName(dynamoTableName)
            .withKeySchema(keySchema)
            .withAttributeDefinitions(attributeDefinitions)
            .withProvisionedThroughput(new ProvisionedThroughput()
                    .withReadCapacityUnits(1L)
                    .withWriteCapacityUnits(1L));

    ImmutableList<Item> items = ImmutableList.of(
            new Item().withPrimaryKey("Id", 0).withString("Name", "foo").withNumber("Score", 3.14f),
            new Item().withPrimaryKey("Id", 1).withString("Name", "bar").withNumber("Score", 1.23f),
            new Item().withPrimaryKey("Id", 2).withString("Name", "baz").withNumber("Score", 5.0f)
    );

    ImmutableList<Map<String, Object>> expected = ImmutableList.of(
            ImmutableMap.of("id", 0, "name", "foo", "score", 3.14f),
            ImmutableMap.of("id", 1, "name", "bar", "score", 1.23f),
            ImmutableMap.of("id", 2, "name", "baz", "score", 5.0f),
            ImmutableMap.of("id", 9, "name", "zzz", "score", 9.99f)
    );

    Table table = null;
    try {
        table = dynamoDB.createTable(request);
        table.waitForActive();

        items.forEach(table::putItem);

        runDigdagWithDynamoDB(configFile, "acceptance/redshift/load_from_dynamodb.dig", redshiftUser, Optional.absent());

        assertTableContents(DEST_TABLE, expected);
    }
    finally {
        if (table != null) {
            table.delete();
            table.waitForDelete();
        }
    }
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:52,代码来源:RedshiftIT.java

示例11: createTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private static void createTable(
    String tableName, long readCapacityUnits, long writeCapacityUnits, 
    String hashKeyName, String hashKeyType, 
    String rangeKeyName, String rangeKeyType) {

    try {

        ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
        keySchema.add(new KeySchemaElement()
            .withAttributeName(hashKeyName)
            .withKeyType(KeyType.HASH));
        
        ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
        attributeDefinitions.add(new AttributeDefinition()
            .withAttributeName(hashKeyName)
            .withAttributeType(hashKeyType));

        if (rangeKeyName != null) {
            keySchema.add(new KeySchemaElement()
                .withAttributeName(rangeKeyName)
                .withKeyType(KeyType.RANGE));
            attributeDefinitions.add(new AttributeDefinition()
                .withAttributeName(rangeKeyName)
                .withAttributeType(rangeKeyType));
        }

        CreateTableRequest request = new CreateTableRequest()
                .withTableName(tableName)
                .withKeySchema(keySchema)
                .withProvisionedThroughput( new ProvisionedThroughput()
                    .withReadCapacityUnits(readCapacityUnits)
                    .withWriteCapacityUnits(writeCapacityUnits));

        // If this is the Reply table, define a local secondary index
        if (replyTableName.equals(tableName)) {
            
            attributeDefinitions.add(new AttributeDefinition()
                .withAttributeName("PostedBy")
                .withAttributeType("S"));

            ArrayList<LocalSecondaryIndex> localSecondaryIndexes = new ArrayList<LocalSecondaryIndex>();
            localSecondaryIndexes.add(new LocalSecondaryIndex()
                .withIndexName("PostedBy-Index")
                .withKeySchema(
                    new KeySchemaElement().withAttributeName(hashKeyName).withKeyType(KeyType.HASH), 
                    new KeySchemaElement() .withAttributeName("PostedBy") .withKeyType(KeyType.RANGE))
                .withProjection(new Projection() .withProjectionType(ProjectionType.KEYS_ONLY)));

            request.setLocalSecondaryIndexes(localSecondaryIndexes);
        }

        request.setAttributeDefinitions(attributeDefinitions);

        System.out.println("Issuing CreateTable request for " + tableName);
        Table table = dynamoDB.createTable(request);
        System.out.println("Waiting for " + tableName
            + " to be created...this may take a while...");
        table.waitForActive();

    } catch (Exception e) {
        System.err.println("CreateTable request failed for " + tableName);
        System.err.println(e.getMessage());
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:65,代码来源:CreateTablesLoadData.java

示例12: createTable

import com.amazonaws.services.dynamodbv2.document.Table; //导入方法依赖的package包/类
private static void createTable(
    String tableName, long readCapacityUnits, long writeCapacityUnits,
    String hashKeyName, String hashKeyType, 
    String rangeKeyName, String rangeKeyType) {
    
    try {
        System.out.println("Creating table " + tableName);
        
        List<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
        keySchema.add(new KeySchemaElement()
            .withAttributeName(hashKeyName)
            .withKeyType(KeyType.HASH));
        
        List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
        attributeDefinitions.add(new AttributeDefinition()
            .withAttributeName(hashKeyName)
            .withAttributeType(hashKeyType));

        if (rangeKeyName != null){
            keySchema.add(new KeySchemaElement()
                .withAttributeName(rangeKeyName)
                .withKeyType(KeyType.RANGE));
            attributeDefinitions.add(new AttributeDefinition()
                  .withAttributeName(rangeKeyName)
                  .withAttributeType(rangeKeyType));
        }

        Table table = dynamoDB.createTable(tableName, 
            keySchema,
            attributeDefinitions, 
            new ProvisionedThroughput()
                .withReadCapacityUnits(readCapacityUnits)
                .withWriteCapacityUnits(writeCapacityUnits));
        System.out.println("Waiting for " + tableName
            + " to be created...this may take a while...");
        table.waitForActive();
   
        
    } catch (Exception e) {
        System.err.println("Failed to create table " + tableName);
        e.printStackTrace(System.err);
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:44,代码来源:DocumentAPIParallelScan.java


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