Search in sources :

Example 1 with GetDatabaseResult

use of com.amazonaws.services.glue.model.GetDatabaseResult in project alluxio by Alluxio.

the class GlueDatabase method getDatabaseInfo.

@Override
public DatabaseInfo getDatabaseInfo() throws IOException {
    try {
        GetDatabaseRequest dbRequest = new GetDatabaseRequest().withCatalogId(mGlueConfiguration.get(Property.CATALOG_ID)).withName(mGlueDbName);
        GetDatabaseResult dbResult = mGlueClient.getDatabase(dbRequest);
        Database glueDatabase = dbResult.getDatabase();
        // Glue database location, description and parameters could be null
        String glueDbLocation = glueDatabase.getLocationUri() == null ? "" : glueDatabase.getLocationUri();
        String glueDbDescription = glueDatabase.getDescription() == null ? "" : glueDatabase.getDescription();
        Map<String, String> glueParameters = new HashMap<>();
        if (glueDatabase.getParameters() != null) {
            glueParameters.putAll(glueDatabase.getParameters());
        }
        return new DatabaseInfo(glueDbLocation, mOwnerName, mOwnerType, glueDbDescription, glueParameters);
    } catch (EntityNotFoundException e) {
        throw new IOException("Cannot find glue database: " + mGlueDbName + "Catalog ID: " + mGlueConfiguration.get(Property.CATALOG_ID) + ". " + e.getMessage(), e);
    }
}
Also used : GetDatabaseRequest(com.amazonaws.services.glue.model.GetDatabaseRequest) HashMap(java.util.HashMap) DatabaseInfo(alluxio.master.table.DatabaseInfo) UnderDatabase(alluxio.table.common.udb.UnderDatabase) Database(com.amazonaws.services.glue.model.Database) GetDatabaseResult(com.amazonaws.services.glue.model.GetDatabaseResult) EntityNotFoundException(com.amazonaws.services.glue.model.EntityNotFoundException) IOException(java.io.IOException)

Aggregations

DatabaseInfo (alluxio.master.table.DatabaseInfo)1 UnderDatabase (alluxio.table.common.udb.UnderDatabase)1 Database (com.amazonaws.services.glue.model.Database)1 EntityNotFoundException (com.amazonaws.services.glue.model.EntityNotFoundException)1 GetDatabaseRequest (com.amazonaws.services.glue.model.GetDatabaseRequest)1 GetDatabaseResult (com.amazonaws.services.glue.model.GetDatabaseResult)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1