ManagementGraph extends ManagementAttachment implements IOReadableWritable { public ManagementStage getStage(final int index) { if (index >= 0 && index < this.stages.size()) { return this.stages.get(index); } return null; } ManagementGraph(final JobID jobID);  ManagementGraph(); JobID getJobID(); ManagementVertex getVertexByID(final ManagementVertexID id); ManagementGroupVertex getGroupVertexByID(final ManagementGroupVertexID id); int getNumberOfStages(); ManagementStage getStage(final int index); int getNumberOfInputGroupVertices(final int stage); int getNumberOfOutputGroupVertices(final int stage); ManagementGroupVertex getInputGroupVertex(final int stage, final int index); ManagementGroupVertex getOutputGroupVertex(final int stage, final int index); int getNumberOfInputVertices(final int stage); int getNumberOfOutputVertices(final int stage); ManagementVertex getInputVertex(final int stage, final int index); ManagementVertex getOutputVertex(final int stage, final int index); Collection<ManagementGroupVertex> getGroupVertices(); List<ManagementGroupVertex> getGroupVerticesInTopologicalOrder(); List<ManagementGroupVertex> getGroupVerticesInReverseTopologicalOrder(); @Override void read(final DataInput in); @Override void write(final DataOutput out);  }
@Test public void testManagementGraphIterator() { final ManagementGraph testGraph = constructTestManagementGraph(); Iterator<ManagementVertex> it = new ManagementGraphIterator(testGraph, true); ManagementVertex[] expectedOrder = new ManagementVertex[5]; expectedOrder[0] = testGraph.getStage(0).getGroupVertex(0).getGroupMember(0); expectedOrder[1] = testGraph.getStage(0).getGroupVertex(1).getGroupMember(0); expectedOrder[2] = testGraph.getStage(1).getGroupVertex(0).getGroupMember(0); expectedOrder[3] = testGraph.getStage(1).getGroupVertex(1).getGroupMember(0); expectedOrder[4] = testGraph.getStage(0).getGroupVertex(1).getGroupMember(1); checkManagementVertexOrder(it, expectedOrder); it = new ManagementGraphIterator(testGraph, 0, false, true); checkManagementVertexOrder(it, expectedOrder); it = new ManagementGraphIterator(testGraph, expectedOrder[0], true); checkManagementVertexOrder(it, expectedOrder); expectedOrder = new ManagementVertex[3]; expectedOrder[0] = testGraph.getStage(0).getGroupVertex(0).getGroupMember(0); expectedOrder[1] = testGraph.getStage(0).getGroupVertex(1).getGroupMember(0); expectedOrder[2] = testGraph.getStage(0).getGroupVertex(1).getGroupMember(1); it = new ManagementGraphIterator(testGraph, 0, true, true); checkManagementVertexOrder(it, expectedOrder); it = new ManagementGraphIterator(testGraph, false); expectedOrder = new ManagementVertex[5]; expectedOrder[0] = testGraph.getStage(1).getGroupVertex(1).getGroupMember(0); expectedOrder[1] = testGraph.getStage(1).getGroupVertex(0).getGroupMember(0); expectedOrder[2] = testGraph.getStage(0).getGroupVertex(1).getGroupMember(0); expectedOrder[3] = testGraph.getStage(0).getGroupVertex(0).getGroupMember(0); expectedOrder[4] = testGraph.getStage(0).getGroupVertex(1).getGroupMember(1); checkManagementVertexOrder(it, expectedOrder); it = new ManagementGraphIterator(testGraph, 1, true, false); expectedOrder = new ManagementVertex[2]; expectedOrder[0] = testGraph.getStage(1).getGroupVertex(1).getGroupMember(0); expectedOrder[1] = testGraph.getStage(1).getGroupVertex(0).getGroupMember(0); checkManagementVertexOrder(it, expectedOrder); }
@Test public void testManagementGroupVertexIterator() { final ManagementGraph testGraph = constructTestManagementGraph(); Iterator<ManagementGroupVertex> it = new ManagementGroupVertexIterator(testGraph, true, -1); ManagementGroupVertex[] expectedOrder = new ManagementGroupVertex[4]; expectedOrder[0] = testGraph.getStage(0).getGroupVertex(0); expectedOrder[1] = testGraph.getStage(0).getGroupVertex(1); expectedOrder[2] = testGraph.getStage(1).getGroupVertex(0); expectedOrder[3] = testGraph.getStage(1).getGroupVertex(1); checkManagementGroupVertexOrder(it, expectedOrder); it = new ManagementGroupVertexIterator(testGraph, false, -1); expectedOrder[0] = testGraph.getStage(1).getGroupVertex(1); expectedOrder[1] = testGraph.getStage(1).getGroupVertex(0); expectedOrder[2] = testGraph.getStage(0).getGroupVertex(1); expectedOrder[3] = testGraph.getStage(0).getGroupVertex(0); checkManagementGroupVertexOrder(it, expectedOrder); it = new ManagementGroupVertexIterator(testGraph, true, 0); expectedOrder = new ManagementGroupVertex[2]; expectedOrder[0] = testGraph.getStage(0).getGroupVertex(0); expectedOrder[1] = testGraph.getStage(0).getGroupVertex(1); checkManagementGroupVertexOrder(it, expectedOrder); it = new ManagementGroupVertexIterator(testGraph, false, 1); expectedOrder[0] = testGraph.getStage(1).getGroupVertex(1); expectedOrder[1] = testGraph.getStage(1).getGroupVertex(0); checkManagementGroupVertexOrder(it, expectedOrder); }