use of com.amazonaws.services.glue.model.AWSGlueException in project alluxio by Alluxio.
the class GlueDatabase method batchGetPartitions.
private List<Partition> batchGetPartitions(AWSGlueAsync glueClient, String tableName) throws IOException {
// TODO(shouwei): make getPartition multi-thread to accelerate the large table fetching
List<Partition> partitions = new ArrayList<>();
String nextToken = null;
try {
do {
GetPartitionsRequest getPartitionsRequest = new GetPartitionsRequest().withCatalogId(mGlueConfiguration.get(Property.CATALOG_ID)).withDatabaseName(mGlueDbName).withTableName(tableName).withMaxResults(mGlueConfiguration.getInt(Property.MAX_GLUE_FETCH_PARTITIONS)).withNextToken(nextToken);
GetPartitionsResult getPartitionsResult = glueClient.getPartitions(getPartitionsRequest);
partitions.addAll(getPartitionsResult.getPartitions());
nextToken = getPartitionsResult.getNextToken();
LOG.debug("Glue table {}.{} adding {} batch partitions with total {} partitions.", mGlueDbName, tableName, getPartitionsResult.getPartitions().size(), partitions.size());
} while (nextToken != null);
if (partitions != null) {
LOG.info("Glue table {}.{} has {} partitions.", mGlueDbName, tableName, partitions.size());
if (LOG.isDebugEnabled()) {
partitions.stream().forEach(partition -> LOG.debug("Glue table {}.{} with partition: {}.", partition.getDatabaseName(), tableName, partition));
}
}
return partitions;
} catch (AWSGlueException e) {
throw new IOException("Cannot get partition information for table: " + tableName + " in Database: " + mGlueDbName + "; Catalog ID: " + mGlueConfiguration.get(Property.CATALOG_ID) + ". error: " + e.getMessage(), e);
}
}
Aggregations