HADOOP-14049. Honour AclBit flag associated to file/folder permission for Azure datalake account. Contributed by Vishwajeet Dusane

(cherry picked from commit f432999025)
This commit is contained in:
Mingliang Liu 2017-02-16 15:14:25 -08:00 committed by Chris Douglas
parent ed4388f903
commit a146866802
4 changed files with 83 additions and 1 deletions

View File

@ -593,7 +593,11 @@ public class AdlFileSystem extends FileSystem {
boolean isDirectory = entry.type == DirectoryEntryType.DIRECTORY; boolean isDirectory = entry.type == DirectoryEntryType.DIRECTORY;
long lastModificationData = entry.lastModifiedTime.getTime(); long lastModificationData = entry.lastModifiedTime.getTime();
long lastAccessTime = entry.lastAccessTime.getTime(); long lastAccessTime = entry.lastAccessTime.getTime();
FsPermission permission = new AdlPermission(aclBitStatus, // set aclBit from ADLS backend response if
// ADL_SUPPORT_ACL_BIT_IN_FSPERMISSION is true.
final boolean aclBit = aclBitStatus ? entry.aclBit : false;
FsPermission permission = new AdlPermission(aclBit,
Short.valueOf(entry.permission, 8)); Short.valueOf(entry.permission, 8));
String user = entry.user; String user = entry.user;
String group = entry.group; String group = entry.group;

View File

@ -66,6 +66,15 @@ public final class TestADLResponseData {
"\"owner\":\"NotSupportYet\",\"group\":\"NotSupportYet\"}}"; "\"owner\":\"NotSupportYet\",\"group\":\"NotSupportYet\"}}";
} }
public static String getGetFileStatusJSONResponse(boolean aclBit) {
return "{\"FileStatus\":{\"length\":1024," +
"\"pathSuffix\":\"\",\"type\":\"FILE\",\"blockSize\":268435456," +
"\"accessTime\":1452103827023,\"modificationTime\":1452103827023," +
"\"replication\":0,\"permission\":\"777\"," +
"\"owner\":\"NotSupportYet\",\"group\":\"NotSupportYet\",\"aclBit\":\""
+ aclBit + "\"}}";
}
public static String getListFileStatusJSONResponse(int dirSize) { public static String getListFileStatusJSONResponse(int dirSize) {
String list = ""; String list = "";
for (int i = 0; i < dirSize; ++i) { for (int i = 0; i < dirSize; ++i) {
@ -81,6 +90,18 @@ public final class TestADLResponseData {
return "{\"FileStatuses\":{\"FileStatus\":[" + list + "]}}"; return "{\"FileStatuses\":{\"FileStatus\":[" + list + "]}}";
} }
public static String getListFileStatusJSONResponse(boolean aclBit) {
return "{\"FileStatuses\":{\"FileStatus\":[{\"length\":0,\"pathSuffix\":\""
+ java.util.UUID.randomUUID()
+ "\",\"type\":\"DIRECTORY\",\"blockSize\":0,"
+ "\"accessTime\":1481184513488,"
+ "\"modificationTime\":1481184513488,\"replication\":0,"
+ "\"permission\":\"770\","
+ "\"owner\":\"4b27fe1a-d9ab-4a04-ad7a-4bba72cd9e6c\","
+ "\"group\":\"4b27fe1a-d9ab-4a04-ad7a-4bba72cd9e6c\",\"aclBit\":\""
+ aclBit + "\"}]}}";
}
public static String getJSONResponse(boolean status) { public static String getJSONResponse(boolean status) {
return "{\"boolean\":" + status + "}"; return "{\"boolean\":" + status + "}";
} }

View File

@ -67,4 +67,29 @@ public class TestGetFileStatus extends AdlMockWebServer {
Assert.assertEquals("NotSupportYet", fileStatus.getGroup()); Assert.assertEquals("NotSupportYet", fileStatus.getGroup());
} }
@Test
public void getFileStatusAclBit()
throws URISyntaxException, IOException {
// With ACLBIT set to true
getMockServer().enqueue(new MockResponse().setResponseCode(200)
.setBody(TestADLResponseData.getGetFileStatusJSONResponse(true)));
long startTime = Time.monotonicNow();
FileStatus fileStatus = getMockAdlFileSystem()
.getFileStatus(new Path("/test1/test2"));
long endTime = Time.monotonicNow();
LOG.debug("Time : " + (endTime - startTime));
Assert.assertTrue(fileStatus.isFile());
Assert.assertEquals(true, fileStatus.getPermission().getAclBit());
// With ACLBIT set to false
getMockServer().enqueue(new MockResponse().setResponseCode(200)
.setBody(TestADLResponseData.getGetFileStatusJSONResponse(false)));
startTime = Time.monotonicNow();
fileStatus = getMockAdlFileSystem()
.getFileStatus(new Path("/test1/test2"));
endTime = Time.monotonicNow();
LOG.debug("Time : " + (endTime - startTime));
Assert.assertTrue(fileStatus.isFile());
Assert.assertEquals(false, fileStatus.getPermission().getAclBit());
}
} }

View File

@ -29,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException;
/** /**
* This class is responsible for testing local listStatus implementation to * This class is responsible for testing local listStatus implementation to
@ -100,4 +101,35 @@ public class TestListStatus extends AdlMockWebServer {
LOG.debug("Time : " + (endTime - startTime)); LOG.debug("Time : " + (endTime - startTime));
} }
@Test
public void listStatusAclBit()
throws URISyntaxException, IOException {
// With ACLBIT set to true
getMockServer().enqueue(new MockResponse().setResponseCode(200)
.setBody(TestADLResponseData.getListFileStatusJSONResponse(true)));
FileStatus[] ls = null;
long startTime = Time.monotonicNow();
ls = getMockAdlFileSystem()
.listStatus(new Path("/test1/test2"));
long endTime = Time.monotonicNow();
LOG.debug("Time : " + (endTime - startTime));
for (int i = 0; i < ls.length; i++) {
Assert.assertTrue(ls[i].isDirectory());
Assert.assertEquals(true, ls[i].getPermission().getAclBit());
}
// With ACLBIT set to false
ls = null;
getMockServer().enqueue(new MockResponse().setResponseCode(200)
.setBody(TestADLResponseData.getListFileStatusJSONResponse(false)));
startTime = Time.monotonicNow();
ls = getMockAdlFileSystem()
.listStatus(new Path("/test1/test2"));
endTime = Time.monotonicNow();
LOG.debug("Time : " + (endTime - startTime));
for (int i = 0; i < ls.length; i++) {
Assert.assertTrue(ls[i].isDirectory());
Assert.assertEquals(false, ls[i].getPermission().getAclBit());
}
}
} }