Search in sources :

Example 11 with ResultPartitionType

use of org.apache.flink.runtime.io.network.partition.ResultPartitionType in project flink by apache.

the class StreamingJobGraphGenerator method connect.

private void connect(Integer headOfChain, StreamEdge edge) {
    physicalEdgesInOrder.add(edge);
    Integer downStreamVertexID = edge.getTargetId();
    JobVertex headVertex = jobVertices.get(headOfChain);
    JobVertex downStreamVertex = jobVertices.get(downStreamVertexID);
    StreamConfig downStreamConfig = new StreamConfig(downStreamVertex.getConfiguration());
    downStreamConfig.setNumberOfNetworkInputs(downStreamConfig.getNumberOfNetworkInputs() + 1);
    StreamPartitioner<?> partitioner = edge.getPartitioner();
    ResultPartitionType resultPartitionType;
    switch(edge.getExchangeMode()) {
        case PIPELINED:
            resultPartitionType = ResultPartitionType.PIPELINED_BOUNDED;
            break;
        case BATCH:
            resultPartitionType = ResultPartitionType.BLOCKING;
            break;
        case UNDEFINED:
            resultPartitionType = determineResultPartitionType(partitioner);
            break;
        default:
            throw new UnsupportedOperationException("Data exchange mode " + edge.getExchangeMode() + " is not supported yet.");
    }
    checkBufferTimeout(resultPartitionType, edge);
    JobEdge jobEdge;
    if (partitioner.isPointwise()) {
        jobEdge = downStreamVertex.connectNewDataSetAsInput(headVertex, DistributionPattern.POINTWISE, resultPartitionType);
    } else {
        jobEdge = downStreamVertex.connectNewDataSetAsInput(headVertex, DistributionPattern.ALL_TO_ALL, resultPartitionType);
    }
    // set strategy name so that web interface can show it.
    jobEdge.setShipStrategyName(partitioner.toString());
    jobEdge.setBroadcast(partitioner.isBroadcast());
    jobEdge.setForward(partitioner instanceof ForwardPartitioner);
    jobEdge.setDownstreamSubtaskStateMapper(partitioner.getDownstreamSubtaskStateMapper());
    jobEdge.setUpstreamSubtaskStateMapper(partitioner.getUpstreamSubtaskStateMapper());
    if (LOG.isDebugEnabled()) {
        LOG.debug("CONNECTED: {} - {} -> {}", partitioner.getClass().getSimpleName(), headOfChain, downStreamVertexID);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ResultPartitionType(org.apache.flink.runtime.io.network.partition.ResultPartitionType) JobEdge(org.apache.flink.runtime.jobgraph.JobEdge) ForwardPartitioner(org.apache.flink.streaming.runtime.partitioner.ForwardPartitioner)

Aggregations

ResultPartitionType (org.apache.flink.runtime.io.network.partition.ResultPartitionType)11 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)8 IntermediateResultPartitionID (org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)3 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 InputChannelDeploymentDescriptor (org.apache.flink.runtime.deployment.InputChannelDeploymentDescriptor)2 JobEdge (org.apache.flink.runtime.jobgraph.JobEdge)2 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 DataDistribution (org.apache.flink.api.common.distributions.DataDistribution)1 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)1 Tuple1 (org.apache.flink.api.java.tuple.Tuple1)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 CompilerException (org.apache.flink.optimizer.CompilerException)1 Channel (org.apache.flink.optimizer.plan.Channel)1 DualInputPlanNode (org.apache.flink.optimizer.plan.DualInputPlanNode)1 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)1