hadoop重启Namenode时,appTokens报FileNotFoundException

现象 报错如下 Application application_1405852606905_0014 failed 3 times due to AM Container for appattempt_1405852606905_0014_000003 exited with exitCode: -1000 due to: RemoteTrace: java.io.FileNotFoundException: File does not exist: hdfs://mycluster:8020/user/kpi/.staging/job_1405852606905_0014/appTokens at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:809) 同时注意到是因为每次……

关闭linux sendmail

service sendmail stop chkconfig --level 2345 sendmail off chkconfig --list sendmail via: http://hi.baidu.com/chenhj_brenda/item/e46c6b3fdb8f03b9124b14f0

impala文档的翻译

weiqingbin 翻译了很多,赞! 电梯如下: http://my.oschina.net/weiqingbin/blog?catalog=423691

vim格式化json

在vim输入以下命令就可以格式化 :%!python -m json.tool 可以在~/.vimrc增加快捷键 map <F4> <Esc>:%!python -m json.tool<CR> 来源……

动态注册hive udf

目标

可以不重启hive服务端动态增加或更新udf,本文用到动态加载以及hive hook实现。

看看原来的代码是怎样写的

我看的是cdh4.3.0代码,目前有两个地方注册udf, 一个是在org.apache.hadoop.hive.ql.exec.FunctionRegistry类里,大部分的内置udf都是在这里注册的,很多网站都是通过修改这里代码重新打包来注册udf。 第二个是最近新增了一个hive-builtins*.jar文件,注册函数是在

public SessionState(HiveConf conf) {
...
      Class<?> pluginClass = Utilities.getBuiltinUtilsClass();
      URL jarLocation = pluginClass.getProtectionDomain().getCodeSource().getLocation();
      add_builtin_resource(ResourceType.JAR, jarLocation.toString());
      FunctionRegistry.registerFunctionsFromPluginJar(jarLocation, pluginClass.getClassLoader());
...
  }

通过找到org.apache.hive.builtins.BuiltinUtils类定位jar的位置,把jar包加入hive.added.jars.path配置里,然后通过FunctionRegistry.registerFunctionsFromPluginJar来注册udf

//我们可以用这两个方法来注册udf
public static void registerTemporaryUDF(String functionName, Class<? extends UDF> UDFClass, boolean isOperator)
public static void registerFunctionsFromPluginJar(URL jarLocation, ClassLoader classLoader)
……