Search in sources :

Example 6 with EdgePlan

use of org.apache.tez.dag.api.records.DAGProtos.EdgePlan in project tez by apache.

the class DAGImpl method parseVertexEdges.

// hooks up this VertexImpl to input and output EdgeProperties
private static void parseVertexEdges(DAGImpl dag, Map<String, EdgePlan> edgePlans, Vertex vertex) {
    VertexPlan vertexPlan = vertex.getVertexPlan();
    Map<Vertex, Edge> inVertices = new HashMap<Vertex, Edge>();
    Map<Vertex, Edge> outVertices = new HashMap<Vertex, Edge>();
    for (String inEdgeId : vertexPlan.getInEdgeIdList()) {
        EdgePlan edgePlan = edgePlans.get(inEdgeId);
        Vertex inVertex = dag.vertexMap.get(edgePlan.getInputVertexName());
        Edge edge = dag.edges.get(inEdgeId);
        edge.setSourceVertex(inVertex);
        edge.setDestinationVertex(vertex);
        inVertices.put(inVertex, edge);
    }
    for (String outEdgeId : vertexPlan.getOutEdgeIdList()) {
        EdgePlan edgePlan = edgePlans.get(outEdgeId);
        Vertex outVertex = dag.vertexMap.get(edgePlan.getOutputVertexName());
        Edge edge = dag.edges.get(outEdgeId);
        edge.setSourceVertex(vertex);
        edge.setDestinationVertex(outVertex);
        outVertices.put(outVertex, edge);
    }
    vertex.setInputVertices(inVertices);
    vertex.setOutputVertices(outVertices);
}
Also used : VertexEventRecoverVertex(org.apache.tez.dag.app.dag.event.VertexEventRecoverVertex) Vertex(org.apache.tez.dag.app.dag.Vertex) VertexPlan(org.apache.tez.dag.api.records.DAGProtos.VertexPlan) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) EdgePlan(org.apache.tez.dag.api.records.DAGProtos.EdgePlan)

Example 7 with EdgePlan

use of org.apache.tez.dag.api.records.DAGProtos.EdgePlan in project tez by apache.

the class TestDAGPlan method testUserPayloadSerde.

@Test(timeout = 5000)
public void testUserPayloadSerde() {
    DAG dag = DAG.create("testDag");
    ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").setUserPayload(UserPayload.create(ByteBuffer.wrap("processor1Bytes".getBytes())));
    ProcessorDescriptor pd2 = ProcessorDescriptor.create("processor2").setUserPayload(UserPayload.create(ByteBuffer.wrap("processor2Bytes".getBytes())));
    Vertex v1 = Vertex.create("v1", pd1, 10, Resource.newInstance(1024, 1));
    Vertex v2 = Vertex.create("v2", pd2, 1, Resource.newInstance(1024, 1));
    v1.setTaskLaunchCmdOpts("").setTaskEnvironment(new HashMap<String, String>()).addTaskLocalFiles(new HashMap<String, LocalResource>());
    v2.setTaskLaunchCmdOpts("").setTaskEnvironment(new HashMap<String, String>()).addTaskLocalFiles(new HashMap<String, LocalResource>());
    InputDescriptor inputDescriptor = InputDescriptor.create("input").setUserPayload(UserPayload.create(ByteBuffer.wrap("inputBytes".getBytes())));
    OutputDescriptor outputDescriptor = OutputDescriptor.create("output").setUserPayload(UserPayload.create(ByteBuffer.wrap("outputBytes".getBytes())));
    Edge edge = Edge.create(v1, v2, EdgeProperty.create(DataMovementType.SCATTER_GATHER, DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL, outputDescriptor, inputDescriptor));
    dag.addVertex(v1).addVertex(v2).addEdge(edge);
    DAGPlan dagProto = dag.createDag(new TezConfiguration(), null, null, null, true);
    assertEquals(2, dagProto.getVertexCount());
    assertEquals(1, dagProto.getEdgeCount());
    VertexPlan v1Proto = dagProto.getVertex(0);
    VertexPlan v2Proto = dagProto.getVertex(1);
    EdgePlan edgeProto = dagProto.getEdge(0);
    assertEquals("processor1Bytes", new String(v1Proto.getProcessorDescriptor().getTezUserPayload().getUserPayload().toByteArray()));
    assertEquals("processor1", v1Proto.getProcessorDescriptor().getClassName());
    assertEquals("processor2Bytes", new String(v2Proto.getProcessorDescriptor().getTezUserPayload().getUserPayload().toByteArray()));
    assertEquals("processor2", v2Proto.getProcessorDescriptor().getClassName());
    assertEquals("inputBytes", new String(edgeProto.getEdgeDestination().getTezUserPayload().getUserPayload().toByteArray()));
    assertEquals("input", edgeProto.getEdgeDestination().getClassName());
    assertEquals("outputBytes", new String(edgeProto.getEdgeSource().getTezUserPayload().getUserPayload().toByteArray()));
    assertEquals("output", edgeProto.getEdgeSource().getClassName());
    EdgeProperty edgeProperty = DagTypeConverters.createEdgePropertyMapFromDAGPlan(dagProto.getEdgeList().get(0));
    byte[] ib = edgeProperty.getEdgeDestination().getUserPayload().deepCopyAsArray();
    assertEquals("inputBytes", new String(ib));
    assertEquals("input", edgeProperty.getEdgeDestination().getClassName());
    byte[] ob = edgeProperty.getEdgeSource().getUserPayload().deepCopyAsArray();
    assertEquals("outputBytes", new String(ob));
    assertEquals("output", edgeProperty.getEdgeSource().getClassName());
}
Also used : HashMap(java.util.HashMap) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) DAGPlan(org.apache.tez.dag.api.records.DAGProtos.DAGPlan) VertexPlan(org.apache.tez.dag.api.records.DAGProtos.VertexPlan) EdgePlan(org.apache.tez.dag.api.records.DAGProtos.EdgePlan) Test(org.junit.Test)

Aggregations

EdgePlan (org.apache.tez.dag.api.records.DAGProtos.EdgePlan)7 HashMap (java.util.HashMap)6 VertexPlan (org.apache.tez.dag.api.records.DAGProtos.VertexPlan)4 Vertex (org.apache.tez.dag.app.dag.Vertex)4 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)3 ByteString (com.google.protobuf.ByteString)2 LinkedHashMap (java.util.LinkedHashMap)2 EdgeProperty (org.apache.tez.dag.api.EdgeProperty)2 VertexLocationHint (org.apache.tez.dag.api.VertexLocationHint)2 DAGPlan (org.apache.tez.dag.api.records.DAGProtos.DAGPlan)2 PlanVertexGroupInfo (org.apache.tez.dag.api.records.DAGProtos.PlanVertexGroupInfo)2 VertexEventRecoverVertex (org.apache.tez.dag.app.dag.event.VertexEventRecoverVertex)2 Test (org.junit.Test)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Credentials (org.apache.hadoop.security.Credentials)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 DrainDispatcher (org.apache.tez.common.DrainDispatcher)1