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());
}
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);
}
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);
}
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());
}
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);
}
Aggregations