コード例 #1
0
ファイル: CLIService.java プロジェクト: alanfgates/hive
 /* (non-Javadoc)
  * @see org.apache.hive.service.cli.ICLIService#closeOperation(org.apache.hive.service.cli.OperationHandle)
  */
 @Override
 public void closeOperation(OperationHandle opHandle) throws HiveSQLException {
   sessionManager
       .getOperationManager()
       .getOperation(opHandle)
       .getParentSession()
       .closeOperation(opHandle);
   LOG.debug(opHandle + ": closeOperation");
 }
コード例 #2
0
ファイル: CLIService.java プロジェクト: alanfgates/hive
 /* (non-Javadoc)
  * @see org.apache.hive.service.cli.ICLIService#getResultSetMetadata(org.apache.hive.service.cli.OperationHandle)
  */
 @Override
 public TableSchema getResultSetMetadata(OperationHandle opHandle) throws HiveSQLException {
   TableSchema tableSchema =
       sessionManager
           .getOperationManager()
           .getOperation(opHandle)
           .getParentSession()
           .getResultSetMetadata(opHandle);
   LOG.debug(opHandle + ": getResultSetMetadata()");
   return tableSchema;
 }
コード例 #3
0
ファイル: CLIService.java プロジェクト: alanfgates/hive
 @Override
 public RowSet fetchResults(
     OperationHandle opHandle, FetchOrientation orientation, long maxRows, FetchType fetchType)
     throws HiveSQLException {
   RowSet rowSet =
       sessionManager
           .getOperationManager()
           .getOperation(opHandle)
           .getParentSession()
           .fetchResults(opHandle, orientation, maxRows, fetchType);
   LOG.debug(opHandle + ": fetchResults()");
   return rowSet;
 }
コード例 #4
0
ファイル: CLIService.java プロジェクト: alanfgates/hive
  /* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getOperationStatus(org.apache.hive.service.cli.OperationHandle)
   */
  @Override
  public OperationStatus getOperationStatus(OperationHandle opHandle) throws HiveSQLException {
    Operation operation = sessionManager.getOperationManager().getOperation(opHandle);
    /**
     * If this is a background operation run asynchronously, we block for a duration determined by a
     * step function, before we return However, if the background operation is complete, we return
     * immediately.
     */
    if (operation.shouldRunAsync()) {
      HiveConf conf = operation.getParentSession().getHiveConf();
      long maxTimeout =
          HiveConf.getTimeVar(
              conf, HiveConf.ConfVars.HIVE_SERVER2_LONG_POLLING_TIMEOUT, TimeUnit.MILLISECONDS);

      final long elapsed = System.currentTimeMillis() - operation.getBeginTime();
      // A step function to increase the polling timeout by 500 ms every 10 sec,
      // starting from 500 ms up to HIVE_SERVER2_LONG_POLLING_TIMEOUT
      final long timeout =
          Math.min(maxTimeout, (elapsed / TimeUnit.SECONDS.toMillis(10) + 1) * 500);

      try {
        operation.getBackgroundHandle().get(timeout, TimeUnit.MILLISECONDS);
      } catch (TimeoutException e) {
        // No Op, return to the caller since long polling timeout has expired
        LOG.trace(opHandle + ": Long polling timed out");
      } catch (CancellationException e) {
        // The background operation thread was cancelled
        LOG.trace(opHandle + ": The background operation was cancelled", e);
      } catch (ExecutionException e) {
        // The background operation thread was aborted
        LOG.warn(opHandle + ": The background operation was aborted", e);
      } catch (InterruptedException e) {
        // No op, this thread was interrupted
        // In this case, the call might return sooner than long polling timeout
      }
    }
    OperationStatus opStatus = operation.getStatus();
    LOG.debug(opHandle + ": getOperationStatus()");
    return opStatus;
  }