Search in sources :

Example 1 with InputConfig

use of org.apache.flink.streaming.api.graph.StreamConfig.InputConfig in project flink by apache.

the class StreamTaskMailboxTestHarnessBuilder method initializeInputs.

protected void initializeInputs(StreamMockEnvironment streamMockEnvironment) {
    inputGates = new StreamTestSingleInputGate[inputChannelsPerGate.size()];
    List<StreamEdge> inPhysicalEdges = new LinkedList<>();
    StreamNode mainNode = new StreamNode(StreamConfigChainer.MAIN_NODE_ID, null, null, (StreamOperator<?>) null, null, null);
    for (int i = 0; i < inputs.size(); i++) {
        if ((inputs.get(i) instanceof NetworkInputConfig)) {
            NetworkInputConfig networkInput = (NetworkInputConfig) inputs.get(i);
            initializeNetworkInput(networkInput, mainNode, streamMockEnvironment, inPhysicalEdges);
        } else if ((inputs.get(i) instanceof StreamTaskMailboxTestHarnessBuilder.SourceInputConfigPlaceHolder)) {
            SourceInputConfigPlaceHolder sourceInput = (SourceInputConfigPlaceHolder) inputs.get(i);
            inputs.set(i, initializeSourceInput(i, sourceInput, mainNode));
        } else {
            throw new UnsupportedOperationException("Unknown input type " + inputs.get(i));
        }
    }
    streamConfig.setInPhysicalEdges(inPhysicalEdges);
    streamConfig.setNumberOfNetworkInputs(inputGates.length);
    streamConfig.setInputs(inputs.toArray(new InputConfig[inputs.size()]));
}
Also used : NetworkInputConfig(org.apache.flink.streaming.api.graph.StreamConfig.NetworkInputConfig) StreamEdge(org.apache.flink.streaming.api.graph.StreamEdge) StreamNode(org.apache.flink.streaming.api.graph.StreamNode) NetworkInputConfig(org.apache.flink.streaming.api.graph.StreamConfig.NetworkInputConfig) InputConfig(org.apache.flink.streaming.api.graph.StreamConfig.InputConfig) SourceInputConfig(org.apache.flink.streaming.api.graph.StreamConfig.SourceInputConfig) LinkedList(java.util.LinkedList)

Example 2 with InputConfig

use of org.apache.flink.streaming.api.graph.StreamConfig.InputConfig in project flink by apache.

the class MultipleInputStreamTask method init.

@SuppressWarnings("rawtypes")
@Override
public void init() throws Exception {
    StreamConfig configuration = getConfiguration();
    ClassLoader userClassLoader = getUserCodeClassLoader();
    InputConfig[] inputs = configuration.getInputs(userClassLoader);
    WatermarkGauge[] watermarkGauges = new WatermarkGauge[inputs.length];
    for (int i = 0; i < inputs.length; i++) {
        watermarkGauges[i] = new WatermarkGauge();
        mainOperator.getMetricGroup().gauge(MetricNames.currentInputWatermarkName(i + 1), watermarkGauges[i]);
    }
    MinWatermarkGauge minInputWatermarkGauge = new MinWatermarkGauge(watermarkGauges);
    mainOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge);
    List<StreamEdge> inEdges = configuration.getInPhysicalEdges(userClassLoader);
    // Those two number may differ for example when one of the inputs is a union. In that case
    // the number of logical network inputs is smaller compared to the number of inputs (input
    // gates)
    int numberOfNetworkInputs = configuration.getNumberOfNetworkInputs();
    ArrayList[] inputLists = new ArrayList[inputs.length];
    for (int i = 0; i < inputLists.length; i++) {
        inputLists[i] = new ArrayList<>();
    }
    for (int i = 0; i < numberOfNetworkInputs; i++) {
        int inputType = inEdges.get(i).getTypeNumber();
        IndexedInputGate reader = getEnvironment().getInputGate(i);
        inputLists[inputType - 1].add(reader);
    }
    ArrayList<ArrayList<?>> networkInputLists = new ArrayList<>();
    for (ArrayList<?> inputList : inputLists) {
        if (!inputList.isEmpty()) {
            networkInputLists.add(inputList);
        }
    }
    createInputProcessor(networkInputLists.toArray(new ArrayList[0]), inputs, watermarkGauges, (index) -> inEdges.get(index).getPartitioner());
    // wrap watermark gauge since registered metrics must be unique
    getEnvironment().getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge::getValue);
}
Also used : ArrayList(java.util.ArrayList) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) MinWatermarkGauge(org.apache.flink.streaming.runtime.metrics.MinWatermarkGauge) StreamEdge(org.apache.flink.streaming.api.graph.StreamEdge) IndexedInputGate(org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate) MinWatermarkGauge(org.apache.flink.streaming.runtime.metrics.MinWatermarkGauge) WatermarkGauge(org.apache.flink.streaming.runtime.metrics.WatermarkGauge) InputConfig(org.apache.flink.streaming.api.graph.StreamConfig.InputConfig)

Aggregations

InputConfig (org.apache.flink.streaming.api.graph.StreamConfig.InputConfig)2 StreamEdge (org.apache.flink.streaming.api.graph.StreamEdge)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 IndexedInputGate (org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate)1 StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)1 NetworkInputConfig (org.apache.flink.streaming.api.graph.StreamConfig.NetworkInputConfig)1 SourceInputConfig (org.apache.flink.streaming.api.graph.StreamConfig.SourceInputConfig)1 StreamNode (org.apache.flink.streaming.api.graph.StreamNode)1 MinWatermarkGauge (org.apache.flink.streaming.runtime.metrics.MinWatermarkGauge)1 WatermarkGauge (org.apache.flink.streaming.runtime.metrics.WatermarkGauge)1