HADOOP-14150. Implement getHomeDirectory() method in NativeAzureFileSystem. Contributed by Santhosh G Nayak

This commit is contained in:
Mingliang Liu 2017-03-07 14:55:52 -08:00
parent 1598fd3b79
commit 28daaf0eb2
1 changed files with 10 additions and 0 deletions

View File

@ -84,6 +84,7 @@ import com.microsoft.azure.storage.StorageException;
@InterfaceStability.Stable @InterfaceStability.Stable
public class NativeAzureFileSystem extends FileSystem { public class NativeAzureFileSystem extends FileSystem {
private static final int USER_WX_PERMISION = 0300; private static final int USER_WX_PERMISION = 0300;
private static final String USER_HOME_DIR_PREFIX_DEFAULT = "/user";
/** /**
* A description of a folder rename operation, including the source and * A description of a folder rename operation, including the source and
* destination keys, and descriptions of the files in the source folder. * destination keys, and descriptions of the files in the source folder.
@ -1129,6 +1130,8 @@ public class NativeAzureFileSystem extends FileSystem {
*/ */
private WasbAuthorizerInterface authorizer = null; private WasbAuthorizerInterface authorizer = null;
private UserGroupInformation ugi;
private String delegationToken = null; private String delegationToken = null;
public NativeAzureFileSystem() { public NativeAzureFileSystem() {
@ -1247,6 +1250,7 @@ public class NativeAzureFileSystem extends FileSystem {
store.initialize(uri, conf, instrumentation); store.initialize(uri, conf, instrumentation);
setConf(conf); setConf(conf);
this.ugi = UserGroupInformation.getCurrentUser();
this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority()); this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority());
this.workingDir = new Path("/user", UserGroupInformation.getCurrentUser() this.workingDir = new Path("/user", UserGroupInformation.getCurrentUser()
.getShortUserName()).makeQualified(getUri(), getWorkingDirectory()); .getShortUserName()).makeQualified(getUri(), getWorkingDirectory());
@ -1276,6 +1280,12 @@ public class NativeAzureFileSystem extends FileSystem {
} }
} }
@Override
public Path getHomeDirectory() {
return makeQualified(new Path(
USER_HOME_DIR_PREFIX_DEFAULT + "/" + this.ugi.getShortUserName()));
}
@VisibleForTesting @VisibleForTesting
public void updateWasbAuthorizer(WasbAuthorizerInterface authorizer) { public void updateWasbAuthorizer(WasbAuthorizerInterface authorizer) {
this.authorizer = authorizer; this.authorizer = authorizer;