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


Java TableStatus类代码示例

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


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

示例1: testCreateTableWithWait

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
@Test
public void testCreateTableWithWait() throws Exception {
    // Create fake responses from AWS. First response is still creating the table, second response the table
    // has become active.
    TableDescription creatingDescription = constructTableDescription(TableStatus.CREATING);
    TableDescription createdDescription = constructTableDescription(TableStatus.ACTIVE);
    CreateTableResult mockCreateResult = new CreateTableResult().withTableDescription(creatingDescription);
    DescribeTableResult mockDescribeResultCreating = new DescribeTableResult().withTable(creatingDescription);
    DescribeTableResult mockDescribeResultCreated = new DescribeTableResult().withTable(createdDescription);

    // Create the table.
    CreateTableRequest expectedRequest = dynamoDB.constructCreateTableRequest();
    when(mockDynamoDBClient.createTable(expectedRequest)).thenReturn(mockCreateResult);
    when(mockDynamoDBClient.describeTable(tableName)).thenReturn(mockDescribeResultCreating, mockDescribeResultCreated);
    assertEquals(dynamoDB.create(), TEST_ARN);

    verify(mockDynamoDBClient, times(1)).createTable(expectedRequest);
    verify(mockDynamoDBClient, times(2)).describeTable(tableName);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:20,代码来源:GenericDynamoDBTest.java

示例2: waitForActiveTableStatus

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private static Task<TableDescription> waitForActiveTableStatus(final DynamoDBConnection dynamoDBConnection, final String tableName)
{
    try
    {
        for (int i = 0; i < WAITING_FOR_ACTIVE_TABLE_STATUS_MAX_ATTEMPTS; i++)
        {
            final DescribeTableResult describe = dynamoDBConnection.getDynamoClient().describeTable(tableName);
            if (describe.getTable().getTableStatus().equals(TableStatus.ACTIVE.name()))
            {
                return Task.fromValue(describe.getTable());
            }

            Thread.sleep(WAITING_FOR_ACTIVE_TABLE_STATUS_RETRY_DELAY_MILLIS);
        }

    }
    catch (InterruptedException e)
    {
        throw new UncheckedException(e);
    }

    throw new UncheckedException("Hit max retry attempts while waiting for table to become active: " + tableName);
}
 
开发者ID:orbit,项目名称:orbit-dynamodb,代码行数:24,代码来源:DynamoDBUtils.java

示例3: ensureTableIsActive

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private void ensureTableIsActive(final String tableName)
{
    try
    {
        while (true)
        {
            final DescribeTableResult describe = dynamoDBConnection.getDynamoClient().describeTable(tableName);
            if (describe.getTable().getTableStatus().equals(TableStatus.ACTIVE.name()))
            {
                return;
            }

            Thread.sleep(500);
        }

    }
    catch (InterruptedException e)
    {
        throw new UncheckedException(e);
    }
}
 
开发者ID:orbit,项目名称:orbit-dynamodb,代码行数:22,代码来源:DynamoDBPersistenceTest.java

示例4: describeTable

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
@Override
public DescribeTableResult describeTable(DescribeTableRequest describeTableRequest) {
    this.describeTableRequest = describeTableRequest;
    String tableName = describeTableRequest.getTableName();
    if ("activeTable".equals(tableName)) {
        return tableWithStatus(TableStatus.ACTIVE);
    } else if ("creatibleTable".equals(tableName) && createTableRequest != null) {
        return tableWithStatus(TableStatus.ACTIVE);
    } else if ("FULL_DESCRIBE_TABLE".equals(tableName)) {
        return new DescribeTableResult().withTable(new TableDescription()
                .withTableName(tableName)
                .withTableStatus(TableStatus.ACTIVE)
                .withCreationDateTime(new Date(NOW))
                .withItemCount(100L)
                .withKeySchema(new KeySchemaElement().withAttributeName("name"))
                .withProvisionedThroughput(new ProvisionedThroughputDescription()
                        .withReadCapacityUnits(20L)
                        .withWriteCapacityUnits(10L))
                .withTableSizeBytes(1000L));
    }
    throw new ResourceNotFoundException(tableName + " is missing");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:AmazonDDBClientMock.java

示例5: waitForStatus

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private void waitForStatus(String tableName, TableStatus status) {
    logger.info("Waiting for " + tableName + " to become " + status.toString() + "...");

    long startTime = System.currentTimeMillis();
    long endTime = startTime + (10 * 60 * 1000);
    while (System.currentTimeMillis() < endTime) {
        try {
            Thread.sleep(1000 * 2);
        } catch (Exception e) {
        }
        try {
            DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName);
            TableDescription tableDescription = dynamoDb.describeTable(request).getTable();
            String tableStatus = tableDescription.getTableStatus();
            logger.debug("  - current state: " + tableStatus);
            if (tableStatus.equals(status.toString()))
                return;
        } catch (AmazonServiceException ase) {
            if (ase.getErrorCode().equalsIgnoreCase("ResourceNotFoundException") == false)
                throw ase;
        }
    }

    throw new RuntimeException("Table " + tableName + " never went " + status.toString());
}
 
开发者ID:intuit,项目名称:Tank,代码行数:26,代码来源:AmazonDynamoDatabaseDocApi.java

示例6: waitForTableToBecomeAvailable

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private void waitForTableToBecomeAvailable(String tableName) {
    System.out.println("Waiting for " + tableName + " to become ACTIVE...");
    long startTime = System.currentTimeMillis();
    long endTime = startTime + (10 * 60 * 1000);
    while (System.currentTimeMillis() < endTime) {
        DescribeTableRequest request = new DescribeTableRequest()
                .withTableName(tableName);
        TableDescription tableDescription = client.describeTable(
                request).getTable();
        String tableStatus = tableDescription.getTableStatus();
        System.out.println("  - current state: " + tableStatus);
        if (tableStatus.equals(TableStatus.ACTIVE.toString()))
            return;
        try { Thread.sleep(1000 * 20); } catch (Exception e) { }
    }
    throw new RuntimeException("Table " + tableName + " never went active");
}
 
开发者ID:awslabs,项目名称:dynamodb-online-index-violation-detector,代码行数:18,代码来源:TableManager.java

示例7: waitForTableAvailable

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private void waitForTableAvailable(String tableName) {
    LOG.info("Waiting for table " + tableName + " to become ACTIVE...");
    
    long startTime = System.currentTimeMillis();
    long endTime = startTime + (10 * 60 * 1000);
    while (System.currentTimeMillis() < endTime) {
        DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(tableName);
        TableDescription tableDescription = dynamoDBClient.describeTable(describeTableRequest).getTable();
        
        // Display current status of table
        String tableStatus = tableDescription.getTableStatus();
        LOG.info("Current state for table " + tableName + ": " + tableStatus);
        if (tableStatus.equals(TableStatus.ACTIVE.toString())) {
            return;
        }
        
        try {
            Thread.sleep(1000 * 20);
        } catch (Exception ex) {
            LOG.warn(ex.getMessage());
        }
    }
    
    throw new RuntimeException("Table " + tableName + " never went active");
}
 
开发者ID:dgks0n,项目名称:milton-aws,代码行数:26,代码来源:DynamoDBServiceImpl.java

示例8: waitForTableState

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
/**
 * Interface which will block until a dynamo table reaches a specified
 * state. Also returns immediately if the object doesn't exist
 * 
 * @param dynamoClient
 *            Dynamo DB Client to use for connection to Dynamo DB.
 * @param dynamoTable
 *            The table name to check.
 * @param status
 *            The status to wait for
 * @throws Exception
 */
private static void waitForTableState(final AmazonDynamoDB dynamoClient,
		final String dynamoTable, TableStatus status) throws Exception {
	DescribeTableResult tableRequest = null;
	while (true) {
		try {
			tableRequest = dynamoClient.describeTable(dynamoTable);
			if (tableRequest.getTable().getTableStatus()
					.equals(status.name()))
				break;

			Thread.sleep(1000);
		} catch (InterruptedException e) {
			return;
		}
	}
}
 
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:29,代码来源:DynamoUtils.java

示例9: waitForTableToBecomeAvailable

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private static void waitForTableToBecomeAvailable(String tableName) {
    System.out.println("Waiting for " + tableName + " to become ACTIVE...");

    long startTime = System.currentTimeMillis();
    long endTime = startTime + (10 * 60 * 1000);
    while (System.currentTimeMillis() < endTime) {
        DescribeTableRequest request = new DescribeTableRequest()
                .withTableName(tableName);
        TableDescription tableDescription = client.describeTable(
                request).getTable();
        String tableStatus = tableDescription.getTableStatus();
        System.out.println("  - current state: " + tableStatus);
        if (tableStatus.equals(TableStatus.ACTIVE.toString()))
            return;
        try { Thread.sleep(1000 * 20); } catch (Exception e) { }
    }
    throw new RuntimeException("Table " + tableName + " never went active");
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:19,代码来源:LowLevelTableExample.java

示例10: waitForTableToBecomeAvailable

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private static void waitForTableToBecomeAvailable(String tableName) {
    System.out.println("Waiting for " + tableName + " to become ACTIVE...");

    long startTime = System.currentTimeMillis();
    long endTime = startTime + (10 * 60 * 1000);

    while (System.currentTimeMillis() < endTime) {
        DescribeTableRequest request = 
            new DescribeTableRequest().withTableName(tableName);
        TableDescription tableDescription = 
            client.describeTable(request).getTable();
        String tableStatus = tableDescription.getTableStatus();

        System.out.println("  - current state: " + tableStatus);

        if (tableStatus.equals(TableStatus.ACTIVE.toString()))
            return;
            try {
                Thread.sleep(1000 * 20);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    throw new RuntimeException("Table " + tableName + " never went active");
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:26,代码来源:LowLevelGlobalSecondaryIndexExample.java

示例11: waitForTable

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private void waitForTable(String name) {
    log.info(String.format("Waiting for creation of table '%s' to complete.", name));
    long startTime = System.currentTimeMillis();
    long endTime = startTime + (10 * 60 * 1000);
    while (System.currentTimeMillis() < endTime) {
        sleep(1000 * 20);
        try {
            DescribeTableRequest request = new DescribeTableRequest().withTableName(name);
            TableDescription tableDescription = client.describeTable(request).getTable();
            String tableStatus = tableDescription.getTableStatus();
            log.info(String.format("Table '%s' is in state: '%s'.", name, tableStatus));
            if (tableStatus.equals(TableStatus.ACTIVE.toString())) {
                return;
            }
        } catch (ResourceNotFoundException e) {
            // nop - maybe the table isn't showing up yet.
        }
    }

    throw new RuntimeException(String.format("Table '%s' never went active.", name));
}
 
开发者ID:mdaley,项目名称:quartz-dynamodb,代码行数:22,代码来源:DynamoDbJobStore.java

示例12: waitForTableToBecomeActive

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private void waitForTableToBecomeActive() {
    int retries = 0;
    String tableStatus = "Unknown";
    try {
        while (retries < MAX_RETRIES) {
            log.info("Waiting for table to become active...");
            Thread.sleep(SLEEP_TIME);
            DescribeTableResult result = client.describeTable(tableName);
            tableStatus = result.getTable().getTableStatus();

            if (tableStatus.equals(TableStatus.ACTIVE.toString()) ||
                    tableStatus.equals(TableStatus.UPDATING.toString())) {
                return;
            }

            if (tableStatus.equals(TableStatus.DELETING.toString())) {
                throw new UnexpectedStateException(
                        tableName, tableStatus, TableStatus.ACTIVE.toString(),
                        "Table state changed to 'DELETING' before creation was confirmed");
            }
            retries++;
        }
    } catch (InterruptedException e) {
        throw new UnexpectedStateException(tableName, tableStatus, TableStatus.ACTIVE.toString(),
                                           "Error occurred while waiting for DynamoDB table", e);
    }
    throw new UnexpectedStateException(tableName, tableStatus, TableStatus.ACTIVE.toString(),
                                       "DynamoDB table did not become active before timeout");
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:30,代码来源:GenericDynamoDB.java

示例13: cleanUpDynamoDBTables

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
private static void cleanUpDynamoDBTables(Regions testRegion, String testResourcePrefix, Date createdBeforeThreshold,
                                          AWSCredentialsProvider awsCredentials) {
    LOG.info("Cleaning DynamoDB...");
    AmazonDynamoDB dynamoDBClient = AmazonDynamoDBClientBuilder.standard()
            .withCredentials(awsCredentials)
            .withRegion(testRegion)
            .build();

    List<String> tableNames = dynamoDBClient.listTables().getTableNames();
    for (String tableName: tableNames) {
        if (!tableName.startsWith(testResourcePrefix)) {
            continue;
        }
        LOG.info(String.format("Checking if table %s needs cleaning...", tableName));

        try {
            TableDescription desc = dynamoDBClient.describeTable(tableName).getTable();
            if (!desc.getTableName().equals(TableStatus.DELETING.toString()) &&
                    desc.getCreationDateTime() != null &&
                    desc.getCreationDateTime().before(createdBeforeThreshold)) {
                LOG.info("Cleaning up table: " + tableName);
                dynamoDBClient.deleteTable(tableName);
            }
        } catch (ResourceNotFoundException e) {
            LOG.info("Looks like table was already cleaned up: " + tableName);
        }
    }
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:29,代码来源:IntegrationTestHelper.java

示例14: testDeleteTableWithWait

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
@Test
public void testDeleteTableWithWait() throws Exception {
    // Create fake responses from AWS.
    TableDescription deletingDescription = constructTableDescription(TableStatus.DELETING);
    DescribeTableResult mockDescribeResult = new DescribeTableResult().withTable(deletingDescription);

    // Delete the table. First response the table is still deleting, the second response the table has deleted
    // and the ResourceNotFoundException is thrown.
    when(mockDynamoDBClient.describeTable(tableName)).thenReturn(mockDescribeResult).thenThrow(
            new ResourceNotFoundException("Table not found"));
    dynamoDB.delete();

    verify(mockDynamoDBClient, times(1)).deleteTable(tableName);
    verify(mockDynamoDBClient, times(2)).describeTable(tableName);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:16,代码来源:GenericDynamoDBTest.java

示例15: tableExists

import com.amazonaws.services.dynamodbv2.model.TableStatus; //导入依赖的package包/类
public boolean tableExists(final String tableName) {
    try {
        return TableStatus.ACTIVE.toString().equals(db.getTable(tableName).describe().getTableStatus().toUpperCase());
    } catch (final ResourceNotFoundException rnfe) {
        return false;
    }
}
 
开发者ID:BackendButters,项目名称:AwsCommons,代码行数:8,代码来源:DynamoCommons.java


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