// intermediate
JobTaskVertex intermediate = createIterationIntermediate(jobGraph, numSubTasks, serializer, comparator);
TaskConfig intermediateConfig = new TaskConfig(intermediate.getConfiguration());
// output and auxiliaries
JobOutputVertex output = createOutput(jobGraph, resultPath, numSubTasks, serializer);
JobOutputVertex ssFakeTail = createFakeTail(jobGraph, numSubTasks);
JobOutputVertex wsFakeTail = createFakeTail(jobGraph, numSubTasks);
JobOutputVertex sync = createSync(jobGraph, numSubTasks, maxIterations);
// ------------------ the intermediate (ss join) ----------------------
JobTaskVertex ssJoinIntermediate = JobGraphUtils.createTask(IterationIntermediatePactTask.class,
"Solution Set Join", jobGraph, numSubTasks, numSubTasks);
TaskConfig ssJoinIntermediateConfig = new TaskConfig(ssJoinIntermediate.getConfiguration());
{
ssJoinIntermediateConfig.setIterationId(ITERATION_ID);
// inputs
ssJoinIntermediateConfig.addInputToGroup(0);
ssJoinIntermediateConfig.setInputSerializer(serializer, 0);
// output
ssJoinIntermediateConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
ssJoinIntermediateConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
ssJoinIntermediateConfig.setOutputComparator(comparator, 0);
ssJoinIntermediateConfig.setOutputComparator(comparator, 1);
ssJoinIntermediateConfig.setOutputSerializer(serializer);
// driver
ssJoinIntermediateConfig.setDriver(JoinWithSolutionSetSecondDriver.class);
ssJoinIntermediateConfig.setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_SECOND);
ssJoinIntermediateConfig.setDriverComparator(comparator, 0);
ssJoinIntermediateConfig.setDriverPairComparator(pairComparator);
ssJoinIntermediateConfig.setStubWrapper(
new UserCodeClassWrapper<UpdateComponentIdMatch>(UpdateComponentIdMatch.class));
}
// -------------------------- ss tail --------------------------------
JobTaskVertex ssTail = JobGraphUtils.createTask(IterationTailPactTask.class, "IterationSolutionSetTail",
jobGraph, numSubTasks, numSubTasks);
TaskConfig ssTailConfig = new TaskConfig(ssTail.getConfiguration());
{
ssTailConfig.setIterationId(ITERATION_ID);
ssTailConfig.setIsSolutionSetUpdate();
ssTailConfig.setIsWorksetIteration();
// inputs and driver
ssTailConfig.addInputToGroup(0);
ssTailConfig.setInputSerializer(serializer, 0);
ssTailConfig.setInputAsynchronouslyMaterialized(0, true);
ssTailConfig.setInputMaterializationMemory(0, MEM_PER_CONSUMER * JobGraphUtils.MEGABYTE);
// output
ssTailConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
ssTailConfig.setOutputSerializer(serializer);
// the driver
ssTailConfig.setDriver(CollectorMapDriver.class);
ssTailConfig.setDriverStrategy(DriverStrategy.COLLECTOR_MAP);
ssTailConfig.setStubWrapper(new UserCodeClassWrapper<DummyMapper>(DummyMapper.class));
}
// -------------------------- ws tail --------------------------------
JobTaskVertex wsTail = JobGraphUtils.createTask(IterationTailPactTask.class, "IterationWorksetTail",
jobGraph, numSubTasks, numSubTasks);
TaskConfig wsTailConfig = new TaskConfig(wsTail.getConfiguration());
{
wsTailConfig.setIterationId(ITERATION_ID);
wsTailConfig.setIsWorksetIteration();
wsTailConfig.setIsWorksetUpdate();
// inputs and driver
wsTailConfig.addInputToGroup(0);
wsTailConfig.setInputSerializer(serializer, 0);
// output
wsTailConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
wsTailConfig.setOutputSerializer(serializer);
// the driver
wsTailConfig.setDriver(CollectorMapDriver.class);
wsTailConfig.setDriverStrategy(DriverStrategy.COLLECTOR_MAP);
wsTailConfig.setStubWrapper(new UserCodeClassWrapper<DummyMapper>(DummyMapper.class));
}
// --------------- the wiring ---------------------
JobGraphUtils.connect(vertices, head, ChannelType.NETWORK, DistributionPattern.BIPARTITE);
JobGraphUtils.connect(edges, head, ChannelType.NETWORK, DistributionPattern.BIPARTITE);
JobGraphUtils.connect(vertices, head, ChannelType.NETWORK, DistributionPattern.BIPARTITE);
JobGraphUtils.connect(head, intermediate, ChannelType.NETWORK, DistributionPattern.BIPARTITE);
intermediateConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, numSubTasks);
JobGraphUtils.connect(intermediate, ssJoinIntermediate, ChannelType.NETWORK, DistributionPattern.POINTWISE);
ssJoinIntermediateConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, 1);
JobGraphUtils.connect(ssJoinIntermediate, ssTail, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
ssTailConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, 1);
JobGraphUtils.connect(ssJoinIntermediate, wsTail, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
wsTailConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, 1);
JobGraphUtils.connect(head, output, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
JobGraphUtils.connect(ssTail, ssFakeTail, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
JobGraphUtils.connect(wsTail, wsFakeTail, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
JobGraphUtils.connect(head, sync, ChannelType.NETWORK, DistributionPattern.POINTWISE);
vertices.setVertexToShareInstancesWith(head);
edges.setVertexToShareInstancesWith(head);
intermediate.setVertexToShareInstancesWith(head);
ssJoinIntermediate.setVertexToShareInstancesWith(head);
wsTail.setVertexToShareInstancesWith(head);
output.setVertexToShareInstancesWith(head);
sync.setVertexToShareInstancesWith(head);
ssTail.setVertexToShareInstancesWith(wsTail);
ssFakeTail.setVertexToShareInstancesWith(ssTail);
wsFakeTail.setVertexToShareInstancesWith(wsTail);