Java源码示例:com.amazonaws.services.dynamodbv2.model.DeleteTableRequest
示例1
@Override
public DynamoDBResponse deleteTable(DeleteTableRequest deleteTableRequest) {
logger.info("deleting JSON table");
String keyspace = keyspaceName;
String table = deleteTableRequest.getTableName();
String statement = String.format("DROP TABLE %s.\"%s\";\n", keyspace, table);
ResultSet result = session().execute(statement);
if (result.wasApplied()) {
logger.info("deleted table " + table);
cassandraManager.refreshSchema();
TableDescription newTableDesc = this.getTableDescription(table, null,null);
DeleteTableResult createResult = (new DeleteTableResult()).withTableDescription(newTableDesc);
return new DynamoDBResponse(createResult, 200);
}
return null;
}
示例2
protected void clean(){
/*
I had to hardcode the DES- prefix due to the fact that DynamoDBMapper doesn't currently have a
generateDeleteTableRequest which takes into account the TableNameOverride settings. I've submited
a PR to aws-sdk-java repository.
https://github.com/aws/aws-sdk-java/pull/606#issuecomment-172940752
As soon as it gets merged I'll remove it
*/
String prefix = "DES-";
amazonDynamoDBClient.deleteTable(new DeleteTableRequest(prefix.concat(extractTableName(OCRTransaction.class))));
amazonDynamoDBClient.deleteTable(new DeleteTableRequest(prefix.concat(extractTableName(TaxReceipt.class))));
amazonDynamoDBClient.deleteTable(new DeleteTableRequest(prefix.concat(extractTableName(TaxReceiptArchive.class))));
amazonDynamoDBClient.deleteTable(new DeleteTableRequest(prefix.concat(extractTableName(ElectronicTaxReceipt.class))));
amazonDynamoDBClient.deleteTable(new DeleteTableRequest(prefix.concat(extractTableName(ElectronicTaxReceiptArchive.class))));
}
示例3
@After
public void destroy() throws Exception {
if (tableWasCreatedForTest) {
DeleteTableRequest dtr = mapper.generateDeleteTableRequest(User.class);
TableUtils.deleteTableIfExists(amazonDynamoDB, dtr);
log.info("Deleted table {}", dtr.getTableName());
}
}
示例4
private static void cleanupAndExit(Integer returnValue) {
String srcTable = tablePrefix + "-src";
String destTable = tablePrefix + "-dest";
dynamoDBClient.deleteTable(new DeleteTableRequest().withTableName(srcTable));
dynamoDBClient.deleteTable(new DeleteTableRequest().withTableName(destTable));
System.exit(returnValue);
}
示例5
private static void deleteTable(String tableName) {
try {
DeleteTableRequest request = new DeleteTableRequest().withTableName(tableName);
client.deleteTable(request);
}
catch (AmazonServiceException ase) {
System.err.println("Failed to delete table " + tableName + " " + ase);
}
}
示例6
public DeleteTableResult deleteTable(final DeleteTableRequest request) throws BackendException {
controlPlaneRateLimiter.acquire();
final Timer.Context apiTimerContext = getTimerContext(DELETE_TABLE, request.getTableName());
DeleteTableResult result;
try {
result = client.deleteTable(request);
} catch (Exception e) {
throw processDynamoDbApiException(e, DELETE_TABLE, request.getTableName());
} finally {
apiTimerContext.stop();
}
return result;
}
示例7
/**
* Utility method to delete tables used in the integration test
*/
public static void deleteCryptoIntegrationTestTables() {
List<String> integrationTestTables = new ArrayList<>();
integrationTestTables.add(TABLE_NAME);
integrationTestTables.add(TABLE_WITH_INDEX_RANGE_ATTRIBUTE);
integrationTestTables.add(TABLE_WITH_RANGE_ATTRIBUTE);
for (String name : integrationTestTables) {
dynamo.deleteTable(new DeleteTableRequest().withTableName(name));
}
}
示例8
@Override
public void deleteAll() throws Exception {
final ListTablesResult tables = client.listTables();
for (final String tableName : tables.getTableNames()) {
if ((gwNamespace == null) || tableName.startsWith(gwNamespace)) {
client.deleteTable(new DeleteTableRequest(tableName));
}
}
tableExistsCache.clear();
}
示例9
private static void deleteTable(String tableName){
try {
DeleteTableRequest request = new DeleteTableRequest()
.withTableName(tableName);
client.deleteTable(request);
} catch (AmazonServiceException ase) {
System.err.println("Failed to delete table " + tableName + " " + ase);
}
}
示例10
private static void cleanupAndExit(Integer returnValue) {
String srcTable = tablePrefix + "-src";
String destTable = tablePrefix + "-dest";
dynamoDBClient.deleteTable(new DeleteTableRequest().withTableName(srcTable));
dynamoDBClient.deleteTable(new DeleteTableRequest().withTableName(destTable));
System.exit(returnValue);
}
示例11
/**
* Deletes an Amazon DynamoDB table if it exists.
*
* @param client
* The {@link AmazonDynamoDBClient} with Amazon DynamoDB read and write privileges
* @param tableName
* The Amazon DynamoDB table to delete
*/
public static void deleteTable(AmazonDynamoDBClient client, String tableName) {
if (tableExists(client, tableName)) {
DeleteTableRequest deleteTableRequest = new DeleteTableRequest();
deleteTableRequest.setTableName(tableName);
client.deleteTable(deleteTableRequest);
LOG.info("Deleted table " + tableName);
} else {
LOG.warn("Table " + tableName + " does not exist");
}
}
示例12
@Override
public DeleteTableResult deleteTable(DeleteTableRequest deleteTableRequest) {
throw new UnsupportedOperationException();
}
示例13
static void deleteExampleTable() {
DeleteTableRequest deleteTableRequest = new DeleteTableRequest().withTableName(tableName);
client.deleteTable(deleteTableRequest);
waitForTableToBeDeleted(tableName);
}
示例14
public static void deleteTable(String tableName) {
System.out.println("Deleting table " + tableName + "...");
client.deleteTable(new DeleteTableRequest().withTableName(tableName));
waitForTableToBeDeleted(tableName);
}
示例15
public static void deleteTable(String tableName) {
System.out.println("Deleting table " + tableName + "...");
client.deleteTable(new DeleteTableRequest().withTableName(tableName));
waitForTableToBeDeleted(tableName);
}
示例16
DeleteTableResult deleteTable(final String tableName) throws BackendException {
return deleteTable(new DeleteTableRequest().withTableName(tableName));
}
示例17
protected static void setUpTableWithIndexRangeAttribute(boolean recreateTable) throws Exception {
setUp();
if (recreateTable) {
dynamo.deleteTable(new DeleteTableRequest().withTableName(TABLE_WITH_INDEX_RANGE_ATTRIBUTE));
waitForTableToBecomeDeleted(TABLE_WITH_INDEX_RANGE_ATTRIBUTE);
}
String keyName = DynamoDBCryptoIntegrationTestBase.KEY_NAME;
String rangeKeyAttributeName = "rangeKey";
String indexFooRangeKeyAttributeName = "indexFooRangeKey";
String indexBarRangeKeyAttributeName = "indexBarRangeKey";
String multipleIndexRangeKeyAttributeName = "multipleIndexRangeKey";
String indexFooName = "index_foo";
String indexBarName = "index_bar";
String indexFooCopyName = "index_foo_copy";
String indexBarCopyName = "index_bar_copy";
CreateTableRequest createTableRequest = new CreateTableRequest()
.withTableName(TABLE_WITH_INDEX_RANGE_ATTRIBUTE)
.withKeySchema(
new KeySchemaElement().withAttributeName(keyName).withKeyType(KeyType.HASH),
new KeySchemaElement().withAttributeName(rangeKeyAttributeName).withKeyType(KeyType.RANGE))
.withLocalSecondaryIndexes(
new LocalSecondaryIndex()
.withIndexName(indexFooName)
.withKeySchema(
new KeySchemaElement().withAttributeName(keyName).withKeyType(KeyType.HASH),
new KeySchemaElement().withAttributeName(indexFooRangeKeyAttributeName).withKeyType(KeyType.RANGE))
.withProjection(new Projection().withProjectionType(ProjectionType.ALL)),
new LocalSecondaryIndex()
.withIndexName(indexBarName)
.withKeySchema(
new KeySchemaElement().withAttributeName(keyName).withKeyType(KeyType.HASH),
new KeySchemaElement().withAttributeName(indexBarRangeKeyAttributeName).withKeyType(KeyType.RANGE))
.withProjection(new Projection()
.withProjectionType(ProjectionType.ALL)),
new LocalSecondaryIndex()
.withIndexName(indexFooCopyName)
.withKeySchema(
new KeySchemaElement().withAttributeName(keyName).withKeyType(KeyType.HASH),
new KeySchemaElement().withAttributeName(multipleIndexRangeKeyAttributeName).withKeyType(KeyType.RANGE))
.withProjection(new Projection()
.withProjectionType(ProjectionType.ALL)),
new LocalSecondaryIndex()
.withIndexName(indexBarCopyName)
.withKeySchema(
new KeySchemaElement().withAttributeName(keyName).withKeyType(KeyType.HASH),
new KeySchemaElement().withAttributeName(multipleIndexRangeKeyAttributeName).withKeyType(KeyType.RANGE))
.withProjection(new Projection()
.withProjectionType(ProjectionType.ALL)))
.withAttributeDefinitions(
new AttributeDefinition().withAttributeName(keyName).withAttributeType(ScalarAttributeType.N),
new AttributeDefinition().withAttributeName(rangeKeyAttributeName).withAttributeType(ScalarAttributeType.N),
new AttributeDefinition().withAttributeName(indexFooRangeKeyAttributeName).withAttributeType(ScalarAttributeType.N),
new AttributeDefinition().withAttributeName(indexBarRangeKeyAttributeName).withAttributeType(ScalarAttributeType.N),
new AttributeDefinition().withAttributeName(multipleIndexRangeKeyAttributeName).withAttributeType(ScalarAttributeType.N));
createTableRequest.setProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(10L)
.withWriteCapacityUnits(5L));
if (TableUtils.createTableIfNotExists(dynamo, createTableRequest)) {
TableUtils.waitUntilActive(dynamo, TABLE_WITH_INDEX_RANGE_ATTRIBUTE);
}
}
示例18
static void deleteExampleTable() {
DeleteTableRequest deleteTableRequest = new DeleteTableRequest()
.withTableName(tableName);
client.deleteTable(deleteTableRequest);
waitForTableToBeDeleted(tableName);
}
示例19
public static void deleteTable(String tableName) {
System.out.println("Deleting table " + tableName + "...");
client.deleteTable(new DeleteTableRequest().withTableName(tableName));
waitForTableToBeDeleted(tableName);
}
示例20
public static void deleteTable(String tableName) {
System.out.println("Deleting table " + tableName + "...");
client.deleteTable(new DeleteTableRequest().withTableName(tableName));
waitForTableToBeDeleted(tableName);
}
示例21
@Override
public DeleteTableResult deleteTable(DeleteTableRequest arg0)
throws AmazonServiceException, AmazonClientException {
throw new UnsupportedOperationException("Use the underlying client instance instead");
}
示例22
@Override
public DeleteTableResult deleteTable(DeleteTableRequest request) throws AmazonServiceException, AmazonClientException {
return getBackend().deleteTable(request);
}
示例23
@Override
public DeleteTableResult deleteTable(DeleteTableRequest arg0)
throws AmazonServiceException, AmazonClientException {
throw new UnsupportedOperationException("Use the underlying client instance instead");
}