// input
JobInputVertex vertices = createVerticesInput(jobGraph, verticesPath, numSubTasks, serializer, comparator);
JobInputVertex edges = createEdgesInput(jobGraph, edgesPath, numSubTasks, serializer, comparator);
// head
JobTaskVertex head = createIterationHead(jobGraph, numSubTasks, serializer, comparator, pairComparator);
TaskConfig headConfig = new TaskConfig(head.getConfiguration());
headConfig.setWaitForSolutionSetUpdate();
// 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 fakeTail = createFakeTail(jobGraph, numSubTasks);
JobOutputVertex sync = createSync(jobGraph, numSubTasks, maxIterations);
// ------------------ the intermediate (ws update) ----------------------
JobTaskVertex wsUpdateIntermediate =
JobGraphUtils.createTask(IterationIntermediatePactTask.class, "WorksetUpdate", jobGraph,
numSubTasks, numSubTasks);
TaskConfig wsUpdateConfig = new TaskConfig(wsUpdateIntermediate.getConfiguration());
{
wsUpdateConfig.setIterationId(ITERATION_ID);
wsUpdateConfig.setIsWorksetIteration();
wsUpdateConfig.setIsWorksetUpdate();
// inputs
wsUpdateConfig.addInputToGroup(0);
wsUpdateConfig.setInputSerializer(serializer, 0);
// output
wsUpdateConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
wsUpdateConfig.setOutputComparator(comparator, 0);
wsUpdateConfig.setOutputSerializer(serializer);
// driver
wsUpdateConfig.setDriver(JoinWithSolutionSetSecondDriver.class);
wsUpdateConfig.setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_SECOND);
wsUpdateConfig.setDriverComparator(comparator, 0);
wsUpdateConfig.setDriverPairComparator(pairComparator);
wsUpdateConfig.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);
// 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));
}
// edges
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, wsUpdateIntermediate, ChannelType.NETWORK,
DistributionPattern.POINTWISE);
wsUpdateConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, 1);
JobGraphUtils.connect(wsUpdateIntermediate, ssTail, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
ssTailConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, 1);
JobGraphUtils.connect(head, output, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
JobGraphUtils.connect(ssTail, fakeTail, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
JobGraphUtils.connect(head, sync, ChannelType.NETWORK, DistributionPattern.POINTWISE);
vertices.setVertexToShareInstancesWith(head);
edges.setVertexToShareInstancesWith(head);
intermediate.setVertexToShareInstancesWith(head);
wsUpdateIntermediate.setVertexToShareInstancesWith(head);
ssTail.setVertexToShareInstancesWith(head);
output.setVertexToShareInstancesWith(head);
sync.setVertexToShareInstancesWith(head);
fakeTail.setVertexToShareInstancesWith(ssTail);