Search code examples
javahbasehadoop2

User used by Java Client API to access Hbase


I am learning Hbase.I want to know a Java Client will communicate with Hbase data ? I can see there are config ,HConnectionManager Classes to communicate with Hbase.I am curios to understand which userID does the client uses for this communication.

For Example : Say, I am running a hbaseTest.jar (i.e. My Java Client Jar file) from my local. My user ID : learner. and my /apps/data for hbase has the owner hbase.

What is the user Id used by my Java Client?

Thanks in advance !


Solution

  • You can use the following to get the user:

    import org.apache.hadoop.hbase.security.User;
    
    User u = User.getCurrent();
    System.out.println(u.getName());
    

    To change the use which you want to access Hbase, you can set environment variable for ("HADOOP_USER_NAME", "yourNewUser"). In eclipse, you can set in Run Configurations -> Arguments -> VM arguments -> -DHADOOP_USER_NAME=pedapna