public class UnixUserGroupInformation extends UserGroupInformation
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_GROUP |
static String |
DEFAULT_USERNAME |
static String |
UGI_PROPERTY_NAME |
LOG
Constructor and Description |
---|
UnixUserGroupInformation()
Default constructor
|
UnixUserGroupInformation(String[] ugi)
Constructor with parameter user/group names
|
UnixUserGroupInformation(String userName,
String[] groupNames)
Constructor with parameters user name and its group names.
|
Modifier and Type | Method and Description |
---|---|
static UnixUserGroupInformation |
createImmutable(String[] ugi)
Create an immutable
UnixUserGroupInformation object. |
boolean |
equals(Object other)
Decide if two UGIs are the same
|
String[] |
getGroupNames()
Return an array of group names
|
String |
getName() |
String |
getUserName()
Return the user's name
|
int |
hashCode()
Returns a hash code for this UGI.
|
static UnixUserGroupInformation |
login()
Get current user's name and the names of all its groups from Unix.
|
static UnixUserGroupInformation |
login(Configuration conf)
Equivalent to login(conf, false).
|
static UnixUserGroupInformation |
login(Configuration conf,
boolean save)
Get a user's name & its group names from the given configuration;
If it is not defined in the configuration, get the current user's
information from Unix.
|
void |
readFields(DataInput in)
Deserialize this object
First check if this is a UGI in the string format.
|
static UnixUserGroupInformation |
readFromConf(Configuration conf,
String attr)
Read a UGI from the given
conf
The object is expected to store with the property name attr
as a comma separated string that starts
with the user name followed by group names. |
static void |
saveToConf(Configuration conf,
String attr,
UnixUserGroupInformation ugi)
Store the given
ugi as a comma separated string in
conf as a property attr
The String starts with the user name followed by the default group names,
and other group names. |
String |
toString()
Convert this object to a string
|
void |
write(DataOutput out)
Serialize this object
First write a string marking that this is a UGI in the string format,
then write this object's serialized form to the given data output
|
getCurrentUGI, readFrom, setCurrentUGI, setCurrentUser
public static final String DEFAULT_USERNAME
public static final String DEFAULT_GROUP
public static final String UGI_PROPERTY_NAME
public UnixUserGroupInformation()
public UnixUserGroupInformation(String userName, String[] groupNames)
userName
- a user's namegroupNames
- groups list, first of which is the default groupIllegalArgumentException
- if any argument is nullpublic UnixUserGroupInformation(String[] ugi)
ugi
- an array containing user/group names, the first
element of which is the user name, the second of
which is the default group name.IllegalArgumentException
- if the array size is less than 2
or any element is null.public static UnixUserGroupInformation createImmutable(String[] ugi)
UnixUserGroupInformation
object.public String[] getGroupNames()
getGroupNames
in class UserGroupInformation
public String getUserName()
getUserName
in class UserGroupInformation
public void readFields(DataInput in) throws IOException
in
- input streamIOException
- is thrown if encounter any error when readingpublic void write(DataOutput out) throws IOException
out
- output streamIOException
- if encounter any error during writingpublic static void saveToConf(Configuration conf, String attr, UnixUserGroupInformation ugi)
ugi
as a comma separated string in
conf
as a property attr
The String starts with the user name followed by the default group names,
and other group names.conf
- configurationattr
- property nameugi
- a UnixUserGroupInformationpublic static UnixUserGroupInformation readFromConf(Configuration conf, String attr) throws LoginException
conf
The object is expected to store with the property name attr
as a comma separated string that starts
with the user name followed by group names.
If the property name is not defined, return null.
It's assumed that there is only one UGI per user. If this user already
has a UGI in the ugi map, return the ugi in the map.
Otherwise, construct a UGI from the configuration, store it in the
ugi map and return it.conf
- configurationattr
- property nameLoginException
- if the stored string is ill-formatted.public static UnixUserGroupInformation login() throws LoginException
DEFAULT_USERNAME
and DEFAULT_GROUP
constants.LoginException
public static UnixUserGroupInformation login(Configuration conf) throws LoginException
LoginException
public static UnixUserGroupInformation login(Configuration conf, boolean save) throws LoginException
conf
- either a job configuration or client's configurationsave
- saving it to conf?LoginException
- if not able to get the user/group informationpublic boolean equals(Object other)
public int hashCode()
public String toString()
public String getName()
Copyright © 2010 The Apache Software Foundation