HADOOP-17011. Tolerate leading and trailing spaces in fs.defaultFS. Contributed by Ctest
Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
parent
6bdab3723e
commit
263c76b678
@ -483,7 +483,7 @@ public class FileContext implements PathCapabilities {
|
|||||||
*/
|
*/
|
||||||
public static FileContext getFileContext(final Configuration aConf)
|
public static FileContext getFileContext(final Configuration aConf)
|
||||||
throws UnsupportedFileSystemException {
|
throws UnsupportedFileSystemException {
|
||||||
final URI defaultFsUri = URI.create(aConf.get(FS_DEFAULT_NAME_KEY,
|
final URI defaultFsUri = URI.create(aConf.getTrimmed(FS_DEFAULT_NAME_KEY,
|
||||||
FS_DEFAULT_NAME_DEFAULT));
|
FS_DEFAULT_NAME_DEFAULT));
|
||||||
if ( defaultFsUri.getScheme() != null
|
if ( defaultFsUri.getScheme() != null
|
||||||
&& !defaultFsUri.getScheme().trim().isEmpty()) {
|
&& !defaultFsUri.getScheme().trim().isEmpty()) {
|
||||||
|
@ -278,7 +278,8 @@ public abstract class FileSystem extends Configured
|
|||||||
* @return the uri of the default filesystem
|
* @return the uri of the default filesystem
|
||||||
*/
|
*/
|
||||||
public static URI getDefaultUri(Configuration conf) {
|
public static URI getDefaultUri(Configuration conf) {
|
||||||
URI uri = URI.create(fixName(conf.get(FS_DEFAULT_NAME_KEY, DEFAULT_FS)));
|
URI uri =
|
||||||
|
URI.create(fixName(conf.getTrimmed(FS_DEFAULT_NAME_KEY, DEFAULT_FS)));
|
||||||
if (uri.getScheme() == null) {
|
if (uri.getScheme() == null) {
|
||||||
throw new IllegalArgumentException("No scheme in default FS: " + uri);
|
throw new IllegalArgumentException("No scheme in default FS: " + uri);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ abstract public class FsCommand extends Command {
|
|||||||
HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY,
|
HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY,
|
||||||
HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_DEFAULT);
|
HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_DEFAULT);
|
||||||
if (displayWarnings) {
|
if (displayWarnings) {
|
||||||
final String defaultFs = getConf().get(FS_DEFAULT_NAME_KEY);
|
final String defaultFs = getConf().getTrimmed(FS_DEFAULT_NAME_KEY);
|
||||||
final boolean missingDefaultFs =
|
final boolean missingDefaultFs =
|
||||||
defaultFs == null || defaultFs.equals(FS_DEFAULT_NAME_DEFAULT);
|
defaultFs == null || defaultFs.equals(FS_DEFAULT_NAME_DEFAULT);
|
||||||
if (missingDefaultFs) {
|
if (missingDefaultFs) {
|
||||||
|
@ -101,7 +101,7 @@ public class HttpFSServerWebApp extends ServerWebApp {
|
|||||||
adminGroup = getConfig().get(getPrefixedName(CONF_ADMIN_GROUP), "admin");
|
adminGroup = getConfig().get(getPrefixedName(CONF_ADMIN_GROUP), "admin");
|
||||||
LOG.info("Connects to Namenode [{}]",
|
LOG.info("Connects to Namenode [{}]",
|
||||||
get().get(FileSystemAccess.class).getFileSystemConfiguration().
|
get().get(FileSystemAccess.class).getFileSystemConfiguration().
|
||||||
get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
getTrimmed(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -341,8 +341,9 @@ public class FileSystemAccessService extends BaseService implements FileSystemAc
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
validateNamenode(
|
validateNamenode(
|
||||||
new URI(conf.get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY)).
|
new URI(conf.getTrimmed(
|
||||||
getAuthority());
|
CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY)).
|
||||||
|
getAuthority());
|
||||||
UserGroupInformation ugi = getUGI(user);
|
UserGroupInformation ugi = getUGI(user);
|
||||||
return ugi.doAs(new PrivilegedExceptionAction<T>() {
|
return ugi.doAs(new PrivilegedExceptionAction<T>() {
|
||||||
@Override
|
@Override
|
||||||
@ -377,7 +378,9 @@ public class FileSystemAccessService extends BaseService implements FileSystemAc
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
validateNamenode(
|
validateNamenode(
|
||||||
new URI(conf.get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY)).getAuthority());
|
new URI(conf.getTrimmed(
|
||||||
|
CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY)).
|
||||||
|
getAuthority());
|
||||||
UserGroupInformation ugi = getUGI(user);
|
UserGroupInformation ugi = getUGI(user);
|
||||||
return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
|
return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,7 +70,7 @@ public final class NameNodeUtils {
|
|||||||
final Collection<String> nameservices =
|
final Collection<String> nameservices =
|
||||||
DFSUtilClient.getNameServiceIds(conf);
|
DFSUtilClient.getNameServiceIds(conf);
|
||||||
|
|
||||||
final String nnAddr = conf.get(FS_DEFAULT_NAME_KEY);
|
final String nnAddr = conf.getTrimmed(FS_DEFAULT_NAME_KEY);
|
||||||
if (nnAddr == null) {
|
if (nnAddr == null) {
|
||||||
// default fs is not set.
|
// default fs is not set.
|
||||||
return null;
|
return null;
|
||||||
|
@ -302,7 +302,8 @@ public class JobHistoryUtils {
|
|||||||
FileContext fc = getDefaultFileContext();
|
FileContext fc = getDefaultFileContext();
|
||||||
if (fc == null ||
|
if (fc == null ||
|
||||||
fc.getDefaultFileSystem().getUri().toString().equals(
|
fc.getDefaultFileSystem().getUri().toString().equals(
|
||||||
conf.get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, "")) ||
|
conf.getTrimmed(
|
||||||
|
CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, "")) ||
|
||||||
path.toUri().getAuthority() != null ||
|
path.toUri().getAuthority() != null ||
|
||||||
path.toUri().getScheme()!= null) {
|
path.toUri().getScheme()!= null) {
|
||||||
return sourcePath;
|
return sourcePath;
|
||||||
|
@ -566,7 +566,7 @@ public class FrameworkUploader implements Runnable {
|
|||||||
path.startsWith("file://");
|
path.startsWith("file://");
|
||||||
|
|
||||||
if (fs == null) {
|
if (fs == null) {
|
||||||
fs = conf.get(FS_DEFAULT_NAME_KEY);
|
fs = conf.getTrimmed(FS_DEFAULT_NAME_KEY);
|
||||||
if (fs == null && !isFullPath) {
|
if (fs == null && !isFullPath) {
|
||||||
LOG.error("No filesystem specified in either fs or target.");
|
LOG.error("No filesystem specified in either fs or target.");
|
||||||
printHelp(opts);
|
printHelp(opts);
|
||||||
|
@ -86,7 +86,7 @@ class ClusterSummarizer implements StatListener<ClusterStats> {
|
|||||||
|
|
||||||
void start(Configuration conf) {
|
void start(Configuration conf) {
|
||||||
jobTrackerInfo = conf.get(JTConfig.JT_IPC_ADDRESS);
|
jobTrackerInfo = conf.get(JTConfig.JT_IPC_ADDRESS);
|
||||||
namenodeInfo = conf.get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY);
|
namenodeInfo = conf.getTrimmed(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
Loading…
x
Reference in New Issue
Block a user