Example usage for com.amazonaws.services.glue.model GetDatabasesResult getDatabaseList

List of usage examples for com.amazonaws.services.glue.model GetDatabasesResult getDatabaseList

Introduction

In this page you can find the example usage for com.amazonaws.services.glue.model GetDatabasesResult getDatabaseList.

Prototype


public java.util.List<Database> getDatabaseList() 

Source Link

Document

A list of Database objects from the specified catalog.

Usage

From source file:com.facebook.presto.hive.metastore.glue.GlueHiveMetastore.java

License:Apache License

@Override
public List<String> getAllDatabases() {
    try {/*w  w  w.j ava 2 s.c om*/
        List<String> databaseNames = new ArrayList<>();
        String nextToken = null;

        do {
            GetDatabasesResult result = glueClient
                    .getDatabases(new GetDatabasesRequest().withNextToken(nextToken));
            nextToken = result.getNextToken();
            result.getDatabaseList().forEach(database -> databaseNames.add(database.getName()));
        } while (nextToken != null);

        return databaseNames;
    } catch (AmazonServiceException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}