Search in sources :

Example 16 with SelectExecutorsContext

use of alluxio.job.SelectExecutorsContext in project alluxio by Alluxio.

the class BatchedJobDefinitionTest method batchLoad.

@Test
public void batchLoad() throws Exception {
    int numBlocks = 2;
    int replication = 2;
    int batchSize = 2;
    HashSet<Map<String, String>> configs = Sets.newHashSet();
    for (int i = 0; i < batchSize; i++) {
        createFileWithNoLocations(TEST_URI + i, numBlocks);
        LoadConfig loadConfig = new LoadConfig(TEST_URI + i, replication, Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, true);
        ObjectMapper oMapper = new ObjectMapper();
        Map<String, String> map = oMapper.convertValue(loadConfig, Map.class);
        configs.add(map);
    }
    BatchedJobConfig config = new BatchedJobConfig("Load", configs);
    Set<Pair<WorkerInfo, BatchedJobDefinition.BatchedJobTask>> assignments = new BatchedJobDefinition().selectExecutors(config, JOB_WORKERS, new SelectExecutorsContext(1, mJobServerContext));
    // Check that we are loading the right number of blocks.
    int totalBlockLoads = 0;
    for (Pair<WorkerInfo, BatchedJobDefinition.BatchedJobTask> assignment : assignments) {
        ArrayList<LoadTask> second = (ArrayList<LoadTask>) assignment.getSecond().getJobTaskArgs();
        totalBlockLoads += second.size();
    }
    Assert.assertEquals(numBlocks * replication * batchSize, totalBlockLoads);
}
Also used : BatchedJobDefinition(alluxio.job.plan.batch.BatchedJobDefinition) ArrayList(java.util.ArrayList) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) WorkerInfo(alluxio.wire.WorkerInfo) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) LoadTask(alluxio.job.plan.load.LoadDefinition.LoadTask) LoadConfig(alluxio.job.plan.load.LoadConfig) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Pair(alluxio.collections.Pair) 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