Search in sources :

Example 6 with LoadTask

use of alluxio.job.plan.load.LoadDefinition.LoadTask 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

LoadTask (alluxio.job.plan.load.LoadDefinition.LoadTask)6 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)5 Pair (alluxio.collections.Pair)5 SelectExecutorsContext (alluxio.job.SelectExecutorsContext)5 WorkerInfo (alluxio.wire.WorkerInfo)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 AlluxioURI (alluxio.AlluxioURI)2 URIStatus (alluxio.client.file.URIStatus)2 WorkerNetAddress (alluxio.wire.WorkerNetAddress)2 Map (java.util.Map)2 Constants (alluxio.Constants)1 FailedPreconditionException (alluxio.exception.status.FailedPreconditionException)1 RunTaskContext (alluxio.job.RunTaskContext)1 AbstractVoidPlanDefinition (alluxio.job.plan.AbstractVoidPlanDefinition)1 BatchedJobDefinition (alluxio.job.plan.batch.BatchedJobDefinition)1 LoadConfig (alluxio.job.plan.load.LoadConfig)1 JobUtils (alluxio.job.util.JobUtils)1 SerializableVoid (alluxio.job.util.SerializableVoid)1