2

我在有关同步删除给定表的 DynamoDB文档中找到了这个示例。

在调用这个方法之前,我们用 class 发送了删除表的请求DeleteTableRequest

private static void waitForTableToBeDeleted(String tableName) {
        System.out.println("Waiting for " + tableName + " while status DELETING...");

        long startTime = System.currentTimeMillis();
        long endTime = startTime + (10 * 60 * 1000);
        while (System.currentTimeMillis() < endTime) {
            try {
                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;
            } catch (ResourceNotFoundException e) {
                System.out.println("Table " + tableName + " is not found. It was deleted.");
                return;
            }
            try {Thread.sleep(1000 * 20);} catch (Exception e) {}
        }
        throw new RuntimeException("Table " + tableName + " was never deleted");
    }

我的问题是,当他们在已弃用的文档ResourceNotFoundException中提到时,他们如何在最新示例中使用?我们应该改用什么?

4

1 回答 1

2

您指向的文档链接适用于已弃用的 Amazon DynamoDB API V1。引入本地二级索引的 V2 版本包含在com.amazonaws.services.dynamodbv2包中。这是V2文档ResourceNotFoundException

于 2013-07-19T20:45:21.090 回答