use of alluxio.thrift.Command in project alluxio by Alluxio.
the class FileSystemMasterTest method ttlDirectoryFreeReplay.
/**
* Tests that TTL free of a directory is not forgotten across restarts.
*/
@Test
public void ttlDirectoryFreeReplay() 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);
// Simulate restart.
stopServices();
startServices();
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 freePinnedFileWithForce.
/**
* Tests {@link FileSystemMaster#free} on pinned file when forced flag is true.
*/
@Test
public void freePinnedFileWithForce() throws Exception {
mNestedFileOptions.setPersisted(true);
long blockId = createFileWithSingleBlock(NESTED_FILE_URI);
mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeOptions.defaults().setPinned(true));
Assert.assertEquals(1, mBlockMaster.getBlockInfo(blockId).getLocations().size());
// free the file
mFileSystemMaster.free(NESTED_FILE_URI, FreeOptions.defaults().setForced(true));
// Update the heartbeat of removedBlockId received from worker 1
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 ttlFileFreeReplay.
/**
* Tests that TTL free of a file is not forgotten across restarts.
*/
@Test
public void ttlFileFreeReplay() 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);
// Simulate restart.
stopServices();
startServices();
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 free.
/**
* Tests {@link FileSystemMaster#free} on persisted file.
*/
@Test
public void free() throws Exception {
mNestedFileOptions.setPersisted(true);
long blockId = createFileWithSingleBlock(NESTED_FILE_URI);
Assert.assertEquals(1, mBlockMaster.getBlockInfo(blockId).getLocations().size());
// free the file
mFileSystemMaster.free(NESTED_FILE_URI, FreeOptions.defaults().setForced(false).setRecursive(false));
// Update the heartbeat of removedBlockId received from worker 1
Command heartbeat2 = 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()), heartbeat2);
Assert.assertEquals(0, mBlockMaster.getBlockInfo(blockId).getLocations().size());
}
use of alluxio.thrift.Command in project alluxio by Alluxio.
the class BlockMasterTest method removeBlockTellsWorkersToRemoveTheBlock.
@Test
public void removeBlockTellsWorkersToRemoveTheBlock() throws Exception {
// Create a worker with a block.
long worker1 = mMaster.getWorkerId(NET_ADDRESS_1);
long blockId = 1L;
mMaster.workerRegister(worker1, Arrays.asList("MEM"), ImmutableMap.of("MEM", 100L), ImmutableMap.of("MEM", 0L), NO_BLOCKS_ON_TIERS);
mMaster.commitBlock(worker1, 50L, "MEM", blockId, 20L);
// Remove the block
mMaster.removeBlocks(Arrays.asList(1L), /*delete=*/
false);
// Check that the worker heartbeat tells the worker to remove the block.
Map<String, Long> memUsage = ImmutableMap.of("MEM", 0L);
Command heartBeat = mMaster.workerHeartbeat(worker1, memUsage, NO_BLOCKS, NO_BLOCKS_ON_TIERS);
Assert.assertEquals(ImmutableList.of(1L), heartBeat.getData());
}
Aggregations