Search in sources :

Example 1 with SetAttributeOptions

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());
}
Also used : SetAttributeOptions(alluxio.master.file.options.SetAttributeOptions) FileSystemCommand(alluxio.thrift.FileSystemCommand) Command(alluxio.thrift.Command) Test(org.junit.Test)

Example 2 with SetAttributeOptions

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());
}
Also used : SetAttributeOptions(alluxio.master.file.options.SetAttributeOptions) FileSystemCommand(alluxio.thrift.FileSystemCommand) Command(alluxio.thrift.Command) CreateDirectoryOptions(alluxio.master.file.options.CreateDirectoryOptions) Test(org.junit.Test)

Example 3 with SetAttributeOptions

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);
    }
}
Also used : SetAttributeOptions(alluxio.master.file.options.SetAttributeOptions) SetAndRestoreConfiguration(alluxio.SetAndRestoreConfiguration) Test(org.junit.Test)

Example 4 with SetAttributeOptions

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
    }
}
Also used : SetAttributeOptions(alluxio.master.file.options.SetAttributeOptions) LockedInodePath(alluxio.master.file.meta.LockedInodePath)

Example 5 with SetAttributeOptions

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());
}
Also used : SetAttributeOptions(alluxio.master.file.options.SetAttributeOptions) FileSystemCommand(alluxio.thrift.FileSystemCommand) Command(alluxio.thrift.Command) CreateDirectoryOptions(alluxio.master.file.options.CreateDirectoryOptions) Test(org.junit.Test)

Aggregations

SetAttributeOptions (alluxio.master.file.options.SetAttributeOptions)9 Test (org.junit.Test)6 Command (alluxio.thrift.Command)4 FileSystemCommand (alluxio.thrift.FileSystemCommand)4 SetAndRestoreConfiguration (alluxio.SetAndRestoreConfiguration)2 CreateDirectoryOptions (alluxio.master.file.options.CreateDirectoryOptions)2 AlluxioURI (alluxio.AlluxioURI)1 SetAndRestoreAuthenticatedUser (alluxio.SetAndRestoreAuthenticatedUser)1 UnexpectedAlluxioException (alluxio.exception.UnexpectedAlluxioException)1 Inode (alluxio.master.file.meta.Inode)1 InodeDirectory (alluxio.master.file.meta.InodeDirectory)1 InodeLockList (alluxio.master.file.meta.InodeLockList)1 LockedInodePath (alluxio.master.file.meta.LockedInodePath)1 TempInodePathForDescendant (alluxio.master.file.meta.TempInodePathForDescendant)1 FileInfo (alluxio.wire.FileInfo)1 ArrayList (java.util.ArrayList)1