/** * 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. * * @throws HiveException */ public static SessionState start(SessionState startSs) { tss.set(startSs); if (StringUtils.isEmpty(startSs.getConf().getVar(HiveConf.ConfVars.HIVESESSIONID))) { startSs.getConf().setVar(HiveConf.ConfVars.HIVESESSIONID, makeSessionId()); } if (startSs.hiveHist == null) { startSs.hiveHist = new HiveHistory(startSs); } if (startSs.getTmpOutputFile() == null) { // per-session temp file containing results to be sent from HiveServer to HiveClient File tmpDir = new File(HiveConf.getVar(startSs.getConf(), HiveConf.ConfVars.HIVEHISTORYFILELOC)); String sessionID = startSs.getConf().getVar(HiveConf.ConfVars.HIVESESSIONID); try { File tmpFile = File.createTempFile(sessionID, ".pipeout", tmpDir); tmpFile.deleteOnExit(); startSs.setTmpOutputFile(tmpFile); } catch (IOException e) { throw new RuntimeException(e); } } try { startSs.authenticator = HiveUtils.getAuthenticator(startSs.getConf()); startSs.authorizer = HiveUtils.getAuthorizeProviderManager(startSs.getConf(), startSs.authenticator); startSs.createTableGrants = CreateTableAutomaticGrant.create(startSs.getConf()); } catch (HiveException e) { throw new RuntimeException(e); } return startSs; }