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);
}
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);
}
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);
}
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);
}
}
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);
}
}
Aggregations