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

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

Introduction

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

Prototype


public String getNextToken() 

Source Link

Document

A continuation token for paginating the returned list of tokens, returned if the current segment of the list is not the last.

Usage

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

License:Apache License

@Override
public List<String> getAllDatabases() {
    try {/*from   w w w. j a  va 2s.co m*/
        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);
    }
}