Search in sources :

Example 6 with MRole

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

the class ObjectStore method listMRoles.

public List<MRoleMap> listMRoles(String principalName, PrincipalType principalType) {
    boolean success = false;
    Query query = null;
    List<MRoleMap> mRoleMember = new ArrayList<>();
    try {
        LOG.debug("Executing listRoles");
        openTransaction();
        query = pm.newQuery(MRoleMap.class, "principalName == t1 && principalType == t2");
        query.declareParameters("java.lang.String t1, java.lang.String t2");
        query.setUnique(false);
        List<MRoleMap> mRoles = (List<MRoleMap>) query.executeWithArray(principalName, principalType.toString());
        pm.retrieveAll(mRoles);
        success = commitTransaction();
        mRoleMember.addAll(mRoles);
        LOG.debug("Done retrieving all objects for listRoles");
    } finally {
        rollbackAndCleanup(success, query);
    }
    if (principalType == PrincipalType.USER) {
        // All users belong to public role implicitly, add that role
        // TODO MS-SPLIT Change this back to HMSHandler.PUBLIC once HiveMetaStore has moved to
        // stand-alone metastore.
        // MRole publicRole = new MRole(HMSHandler.PUBLIC, 0, HMSHandler.PUBLIC);
        MRole publicRole = new MRole("public", 0, "public");
        mRoleMember.add(new MRoleMap(principalName, principalType.toString(), publicRole, 0, null, null, false));
    }
    return mRoleMember;
}
Also used : ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery) Query(javax.jdo.Query) MScheduledQuery(org.apache.hadoop.hive.metastore.model.MScheduledQuery) MRole(org.apache.hadoop.hive.metastore.model.MRole) ArrayList(java.util.ArrayList) ValidWriteIdList(org.apache.hadoop.hive.common.ValidWriteIdList) ReplicationMetricList(org.apache.hadoop.hive.metastore.api.ReplicationMetricList) LinkedList(java.util.LinkedList) MStringList(org.apache.hadoop.hive.metastore.model.MStringList) ArrayList(java.util.ArrayList) ValidReaderWriteIdList(org.apache.hadoop.hive.common.ValidReaderWriteIdList) List(java.util.List) MRoleMap(org.apache.hadoop.hive.metastore.model.MRoleMap)

Example 7 with MRole

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

the class ObjectStore method getMRole.

private MRole getMRole(String roleName) {
    MRole mrole = null;
    boolean commited = false;
    Query query = null;
    try {
        openTransaction();
        query = pm.newQuery(MRole.class, "roleName == t1");
        query.declareParameters("java.lang.String t1");
        query.setUnique(true);
        mrole = (MRole) query.execute(roleName);
        pm.retrieve(mrole);
        commited = commitTransaction();
    } finally {
        rollbackAndCleanup(commited, query);
    }
    return mrole;
}
Also used : ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery) Query(javax.jdo.Query) MScheduledQuery(org.apache.hadoop.hive.metastore.model.MScheduledQuery) MRole(org.apache.hadoop.hive.metastore.model.MRole)

Aggregations

MRole (org.apache.hadoop.hive.metastore.model.MRole)7 MRoleMap (org.apache.hadoop.hive.metastore.model.MRoleMap)4 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)3 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)3 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)2 ArrayList (java.util.ArrayList)2 JDODataStoreException (javax.jdo.JDODataStoreException)2 JDOException (javax.jdo.JDOException)2 JDOObjectNotFoundException (javax.jdo.JDOObjectNotFoundException)2 Query (javax.jdo.Query)2 AlreadyExistsException (org.apache.hadoop.hive.metastore.api.AlreadyExistsException)2 InvalidInputException (org.apache.hadoop.hive.metastore.api.InvalidInputException)2 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)2 InvalidPartitionException (org.apache.hadoop.hive.metastore.api.InvalidPartitionException)2 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)2 Role (org.apache.hadoop.hive.metastore.api.Role)2 ScheduledQuery (org.apache.hadoop.hive.metastore.api.ScheduledQuery)2 UnknownDBException (org.apache.hadoop.hive.metastore.api.UnknownDBException)2