Search in sources :

Example 1 with CompileLock

use of org.apache.hadoop.hive.ql.lock.CompileLock in project hive by apache.

the class Driver method compileInternal.

private void compileInternal(String command, boolean deferClose) throws CommandProcessorException {
    Metrics metrics = MetricsFactory.getInstance();
    if (metrics != null) {
        metrics.incrementCounter(MetricsConstant.WAITING_COMPILE_OPS, 1);
    }
    PerfLogger perfLogger = SessionState.getPerfLogger(true);
    perfLogger.perfLogBegin(CLASS_NAME, PerfLogger.WAIT_COMPILE);
    try (CompileLock compileLock = CompileLockFactory.newInstance(driverContext.getConf(), command)) {
        boolean success = compileLock.tryAcquire();
        perfLogger.perfLogEnd(CLASS_NAME, PerfLogger.WAIT_COMPILE);
        if (metrics != null) {
            metrics.decrementCounter(MetricsConstant.WAITING_COMPILE_OPS, 1);
        }
        if (!success) {
            String errorMessage = ErrorMsg.COMPILE_LOCK_TIMED_OUT.getErrorCodedMsg();
            throw DriverUtils.createProcessorException(driverContext, ErrorMsg.COMPILE_LOCK_TIMED_OUT.getErrorCode(), errorMessage, null, null);
        }
        try {
            compile(command, true, deferClose);
        } catch (CommandProcessorException cpe) {
            try {
                driverTxnHandler.endTransactionAndCleanup(false);
            } catch (LockException e) {
                LOG.warn("Exception in releasing locks", e);
            }
            throw cpe;
        }
    }
    // Save compile-time PerfLogging for WebUI.
    // Execution-time Perf logs are done by either another thread's PerfLogger or a reset PerfLogger.
    driverContext.getQueryDisplay().setPerfLogStarts(QueryDisplay.Phase.COMPILATION, perfLogger.getStartTimes());
    driverContext.getQueryDisplay().setPerfLogEnds(QueryDisplay.Phase.COMPILATION, perfLogger.getEndTimes());
}
Also used : Metrics(org.apache.hadoop.hive.common.metrics.common.Metrics) CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException) LockException(org.apache.hadoop.hive.ql.lockmgr.LockException) PerfLogger(org.apache.hadoop.hive.ql.log.PerfLogger) CompileLock(org.apache.hadoop.hive.ql.lock.CompileLock)

Aggregations

Metrics (org.apache.hadoop.hive.common.metrics.common.Metrics)1 CompileLock (org.apache.hadoop.hive.ql.lock.CompileLock)1 LockException (org.apache.hadoop.hive.ql.lockmgr.LockException)1 PerfLogger (org.apache.hadoop.hive.ql.log.PerfLogger)1 CommandProcessorException (org.apache.hadoop.hive.ql.processors.CommandProcessorException)1