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