// create job graph
final JobGraph jg = new JobGraph("Instance Sharing Test Job");
jobID = jg.getJobID();
// input vertex
final JobFileInputVertex input1 = new JobFileInputVertex("Input 1", jg);
input1.setFileInputClass(FileLineReader.class);
input1.setFilePath(new Path(inputFile1.toURI()));
input1.setNumberOfSubtasks(degreeOfParallelism);
// forward vertex 1
final JobTaskVertex forward1 = new JobTaskVertex("Forward 1", jg);
forward1.setTaskClass(ForwardTask1Input1Output.class);
forward1.setNumberOfSubtasks(degreeOfParallelism);
// forward vertex 2
final JobTaskVertex forward2 = new JobTaskVertex("Forward 2", jg);
forward2.setTaskClass(ForwardTask1Input1Output.class);
forward2.setNumberOfSubtasks(degreeOfParallelism);
// forward vertex 3
final JobTaskVertex forward3 = new JobTaskVertex("Forward 3", jg);
forward3.setTaskClass(ForwardTask1Input1Output.class);
forward3.setNumberOfSubtasks(degreeOfParallelism);
// output vertex
final JobFileOutputVertex output1 = new JobFileOutputVertex("Output 1", jg);
output1.setFileOutputClass(FileLineWriter.class);
output1.setFilePath(new Path(outputFile1.toURI()));
output1.setNumberOfSubtasks(degreeOfParallelism);
// connect vertices
input1.connectTo(forward1, ChannelType.IN_MEMORY,
DistributionPattern.POINTWISE);
forward1.connectTo(forward2, ChannelType.IN_MEMORY,
DistributionPattern.POINTWISE);
forward2.connectTo(forward3, ChannelType.NETWORK,
DistributionPattern.POINTWISE);
forward3.connectTo(output1, ChannelType.IN_MEMORY);
// setup instance sharing
input1.setVertexToShareInstancesWith(forward1);
forward1.setVertexToShareInstancesWith(forward2);
forward2.setVertexToShareInstancesWith(forward3);
forward3.setVertexToShareInstancesWith(output1);
LibraryCacheManager.register(jobID, new String[0]);