use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class PermissionCheckTest method setOwnerSuccess.
@Test
public void setOwnerSuccess() throws Exception {
verifySetAcl(TEST_USER_ADMIN, TEST_FILE_URI, TEST_USER_1.getUser(), null, (short) -1, false);
verifySetAcl(TEST_USER_SUPERGROUP, TEST_DIR_URI, TEST_USER_2.getUser(), null, (short) -1, true);
FileInfo fileInfo = mFileSystemMaster.getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(TEST_DIR_FILE_URI)));
Assert.assertEquals(TEST_USER_2.getUser(), fileInfo.getOwner());
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class PermissionCheckTest method verifyGetFileInfoOrList.
private void verifyGetFileInfoOrList(TestUser user, String path, boolean isFile) throws Exception {
try (SetAndRestoreAuthenticatedUser u = new SetAndRestoreAuthenticatedUser(user.getUser())) {
if (isFile) {
Assert.assertEquals(path, mFileSystemMaster.getFileInfo(new AlluxioURI(path)).getPath());
Assert.assertEquals(1, mFileSystemMaster.listStatus(new AlluxioURI(path), ListStatusOptions.defaults()).size());
} else {
List<FileInfo> fileInfoList = mFileSystemMaster.listStatus(new AlluxioURI(path), ListStatusOptions.defaults());
if (fileInfoList.size() > 0) {
Assert.assertTrue(PathUtils.getParent(fileInfoList.get(0).getPath()).equals(path));
}
}
}
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class PermissionCheckTest method verifyCreateDirectory.
private void verifyCreateDirectory(TestUser user, String path, boolean recursive) throws Exception {
try (SetAndRestoreAuthenticatedUser u = new SetAndRestoreAuthenticatedUser(user.getUser())) {
CreateDirectoryOptions options = CreateDirectoryOptions.defaults().setRecursive(recursive).setOwner(SecurityUtils.getOwnerFromThriftClient()).setGroup(SecurityUtils.getGroupFromThriftClient());
mFileSystemMaster.createDirectory(new AlluxioURI(path), options);
FileInfo fileInfo = mFileSystemMaster.getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(path)));
String[] pathComponents = path.split("/");
Assert.assertEquals(pathComponents[pathComponents.length - 1], fileInfo.getName());
Assert.assertEquals(true, fileInfo.isFolder());
Assert.assertEquals(user.getUser(), fileInfo.getOwner());
}
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class WebInterfaceDownloadServlet method doGet.
/**
* Prepares for downloading a file.
*
* @param request the {@link HttpServletRequest} object
* @param response the {@link HttpServletResponse} object
* @throws ServletException if the target resource throws this exception
* @throws IOException if the target resource throws this exception
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (SecurityUtils.isSecurityEnabled() && AuthenticatedClientUser.get() == null) {
AuthenticatedClientUser.set(LoginUser.get().getName());
}
String requestPath = request.getParameter("path");
if (requestPath == null || requestPath.isEmpty()) {
requestPath = AlluxioURI.SEPARATOR;
}
AlluxioURI currentPath = new AlluxioURI(requestPath);
try {
long fileId = mFsMaster.getFileId(currentPath);
FileInfo fileInfo = mFsMaster.getFileInfo(fileId);
if (fileInfo == null) {
throw new FileDoesNotExistException(currentPath.toString());
}
downloadFile(new AlluxioURI(fileInfo.getPath()), request, response);
} catch (FileDoesNotExistException e) {
request.setAttribute("invalidPathError", "Error: Invalid Path " + e.getMessage());
getServletContext().getRequestDispatcher("/browse.jsp").forward(request, response);
} catch (InvalidPathException e) {
request.setAttribute("invalidPathError", "Error: Invalid Path " + e.getLocalizedMessage());
getServletContext().getRequestDispatcher("/browse.jsp").forward(request, response);
} catch (AlluxioException e) {
request.setAttribute("invalidPathError", "Error: " + e.getLocalizedMessage());
getServletContext().getRequestDispatcher("/browse.jsp").forward(request, response);
}
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class DefaultAsyncPersistHandlerTest method persistenceFileWithBlocksOnMultipleWorkers.
/**
* Tests the persistence of file with block on multiple workers.
*/
@Test
public void persistenceFileWithBlocksOnMultipleWorkers() throws Exception {
DefaultAsyncPersistHandler handler = new DefaultAsyncPersistHandler(new FileSystemMasterView(mFileSystemMaster));
AlluxioURI path = new AlluxioURI("/test");
List<FileBlockInfo> blockInfoList = new ArrayList<>();
BlockLocation location1 = new BlockLocation().setWorkerId(1);
blockInfoList.add(new FileBlockInfo().setBlockInfo(new BlockInfo().setLocations(Lists.newArrayList(location1))));
BlockLocation location2 = new BlockLocation().setWorkerId(2);
blockInfoList.add(new FileBlockInfo().setBlockInfo(new BlockInfo().setLocations(Lists.newArrayList(location2))));
long fileId = 2;
Mockito.when(mFileSystemMaster.getFileId(path)).thenReturn(fileId);
Mockito.when(mFileSystemMaster.getFileInfo(fileId)).thenReturn(new FileInfo().setLength(1).setCompleted(true));
Mockito.when(mFileSystemMaster.getFileBlockInfoList(path)).thenReturn(blockInfoList);
// no persist scheduled on any worker
Assert.assertEquals(0, handler.pollFilesToPersist(1).size());
Assert.assertEquals(0, handler.pollFilesToPersist(2).size());
}
Aggregations