Search in sources :

Example 6 with Command

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());
}
Also used : SetAttributeOptions(alluxio.master.file.options.SetAttributeOptions) FileSystemCommand(alluxio.thrift.FileSystemCommand) Command(alluxio.thrift.Command) CreateDirectoryOptions(alluxio.master.file.options.CreateDirectoryOptions) Test(org.junit.Test)

Example 7 with Command

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());
}
Also used : FileSystemCommand(alluxio.thrift.FileSystemCommand) Command(alluxio.thrift.Command) Test(org.junit.Test)

Example 8 with Command

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());
}
Also used : SetAttributeOptions(alluxio.master.file.options.SetAttributeOptions) FileSystemCommand(alluxio.thrift.FileSystemCommand) Command(alluxio.thrift.Command) Test(org.junit.Test)

Example 9 with Command

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());
}
Also used : FileSystemCommand(alluxio.thrift.FileSystemCommand) Command(alluxio.thrift.Command) Test(org.junit.Test)

Example 10 with Command

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());
}
Also used : Command(alluxio.thrift.Command) Test(org.junit.Test)

Aggregations

Command (alluxio.thrift.Command)13 Test (org.junit.Test)11 FileSystemCommand (alluxio.thrift.FileSystemCommand)9 SetAttributeOptions (alluxio.master.file.options.SetAttributeOptions)4 CreateDirectoryOptions (alluxio.master.file.options.CreateDirectoryOptions)2 AlluxioURI (alluxio.AlluxioURI)1 AlluxioException (alluxio.exception.AlluxioException)1 BlockDoesNotExistException (alluxio.exception.BlockDoesNotExistException)1 ConnectionFailedException (alluxio.exception.ConnectionFailedException)1 InvalidPathException (alluxio.exception.InvalidPathException)1 InvalidWorkerStateException (alluxio.exception.InvalidWorkerStateException)1 MasterWorkerInfo (alluxio.master.block.meta.MasterWorkerInfo)1 IOException (java.io.IOException)1