我在有关同步删除给定表的 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
中提到时,他们如何在最新示例中使用?我们应该改用什么?