Search in sources :

Example 1 with HiveHistoryImpl

use of org.apache.hadoop.hive.ql.history.HiveHistoryImpl in project hive by apache.

the class ResourceMaps method start.

private static synchronized void start(SessionState startSs, boolean isAsync, LogHelper console) {
    setCurrentSessionState(startSs);
    if (startSs.isStarted) {
        return;
    }
    startSs.isStarted = true;
    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();
        }
    }
    // while and should be done when we start up.
    try {
        UserGroupInformation sessionUGI = Utils.getUGI();
        FileSystem.get(startSs.sessionConf);
        // 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);
            }
        }
        // Set temp file containing error output to be sent to client
        if (startSs.getTmpErrOutputFile() == null) {
            try {
                startSs.setTmpErrOutputFile(createTempFile(startSs.getConf()));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        // that would cause ClassNoFoundException otherwise
        throw new RuntimeException(e);
    }
    String engine = HiveConf.getVar(startSs.getConf(), HiveConf.ConfVars.HIVE_EXECUTION_ENGINE);
    if (!engine.equals("tez") || startSs.isHiveServerQuery)
        return;
    try {
        if (startSs.tezSessionState == null) {
            startSs.setTezSession(new TezSessionState(startSs.getSessionId()));
        }
        if (startSs.tezSessionState.isOpen()) {
            return;
        }
        if (startSs.tezSessionState.isOpening()) {
            if (!isAsync) {
                startSs.tezSessionState.endOpen();
            }
            return;
        }
        // Neither open nor opening.
        if (!isAsync) {
            // should use conf on session start-up
            startSs.tezSessionState.open(startSs.sessionConf);
        } else {
            startSs.tezSessionState.beginOpen(startSs.sessionConf, null, console);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : IOException(java.io.IOException) HiveHistoryImpl(org.apache.hadoop.hive.ql.history.HiveHistoryImpl) URISyntaxException(java.net.URISyntaxException) LockException(org.apache.hadoop.hive.ql.lockmgr.LockException) CancellationException(java.util.concurrent.CancellationException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) TezSessionState(org.apache.hadoop.hive.ql.exec.tez.TezSessionState)

Aggregations

IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 CancellationException (java.util.concurrent.CancellationException)1 TezSessionState (org.apache.hadoop.hive.ql.exec.tez.TezSessionState)1 HiveHistoryImpl (org.apache.hadoop.hive.ql.history.HiveHistoryImpl)1 LockException (org.apache.hadoop.hive.ql.lockmgr.LockException)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1