Search in sources :

Example 26 with PrincipalType

use of org.apache.hadoop.hive.metastore.api.PrincipalType in project hive by apache.

the class ObjectStore method convertTable.

private List<HiveObjectPrivilege> convertTable(List<MTablePrivilege> privs) {
    List<HiveObjectPrivilege> result = new ArrayList<>();
    for (MTablePrivilege priv : privs) {
        String pname = priv.getPrincipalName();
        String authorizer = priv.getAuthorizer();
        PrincipalType ptype = PrincipalType.valueOf(priv.getPrincipalType());
        String table = priv.getTable().getTableName();
        String database = priv.getTable().getDatabase().getName();
        HiveObjectRef objectRef = new HiveObjectRef(HiveObjectType.TABLE, database, table, null, null);
        objectRef.setCatName(priv.getTable().getDatabase().getCatalogName());
        PrivilegeGrantInfo grantor = new PrivilegeGrantInfo(priv.getPrivilege(), priv.getCreateTime(), priv.getGrantor(), PrincipalType.valueOf(priv.getGrantorType()), priv.getGrantOption());
        result.add(new HiveObjectPrivilege(objectRef, pname, ptype, grantor, authorizer));
    }
    return result;
}
Also used : HiveObjectPrivilege(org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege) PrivilegeGrantInfo(org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo) HiveObjectRef(org.apache.hadoop.hive.metastore.api.HiveObjectRef) ArrayList(java.util.ArrayList) PrincipalType(org.apache.hadoop.hive.metastore.api.PrincipalType) MTablePrivilege(org.apache.hadoop.hive.metastore.model.MTablePrivilege)

Example 27 with PrincipalType

use of org.apache.hadoop.hive.metastore.api.PrincipalType in project hive by apache.

the class ObjectStore method convertDB.

private List<HiveObjectPrivilege> convertDB(List<MDBPrivilege> privs) {
    List<HiveObjectPrivilege> result = new ArrayList<>();
    for (MDBPrivilege priv : privs) {
        String pname = priv.getPrincipalName();
        String authorizer = priv.getAuthorizer();
        PrincipalType ptype = PrincipalType.valueOf(priv.getPrincipalType());
        String database = priv.getDatabase().getName();
        HiveObjectRef objectRef = new HiveObjectRef(HiveObjectType.DATABASE, database, null, null, null);
        objectRef.setCatName(priv.getDatabase().getCatalogName());
        PrivilegeGrantInfo grantor = new PrivilegeGrantInfo(priv.getPrivilege(), priv.getCreateTime(), priv.getGrantor(), PrincipalType.valueOf(priv.getGrantorType()), priv.getGrantOption());
        result.add(new HiveObjectPrivilege(objectRef, pname, ptype, grantor, authorizer));
    }
    return result;
}
Also used : HiveObjectPrivilege(org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege) PrivilegeGrantInfo(org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo) HiveObjectRef(org.apache.hadoop.hive.metastore.api.HiveObjectRef) ArrayList(java.util.ArrayList) MDBPrivilege(org.apache.hadoop.hive.metastore.model.MDBPrivilege) PrincipalType(org.apache.hadoop.hive.metastore.api.PrincipalType)

Example 28 with PrincipalType

use of org.apache.hadoop.hive.metastore.api.PrincipalType in project hive by apache.

the class ObjectStore method getDataConnector.

@Override
public DataConnector getDataConnector(String name) throws NoSuchObjectException {
    MDataConnector mdc = null;
    boolean commited = false;
    try {
        openTransaction();
        mdc = getMDataConnector(name);
        commited = commitTransaction();
    } catch (NoSuchObjectException no) {
        throw new NoSuchObjectException("Dataconnector named " + name + " does not exist:" + no.getCause());
    } finally {
        if (!commited) {
            rollbackTransaction();
        }
    }
    DataConnector connector = new DataConnector();
    connector.setName(mdc.getName());
    connector.setType(mdc.getType());
    connector.setUrl(mdc.getUrl());
    connector.setDescription(mdc.getDescription());
    connector.setParameters(convertMap(mdc.getParameters()));
    connector.setOwnerName(mdc.getOwnerName());
    String type = org.apache.commons.lang3.StringUtils.defaultIfBlank(mdc.getOwnerType(), null);
    PrincipalType principalType = (type == null) ? null : PrincipalType.valueOf(type);
    connector.setOwnerType(principalType);
    connector.setCreateTime(mdc.getCreateTime());
    return connector;
}
Also used : MDataConnector(org.apache.hadoop.hive.metastore.model.MDataConnector) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) DataConnector(org.apache.hadoop.hive.metastore.api.DataConnector) MDataConnector(org.apache.hadoop.hive.metastore.model.MDataConnector) PrincipalType(org.apache.hadoop.hive.metastore.api.PrincipalType)

Example 29 with PrincipalType

use of org.apache.hadoop.hive.metastore.api.PrincipalType in project hive by apache.

the class ObjectStore method convertDC.

private List<HiveObjectPrivilege> convertDC(List<MDCPrivilege> privs) {
    List<HiveObjectPrivilege> result = new ArrayList<>();
    for (MDCPrivilege priv : privs) {
        String pname = priv.getPrincipalName();
        String authorizer = priv.getAuthorizer();
        PrincipalType ptype = PrincipalType.valueOf(priv.getPrincipalType());
        String dataConnectorName = priv.getDataConnector().getName();
        HiveObjectRef objectRef = new HiveObjectRef(HiveObjectType.DATACONNECTOR, null, dataConnectorName, null, null);
        PrivilegeGrantInfo grantor = new PrivilegeGrantInfo(priv.getPrivilege(), priv.getCreateTime(), priv.getGrantor(), PrincipalType.valueOf(priv.getGrantorType()), priv.getGrantOption());
        result.add(new HiveObjectPrivilege(objectRef, pname, ptype, grantor, authorizer));
    }
    return result;
}
Also used : HiveObjectPrivilege(org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege) PrivilegeGrantInfo(org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo) MDCPrivilege(org.apache.hadoop.hive.metastore.model.MDCPrivilege) HiveObjectRef(org.apache.hadoop.hive.metastore.api.HiveObjectRef) ArrayList(java.util.ArrayList) PrincipalType(org.apache.hadoop.hive.metastore.api.PrincipalType)

Aggregations

PrincipalType (org.apache.hadoop.hive.metastore.api.PrincipalType)29 HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)15 ArrayList (java.util.ArrayList)14 HiveObjectRef (org.apache.hadoop.hive.metastore.api.HiveObjectRef)13 PrivilegeGrantInfo (org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo)11 MDatabase (org.apache.hadoop.hive.metastore.model.MDatabase)8 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)6 MTable (org.apache.hadoop.hive.metastore.model.MTable)6 Hive (org.apache.hadoop.hive.ql.metadata.Hive)6 Database (org.apache.hadoop.hive.metastore.api.Database)5 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)5 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)5 MDataConnector (org.apache.hadoop.hive.metastore.model.MDataConnector)4 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)4 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 List (java.util.List)3 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)3 MDBPrivilege (org.apache.hadoop.hive.metastore.model.MDBPrivilege)3 MDCPrivilege (org.apache.hadoop.hive.metastore.model.MDCPrivilege)3