Java Code Examples for org.apache.hadoop.security.UserGroupInformation.getPrimaryGroupName()

The following are Jave code examples for showing how to use getPrimaryGroupName() of the org.apache.hadoop.security.UserGroupInformation class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: hadoop   File: CachePool.java   View Source Code Vote up 6 votes
/**
 * Create a new cache pool based on a CachePoolInfo object and the defaults.
 * We will fill in information that was not supplied according to the
 * defaults.
 */
static CachePool createFromInfoAndDefaults(CachePoolInfo info)
    throws IOException {
  UserGroupInformation ugi = null;
  String ownerName = info.getOwnerName();
  if (ownerName == null) {
    ugi = NameNode.getRemoteUser();
    ownerName = ugi.getShortUserName();
  }
  String groupName = info.getGroupName();
  if (groupName == null) {
    if (ugi == null) {
      ugi = NameNode.getRemoteUser();
    }
    groupName = ugi.getPrimaryGroupName();
  }
  FsPermission mode = (info.getMode() == null) ? 
      FsPermission.getCachePoolDefault() : info.getMode();
  long limit = info.getLimit() == null ?
      CachePoolInfo.DEFAULT_LIMIT : info.getLimit();
  long maxRelativeExpiry = info.getMaxRelativeExpiryMs() == null ?
      CachePoolInfo.DEFAULT_MAX_RELATIVE_EXPIRY :
      info.getMaxRelativeExpiryMs();
  return new CachePool(info.getPoolName(),
      ownerName, groupName, mode, limit, maxRelativeExpiry);
}