use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class MountTableTest method readOnlyMount.
/**
* Tests check of readonly mount points.
*/
@Test
public void readOnlyMount() throws Exception {
MountPOptions options = MountContext.mergeFrom(MountPOptions.newBuilder().setReadOnly(true)).getOptions().build();
String mountPath = "/mnt/foo";
AlluxioURI alluxioUri = new AlluxioURI("alluxio://localhost:1234" + mountPath);
mMountTable.add(NoopJournalContext.INSTANCE, alluxioUri, new AlluxioURI("hdfs://localhost:5678/foo"), 2L, options);
try {
mMountTable.checkUnderWritableMountPoint(alluxioUri);
Assert.fail("Readonly mount point should not be writable.");
} catch (AccessControlException e) {
// Exception expected
Assert.assertEquals(ExceptionMessage.MOUNT_READONLY.getMessage(alluxioUri, mountPath), e.getMessage());
}
try {
String path = mountPath + "/sub/directory";
alluxioUri = new AlluxioURI("alluxio://localhost:1234" + path);
mMountTable.checkUnderWritableMountPoint(alluxioUri);
Assert.fail("Readonly mount point should not be writable.");
} catch (AccessControlException e) {
// Exception expected
Assert.assertEquals(ExceptionMessage.MOUNT_READONLY.getMessage(alluxioUri, mountPath), e.getMessage());
}
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class WebInterfaceMemoryServlet method doGet.
/**
* Populates attributes before redirecting to a jsp.
*
* @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
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (SecurityUtils.isSecurityEnabled() && AuthenticatedClientUser.get() == null) {
AuthenticatedClientUser.set(LoginUser.get().getName());
}
request.setAttribute("masterNodeAddress", mMaster.getRpcAddress().toString());
request.setAttribute("fatalError", "");
request.setAttribute("showPermissions", Configuration.getBoolean(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED));
List<AlluxioURI> inMemoryFiles = mMaster.getFileSystemMaster().getInMemoryFiles();
Collections.sort(inMemoryFiles);
List<UIFileInfo> fileInfos = new ArrayList<>(inMemoryFiles.size());
for (AlluxioURI file : inMemoryFiles) {
try {
long fileId = mMaster.getFileSystemMaster().getFileId(file);
FileInfo fileInfo = mMaster.getFileSystemMaster().getFileInfo(fileId);
if (fileInfo != null && fileInfo.getInMemoryPercentage() == 100) {
fileInfos.add(new UIFileInfo(fileInfo));
}
} catch (FileDoesNotExistException e) {
request.setAttribute("fatalError", "Error: File does not exist " + e.getLocalizedMessage());
getServletContext().getRequestDispatcher("/memory.jsp").forward(request, response);
return;
} catch (AccessControlException e) {
request.setAttribute("permissionError", "Error: File " + file + " cannot be accessed " + e.getMessage());
getServletContext().getRequestDispatcher("/memory.jsp").forward(request, response);
return;
}
}
request.setAttribute("inMemoryFileNum", fileInfos.size());
// and redirect to "./memory?offset=xxx&limit=xxx"
if (request.getParameter("offset") == null && request.getParameter("limit") == null) {
getServletContext().getRequestDispatcher("/memory.jsp").forward(request, response);
return;
}
try {
int offset = Integer.parseInt(request.getParameter("offset"));
int limit = Integer.parseInt(request.getParameter("limit"));
List<UIFileInfo> sub = fileInfos.subList(offset, offset + limit);
request.setAttribute("fileInfos", sub);
} catch (NumberFormatException e) {
request.setAttribute("fatalError", "Error: offset or limit parse error, " + e.getLocalizedMessage());
getServletContext().getRequestDispatcher("/memory.jsp").forward(request, response);
return;
} catch (IndexOutOfBoundsException e) {
request.setAttribute("fatalError", "Error: offset or offset + limit is out of bound, " + e.getLocalizedMessage());
getServletContext().getRequestDispatcher("/memory.jsp").forward(request, response);
return;
} catch (IllegalArgumentException e) {
request.setAttribute("fatalError", e.getLocalizedMessage());
getServletContext().getRequestDispatcher("/memory.jsp").forward(request, response);
return;
}
getServletContext().getRequestDispatcher("/memory.jsp").forward(request, response);
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class CheckpointLatestPlanner method generatePlan.
@Override
public CheckpointPlan generatePlan(LineageStoreView store, FileSystemMasterView fileSystemMasterView) {
Lineage toCheckpoint = null;
long latestCreated = 0;
for (Lineage lineage : store.getAllLineagesInTopologicalOrder()) {
try {
if (!LineageStateUtils.isCompleted(lineage, fileSystemMasterView) || LineageStateUtils.isPersisted(lineage, fileSystemMasterView) || LineageStateUtils.needRecompute(lineage, fileSystemMasterView) || LineageStateUtils.isInCheckpointing(lineage, fileSystemMasterView)) {
continue;
}
} catch (FileDoesNotExistException | AccessControlException e) {
LOG.error("The lineage file does not exist", e);
continue;
}
if (lineage.getCreationTime() > latestCreated) {
latestCreated = lineage.getCreationTime();
toCheckpoint = lineage;
}
}
return toCheckpoint == null ? new CheckpointPlan(new ArrayList<Long>()) : new CheckpointPlan(Lists.newArrayList(toCheckpoint.getId()));
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class ReadOnlyMountIntegrationTest method deleteFile.
@Test
public void deleteFile() throws IOException, AlluxioException {
AlluxioURI fileUri = new AlluxioURI(FILE_PATH);
mFileSystem.loadMetadata(fileUri);
try {
mFileSystem.delete(fileUri);
Assert.fail("deleteFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertEquals(e.getMessage(), ExceptionMessage.MOUNT_READONLY.getMessage(fileUri, MOUNT_PATH));
}
Assert.assertTrue(mFileSystem.exists(fileUri));
Assert.assertNotNull(mFileSystem.getStatus(fileUri));
fileUri = new AlluxioURI(SUB_FILE_PATH);
mFileSystem.loadMetadata(fileUri, LoadMetadataOptions.defaults().setRecursive(true));
try {
mFileSystem.delete(fileUri);
Assert.fail("deleteFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertEquals(e.getMessage(), ExceptionMessage.MOUNT_READONLY.getMessage(fileUri, MOUNT_PATH));
}
Assert.assertTrue(mFileSystem.exists(fileUri));
Assert.assertNotNull(mFileSystem.getStatus(fileUri));
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class ReadOnlyMountIntegrationTest method renameFileSrc.
@Test
public void renameFileSrc() throws IOException, AlluxioException {
AlluxioURI srcUri = new AlluxioURI(FILE_PATH);
AlluxioURI dstUri = new AlluxioURI("/tmp");
try {
mFileSystem.rename(srcUri, dstUri);
Assert.fail("rename should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertEquals(e.getMessage(), ExceptionMessage.MOUNT_READONLY.getMessage(srcUri, MOUNT_PATH));
}
srcUri = new AlluxioURI(SUB_FILE_PATH);
try {
mFileSystem.rename(srcUri, dstUri);
Assert.fail("rename should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertEquals(e.getMessage(), ExceptionMessage.MOUNT_READONLY.getMessage(srcUri, MOUNT_PATH));
}
}
Aggregations