Search in sources :

Example 1 with Hive

use of org.apache.hadoop.hive.ql.metadata.Hive in project hive by apache.

the class TestSessionManagerMetrics method setup.

@Before
public void setup() throws Exception {
    HiveConf conf = new HiveConf();
    conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_ASYNC_EXEC_THREADS, 2);
    conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_ASYNC_EXEC_WAIT_QUEUE_SIZE, 10);
    conf.setVar(HiveConf.ConfVars.HIVE_SERVER2_ASYNC_EXEC_KEEPALIVE_TIME, "1000000s");
    conf.setVar(HiveConf.ConfVars.HIVE_SERVER2_IDLE_SESSION_TIMEOUT, "500ms");
    conf.setVar(HiveConf.ConfVars.HIVE_SERVER2_SESSION_CHECK_INTERVAL, "3s");
    conf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_METRICS_ENABLED, true);
    conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    conf.setVar(HiveConf.ConfVars.HIVE_METRICS_REPORTER, MetricsReporting.JSON_FILE.name() + "," + MetricsReporting.JMX.name());
    conf.setBoolVar(HiveConf.ConfVars.HIVEOPTIMIZEMETADATAQUERIES, false);
    MetricsFactory.init(conf);
    HiveServer2 hs2 = new HiveServer2();
    sm = new SessionManager(hs2);
    sm.init(conf);
    metrics = (CodahaleMetrics) MetricsFactory.getInstance();
    Hive doNothingHive = mock(Hive.class);
    Hive.set(doNothingHive);
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2) Hive(org.apache.hadoop.hive.ql.metadata.Hive) HiveConf(org.apache.hadoop.hive.conf.HiveConf) Before(org.junit.Before)

Example 2 with Hive

use of org.apache.hadoop.hive.ql.metadata.Hive in project hive by apache.

the class TestQBCompact method init.

@BeforeClass
public static void init() throws Exception {
    queryState = new QueryState(null);
    conf = queryState.getConf();
    conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    SessionState.start(conf);
    // Create a table so we can work against it
    Hive h = Hive.get(conf);
    List<String> cols = new ArrayList<String>();
    cols.add("a");
    List<String> partCols = new ArrayList<String>();
    partCols.add("ds");
    h.createTable("foo", cols, partCols, OrcInputFormat.class, OrcOutputFormat.class);
    Table t = h.getTable("foo");
    Map<String, String> partSpec = new HashMap<String, String>();
    partSpec.put("ds", "today");
    h.createPartition(t, partSpec);
}
Also used : Hive(org.apache.hadoop.hive.ql.metadata.Hive) Table(org.apache.hadoop.hive.ql.metadata.Table) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) QueryState(org.apache.hadoop.hive.ql.QueryState) BeforeClass(org.junit.BeforeClass)

Example 3 with Hive

use of org.apache.hadoop.hive.ql.metadata.Hive in project hive by apache.

the class TestReplicationSemanticAnalyzer method initialize.

@BeforeClass
public static void initialize() throws HiveException {
    queryState = new QueryState(new HiveConf(SemanticAnalyzer.class));
    conf = queryState.getConf();
    conf.set("hive.security.authorization.manager", "");
    SessionState.start(conf);
    Hive hiveDb = Hive.get(conf);
    hiveDb.createTable(defaultDB + "." + tblName, cols, null, OrcInputFormat.class, OrcOutputFormat.class);
    Table t = hiveDb.getTable(tblName);
}
Also used : Hive(org.apache.hadoop.hive.ql.metadata.Hive) Table(org.apache.hadoop.hive.ql.metadata.Table) HiveConf(org.apache.hadoop.hive.conf.HiveConf) QueryState(org.apache.hadoop.hive.ql.QueryState) BeforeClass(org.junit.BeforeClass)

Example 4 with Hive

use of org.apache.hadoop.hive.ql.metadata.Hive in project hive by apache.

the class HiveV1Authorizer method getCurrentRoleNames.

@Override
public List<String> getCurrentRoleNames() throws HiveAuthzPluginException {
    String userName = SessionState.get().getUserName();
    if (userName == null) {
        userName = SessionState.getUserFromAuthenticator();
    }
    if (userName == null) {
        throw new HiveAuthzPluginException("Cannot resolve current user name");
    }
    try {
        Hive hive = Hive.getWithFastCheck(this.conf);
        List<String> roleNames = new ArrayList<String>();
        for (Role role : hive.listRoles(userName, PrincipalType.USER)) {
            roleNames.add(role.getRoleName());
        }
        return roleNames;
    } catch (HiveException e) {
        throw new HiveAuthzPluginException(e);
    }
}
Also used : Role(org.apache.hadoop.hive.metastore.api.Role) Hive(org.apache.hadoop.hive.ql.metadata.Hive) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) ArrayList(java.util.ArrayList)

Example 5 with Hive

use of org.apache.hadoop.hive.ql.metadata.Hive in project hive by apache.

the class HiveV1Authorizer method dropRole.

@Override
public void dropRole(String roleName) throws HiveAuthzPluginException, HiveAccessControlException {
    try {
        Hive hive = Hive.getWithFastCheck(this.conf);
        hive.dropRole(roleName);
    } catch (HiveException e) {
        throw new HiveAuthzPluginException(e);
    }
}
Also used : Hive(org.apache.hadoop.hive.ql.metadata.Hive) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException)

Aggregations

Hive (org.apache.hadoop.hive.ql.metadata.Hive)33 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)17 Table (org.apache.hadoop.hive.ql.metadata.Table)10 ArrayList (java.util.ArrayList)7 PrincipalType (org.apache.hadoop.hive.metastore.api.PrincipalType)5 Partition (org.apache.hadoop.hive.ql.metadata.Partition)5 Path (org.apache.hadoop.fs.Path)4 HiveConf (org.apache.hadoop.hive.conf.HiveConf)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)3 HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)3 QueryState (org.apache.hadoop.hive.ql.QueryState)3 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)3 SessionState (org.apache.hadoop.hive.ql.session.SessionState)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2