Q:

How to create HDFS file with a different owner than the client process

The HDFS Administrator Guide states

"When a file or directory is created, its owner is the user identity
  of the client process, and its group is the group of the parent
  directory (the BSD rule)."

Are there any exceptions to this rule?  Running a process as user 'clientA' is there any way to create a file with a different owner?
I'm running with hadoop.security.authentication=simple.  It looks like I can call setOwner after the fact, and that's a perfectly valid fallback solution.

A:

Does it look sane??
public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException {
        // TODO Auto-generated method stub

        Configuration conf = new Configuration();
        conf.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/core-site.xml"));
        conf.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/hdfs-site.xml"));
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter the directory URI...");
        String dirPath = br.readLine();
        URI uri = new URI(dirPath);
        System.out.println("Enter the user...");
        String user = br.readLine();
        FileSystem fs = FileSystem.get(uri, conf, user);
        fs.mkdirs(new Path(uri.toString()), FsPermission.getDefault());
        FSDataOutputStream fsDataOutputStream = fs.create(new Path(uri.toString()+"/file.txt"));
        fsDataOutputStream.writeBytes("This is a demo file..!!!!");
    }

