Search in sources :

Example 1 with CompleteFileOptions

use of alluxio.master.file.options.CompleteFileOptions in project alluxio by Alluxio.

the class PermissionCheckTest method completeFileFail.

@Test
public void completeFileFail() throws Exception {
    // set unmask
    try (SetAndRestoreConfiguration c = new SetAndRestoreConfiguration(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066")) {
        String file = PathUtils.concatPath(TEST_DIR_URI, "/testComplete1");
        verifyCreateFile(TEST_USER_1, file, false);
        CompleteFileOptions expect = getNonDefaultCompleteFileOptions();
        mThrown.expect(AccessControlException.class);
        mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage(toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.WRITE, file, "testComplete1")));
        verifyCompleteFile(TEST_USER_2, file, expect);
    }
}
Also used : SetAndRestoreConfiguration(alluxio.SetAndRestoreConfiguration) CompleteFileOptions(alluxio.master.file.options.CompleteFileOptions) Test(org.junit.Test)

Example 2 with CompleteFileOptions

use of alluxio.master.file.options.CompleteFileOptions in project alluxio by Alluxio.

the class FileSystemMasterTest method createFileWithSingleBlock.

private long createFileWithSingleBlock(AlluxioURI uri) throws Exception {
    mFileSystemMaster.createFile(uri, mNestedFileOptions);
    long blockId = mFileSystemMaster.getNewBlockIdForFile(uri);
    mBlockMaster.commitBlock(mWorkerId1, Constants.KB, "MEM", blockId, Constants.KB);
    CompleteFileOptions options = CompleteFileOptions.defaults().setUfsLength(Constants.KB);
    mFileSystemMaster.completeFile(uri, options);
    return blockId;
}
Also used : CompleteFileOptions(alluxio.master.file.options.CompleteFileOptions)

Example 3 with CompleteFileOptions

use of alluxio.master.file.options.CompleteFileOptions in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method notFileCompletion.

@Test
public void notFileCompletion() throws Exception {
    mThrown.expect(FileDoesNotExistException.class);
    mFsMaster.createDirectory(new AlluxioURI("/testFile"), CreateDirectoryOptions.defaults());
    CompleteFileOptions options = CompleteFileOptions.defaults();
    mFsMaster.completeFile(new AlluxioURI("/testFile"), options);
}
Also used : CompleteFileOptions(alluxio.master.file.options.CompleteFileOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 4 with CompleteFileOptions

use of alluxio.master.file.options.CompleteFileOptions in project alluxio by Alluxio.

the class PermissionCheckTest method completeFileSuccess.

@Test
public void completeFileSuccess() throws Exception {
    // set unmask
    try (SetAndRestoreConfiguration c = new SetAndRestoreConfiguration(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "044")) {
        String file = PathUtils.concatPath(TEST_DIR_URI, "/testState1");
        verifyCreateFile(TEST_USER_1, file, false);
        CompleteFileOptions expect = getNonDefaultCompleteFileOptions();
        verifyCompleteFile(TEST_USER_2, file, expect);
    }
}
Also used : SetAndRestoreConfiguration(alluxio.SetAndRestoreConfiguration) CompleteFileOptions(alluxio.master.file.options.CompleteFileOptions) Test(org.junit.Test)

Example 5 with CompleteFileOptions

use of alluxio.master.file.options.CompleteFileOptions in project alluxio by Alluxio.

the class FileSystemMaster method loadFileMetadataAndJournal.

/**
   * Loads metadata for the file identified by the given path from UFS into Alluxio.
   *
   * @param inodePath the path for which metadata should be loaded
   * @param resolution the UFS resolution of path
   * @param options the load metadata options
   * @param journalContext the journal context
   * @throws BlockInfoException if an invalid block size is encountered
   * @throws FileDoesNotExistException if there is no UFS path
   * @throws InvalidPathException if invalid path is encountered
   * @throws AccessControlException if permission checking fails or permission setting fails
   * @throws FileAlreadyCompletedException if the file is already completed
   * @throws InvalidFileSizeException if invalid file size is encountered
   * @throws IOException if an I/O error occurs
   */
private void loadFileMetadataAndJournal(LockedInodePath inodePath, MountTable.Resolution resolution, LoadMetadataOptions options, JournalContext journalContext) throws BlockInfoException, FileDoesNotExistException, InvalidPathException, AccessControlException, FileAlreadyCompletedException, InvalidFileSizeException, IOException {
    if (inodePath.fullPathExists()) {
        return;
    }
    AlluxioURI ufsUri = resolution.getUri();
    UnderFileSystem ufs = resolution.getUfs();
    long ufsBlockSizeByte = ufs.getBlockSizeByte(ufsUri.toString());
    long ufsLength = ufs.getFileSize(ufsUri.toString());
    // Metadata loaded from UFS has no TTL set.
    CreateFileOptions createFileOptions = CreateFileOptions.defaults().setBlockSizeBytes(ufsBlockSizeByte).setRecursive(options.isCreateAncestors()).setMetadataLoad(true).setPersisted(true);
    String ufsOwner = ufs.getOwner(ufsUri.toString());
    String ufsGroup = ufs.getGroup(ufsUri.toString());
    short ufsMode = ufs.getMode(ufsUri.toString());
    Mode mode = new Mode(ufsMode);
    if (resolution.getShared()) {
        mode.setOtherBits(mode.getOtherBits().or(mode.getOwnerBits()));
    }
    createFileOptions = createFileOptions.setOwner(ufsOwner).setGroup(ufsGroup).setMode(mode);
    try {
        createFileAndJournal(inodePath, createFileOptions, journalContext);
        CompleteFileOptions completeOptions = CompleteFileOptions.defaults().setUfsLength(ufsLength);
        completeFileAndJournal(inodePath, completeOptions, journalContext);
    } catch (FileAlreadyExistsException e) {
        LOG.error("FileAlreadyExistsException seen unexpectedly.", e);
        throw new RuntimeException(e);
    }
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) FileAlreadyExistsException(alluxio.exception.FileAlreadyExistsException) Mode(alluxio.security.authorization.Mode) CompleteFileOptions(alluxio.master.file.options.CompleteFileOptions) UnderFileSystem(alluxio.underfs.UnderFileSystem) AlluxioURI(alluxio.AlluxioURI)

Aggregations

CompleteFileOptions (alluxio.master.file.options.CompleteFileOptions)5 Test (org.junit.Test)3 AlluxioURI (alluxio.AlluxioURI)2 SetAndRestoreConfiguration (alluxio.SetAndRestoreConfiguration)2 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)1 CreateFileOptions (alluxio.master.file.options.CreateFileOptions)1 Mode (alluxio.security.authorization.Mode)1 UnderFileSystem (alluxio.underfs.UnderFileSystem)1