Sajal Rastogi
Sajal Rastogi

Reputation: 21

Accessing HDFS using a different username

I am writing a Java module where I need to access the HDFS file system using the hdfs URI. The user who will be executing the module could be different than the user who have launched the namenode and datanode.

Also, there is a possibility that the java module and hadoop cluster runs on separate machines.

The problem that I am facing is that when I try to access the hdfs using FileSystem object, The user name that is being used to access the FS object is the local user running the java module.

My question is how can we enforce the access to HDFS by using the same user name that has launched the namenode and datanode instances.

I tried setting the user.name system property but even that didn't work. I read at couple of places to put an implementation of whoami on the machine where my java module is running as the client code uses this command to fetch the user name.

I want to know if there is any other way to achieve this?

Regards Sajal

Upvotes: 0

Views: 268

Answers (1)

Harsh J
Harsh J

Reputation: 1494

For Java programs, you may use the Secure Impersonation feature, available in CDH3 or 1.x onwards.

Upvotes: 0

Related Questions