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

The following are Jave code examples for showing how to use getBestUGI() 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-oss   File: FileSystem.java   View Source Code Vote up 5 votes
/**
 * Get a filesystem instance based on the uri, the passed
 * configuration and the user
 * @param uri of the filesystem
 * @param conf the configuration to use
 * @param user to perform the get as
 * @return the filesystem instance
 * @throws IOException
 * @throws InterruptedException
 */
public static FileSystem get(final URI uri, final Configuration conf,
      final String user) throws IOException, InterruptedException {
  String ticketCachePath =
    conf.get(CommonConfigurationKeys.KERBEROS_TICKET_CACHE_PATH);
  UserGroupInformation ugi =
      UserGroupInformation.getBestUGI(ticketCachePath, user);
  return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
    @Override
    public FileSystem run() throws IOException {
      return get(uri, conf);
    }
  });
}
 
Example 2
Project: hadoop-oss   File: FileSystem.java   View Source Code Vote up 5 votes
/**
 * Returns the FileSystem for this URI's scheme and authority and the 
 * passed user. Internally invokes {@link #newInstance(URI, Configuration)}
 * @param uri of the filesystem
 * @param conf the configuration to use
 * @param user to perform the get as
 * @return filesystem instance
 * @throws IOException
 * @throws InterruptedException
 */
public static FileSystem newInstance(final URI uri, final Configuration conf,
    final String user) throws IOException, InterruptedException {
  String ticketCachePath =
    conf.get(CommonConfigurationKeys.KERBEROS_TICKET_CACHE_PATH);
  UserGroupInformation ugi =
      UserGroupInformation.getBestUGI(ticketCachePath, user);
  return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
    @Override
    public FileSystem run() throws IOException {
      return newInstance(uri,conf); 
    }
  });
}
 
Example 3
Project: hadoop   File: FileSystem.java   View Source Code Vote up 5 votes
/**
 * Get a filesystem instance based on the uri, the passed
 * configuration and the user
 * @param uri of the filesystem
 * @param conf the configuration to use
 * @param user to perform the get as
 * @return the filesystem instance
 * @throws IOException
 * @throws InterruptedException
 */
public static FileSystem get(final URI uri, final Configuration conf,
      final String user) throws IOException, InterruptedException {
  String ticketCachePath =
    conf.get(CommonConfigurationKeys.KERBEROS_TICKET_CACHE_PATH);
  UserGroupInformation ugi =
      UserGroupInformation.getBestUGI(ticketCachePath, user);
  return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
    @Override
    public FileSystem run() throws IOException {
      return get(uri, conf);
    }
  });
}
 
Example 4
Project: hadoop   File: FileSystem.java   View Source Code Vote up 5 votes
/**
 * Returns the FileSystem for this URI's scheme and authority and the 
 * passed user. Internally invokes {@link #newInstance(URI, Configuration)}
 * @param uri of the filesystem
 * @param conf the configuration to use
 * @param user to perform the get as
 * @return filesystem instance
 * @throws IOException
 * @throws InterruptedException
 */
public static FileSystem newInstance(final URI uri, final Configuration conf,
    final String user) throws IOException, InterruptedException {
  String ticketCachePath =
    conf.get(CommonConfigurationKeys.KERBEROS_TICKET_CACHE_PATH);
  UserGroupInformation ugi =
      UserGroupInformation.getBestUGI(ticketCachePath, user);
  return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
    @Override
    public FileSystem run() throws IOException {
      return newInstance(uri,conf); 
    }
  });
}