运行pig local时,UDF程序无法写入文件/文件夹:PriviledgedActionException

运行pig local时,UDF程序无法写入文件/文件夹:PriviledgedActionException,exception,hadoop,permissions,user-defined-functions,apache-pig,Exception,Hadoop,Permissions,User Defined Functions,Apache 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_

有猪/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;
尝试使用我的自定义项写入文件夹/文件:

[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
以下代码必须(!)写入下次加载时使用的文件

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";
    }
}
(…)
公共字符串exec(元组输入)引发IOException{
试一试{
System.out.println(input.get(0.toString());
大黄蜂b=新大黄蜂(input.get(0.toString());
返回b.writeRelation(input.get(1.toString());
}捕获(例外e){
System.err.println(“处理输入失败;错误-”+e.getMessage());
返回null;
}
}
公共字符串writeRelation(字符串文件夹)引发IOException{
试一试{
//写文件!
文件输出=新文件(“输出/删除”+文件夹+”.txt”);
output.getParentFile().mkdirs();
FileWriter fw=新的FileWriter(输出);
String line=System.getProperty(“line.separator”);
fw.追加(“年;字;计数”+行);
对于(整数年:buzzCandidates.keySet()){
Map wordCounts=buzzCandidates.get(年);
for(字符串字:wordCounts.keySet()){
long value=wordCounts.get(word);
如果(值>=3){
fw.append(year+“;”+word.replace(“,”)+“;”+String.valueOf(value)+行);
}
}
}
fw.flush();
fw.close();
返回输出。getAbsolutePath();
}捕获(例外e){
System.out.println(“>>>错误!!\t”+e.getMessage());
返回“错误”;
}
}
我认为这是关于使用UDF编写文件的权限,但我不知道在哪里设置权限。有什么帮助吗


伙计们,先谢谢你们

错误读取输入路径不存在:文件:/Users/felipehorta/dev/ufrj/pig/pig buzz/output请检查pig脚本,了解如何使用加载

relation = load '/Users/felipehorta/dev/ufrj/pig/pig-buzz/output' using ...
这才是正确的做法


不确定这是否是确切的原因。如果您可以发布脚本,那就太好了。

您可以附加pig-*-.log来显示堆栈跟踪吗?