use of org.apache.hadoop.hive.conf.HiveConf in project hive by apache.
the class TestPluggableHiveSessionImpl method testSessionImplWithUGI.
@Test
public void testSessionImplWithUGI() throws Exception {
HiveConf hiveConf = new HiveConf();
hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER.getDefaultValue());
hiveConf.setVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_WITH_UGI_CLASSNAME, SampleHiveSessionImplWithUGI.class.getName());
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, true);
CLIService cliService = new CLIService(null);
cliService.init(hiveConf);
ThriftBinaryCLIService service = new ThriftBinaryCLIService(cliService, null);
service.init(hiveConf);
ThriftCLIServiceClient client = new ThriftCLIServiceClient(service);
SessionHandle sessionHandle = null;
sessionHandle = client.openSession("tom", "password");
assertEquals(SampleHiveSessionImplWithUGI.class.getName(), service.getHiveConf().getVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_WITH_UGI_CLASSNAME));
HiveSession session = cliService.getSessionManager().getSession(sessionHandle);
assertEquals(SampleHiveSessionImplWithUGI.MAGIC_RETURN_VALUE, session.getNoOperationTime());
client.closeSession(sessionHandle);
}
use of org.apache.hadoop.hive.conf.HiveConf in project hive by apache.
the class TestSessionCleanup method testTempSessionFileCleanup.
@Test
public // This is to test session temporary files are cleaned up after HIVE-11768
void testTempSessionFileCleanup() throws Exception {
EmbeddedThriftBinaryCLIService service = new EmbeddedThriftBinaryCLIService();
HiveConf hiveConf = new HiveConf();
hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
service.init(hiveConf);
ThriftCLIServiceClient client = new ThriftCLIServiceClient(service);
Set<String> existingPipeoutFiles = new HashSet<String>(Arrays.asList(getPipeoutFiles()));
SessionHandle sessionHandle = client.openSession("user1", "foobar", Collections.<String, String>emptyMap());
client.executeStatement(sessionHandle, "set a=b", null);
File operationLogRootDir = new File(new HiveConf().getVar(ConfVars.HIVE_SERVER2_LOGGING_OPERATION_LOG_LOCATION));
Assert.assertNotEquals(operationLogRootDir.list().length, 0);
client.closeSession(sessionHandle);
// Check if session files are removed
Assert.assertEquals(operationLogRootDir.list().length, 0);
// Check if the pipeout files are removed
Set<String> finalPipeoutFiles = new HashSet<String>(Arrays.asList(getPipeoutFiles()));
finalPipeoutFiles.removeAll(existingPipeoutFiles);
Assert.assertTrue(finalPipeoutFiles.isEmpty());
}
use of org.apache.hadoop.hive.conf.HiveConf in project hive by apache.
the class TestSessionGlobalInitFile method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
// create and put .hiverc sample file to default directory
initFile = File.createTempFile("test", "hive");
tmpDir = initFile.getParentFile().getAbsoluteFile() + File.separator + "TestSessionGlobalInitFile";
initFile.delete();
FileUtils.deleteDirectory(new File(tmpDir));
initFile = new File(tmpDir + File.separator + SessionManager.HIVERCFILE);
initFile.getParentFile().mkdirs();
initFile.createNewFile();
String[] fileContent = new String[] { "-- global init hive file for test", "set a=1;", "set hiveconf:b=1;", "set hivevar:c=1;", "set d\\", " =1;", "add jar " + initFile.getAbsolutePath() };
FileUtils.writeLines(initFile, Arrays.asList(fileContent));
// set up service and client
hiveConf = new HiveConf();
hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_GLOBAL_INIT_FILE_LOCATION, initFile.getParentFile().getAbsolutePath());
hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
service = new FakeEmbeddedThriftBinaryCLIService(hiveConf);
service.init(new HiveConf());
client = new ThriftCLIServiceClient(service);
}
use of org.apache.hadoop.hive.conf.HiveConf 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.conf.HiveConf in project hive by apache.
the class ThriftCLIServiceTest method setUpBeforeClass.
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
// Find a free port
port = MetaStoreUtils.findFreePort();
hiveServer2 = new HiveServer2();
hiveConf = new HiveConf();
}
Aggregations