Search in sources :

Example 1 with RenameOptions

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

the class FileSystemMasterIntegrationTest method lastModificationTimeRename.

@Test
public void lastModificationTimeRename() throws Exception {
    AlluxioURI srcPath = new AlluxioURI("/testFolder/testFile1");
    AlluxioURI dstPath = new AlluxioURI("/testFolder/testFile2");
    mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
    mFsMaster.createFile(srcPath, CreateFileOptions.defaults());
    RenameOptions options = RenameOptions.defaults().setOperationTimeMs(TEST_TIME_MS);
    mFsMaster.rename(srcPath, dstPath, options);
    FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder")));
    Assert.assertEquals(TEST_TIME_MS, folderInfo.getLastModificationTimeMs());
}
Also used : RenameOptions(alluxio.master.file.options.RenameOptions) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 2 with RenameOptions

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

the class FileSystemMasterIntegrationTest method ttlRename.

@Test
public void ttlRename() throws Exception {
    AlluxioURI srcPath = new AlluxioURI("/testFolder/testFile1");
    AlluxioURI dstPath = new AlluxioURI("/testFolder/testFile2");
    mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
    long ttl = 1;
    CreateFileOptions createOptions = CreateFileOptions.defaults().setTtl(ttl);
    mFsMaster.createFile(srcPath, createOptions);
    RenameOptions renameOptions = RenameOptions.defaults().setOperationTimeMs(TEST_TIME_MS);
    mFsMaster.rename(srcPath, dstPath, renameOptions);
    FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder/testFile2")));
    Assert.assertEquals(ttl, folderInfo.getTtl());
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) RenameOptions(alluxio.master.file.options.RenameOptions) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 3 with RenameOptions

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

the class FileSystemMaster method renameFromEntry.

/**
   * @param entry the entry to use
   */
private void renameFromEntry(RenameEntry entry) {
    Metrics.RENAME_PATH_OPS.inc();
    // Determine the srcPath and dstPath
    AlluxioURI srcPath;
    try (LockedInodePath inodePath = mInodeTree.lockFullInodePath(entry.getId(), InodeTree.LockMode.READ)) {
        srcPath = inodePath.getUri();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    AlluxioURI dstPath = new AlluxioURI(entry.getDstPath());
    // Both src and dst paths should lock WRITE_PARENT, to modify the parent inodes for both paths.
    try (InodePathPair inodePathPair = mInodeTree.lockInodePathPair(srcPath, InodeTree.LockMode.WRITE_PARENT, dstPath, InodeTree.LockMode.WRITE_PARENT)) {
        LockedInodePath srcInodePath = inodePathPair.getFirst();
        LockedInodePath dstInodePath = inodePathPair.getSecond();
        RenameOptions options = RenameOptions.defaults().setOperationTimeMs(entry.getOpTimeMs());
        renameInternal(srcInodePath, dstInodePath, true, options);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : LockedInodePath(alluxio.master.file.meta.LockedInodePath) RenameOptions(alluxio.master.file.options.RenameOptions) InodePathPair(alluxio.master.file.meta.InodePathPair) AlluxioException(alluxio.exception.AlluxioException) BlockInfoException(alluxio.exception.BlockInfoException) FileAlreadyExistsException(alluxio.exception.FileAlreadyExistsException) IOException(java.io.IOException) InvalidPathException(alluxio.exception.InvalidPathException) AccessControlException(alluxio.exception.AccessControlException) InvalidFileSizeException(alluxio.exception.InvalidFileSizeException) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) FileAlreadyCompletedException(alluxio.exception.FileAlreadyCompletedException) DirectoryNotEmptyException(alluxio.exception.DirectoryNotEmptyException) UnexpectedAlluxioException(alluxio.exception.UnexpectedAlluxioException) AlluxioURI(alluxio.AlluxioURI)

Aggregations

AlluxioURI (alluxio.AlluxioURI)3 RenameOptions (alluxio.master.file.options.RenameOptions)3 FileInfo (alluxio.wire.FileInfo)2 Test (org.junit.Test)2 AccessControlException (alluxio.exception.AccessControlException)1 AlluxioException (alluxio.exception.AlluxioException)1 BlockInfoException (alluxio.exception.BlockInfoException)1 DirectoryNotEmptyException (alluxio.exception.DirectoryNotEmptyException)1 FileAlreadyCompletedException (alluxio.exception.FileAlreadyCompletedException)1 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)1 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)1 InvalidFileSizeException (alluxio.exception.InvalidFileSizeException)1 InvalidPathException (alluxio.exception.InvalidPathException)1 UnexpectedAlluxioException (alluxio.exception.UnexpectedAlluxioException)1 InodePathPair (alluxio.master.file.meta.InodePathPair)1 LockedInodePath (alluxio.master.file.meta.LockedInodePath)1 CreateFileOptions (alluxio.master.file.options.CreateFileOptions)1 IOException (java.io.IOException)1