HiveInterruptUtils.interrupt()如何工作?

时间:2013-07-30 03:34:12

标签: hive interrupt

我最近一直在阅读hive源代码,但我对此interrupt()感到困惑。我想知道它是如何中断当前的hive命令的。这个函数的位置在CliDriver.processLine()

1 个答案:

答案 0 :(得分:0)

在HiveInterruptUtils http://people.apache.org/~hashutosh/hive-clover/common/org/apache/hadoop/hive/common/HiveInterruptUtils.html的实现中,找到这个:

public static void interrupt() {
    synchronized (interruptCallbacks) {
          for (HiveInterruptCallback resource : 
                       new ArrayList<HiveInterruptCallback>(interruptCallbacks)) {
            resource.interrupt();
          }
    }
}

这可能会中断以前添加到HiveInterruptCallback列表中的所有资源。

HiveInterruptCallback,http://people.apache.org/~hashutosh/hive-clover/common/org/apache/hadoop/hive/common/HiveInterruptCallback.html#HiveInterruptCallback也是一个接口。

public interface HiveInterruptCallback {
  /**
  * Request interrupting of the processing
  */
  void interrupt();
}

以前注册的资源实现了HiveInterruptCallback interrupt()方法,因此HiveInterruptUtils.interrupt()行为取决于特定的资源实现。