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);
}
Aggregations