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());
}
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());
}
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);
}
}
Aggregations