Search in sources :

Example 1 with ProgressMonitor

use of org.apache.hadoop.hive.common.log.ProgressMonitor in project hive by apache.

the class CLIService method progressUpdateLog.

private JobProgressUpdate progressUpdateLog(boolean isProgressLogRequested, Operation operation, HiveConf conf) {
    if (!isProgressLogRequested || !ServiceUtils.canProvideProgressLog(conf) || !OperationType.EXECUTE_STATEMENT.equals(operation.getType())) {
        return new JobProgressUpdate(ProgressMonitor.NULL);
    }
    SessionState sessionState = operation.getParentSession().getSessionState();
    long startTime = System.nanoTime();
    int timeOutMs = 8;
    try {
        while (sessionState.getProgressMonitor() == null && !operation.isDone()) {
            long remainingMs = (PROGRESS_MAX_WAIT_NS - (System.nanoTime() - startTime)) / 1000000l;
            if (remainingMs <= 0) {
                LOG.debug("timed out and hence returning progress log as NULL");
                return new JobProgressUpdate(ProgressMonitor.NULL);
            }
            Thread.sleep(Math.min(remainingMs, timeOutMs));
            timeOutMs <<= 1;
        }
    } catch (InterruptedException e) {
        LOG.warn("Error while getting progress update", e);
    }
    ProgressMonitor pm = sessionState.getProgressMonitor();
    return new JobProgressUpdate(pm != null ? pm : ProgressMonitor.NULL);
}
Also used : ProgressMonitor(org.apache.hadoop.hive.common.log.ProgressMonitor) SessionState(org.apache.hadoop.hive.ql.session.SessionState)

Example 2 with ProgressMonitor

use of org.apache.hadoop.hive.common.log.ProgressMonitor in project hive by apache.

the class ThriftCLIService method getProgressedPercentage.

private double getProgressedPercentage(OperationHandle opHandle) throws HiveSQLException {
    checkArgument(OperationType.EXECUTE_STATEMENT.equals(opHandle.getOperationType()));
    Operation operation = cliService.getSessionManager().getOperationManager().getOperation(opHandle);
    SessionState state = operation.getParentSession().getSessionState();
    ProgressMonitor monitor = state.getProgressMonitor();
    return monitor == null ? 0.0 : monitor.progressedPercentage();
}
Also used : ProgressMonitor(org.apache.hadoop.hive.common.log.ProgressMonitor) SessionState(org.apache.hadoop.hive.ql.session.SessionState) Operation(org.apache.hive.service.cli.operation.Operation)

Aggregations

ProgressMonitor (org.apache.hadoop.hive.common.log.ProgressMonitor)2 SessionState (org.apache.hadoop.hive.ql.session.SessionState)2 Operation (org.apache.hive.service.cli.operation.Operation)1