【问题标题】:Running pig local, UDF program cannot write files/folder: PriviledgedActionException在本地运行 pig,UDF 程序无法写入文件/文件夹:PriviledgedActionException
【发布时间】:2013-06-03 01:55:05
【问题描述】:

Pig/hadoop 新手..

在当地跑猪。

java  -Xmx512m -Xmx1024m -cp $PIGDIR/pig.jar org.apache.pig.Main -Dpig.temp.dir=/tmp/$USER/$RANDOM -stop_on_failure -x  local script-buzz.pig

用我的 script.pig:

(...) 
buzz = FOREACH files GENERATE chiron.buzz.Honey(file, id) as buzz_file, id;

尝试使用我的 UDF 提升写入文件夹/文件:

[JobControl] ERROR org.apache.hadoop.security.UserGroupInformation - PriviledgedActionException as:felipehorta cause:org.apache.pig.backend.executionengine.ExecException: ERROR 2118: Input path does not exist: file:/Users/felipehorta/dev/ufrj/pig/pig-buzz/output

以下代码必须 (!) 写入在下一次 LOAD 时使用的文件。

jar 适用于:$ java -jar Pgm.jar *

(...)
public String exec(Tuple input) throws IOException {
    try{
        System.out.println(input.get(0).toString());
        BumbleBee b = new BumbleBee(input.get(0).toString());
        return b.writeRelation(input.get(1).toString());
    } catch(Exception e){
        System.err.println("Failed to process input; error - " + e.getMessage());
        return null;
    }
}

public String writeRelation(String folder) throws IOException {
    try {
        // writing file!
        File output = new File("output/ERelation_" + folder +  ".txt");
        output.getParentFile().mkdirs();
        FileWriter fw = new FileWriter(output);
        String line = System.getProperty("line.separator");
        fw.append("YEAR;WORD;COUNT" + line);
        for (Integer year : buzzCandidates.keySet()) {
            Map<String, Long> wordCounts = buzzCandidates.get(year);
            for (String word : wordCounts.keySet()) {
                long value = wordCounts.get(word);
                if (value >= 3) {
                    fw.append(year + ";" + word.replace(" ", "_") + ";" + String.valueOf(value) + line);
                }
            }
        }
        fw.flush();
        fw.close();
        return output.getAbsolutePath();
    } catch (Exception e) {
        System.out.println(">>> ERROR!!\t" + e.getMessage());
        return "ERROR";
    }
}

我认为这是关于使用 UDF 写入文件的权限,但我不知道在哪里设置权限。有什么帮助吗?

提前谢谢各位!

【问题讨论】:

  • 能否附上 pig-*-.log 以显示堆栈跟踪?

标签: exception hadoop permissions user-defined-functions apache-pig


【解决方案1】:

错误读取输入路径不存在:文件:/Users/felipehorta/dev/ufrj/pig/pig-buzz/output请检查pig脚本以了解负载的使用方式。

relation = load '/Users/felipehorta/dev/ufrj/pig/pig-buzz/output' using ...

这将是正确的做法。

不确定这是否是确切的原因。如果你能发布脚本就好了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    • 1970-01-01
    • 2015-02-05
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多