Search in sources :

Example 1 with MinWatermarkGauge

use of org.apache.flink.streaming.runtime.metrics.MinWatermarkGauge 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

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