public class HadoopAccessorService extends Object implements Service
The default accessor used is the base accessor which just injects the UGI into the configuration instance used to create/obtain JobClient and FileSystem instances.
| Modifier and Type | Field and Description |
|---|---|
static String |
ACTION_CONFS |
static String |
ACTION_CONFS_LOAD_DEFAULT_RESOURCES |
static String |
CONF_PREFIX |
static String |
HADOOP_CONFS |
static String |
JOB_TRACKER_WHITELIST |
static String |
KERBEROS_AUTH_ENABLED |
static String |
KERBEROS_KEYTAB |
static String |
KERBEROS_PRINCIPAL |
static String |
NAME_NODE_WHITELIST |
static String |
SUPPORTED_FILESYSTEMS
Supported filesystem schemes for namespace federation
|
DEFAULT_LOCK_TIMEOUT, lockTimeout| Constructor and Description |
|---|
HadoopAccessorService() |
| Modifier and Type | Method and Description |
|---|---|
void |
addFileToClassPath(String user,
org.apache.hadoop.fs.Path file,
org.apache.hadoop.conf.Configuration conf) |
void |
checkSupportedFilesystem(URI uri)
checks configuration parameter if filesystem scheme is among the list of supported ones
this makes system robust to filesystems other than HDFS also
|
XConfiguration |
createActionDefaultConf(String hostPort,
String action)
Returns a Configuration containing any defaults for an action for a particular cluster.
|
org.apache.hadoop.conf.Configuration |
createConfiguration(String hostPort)
Creates a Configuration using the site configuration for the specified hostname:port.
|
org.apache.hadoop.fs.FileSystem |
createFileSystem(String user,
URI uri,
org.apache.hadoop.conf.Configuration conf)
Return a FileSystem created with the provided user for the specified URI.
|
org.apache.hadoop.mapred.JobClient |
createJobClient(String user,
org.apache.hadoop.conf.Configuration conf)
Return a JobClient created with the provided user/group.
|
org.apache.hadoop.mapred.JobClient |
createJobClient(String user,
org.apache.hadoop.mapred.JobConf conf)
Return a JobClient created with the provided user/group.
|
org.apache.hadoop.yarn.api.records.LocalResource |
createLocalResourceForConfigurationFile(String filename,
String user,
org.apache.hadoop.conf.Configuration conf,
URI uri,
org.apache.hadoop.fs.Path dir)
Creates a
LocalResource for the Configuration to localize it for a Yarn Container. |
org.apache.hadoop.yarn.client.api.YarnClient |
createYarnClient(String user,
org.apache.hadoop.conf.Configuration conf)
Return a YarnClient created with the provided user and configuration.
|
void |
destroy()
Destroy the service.
|
org.apache.hadoop.conf.Configuration |
getCachedConf() |
Class<? extends Service> |
getInterface()
Return the public interface of the service.
|
Set<String> |
getSupportedSchemes() |
void |
init(org.apache.hadoop.conf.Configuration conf) |
void |
init(Services services)
Initialize the service.
|
protected void |
validateJobTracker(String jobTrackerUri)
Validate Job tracker
|
protected void |
validateNameNode(String nameNodeUri)
Validate Namenode list
|
public static final String CONF_PREFIX
public static final String JOB_TRACKER_WHITELIST
public static final String NAME_NODE_WHITELIST
public static final String HADOOP_CONFS
public static final String ACTION_CONFS
public static final String ACTION_CONFS_LOAD_DEFAULT_RESOURCES
public static final String KERBEROS_AUTH_ENABLED
public static final String KERBEROS_KEYTAB
public static final String KERBEROS_PRINCIPAL
public static final String SUPPORTED_FILESYSTEMS
public HadoopAccessorService()
public void init(Services services) throws ServiceException
Service Invoked by the Service singleton at start up time.
init in interface Serviceservices - services singleton initializing the service.ServiceException - thrown if the service could not initialize.public void init(org.apache.hadoop.conf.Configuration conf) throws ServiceException
ServiceExceptionpublic void destroy()
Service Invoked by the Service singleton at shutdown time.
public Class<? extends Service> getInterface()
ServiceServices are retrieved by its public interface. Specializations of services must return the public interface.
getInterface in interface Servicepublic org.apache.hadoop.conf.Configuration createConfiguration(String hostPort)
If the specified hostname:port is not defined it falls back to the '*' site configuration if available. If the '*' site configuration is not available, the JobConf has all Hadoop defaults.
hostPort - hostname:port to lookup Hadoop site configuration.public org.apache.hadoop.conf.Configuration getCachedConf()
public XConfiguration createActionDefaultConf(String hostPort, String action)
This configuration is used as default for the action configuration and enables cluster level default values per action.
hostPort - hostname"port to lookup the action default confiugration.action - action name.public org.apache.hadoop.mapred.JobClient createJobClient(String user, org.apache.hadoop.mapred.JobConf conf) throws HadoopAccessorException
conf - JobConf with all necessary information to create the
JobClient.HadoopAccessorException - if the client could not be created.public org.apache.hadoop.mapred.JobClient createJobClient(String user, org.apache.hadoop.conf.Configuration conf) throws HadoopAccessorException
conf - Configuration with all necessary information to create the
JobClient.HadoopAccessorException - if the client could not be created.public org.apache.hadoop.yarn.client.api.YarnClient createYarnClient(String user, org.apache.hadoop.conf.Configuration conf) throws HadoopAccessorException
user - The username to impersonateconf - The confHadoopAccessorException - if the client could not be created.public org.apache.hadoop.fs.FileSystem createFileSystem(String user, URI uri, org.apache.hadoop.conf.Configuration conf) throws HadoopAccessorException
user - The username to impersonateuri - file system URI.conf - Configuration with all necessary information to create the FileSystem.HadoopAccessorException - if the filesystem could not be created.protected void validateJobTracker(String jobTrackerUri) throws HadoopAccessorException
jobTrackerUri - HadoopAccessorExceptionprotected void validateNameNode(String nameNodeUri) throws HadoopAccessorException
nameNodeUri - HadoopAccessorExceptionpublic void addFileToClassPath(String user, org.apache.hadoop.fs.Path file, org.apache.hadoop.conf.Configuration conf) throws IOException
IOExceptionpublic void checkSupportedFilesystem(URI uri) throws HadoopAccessorException
HadoopAccessorExceptionpublic Set<String> getSupportedSchemes()
public org.apache.hadoop.yarn.api.records.LocalResource createLocalResourceForConfigurationFile(String filename, String user, org.apache.hadoop.conf.Configuration conf, URI uri, org.apache.hadoop.fs.Path dir) throws IOException, HadoopAccessorException, URISyntaxException
LocalResource for the Configuration to localize it for a Yarn Container. This involves also writing it
to HDFS.
Example usage:
*
LocalResource res1 = createLocalResourceForConfigurationFile(filename1, user, conf, uri, dir);
LocalResource res2 = createLocalResourceForConfigurationFile(filename2, user, conf, uri, dir);
...
Map<String, LocalResource> localResources = new HashMap<String, LocalResource>();
localResources.put(filename1, res1);
localResources.put(filename2, res2);
...
containerLaunchContext.setLocalResources(localResources);
filename - The filename to use on the remote filesystem and once it has been localized.user - The userconf - The configuration to processuri - The URI of the remote filesystem (e.g. HDFS)dir - The directory on the remote filesystem to write the file toIOException - A problem occurred writing the fileHadoopAccessorException - A problem occured with HadoopURISyntaxException - A problem occurred parsing the URICopyright © 2018 Apache Software Foundation. All rights reserved.