Java 类com.amazonaws.services.dynamodbv2.model.DeleteTableRequest 实例源码

项目:Tank    文件:AmazonDynamoDatabaseDocApi.java   
/**
 * 
 * @{inheritDoc
 */
@Override
public void deleteTable(String tableName) {
    try {
        if (hasTable(tableName)) {
            logger.info("Deleting table: " + tableName);
            DeleteTableRequest deleteTableRequest = new DeleteTableRequest(tableName);
            DeleteTableResult result = dynamoDb.deleteTable(deleteTableRequest);
            logger.info("Deleted table: " + result.getTableDescription().getTableName());
            waitForDelete(tableName);
        }
    } catch (Exception t) {
        logger.error(t, t);
        throw new RuntimeException(t);
    }
}
项目:nfscan    文件:BaseDatabaseControllerTest.java   
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))));
}
项目:milton-aws    文件:DynamoDBServiceImpl.java   
@Override
  public boolean deleteTable(String tableName) {
      try {
        DeleteTableRequest deleteTableRequest = new DeleteTableRequest().withTableName(tableName);
          DeleteTableResult deleteTableResult = dynamoDBClient.deleteTable(deleteTableRequest);
          if (deleteTableRequest != null) {
            LOG.info("Deleting table description: " + deleteTableResult);

            // Waiting for table deleted
            waitForTableDeleted(tableName);
            LOG.info("Successfully deleted table " + tableName);
            return true;
          }
} catch (ResourceInUseException rie) {
          LOG.warn("Table " + tableName + " already exists");
} catch (AmazonServiceException ase) {
    LOG.error(ase.getMessage(), ase);
} catch (AmazonClientException ace) {
    LOG.error(ace.getMessage(), ace);
}
      return false;
  }
项目:cas-5.1.0    文件:DynamoDbTicketRegistryFacilitator.java   
/**
 * Create ticket tables.
 *
 * @param deleteTables the delete tables
 */
public void createTicketTables(final boolean deleteTables) {
    final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
    metadata.forEach(Unchecked.consumer(r -> {
        final CreateTableRequest request = new CreateTableRequest()
                .withAttributeDefinitions(new AttributeDefinition(ColumnNames.ID.getName(), ScalarAttributeType.S))
                .withKeySchema(new KeySchemaElement(ColumnNames.ID.getName(), KeyType.HASH))
                .withProvisionedThroughput(new ProvisionedThroughput(dynamoDbProperties.getReadCapacity(),
                        dynamoDbProperties.getWriteCapacity()))
                .withTableName(r.getProperties().getStorageName());


        if (deleteTables) {
            final DeleteTableRequest delete = new DeleteTableRequest(r.getProperties().getStorageName());
            LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
            TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
        }
        LOGGER.debug("Sending delete request [{}] to create table", request);
        TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);

        LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
        TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());

        final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
        LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);

        final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
        LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
    }));
}
项目:cas-5.1.0    文件:DynamoDbServiceRegistryFacilitator.java   
/**
 * Create tables.
 *
 * @param deleteTables the delete tables
 */
public void createServicesTable(final boolean deleteTables) {
    try {
        final CreateTableRequest request = new CreateTableRequest()
                .withAttributeDefinitions(new AttributeDefinition(ColumnNames.ID.getName(), ScalarAttributeType.S))
                .withKeySchema(new KeySchemaElement(ColumnNames.ID.getName(), KeyType.HASH))
                .withProvisionedThroughput(new ProvisionedThroughput(dynamoDbProperties.getReadCapacity(),
                        dynamoDbProperties.getWriteCapacity()))
                .withTableName(TABLE_NAME);

        if (deleteTables) {
            final DeleteTableRequest delete = new DeleteTableRequest(request.getTableName());
            LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
            TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
        }
        LOGGER.debug("Sending delete request [{}] to create table", request);
        TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);

        LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
        TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());

        final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
        LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);

        final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
        LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
项目:cas-5.1.0    文件:DynamoDbCloudConfigBootstrapConfiguration.java   
private static void createSettingsTable(final AmazonDynamoDBClient amazonDynamoDBClient, final boolean deleteTables) {
    try {
        final CreateTableRequest request = new CreateTableRequest()
                .withAttributeDefinitions(new AttributeDefinition(ColumnNames.ID.getName(), ScalarAttributeType.S))
                .withKeySchema(new KeySchemaElement(ColumnNames.ID.getName(), KeyType.HASH))
                .withProvisionedThroughput(new ProvisionedThroughput(PROVISIONED_THROUGHPUT, PROVISIONED_THROUGHPUT))
                .withTableName(TABLE_NAME);

        if (deleteTables) {
            final DeleteTableRequest delete = new DeleteTableRequest(request.getTableName());
            LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
            TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
        }
        LOGGER.debug("Sending delete request [{}] to create table", request);
        TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);

        LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
        TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());

        final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
        LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);

        final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
        LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
项目:alexa-skills-kit-states-java    文件:AWSDynamoStateHandlerIT.java   
@AfterClass
public static void deleteTable() {
    final DeleteTableRequest deleteTableRequest = new DeleteTableRequest(tableName);
    // credentials need to be set in local environment
    // see http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html
    TableUtils.deleteTableIfExists(new AmazonDynamoDBClient(), deleteTableRequest);
}
项目:Camel    文件:DeleteTableCommand.java   
@Override
public void execute() {
    TableDescription tableDescription = ddbClient
            .deleteTable(new DeleteTableRequest(determineTableName())).getTableDescription();

    Map tmp = new HashMap<>();
    tmp.put(DdbConstants.PROVISIONED_THROUGHPUT, tableDescription.getProvisionedThroughput());
    tmp.put(DdbConstants.CREATION_DATE, tableDescription.getCreationDateTime());
    tmp.put(DdbConstants.ITEM_COUNT, tableDescription.getItemCount());
    tmp.put(DdbConstants.KEY_SCHEMA, tableDescription.getKeySchema());
    tmp.put(DdbConstants.TABLE_NAME, tableDescription.getTableName());
    tmp.put(DdbConstants.TABLE_SIZE, tableDescription.getTableSizeBytes());
    tmp.put(DdbConstants.TABLE_STATUS, tableDescription.getTableStatus());
    addToResults(tmp);
}
项目:Camel    文件:AmazonDDBClientMock.java   
@Override
public DeleteTableResult deleteTable(DeleteTableRequest deleteTableRequest) {
    this.deleteTableRequest = deleteTableRequest;
    return new DeleteTableResult().withTableDescription(new TableDescription()
            .withProvisionedThroughput(new ProvisionedThroughputDescription())
            .withTableName(deleteTableRequest.getTableName())
            .withCreationDateTime(new Date(NOW))
            .withItemCount(10L)
            .withKeySchema(new ArrayList<KeySchemaElement>())
            .withTableSizeBytes(20L)
            .withTableStatus(TableStatus.ACTIVE));
}
项目:dynamodb-janusgraph-storage-backend    文件:DynamoDbDelegate.java   
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;
}
项目:ColumnStoreUnifier    文件:DynamoDbQueryHandler.java   
/**
 * Delete the table with given name
 * 
 * @param tableName
 */
public static void deleteTable(String tableName) {
    try {
        DynamoDbHandler.CLIENT
                .deleteTable(new DeleteTableRequest(tableName));
    } catch (Exception e) {
        //Table does not exist
    }
}
项目:para    文件:AWSDynamoUtils.java   
/**
 * Deletes the main table from AWS DynamoDB.
 * @param appid name of the {@link com.erudika.para.core.App}
 * @return true if deleted
 */
public static boolean deleteTable(String appid) {
    if (StringUtils.isBlank(appid) || !existsTable(appid)) {
        return false;
    }
    try {
        String table = getTableNameForAppid(appid);
        getClient().deleteTable(new DeleteTableRequest().withTableName(table));
        logger.info("Deleted DynamoDB table '{}'.", table);
    } catch (Exception e) {
        logger.error(null, e);
        return false;
    }
    return true;
}
项目:gora    文件:DynamoDBStore.java   
/**
 * Executes a delete table request using the DynamoDB client
 * 
 * @param pTableName
 */
public void executeDeleteTableRequest(String pTableName) {
  try {
    DeleteTableRequest deleteTableRequest = new DeleteTableRequest()
        .withTableName(pTableName);
    DeleteTableResult result = getDynamoDBClient().deleteTable(
        deleteTableRequest);
    waitForTableToBeDeleted(pTableName);
    LOG.debug("Schema: " + result.getTableDescription()
    + " deleted successfully.");
  } catch (Exception e) {
    LOG.debug("Schema: {} deleted.", pTableName, e.getMessage());
    throw new RuntimeException(e);
  }
}
项目:aws-dynamodb-examples    文件:LowLevelParallelScan.java   
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);
    }
}
项目:aws-dynamodb-examples    文件:StreamsAdapterDemo.java   
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);
}
项目:jcabi-dynamo    文件:MadeTable.java   
/**
 * Drop table.
 * @throws InterruptedException If something fails
 */
public void drop() throws InterruptedException {
    final AmazonDynamoDB aws = this.region.aws();
    final String name = this.request.getTableName();
    aws.deleteTable(new DeleteTableRequest().withTableName(name));
    Logger.info(this, "DynamoDB table '%s' deletion requested", name);
    while (this.exists()) {
        Logger.info(this, "DynamoDB table '%s' still exists", name);
        TimeUnit.SECONDS.sleep((long) Tv.TEN);
    }
    Logger.info(this, "DynamoDB table '%s' deleted", name);
}
项目:aws-sdk-android-samples    文件:DynamoDBManager.java   
public static void cleanUp() {

        AmazonDynamoDBClient ddb = UserPreferenceDemoActivity.clientManager
                .ddb();

        DeleteTableRequest request = new DeleteTableRequest()
                .withTableName(Constants.TEST_TABLE_NAME);
        try {
            ddb.deleteTable(request);

        } catch (AmazonServiceException ex) {
            UserPreferenceDemoActivity.clientManager
                    .wipeCredentialsOnAuthError(ex);
        }
    }
项目:plano    文件:PlanoApplicationDynamoDBTests.java   
private DeleteTableResult deletePlanoRequestsTable() {
    DeleteTableRequest request = mapper.generateDeleteTableRequest(DynamoDBPlanoRequest.class);
    DeleteTableResult deleteTableResult = dynamoDB.deleteTable(request);

    return deleteTableResult;
}
项目:plano    文件:DynamoDBRepositoryTests.java   
private DeleteTableResult deletePlanoRequestsTable() {
    DeleteTableRequest request = sDynamoDBMapper.generateDeleteTableRequest(DynamoDBPlanoRequest.class);
    DeleteTableResult deleteTableResult = sDynamoDB.deleteTable(request);

    return deleteTableResult;
}
项目:dynamodb-janusgraph-storage-backend    文件:DynamoDbDelegate.java   
DeleteTableResult deleteTable(final String tableName) throws BackendException {
    return deleteTable(new DeleteTableRequest().withTableName(tableName));
}
项目:dynamodb-streams-kafka    文件:StreamAdapterDemoHelper.java   
public static void cleanupAndExit(AmazonDynamoDBClient dynamoDBClient, String srcTable, Integer returnValue) {
    dynamoDBClient.deleteTable(new DeleteTableRequest().withTableName(srcTable));
    System.exit(returnValue);
}
项目:aws-dynamodb-examples    文件:LowLevelTableExample.java   
static void deleteExampleTable() {
    DeleteTableRequest deleteTableRequest = new DeleteTableRequest()
        .withTableName(tableName);
    client.deleteTable(deleteTableRequest);
    waitForTableToBeDeleted(tableName);  
}
项目:aws-dynamodb-examples    文件:LowLevelLocalSecondaryIndexExample.java   
public static void deleteTable(String tableName) {
    System.out.println("Deleting table " + tableName + "...");
    client.deleteTable(new DeleteTableRequest().withTableName(tableName));
    waitForTableToBeDeleted(tableName);
}
项目:aws-dynamodb-examples    文件:LowLevelGlobalSecondaryIndexExample.java   
public static void deleteTable(String tableName) {
    System.out.println("Deleting table " + tableName + "...");
    client.deleteTable(new DeleteTableRequest().withTableName(tableName));
    waitForTableToBeDeleted(tableName);
}