in java/core/src/main/java/com/aliyun/openservices/tablestore/agent/util/TablestoreHelper.java [212:238]
public static void deleteTable(SyncClient client, String tableName) {
List<String> tableNames = client.listTable().getTableNames();
if (!tableNames.contains(tableName)) {
return;
}
ListSearchIndexRequest listSearchIndexRequest = new ListSearchIndexRequest();
listSearchIndexRequest.setTableName(tableName);
ListSearchIndexResponse listSearchIndexResponse = client.listSearchIndex(listSearchIndexRequest);
for (SearchIndexInfo indexInfo : listSearchIndexResponse.getIndexInfos()) {
DeleteSearchIndexRequest deleteSearchIndexRequest = new DeleteSearchIndexRequest();
deleteSearchIndexRequest.setTableName(indexInfo.getTableName());
deleteSearchIndexRequest.setIndexName(indexInfo.getIndexName());
client.deleteSearchIndex(deleteSearchIndexRequest);
log.info("tablestore delete search index:[{}] successfully.", indexInfo.getIndexName());
}
try {
DeleteTableRequest request = new DeleteTableRequest(tableName);
client.deleteTable(request);
} catch (TableStoreException e) {
if ("OTSObjectNotExist".equals(e.getErrorCode()) && e.getMessage().contains("does not exist")) {
log.warn("tablestore table:[{}] not found", tableName);
} else {
throw Exceptions.runtimeThrowable(String.format("tablestore delete table:[%s] failed", tableName), e);
}
}
}