Search in sources :

Example 1 with GetDatabasesRequest

use of com.amazonaws.services.glue.model.GetDatabasesRequest in project presto by prestodb.

the class GlueHiveMetastore method getAllDatabases.

@Override
public List<String> getAllDatabases(MetastoreContext metastoreContext) {
    try {
        List<String> databaseNames = new ArrayList<>();
        GetDatabasesRequest request = new GetDatabasesRequest().withCatalogId(catalogId);
        do {
            GetDatabasesResult result = stats.getGetDatabases().record(() -> glueClient.getDatabases(request));
            request.setNextToken(result.getNextToken());
            result.getDatabaseList().forEach(database -> databaseNames.add(database.getName()));
        } while (request.getNextToken() != null);
        return databaseNames;
    } catch (AmazonServiceException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}
Also used : ArrayList(java.util.ArrayList) GetDatabasesResult(com.amazonaws.services.glue.model.GetDatabasesResult) AmazonServiceException(com.amazonaws.AmazonServiceException) GetDatabasesRequest(com.amazonaws.services.glue.model.GetDatabasesRequest) PrestoException(com.facebook.presto.spi.PrestoException)

Aggregations

AmazonServiceException (com.amazonaws.AmazonServiceException)1 GetDatabasesRequest (com.amazonaws.services.glue.model.GetDatabasesRequest)1 GetDatabasesResult (com.amazonaws.services.glue.model.GetDatabasesResult)1 PrestoException (com.facebook.presto.spi.PrestoException)1 ArrayList (java.util.ArrayList)1