use of alluxio.thrift.Command in project alluxio by Alluxio.
the class BlockMasterTest method unknownWorkerHeartbeatTriggersRegisterRequest.
@Test
public void unknownWorkerHeartbeatTriggersRegisterRequest() {
Command heartBeat = mMaster.workerHeartbeat(0, null, null, null);
Assert.assertEquals(new Command(CommandType.Register, ImmutableList.<Long>of()), heartBeat);
}
use of alluxio.thrift.Command in project alluxio by Alluxio.
the class FileSystemMasterTest method deleteFile.
/**
* Tests the {@link FileSystemMaster#delete(AlluxioURI, DeleteOptions)} method.
*/
@Test
public void deleteFile() throws Exception {
// cannot delete root
try {
mFileSystemMaster.delete(ROOT_URI, DeleteOptions.defaults().setRecursive(true));
Assert.fail("Should not have been able to delete the root");
} catch (InvalidPathException e) {
Assert.assertEquals(ExceptionMessage.DELETE_ROOT_DIRECTORY.getMessage(), e.getMessage());
}
// delete the file
long blockId = createFileWithSingleBlock(NESTED_FILE_URI);
mFileSystemMaster.delete(NESTED_FILE_URI, DeleteOptions.defaults().setRecursive(false));
mThrown.expect(BlockInfoException.class);
mBlockMaster.getBlockInfo(blockId);
// Update the heartbeat of removedBlockId received from worker 1
Command heartbeat1 = 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()), heartbeat1);
Assert.assertFalse(mBlockMaster.getLostBlocks().contains(blockId));
// verify the file is deleted
Assert.assertEquals(IdUtils.INVALID_FILE_ID, mFileSystemMaster.getFileId(NESTED_FILE_URI));
AlluxioURI ufsMount = new AlluxioURI(mTestFolder.newFolder().getAbsolutePath());
mFileSystemMaster.createDirectory(new AlluxioURI("/mnt/"), CreateDirectoryOptions.defaults());
// Create ufs file
Files.createDirectory(Paths.get(ufsMount.join("dir1").getPath()));
Files.createFile(Paths.get(ufsMount.join("dir1").join("file1").getPath()));
mFileSystemMaster.mount(new AlluxioURI("/mnt/local"), ufsMount, MountOptions.defaults());
AlluxioURI uri = new AlluxioURI("/mnt/local/dir1");
mFileSystemMaster.listStatus(uri, ListStatusOptions.defaults().setLoadMetadataType(LoadMetadataType.Always));
mFileSystemMaster.delete(new AlluxioURI("/mnt/local/dir1/file1"), DeleteOptions.defaults().setAlluxioOnly(true));
// ufs file still exists
Assert.assertTrue(Files.exists(Paths.get(ufsMount.join("dir1").join("file1").getPath())));
// verify the file is deleted
Assert.assertEquals(IdUtils.INVALID_FILE_ID, mFileSystemMaster.getFileId(new AlluxioURI("/mnt/local/dir1/file1")));
}
use of alluxio.thrift.Command 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());
}
use of alluxio.thrift.Command 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());
}
use of alluxio.thrift.Command in project alluxio by Alluxio.
the class FileSystemMasterTest method freeDir.
/**
* Tests the {@link FileSystemMaster#free} method with a directory.
*/
@Test
public void freeDir() throws Exception {
mNestedFileOptions.setPersisted(true);
long blockId = createFileWithSingleBlock(NESTED_FILE_URI);
Assert.assertEquals(1, mBlockMaster.getBlockInfo(blockId).getLocations().size());
// free the dir
mFileSystemMaster.free(NESTED_FILE_URI.getParent(), FreeOptions.defaults().setForced(true).setRecursive(true));
// Update the heartbeat of removedBlockId received from worker 1
Command heartbeat3 = 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()), heartbeat3);
Assert.assertEquals(0, mBlockMaster.getBlockInfo(blockId).getLocations().size());
}
Aggregations