Search in sources :

Example 11 with SelectExecutorsContext

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."));
    }
}
Also used : SelectExecutorsContext(alluxio.job.SelectExecutorsContext) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with SelectExecutorsContext

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]"));
    }
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with SelectExecutorsContext

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);
}
Also used : LoadTask(alluxio.job.plan.load.LoadDefinition.LoadTask) ArrayList(java.util.ArrayList) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) WorkerInfo(alluxio.wire.WorkerInfo) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) Pair(alluxio.collections.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with SelectExecutorsContext

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);
}
Also used : JobServerContext(alluxio.job.JobServerContext) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) Pair(alluxio.collections.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) SelectExecutorsTest(alluxio.job.plan.SelectExecutorsTest) Test(org.junit.Test)

Example 15 with SelectExecutorsContext

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());
    }
}
Also used : FileInfo(alluxio.wire.FileInfo) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) WorkerInfo(alluxio.wire.WorkerInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) URIStatus(alluxio.client.file.URIStatus) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

SelectExecutorsContext (alluxio.job.SelectExecutorsContext)16 Pair (alluxio.collections.Pair)10 WorkerInfo (alluxio.wire.WorkerInfo)10 Test (org.junit.Test)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)7 ArrayList (java.util.ArrayList)6 AlluxioURI (alluxio.AlluxioURI)5 URIStatus (alluxio.client.file.URIStatus)5 LoadTask (alluxio.job.plan.load.LoadDefinition.LoadTask)5 WorkerNetAddress (alluxio.wire.WorkerNetAddress)5 BlockInfo (alluxio.wire.BlockInfo)4 FileBlockInfo (alluxio.wire.FileBlockInfo)4 Map (java.util.Map)4 BlockLocation (alluxio.wire.BlockLocation)3 FileInfo (alluxio.wire.FileInfo)3 JobServerContext (alluxio.job.JobServerContext)2 RunTaskContext (alluxio.job.RunTaskContext)2 SelectExecutorsTest (alluxio.job.plan.SelectExecutorsTest)2 BatchedJobDefinition (alluxio.job.plan.batch.BatchedJobDefinition)2