Search in sources :

Example 16 with BlockLocation

use of alluxio.wire.BlockLocation in project alluxio by Alluxio.

the class PersistDefinitionTest method selectExecutorsTest.

@Test
public void selectExecutorsTest() throws Exception {
    AlluxioURI uri = new AlluxioURI("/test");
    PersistConfig config = new PersistConfig(uri.getPath(), -1, true, "");
    WorkerNetAddress workerNetAddress = new WorkerNetAddress().setDataPort(10);
    WorkerInfo workerInfo = new WorkerInfo().setAddress(workerNetAddress);
    long blockId = 1;
    BlockInfo blockInfo = new BlockInfo().setBlockId(blockId);
    FileBlockInfo fileBlockInfo = new FileBlockInfo().setBlockInfo(blockInfo);
    BlockLocation location = new BlockLocation();
    location.setWorkerAddress(workerNetAddress);
    blockInfo.setLocations(Lists.newArrayList(location));
    FileInfo testFileInfo = new FileInfo();
    testFileInfo.setFileBlockInfos(Lists.newArrayList(fileBlockInfo));
    Mockito.when(mMockFileSystem.getStatus(uri)).thenReturn(new URIStatus(testFileInfo));
    Set<Pair<WorkerInfo, SerializableVoid>> result = new PersistDefinition().selectExecutors(config, Lists.newArrayList(workerInfo), new SelectExecutorsContext(1, mJobServerContext));
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(workerInfo, result.iterator().next().getFirst());
}
Also used : WorkerInfo(alluxio.wire.WorkerInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) BlockLocation(alluxio.wire.BlockLocation) URIStatus(alluxio.client.file.URIStatus) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) FileInfo(alluxio.wire.FileInfo) WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) AlluxioURI(alluxio.AlluxioURI) Pair(alluxio.collections.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 17 with BlockLocation

use of alluxio.wire.BlockLocation in project alluxio by Alluxio.

the class EvictDefinitionTest method selectExecutorsAllWorkers.

@Test
public void selectExecutorsAllWorkers() throws Exception {
    Set<Pair<WorkerInfo, SerializableVoid>> result = selectExecutorsTestHelper(Lists.newArrayList(new BlockLocation().setWorkerAddress(ADDRESS_1), new BlockLocation().setWorkerAddress(ADDRESS_2), new BlockLocation().setWorkerAddress(ADDRESS_3)), 3, Lists.newArrayList(WORKER_INFO_1, WORKER_INFO_2, WORKER_INFO_3));
    Set<Pair<WorkerInfo, SerializableVoid>> expected = Sets.newHashSet();
    expected.add(new Pair<>(WORKER_INFO_1, null));
    expected.add(new Pair<>(WORKER_INFO_2, null));
    expected.add(new Pair<>(WORKER_INFO_3, null));
    // Expect all workers are selected as they all have this block
    Assert.assertEquals(expected, result);
}
Also used : BlockLocation(alluxio.wire.BlockLocation) Pair(alluxio.collections.Pair) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 18 with BlockLocation

use of alluxio.wire.BlockLocation in project alluxio by Alluxio.

the class EvictDefinitionTest method selectExecutorsOnlyOneBlockWorkerHasBlock.

@Test
public void selectExecutorsOnlyOneBlockWorkerHasBlock() throws Exception {
    Set<Pair<WorkerInfo, SerializableVoid>> result = selectExecutorsTestHelper(Lists.newArrayList(new BlockLocation().setWorkerAddress(ADDRESS_1)), 1, Lists.newArrayList(WORKER_INFO_1, WORKER_INFO_2, WORKER_INFO_3));
    Set<Pair<WorkerInfo, SerializableVoid>> expected = Sets.newHashSet();
    expected.add(new Pair<>(WORKER_INFO_1, null));
    // Expect the only worker 1 having this block
    Assert.assertEquals(expected, result);
}
Also used : BlockLocation(alluxio.wire.BlockLocation) Pair(alluxio.collections.Pair) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 19 with BlockLocation

use of alluxio.wire.BlockLocation in project alluxio by Alluxio.

the class EvictDefinitionTest method selectExecutorsAnyOneWorkers.

@Test
public void selectExecutorsAnyOneWorkers() throws Exception {
    Set<Pair<WorkerInfo, SerializableVoid>> result = selectExecutorsTestHelper(Lists.newArrayList(new BlockLocation().setWorkerAddress(ADDRESS_1), new BlockLocation().setWorkerAddress(ADDRESS_2), new BlockLocation().setWorkerAddress(ADDRESS_3)), 1, Lists.newArrayList(WORKER_INFO_1, WORKER_INFO_2, WORKER_INFO_3));
    // Expect one worker from all workers having this block
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(null, result.iterator().next().getSecond());
}
Also used : BlockLocation(alluxio.wire.BlockLocation) Pair(alluxio.collections.Pair) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 20 with BlockLocation

use of alluxio.wire.BlockLocation in project alluxio by Alluxio.

the class ReplicateDefinitionTest method selectExecutorsOnlyOneWorkerValid.

@Test
public void selectExecutorsOnlyOneWorkerValid() throws Exception {
    mTestBlockInfo.setLocations(Lists.newArrayList(new BlockLocation().setWorkerAddress(ADDRESS_1)));
    Set<Pair<WorkerInfo, SerializableVoid>> result = selectExecutorsTestHelper(1, Lists.newArrayList(WORKER_INFO_1, WORKER_INFO_2));
    Set<Pair<WorkerInfo, SerializableVoid>> expected = Sets.newHashSet();
    expected.add(new Pair<>(WORKER_INFO_2, null));
    // select one worker left
    assertEquals(expected, result);
}
Also used : BlockLocation(alluxio.wire.BlockLocation) Pair(alluxio.collections.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BlockLocation (alluxio.wire.BlockLocation)42 Test (org.junit.Test)22 BlockInfo (alluxio.wire.BlockInfo)21 FileBlockInfo (alluxio.wire.FileBlockInfo)17 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)17 Pair (alluxio.collections.Pair)15 WorkerNetAddress (alluxio.wire.WorkerNetAddress)14 FileInfo (alluxio.wire.FileInfo)13 URIStatus (alluxio.client.file.URIStatus)12 ArrayList (java.util.ArrayList)11 AlluxioURI (alluxio.AlluxioURI)10 InStreamOptions (alluxio.client.file.options.InStreamOptions)8 IOException (java.io.IOException)8 WorkerInfo (alluxio.wire.WorkerInfo)7 HashSet (java.util.HashSet)7 UnavailableException (alluxio.exception.status.UnavailableException)6 Map (java.util.Map)6 AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)5 OutStreamOptions (alluxio.client.file.options.OutStreamOptions)5 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)5