use of alluxio.master.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class FileSystemMasterTest method ttlFileFree.
/**
* Tests that file information is still present after it has been freed after the TTL has been set
* to 0.
*/
@Test
public void ttlFileFree() throws Exception {
long blockId = createFileWithSingleBlock(NESTED_FILE_URI);
Assert.assertEquals(1, mBlockMaster.getBlockInfo(blockId).getLocations().size());
// Set ttl & operation
SetAttributeOptions options = SetAttributeOptions.defaults();
options.setTtl(0);
options.setTtlAction(TtlAction.FREE);
mFileSystemMaster.setAttribute(NESTED_FILE_URI, options);
Command heartbeat = mBlockMaster.workerHeartbeat(mWorkerId1, ImmutableMap.of("MEM", (long) Constants.KB), ImmutableList.of(blockId), ImmutableMap.<String, List<Long>>of());
// Verify the muted Free command on worker1
Assert.assertEquals(new Command(CommandType.Nothing, ImmutableList.<Long>of()), heartbeat);
Assert.assertEquals(0, mBlockMaster.getBlockInfo(blockId).getLocations().size());
}
use of alluxio.master.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class FileSystemMasterTest method ttlDirectoryFree.
/**
* Tests that file information is still present after it has been freed after the parent
* directory's TTL has been set to 0.
*/
@Test
public void ttlDirectoryFree() throws Exception {
CreateDirectoryOptions createDirectoryOptions = CreateDirectoryOptions.defaults().setRecursive(true);
mFileSystemMaster.createDirectory(NESTED_URI, createDirectoryOptions);
long blockId = createFileWithSingleBlock(NESTED_FILE_URI);
Assert.assertEquals(1, mBlockMaster.getBlockInfo(blockId).getLocations().size());
// Set ttl & operation
SetAttributeOptions options = SetAttributeOptions.defaults();
options.setTtl(0);
options.setTtlAction(TtlAction.FREE);
mFileSystemMaster.setAttribute(NESTED_URI, options);
Command heartbeat = mBlockMaster.workerHeartbeat(mWorkerId1, ImmutableMap.of("MEM", (long) Constants.KB), ImmutableList.of(blockId), ImmutableMap.<String, List<Long>>of());
// Verify the muted Free command on worker1
Assert.assertEquals(new Command(CommandType.Nothing, ImmutableList.<Long>of()), heartbeat);
Assert.assertEquals(0, mBlockMaster.getBlockInfo(blockId).getLocations().size());
}
use of alluxio.master.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class PermissionCheckTest method setStateFail.
@Test
public void setStateFail() throws Exception {
// set unmask
try (SetAndRestoreConfiguration c = new SetAndRestoreConfiguration(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066")) {
String file = PathUtils.concatPath(TEST_DIR_URI, "testState1");
verifyCreateFile(TEST_USER_1, file, false);
SetAttributeOptions expect = getNonDefaultSetState();
mThrown.expect(AccessControlException.class);
mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage(toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.WRITE, file, "testState1")));
verifySetState(TEST_USER_2, file, expect);
}
}
use of alluxio.master.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class FileSystemMaster method setAttributeFromEntry.
/**
* @param entry the entry to use
* @throws FileDoesNotExistException if the file does not exist
* @throws InvalidPathException if the file path corresponding to the file id is invalid
* @throws AccessControlException if failed to set permission
*/
private void setAttributeFromEntry(SetAttributeEntry entry) throws FileDoesNotExistException, InvalidPathException, AccessControlException {
SetAttributeOptions options = SetAttributeOptions.defaults();
if (entry.hasPinned()) {
options.setPinned(entry.getPinned());
}
if (entry.hasTtl()) {
options.setTtl(entry.getTtl());
options.setTtlAction(ProtobufUtils.fromProtobuf(entry.getTtlAction()));
}
if (entry.hasPersisted()) {
options.setPersisted(entry.getPersisted());
}
if (entry.hasOwner()) {
options.setOwner(entry.getOwner());
}
if (entry.hasGroup()) {
options.setGroup(entry.getGroup());
}
if (entry.hasPermission()) {
options.setMode((short) entry.getPermission());
}
try (LockedInodePath inodePath = mInodeTree.lockFullInodePath(entry.getId(), InodeTree.LockMode.WRITE)) {
setAttributeInternal(inodePath, true, entry.getOpTimeMs(), options);
// Intentionally not journaling the persisted inodes from setAttributeInternal
}
}
use of alluxio.master.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class FileSystemMasterTest method ttlDirectoryFreeReplay.
/**
* Tests that TTL free of a directory is not forgotten across restarts.
*/
@Test
public void ttlDirectoryFreeReplay() throws Exception {
CreateDirectoryOptions createDirectoryOptions = CreateDirectoryOptions.defaults().setRecursive(true);
mFileSystemMaster.createDirectory(NESTED_URI, createDirectoryOptions);
long blockId = createFileWithSingleBlock(NESTED_FILE_URI);
Assert.assertEquals(1, mBlockMaster.getBlockInfo(blockId).getLocations().size());
// Set ttl & operation
SetAttributeOptions options = SetAttributeOptions.defaults();
options.setTtl(0);
options.setTtlAction(TtlAction.FREE);
mFileSystemMaster.setAttribute(NESTED_URI, options);
// Simulate restart.
stopServices();
startServices();
Command heartbeat = mBlockMaster.workerHeartbeat(mWorkerId1, ImmutableMap.of("MEM", (long) Constants.KB), ImmutableList.of(blockId), ImmutableMap.<String, List<Long>>of());
// Verify the muted Free command on worker1
Assert.assertEquals(new Command(CommandType.Nothing, ImmutableList.<Long>of()), heartbeat);
Assert.assertEquals(0, mBlockMaster.getBlockInfo(blockId).getLocations().size());
}
Aggregations