Search in sources :

Example 11 with MDBPrivilege

use of org.apache.hadoop.hive.metastore.model.MDBPrivilege in project hive by apache.

the class ObjectStore method listPrincipalAllDBGrant.

private List<MDBPrivilege> listPrincipalAllDBGrant(String principalName, PrincipalType principalType) throws Exception {
    final List<MDBPrivilege> mSecurityDBList;
    LOG.debug("Executing listPrincipalAllDBGrant");
    Preconditions.checkState(this.currentTransaction.isActive());
    if (principalName != null && principalType != null) {
        try (Query query = pm.newQuery(MDBPrivilege.class, "principalName == t1 && principalType == t2")) {
            query.declareParameters("java.lang.String t1, java.lang.String t2");
            mSecurityDBList = (List<MDBPrivilege>) query.execute(principalName, principalType.toString());
            pm.retrieveAll(mSecurityDBList);
            LOG.debug("Done retrieving all objects for listPrincipalAllDBGrant: {}", mSecurityDBList);
            return Collections.unmodifiableList(new ArrayList<>(mSecurityDBList));
        }
    } else {
        try (Query query = pm.newQuery(MDBPrivilege.class)) {
            mSecurityDBList = (List<MDBPrivilege>) query.execute();
            pm.retrieveAll(mSecurityDBList);
            LOG.debug("Done retrieving all objects for listPrincipalAllDBGrant: {}", mSecurityDBList);
            return Collections.unmodifiableList(new ArrayList<>(mSecurityDBList));
        }
    }
}
Also used : ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery) Query(javax.jdo.Query) MScheduledQuery(org.apache.hadoop.hive.metastore.model.MScheduledQuery) MDBPrivilege(org.apache.hadoop.hive.metastore.model.MDBPrivilege)

Example 12 with MDBPrivilege

use of org.apache.hadoop.hive.metastore.model.MDBPrivilege in project hive by apache.

the class ObjectStore method dropDatabase.

@Override
public boolean dropDatabase(String catName, String dbname) throws NoSuchObjectException, MetaException {
    boolean success = false;
    LOG.info("Dropping database {}.{} along with all tables", catName, dbname);
    dbname = normalizeIdentifier(dbname);
    catName = normalizeIdentifier(catName);
    try {
        openTransaction();
        // then drop the database
        MDatabase db = getMDatabase(catName, dbname);
        pm.retrieve(db);
        List<MDBPrivilege> dbGrants = this.listDatabaseGrants(catName, dbname, null);
        if (CollectionUtils.isNotEmpty(dbGrants)) {
            pm.deletePersistentAll(dbGrants);
        }
        pm.deletePersistent(db);
        success = commitTransaction();
    } catch (Exception e) {
        throw new MetaException(e.getMessage() + " " + org.apache.hadoop.hive.metastore.utils.StringUtils.stringifyException(e));
    } finally {
        rollbackAndCleanup(success, null);
    }
    return success;
}
Also used : MDatabase(org.apache.hadoop.hive.metastore.model.MDatabase) MDBPrivilege(org.apache.hadoop.hive.metastore.model.MDBPrivilege) AlreadyExistsException(org.apache.hadoop.hive.metastore.api.AlreadyExistsException) InvalidInputException(org.apache.hadoop.hive.metastore.api.InvalidInputException) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) IOException(java.io.IOException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) InvalidPartitionException(org.apache.hadoop.hive.metastore.api.InvalidPartitionException) UnknownPartitionException(org.apache.hadoop.hive.metastore.api.UnknownPartitionException) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) JDOException(javax.jdo.JDOException) MissingTableException(org.datanucleus.store.rdbms.exceptions.MissingTableException) SQLException(java.sql.SQLException) UnknownDBException(org.apache.hadoop.hive.metastore.api.UnknownDBException) TException(org.apache.thrift.TException) JDODataStoreException(javax.jdo.JDODataStoreException) JDOObjectNotFoundException(javax.jdo.JDOObjectNotFoundException) UnknownTableException(org.apache.hadoop.hive.metastore.api.UnknownTableException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Aggregations

MDBPrivilege (org.apache.hadoop.hive.metastore.model.MDBPrivilege)12 ArrayList (java.util.ArrayList)8 Query (javax.jdo.Query)5 LinkedList (java.util.LinkedList)4 List (java.util.List)4 HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)4 HiveObjectRef (org.apache.hadoop.hive.metastore.api.HiveObjectRef)4 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)4 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)3 PrincipalType (org.apache.hadoop.hive.metastore.api.PrincipalType)3 PrivilegeGrantInfo (org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo)3 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)3 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)3 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)3 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)3 MConstraint (org.apache.hadoop.hive.metastore.model.MConstraint)3 MDCPrivilege (org.apache.hadoop.hive.metastore.model.MDCPrivilege)3 MDatabase (org.apache.hadoop.hive.metastore.model.MDatabase)3 MGlobalPrivilege (org.apache.hadoop.hive.metastore.model.MGlobalPrivilege)3 MPartitionColumnPrivilege (org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege)3