use of alluxio.job.SelectExecutorsContext in project alluxio by Alluxio.
the class LoadDefinitionTest method notEnoughWorkersForReplication.
@Test
public void notEnoughWorkersForReplication() throws Exception {
createFileWithNoLocations(TEST_URI, 1);
LoadConfig config = new LoadConfig(TEST_URI, 5, Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, // set replication to 5
false);
try {
new LoadDefinition().selectExecutors(config, JOB_WORKERS, new SelectExecutorsContext(1, mJobServerContext));
Assert.fail();
} catch (Exception e) {
Assert.assertThat(e.getMessage(), CoreMatchers.containsString("Failed to find enough block workers to replicate to. Needed 5 but only found 4."));
}
}
use of alluxio.job.SelectExecutorsContext in project alluxio by Alluxio.
the class LoadDefinitionTest method notEnoughJobWorkersWithLocalBlockWorkers.
@Test
public void notEnoughJobWorkersWithLocalBlockWorkers() throws Exception {
List<BlockWorkerInfo> blockWorkers = Arrays.asList(new BlockWorkerInfo(new WorkerNetAddress().setHost("host0"), 0, 0), new BlockWorkerInfo(new WorkerNetAddress().setHost("otherhost"), 0, 0));
Mockito.when(mMockFsContext.getCachedWorkers()).thenReturn(blockWorkers);
createFileWithNoLocations(TEST_URI, 1);
LoadConfig config = new LoadConfig(TEST_URI, 2, Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, // set replication to 2
false);
try {
new LoadDefinition().selectExecutors(config, JOB_WORKERS, new SelectExecutorsContext(1, mJobServerContext));
Assert.fail();
} catch (Exception e) {
Assert.assertThat(e.getMessage(), CoreMatchers.containsString("Available workers without the block"));
Assert.assertThat(e.getMessage(), CoreMatchers.containsString("The following workers could not be used because " + "they have no local job workers: [otherhost]"));
}
}
use of alluxio.job.SelectExecutorsContext in project alluxio by Alluxio.
the class LoadDefinitionTest method replicationSatisfied.
@Test
public void replicationSatisfied() throws Exception {
int numBlocks = 7;
int replication = 3;
createFileWithNoLocations(TEST_URI, numBlocks);
LoadConfig config = new LoadConfig(TEST_URI, replication, Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, false);
Set<Pair<WorkerInfo, ArrayList<LoadTask>>> assignments = new LoadDefinition().selectExecutors(config, JOB_WORKERS, new SelectExecutorsContext(1, mJobServerContext));
// Check that we are loading the right number of blocks.
int totalBlockLoads = 0;
for (Pair<WorkerInfo, ArrayList<LoadTask>> assignment : assignments) {
totalBlockLoads += assignment.getSecond().size();
}
Assert.assertEquals(numBlocks * replication, totalBlockLoads);
}
use of alluxio.job.SelectExecutorsContext in project alluxio by Alluxio.
the class MigrateDefinitionSelectExecutorsTest method migrateNoLocalJobWorker.
@Test
public void migrateNoLocalJobWorker() throws Exception {
createFileWithBlocksOnWorkers("/src", 0);
setPathToNotExist("/dst");
Set<Pair<WorkerInfo, MigrateCommand>> assignments = new MigrateDefinition().selectExecutors(new MigrateConfig("/src", "/dst", "THROUGH", true), ImmutableList.of(JOB_WORKER_3), new SelectExecutorsContext(1, new JobServerContext(mMockFileSystem, mMockFileSystemContext, mMockUfsManager)));
Assert.assertEquals(ImmutableSet.of(new Pair<>(JOB_WORKER_3, new MigrateCommand("/src", "/dst"))), assignments);
}
use of alluxio.job.SelectExecutorsContext in project alluxio by Alluxio.
the class PersistDefinitionTest method selectExecutorsMissingLocationTest.
@Test
public void selectExecutorsMissingLocationTest() throws Exception {
AlluxioURI uri = new AlluxioURI("/test");
PersistConfig config = new PersistConfig(uri.getPath(), -1, true, "");
long blockId = 1;
BlockInfo blockInfo = new BlockInfo().setBlockId(blockId);
FileBlockInfo fileBlockInfo = new FileBlockInfo().setBlockInfo(blockInfo);
FileInfo testFileInfo = new FileInfo();
testFileInfo.setFileBlockInfos(Lists.newArrayList(fileBlockInfo));
Mockito.when(mMockFileSystem.getStatus(uri)).thenReturn(new URIStatus(testFileInfo));
try {
new PersistDefinition().selectExecutors(config, Lists.newArrayList(new WorkerInfo()), new SelectExecutorsContext(1, mJobServerContext));
} catch (Exception e) {
Assert.assertEquals("Block " + blockId + " does not exist", e.getMessage());
}
}
Aggregations