Hive Hook类型

Hive在程序启动不同阶段设置了hook供用户自定义不同的行为

一共有四个阶段提供Hook以供注入定制化代码

  • Driver run hooks (Pre/Post)
  • Semantic analyizer hooks (Pre/Post)
  • Execution hooks (Pre/Failure/Post)
  • Client statistics publisher
Hive的运行流程为:

  1. Driver.run() takes the command
  2. HiveDriverRunHook.preDriverRun()
    (HiveConf.ConfVars.HIVE_DRIVER_RUN_HOOKS)
  3. Driver.compile() starts processing the command: creates the abstract syntax tree
  4. AbstractSemanticAnalyzerHook.preAnalyze()
    (HiveConf.ConfVars.SEMANTIC_ANALYZER_HOOK)
  5. Semantic analysis
  6. AbstractSemanticAnalyzerHook.postAnalyze()
    (HiveConf.ConfVars.SEMANTIC_ANALYZER_HOOK)
  7. Create and validate the query plan (physical plan)
  8. Driver.execute() : ready to run the jobs
  9. ExecuteWithHookContext.run()
    (HiveConf.ConfVars.PREEXECHOOKS)
  10. ExecDriver.execute() runs all the jobs
  11. For each job at every HiveConf.ConfVars.HIVECOUNTERSPULLINTERVAL interval:
    ClientStatsPublisher.run() is called to publish statistics
    (HiveConf.ConfVars.CLIENTSTATSPUBLISHERS)
    If a task fails: ExecuteWithHookContext.run()
    (HiveConf.ConfVars.ONFAILUREHOOKS)
  12. Finish all the tasks
  13. ExecuteWithHookContext.run()
    (HiveConf.ConfVars.POSTEXECHOOKS)
  14. Before returning the result HiveDriverRunHook.postDriverRun()
    ( HiveConf.ConfVars.HIVE_DRIVER_RUN_HOOKS)
  15. Return the result.

For each of the hooks I indicated the interfaces you have to implement. In the brackets there's the corresponding conf. prop. key you have to set in order to register the class at the beginning of the script. E.g: setting the PreExecution hook (9th stage of the workflow)

HiveConf.ConfVars.PREEXECHOOKS -> hive.exec.pre.hooks :
set hive.exec.pre.hooks=com.example.MyPreHook;

Unfortunately these features aren't really documented, but you can always look into the Driver class to see the evaluation order of the hooks.

Remark: I assumed here Hive 0.11.0, I don't think that the Cloudera distribution differs (too much


参考:

http://stackoverflow.com/questions/17461932/hive-execution-hook

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值