/** * set current session to existing session object if a thread is running multiple sessions - it * must call this method with the new session object when switching from one session to another. */ public static SessionState start(SessionState startSs) { setCurrentSessionState(startSs); if (startSs.hiveHist == null) { if (startSs.getConf().getBoolVar(HiveConf.ConfVars.HIVE_SESSION_HISTORY_ENABLED)) { startSs.hiveHist = new HiveHistoryImpl(startSs); } else { // Hive history is disabled, create a no-op proxy startSs.hiveHist = HiveHistoryProxyHandler.getNoOpHiveHistoryProxy(); } } // Get the following out of the way when you start the session these take a // while and should be done when we start up. try { // Hive object instance should be created with a copy of the conf object. If the conf is // shared with SessionState, other parts of the code might update the config, but // Hive.get(HiveConf) would not recognize the case when it needs refreshing Hive.get(new HiveConf(startSs.conf)).getMSC(); UserGroupInformation sessionUGI = Utils.getUGI(); FileSystem.get(startSs.conf); // Create scratch dirs for this session startSs.createSessionDirs(sessionUGI.getShortUserName()); // Set temp file containing results to be sent to HiveClient if (startSs.getTmpOutputFile() == null) { try { startSs.setTmpOutputFile(createTempFile(startSs.getConf())); } catch (IOException e) { throw new RuntimeException(e); } } } catch (Exception e) { // Catch-all due to some exec time dependencies on session state // that would cause ClassNoFoundException otherwise throw new RuntimeException(e); } if (HiveConf.getVar(startSs.getConf(), HiveConf.ConfVars.HIVE_EXECUTION_ENGINE).equals("tez") && (startSs.isHiveServerQuery == false)) { try { if (startSs.tezSessionState == null) { startSs.tezSessionState = new TezSessionState(startSs.getSessionId()); } if (!startSs.tezSessionState.isOpen()) { startSs.tezSessionState.open(startSs.conf); // should use conf on session start-up } } catch (Exception e) { throw new RuntimeException(e); } } else { LOG.info("No Tez session required at this point. hive.execution.engine=mr."); } return startSs; }
@BeforeClass public void setUp() throws Exception { // Set-up hive session HiveConf conf = new HiveConf(); driver = new Driver(conf); ss = new SessionState(conf, System.getProperty("user.name")); ss = SessionState.start(ss); SessionState.setCurrentSessionState(ss); Configuration configuration = ApplicationProperties.get(); dgiCLient = new AtlasClient(configuration.getString(HiveMetaStoreBridge.ATLAS_ENDPOINT, DGI_URL)); }