Set hadoop system user for client embedded in Java webapp

后端 未结 3 1728
无人及你
无人及你 2020-11-28 10:23

I would like to submit MapReduce jobs from a java web application to a remote Hadoop cluster but am unable to specify which user the job should be submitted for. I would lik

3条回答
  •  余生分开走
    2020-11-28 11:15

    The code below works for me the same as

    System.setProperty("HADOOP_USER_NAME", "hduser")
    
    UserGroupInformation ugi = UserGroupInformation.createRemoteUser("hduser"); 
    ugi.doAs(new PrivilegedExceptionAction() {
        public Void run() throws Exception {
            Configuration configuration = new Configuration(); 
            configuration.set("hadoop.job.ugi", "hduser");
            int res = ToolRunner.run(configuration, new YourTool(), args);
            return null; 
        }
    });
    

提交回复
热议问题