Search in sources :

Example 1 with Command

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

Example 2 with Command

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

Example 3 with Command

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

Example 4 with Command

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());
}
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 5 with Command

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