/** * @return the unique identifier of the entity referenced by this uri used by Alluxio servers, * immutable */ public long getFileId() { return mInfo.getFileId(); }
private void checkPersistenceInProgress(AlluxioURI testFile, long jobId) throws Exception { FileInfo fileInfo = mFileSystemMaster.getFileInfo(testFile, GET_STATUS_CONTEXT); Map<Long, PersistJob> persistJobs = getPersistJobs(); Assert.assertEquals(0, getPersistRequests().size()); Assert.assertEquals(1, persistJobs.size()); Assert.assertTrue(persistJobs.containsKey(fileInfo.getFileId())); PersistJob job = persistJobs.get(fileInfo.getFileId()); Assert.assertEquals(fileInfo.getFileId(), job.getFileId()); Assert.assertEquals(jobId, job.getId()); Assert.assertTrue(job.getTempUfsPath().contains(testFile.getPath())); Assert.assertEquals( PersistenceState.TO_BE_PERSISTED.toString(), fileInfo.getPersistenceState()); }
private void checkPersistenceRequested(AlluxioURI testFile) throws Exception { FileInfo fileInfo = mFileSystemMaster.getFileInfo(testFile, GET_STATUS_CONTEXT); Map<Long, ExponentialTimer> persistRequests = getPersistRequests(); Assert.assertEquals(1, persistRequests.size()); Assert.assertEquals(0, getPersistJobs().size()); Assert.assertTrue(persistRequests.containsKey(fileInfo.getFileId())); Assert.assertEquals( PersistenceState.TO_BE_PERSISTED.toString(), fileInfo.getPersistenceState()); }
/** * Tests that a file has not been deleted after the TTL has been reset to a valid value. */ @Test public void setLargerTtlForFileWithTtl() throws Exception { mFileSystemMaster.createDirectory(NESTED_URI, CreateDirectoryContext .defaults(CreateDirectoryPOptions.newBuilder().setRecursive(true))); CreateFileContext context = CreateFileContext.defaults(CreateFilePOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)) .setBlockSizeBytes(Constants.KB).setRecursive(true)); long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, context); assertEquals(fileId, mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT).getFileId()); mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext .defaults(SetAttributePOptions.newBuilder().setTtl(Constants.HOUR_MS))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); // TTL is reset to 1 hour, the file should not be deleted during last TTL check. assertEquals(fileId, mFileSystemMaster.getFileInfo(fileId).getFileId()); }
PersistJob job = persistJobs.get(fileInfo.getFileId()); UnderFileSystem ufs = UnderFileSystem.Factory.create(job.getTempUfsPath(), ServerConfiguration.global());
/** * Tests that an exception is in the * {@literal FileSystemMaster#createDirectory(AlluxioURI, CreateDirectoryOptions)} * with a TTL set in the {@link CreateDirectoryContext} after the TTL check was done once. */ @Test public void ttlDirectoryDelete() throws Exception { CreateDirectoryContext context = CreateDirectoryContext.defaults(CreateDirectoryPOptions.newBuilder().setRecursive(true) .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0))); long dirId = mFileSystemMaster.createDirectory(NESTED_DIR_URI, context); FileInfo fileInfo = mFileSystemMaster.getFileInfo(dirId); assertEquals(fileInfo.getFileId(), dirId); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); mThrown.expect(FileDoesNotExistException.class); mFileSystemMaster.getFileInfo(dirId); }
/** * Tests that TTL delete of a directory is not forgotten across restarts. */ @Test public void ttlDirectoryDeleteReplay() throws Exception { CreateDirectoryContext context = CreateDirectoryContext.defaults(CreateDirectoryPOptions.newBuilder().setRecursive(true) .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0))); long dirId = mFileSystemMaster.createDirectory(NESTED_DIR_URI, context); // Simulate restart. stopServices(); startServices(); FileInfo fileInfo = mFileSystemMaster.getFileInfo(dirId); assertEquals(fileInfo.getFileId(), dirId); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); mThrown.expect(FileDoesNotExistException.class); mFileSystemMaster.getFileInfo(dirId); }
/** * Tests that an exception is in the * {@link FileSystemMaster#createFile(AlluxioURI, CreateFileContext)} with a * TTL set in the {@link CreateFileContext} after the TTL check was done once. */ @Test public void ttlFileDelete() throws Exception { CreateFileContext context = CreateFileContext.defaults(); context.getOptions().setBlockSizeBytes(Constants.KB); context.getOptions().setRecursive(true); context.getOptions().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)); long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, context); FileInfo fileInfo = mFileSystemMaster.getFileInfo(fileId); assertEquals(fileInfo.getFileId(), fileId); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); mThrown.expect(FileDoesNotExistException.class); mFileSystemMaster.getFileInfo(fileId); }
/** * Tests that an exception is thrown when trying to get information about a file after it * has been deleted because of a TTL of 0. */ @Test public void setTtlForFileWithNoTtl() throws Exception { CreateFileContext context = CreateFileContext.defaults( CreateFilePOptions.newBuilder().setBlockSizeBytes(Constants.KB).setRecursive(true)); long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, context); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); // Since no TTL is set, the file should not be deleted. assertEquals(fileId, mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT).getFileId()); mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setTtl(0))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); // TTL is set to 0, the file should have been deleted during last TTL check. mThrown.expect(FileDoesNotExistException.class); mFileSystemMaster.getFileInfo(fileId); }
/** * Tests that TTL delete of a file is not forgotten across restarts. */ @Test public void ttlFileDeleteReplay() throws Exception { CreateFileContext context = CreateFileContext.defaults(); context.getOptions().setBlockSizeBytes(Constants.KB); context.getOptions().setRecursive(true); context.getOptions().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)); long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, context); // Simulate restart. stopServices(); startServices(); FileInfo fileInfo = mFileSystemMaster.getFileInfo(fileId); assertEquals(fileInfo.getFileId(), fileId); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); mThrown.expect(FileDoesNotExistException.class); mFileSystemMaster.getFileInfo(fileId); }
/** * Tests that the original TTL is removed after setting it to {@link Constants#NO_TTL} for a file. */ @Test public void setNoTtlForFileWithTtl() throws Exception { mFileSystemMaster.createDirectory(NESTED_URI, CreateDirectoryContext .defaults(CreateDirectoryPOptions.newBuilder().setRecursive(true))); CreateFileContext context = CreateFileContext.defaults(CreateFilePOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)) .setBlockSizeBytes(Constants.KB).setRecursive(true)); long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, context); // After setting TTL to NO_TTL, the original TTL will be removed, and the file will not be // deleted during next TTL check. mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext .defaults(SetAttributePOptions.newBuilder().setTtl(Constants.NO_TTL))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); assertEquals(fileId, mFileSystemMaster.getFileInfo(fileId).getFileId()); }
/** * Tests that an exception is thrown when trying to get information about a file after it * has been deleted after the TTL has been set to 0. */ @Test public void setSmallerTtlForFileWithTtl() throws Exception { CreateFileContext context = CreateFileContext.defaults(CreateFilePOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(Constants.HOUR_MS)) .setBlockSizeBytes(Constants.KB).setRecursive(true)); long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, context); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); // Since TTL is 1 hour, the file won't be deleted during last TTL check. assertEquals(fileId, mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT).getFileId()); mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setTtl(0))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); // TTL is reset to 0, the file should have been deleted during last TTL check. mThrown.expect(FileDoesNotExistException.class); mFileSystemMaster.getFileInfo(fileId); }
.setFileId(fileInfo.getFileId()).setName(fileInfo.getName()).setPath(fileInfo.getPath()) .setUfsPath(fileInfo.getUfsPath()).setLength(fileInfo.getLength()) .setBlockSizeBytes(fileInfo.getBlockSizeBytes())
/** * Tests that an exception is thrown when trying to get information about a Directory after * it has been deleted because of a TTL of 0. */ @Test public void setTtlForDirectoryWithNoTtl() throws Exception { CreateDirectoryContext directoryContext = CreateDirectoryContext .defaults(CreateDirectoryPOptions.newBuilder().setRecursive(true)); mFileSystemMaster.createDirectory(NESTED_URI, directoryContext); mFileSystemMaster.createDirectory(NESTED_DIR_URI, directoryContext); CreateFileContext createFileContext = CreateFileContext.defaults( CreateFilePOptions.newBuilder().setBlockSizeBytes(Constants.KB).setRecursive(true)); long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, createFileContext); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); // Since no TTL is set, the file should not be deleted. assertEquals(fileId, mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT).getFileId()); // Set ttl. mFileSystemMaster.setAttribute(NESTED_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setTtl(0))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); // TTL is set to 0, the file and directory should have been deleted during last TTL check. mThrown.expect(FileDoesNotExistException.class); mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT); mFileSystemMaster.getFileInfo(NESTED_DIR_URI, GET_STATUS_CONTEXT); mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT); }
/** * Tests the {@link MutableInodeDirectory#generateClientFileInfo(String)} method. */ @Test public void generateClientFileInfo() { MutableInodeDirectory inodeDirectory = createInodeDirectory(); String path = "/test/path"; FileInfo info = inodeDirectory.generateClientFileInfo(path); Assert.assertEquals(inodeDirectory.getId(), info.getFileId()); Assert.assertEquals(inodeDirectory.getName(), info.getName()); Assert.assertEquals(path, info.getPath()); Assert.assertEquals("", info.getUfsPath()); Assert.assertEquals(0, info.getLength()); Assert.assertEquals(0, info.getBlockSizeBytes()); Assert.assertEquals(inodeDirectory.getCreationTimeMs(), info.getCreationTimeMs()); Assert.assertTrue(info.isCompleted()); Assert.assertTrue(info.isFolder()); Assert.assertEquals(inodeDirectory.isPinned(), info.isPinned()); Assert.assertFalse(info.isCacheable()); Assert.assertNotNull(info.getBlockIds()); Assert.assertEquals(inodeDirectory.getLastModificationTimeMs(), info.getLastModificationTimeMs()); } }
/** * @return the unique identifier of the entity referenced by this uri used by Alluxio servers, * immutable */ public long getFileId() { return mInfo.getFileId(); }
/** * @return the unique identifier of the entity referenced by this uri used by Alluxio servers, * immutable */ public long getFileId() { return mInfo.getFileId(); }
Assert.assertEquals(a.getCreationTimeMs(), b.getCreationTimeMs()); Assert.assertEquals(a.getFileBlockInfos(), b.getFileBlockInfos()); Assert.assertEquals(a.getFileId(), b.getFileId()); Assert.assertEquals(a.getGroup(), b.getGroup()); Assert.assertEquals(a.getLastModificationTimeMs(), b.getLastModificationTimeMs());
Assert.assertEquals(uriStatus.getCreationTimeMs(), fileInfo.getCreationTimeMs()); Assert.assertEquals(uriStatus.getFileId(), fileInfo.getFileId()); Assert.assertEquals(uriStatus.getGroup(), fileInfo.getGroup()); Assert.assertEquals(uriStatus.getInMemoryPercentage(),