Java Code Examples for org.apache.flink.streaming.api.graph.StreamConfig#getNumberOfInputs()

The following examples show how to use org.apache.flink.streaming.api.graph.StreamConfig#getNumberOfInputs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OneInputStreamTask.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void init() throws Exception {
	StreamConfig configuration = getConfiguration();
	int numberOfInputs = configuration.getNumberOfInputs();

	if (numberOfInputs > 0) {
		CheckpointedInputGate inputGate = createCheckpointedInputGate();
		DataOutput<IN> output = createDataOutput();
		StreamTaskInput<IN> input = createTaskInput(inputGate, output);
		inputProcessor = new StreamOneInputProcessor<>(
			input,
			output,
			operatorChain);
	}
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, this.inputWatermarkGauge);
	// wrap watermark gauge since registered metrics must be unique
	getEnvironment().getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, this.inputWatermarkGauge::getValue);
}
 
Example 2
Source File: OneInputStreamTask.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void init() throws Exception {
	StreamConfig configuration = getConfiguration();

	TypeSerializer<IN> inSerializer = configuration.getTypeSerializerIn1(getUserCodeClassLoader());
	int numberOfInputs = configuration.getNumberOfInputs();

	if (numberOfInputs > 0) {
		InputGate[] inputGates = getEnvironment().getAllInputGates();

		inputProcessor = new StreamInputProcessor<>(
				inputGates,
				inSerializer,
				this,
				configuration.getCheckpointMode(),
				getCheckpointLock(),
				getEnvironment().getIOManager(),
				getEnvironment().getTaskManagerInfo().getConfiguration(),
				getStreamStatusMaintainer(),
				this.headOperator,
				getEnvironment().getMetricGroup().getIOMetricGroup(),
				inputWatermarkGauge);
	}
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, this.inputWatermarkGauge);
	// wrap watermark gauge since registered metrics must be unique
	getEnvironment().getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, this.inputWatermarkGauge::getValue);
}
 
Example 3
Source File: OneInputStreamTask.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void init() throws Exception {
	StreamConfig configuration = getConfiguration();

	TypeSerializer<IN> inSerializer = configuration.getTypeSerializerIn1(getUserCodeClassLoader());
	int numberOfInputs = configuration.getNumberOfInputs();

	if (numberOfInputs > 0) {
		InputGate[] inputGates = getEnvironment().getAllInputGates();

		inputProcessor = new StreamOneInputProcessor<>(
				inputGates,
				inSerializer,
				this,
				configuration.getCheckpointMode(),
				getCheckpointLock(),
				getEnvironment().getIOManager(),
				getEnvironment().getTaskManagerInfo().getConfiguration(),
				getStreamStatusMaintainer(),
				this.headOperator,
				getEnvironment().getMetricGroup().getIOMetricGroup(),
				inputWatermarkGauge,
				getTaskNameWithSubtaskAndId(),
				operatorChain);
	}
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, this.inputWatermarkGauge);
	// wrap watermark gauge since registered metrics must be unique
	getEnvironment().getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, this.inputWatermarkGauge::getValue);
}
 
Example 4
Source File: AbstractTwoInputStreamTask.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void init() throws Exception {
	StreamConfig configuration = getConfiguration();
	ClassLoader userClassLoader = getUserCodeClassLoader();

	TypeSerializer<IN1> inputDeserializer1 = configuration.getTypeSerializerIn1(userClassLoader);
	TypeSerializer<IN2> inputDeserializer2 = configuration.getTypeSerializerIn2(userClassLoader);

	int numberOfInputs = configuration.getNumberOfInputs();

	ArrayList<InputGate> inputList1 = new ArrayList<InputGate>();
	ArrayList<InputGate> inputList2 = new ArrayList<InputGate>();

	List<StreamEdge> inEdges = configuration.getInPhysicalEdges(userClassLoader);

	for (int i = 0; i < numberOfInputs; i++) {
		int inputType = inEdges.get(i).getTypeNumber();
		InputGate reader = getEnvironment().getInputGate(i);
		switch (inputType) {
			case 1:
				inputList1.add(reader);
				break;
			case 2:
				inputList2.add(reader);
				break;
			default:
				throw new RuntimeException("Invalid input type number: " + inputType);
		}
	}

	createInputProcessor(inputList1, inputList2, inputDeserializer1, inputDeserializer2);

	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge);
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_1_WATERMARK, input1WatermarkGauge);
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_2_WATERMARK, input2WatermarkGauge);
	// wrap watermark gauge since registered metrics must be unique
	getEnvironment().getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge::getValue);
}
 
Example 5
Source File: AbstractTwoInputStreamTask.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void init() throws Exception {
	StreamConfig configuration = getConfiguration();
	ClassLoader userClassLoader = getUserCodeClassLoader();

	TypeSerializer<IN1> inputDeserializer1 = configuration.getTypeSerializerIn1(userClassLoader);
	TypeSerializer<IN2> inputDeserializer2 = configuration.getTypeSerializerIn2(userClassLoader);

	int numberOfInputs = configuration.getNumberOfInputs();

	ArrayList<IndexedInputGate> inputList1 = new ArrayList<>();
	ArrayList<IndexedInputGate> inputList2 = new ArrayList<>();

	List<StreamEdge> inEdges = configuration.getInPhysicalEdges(userClassLoader);

	for (int i = 0; i < numberOfInputs; i++) {
		int inputType = inEdges.get(i).getTypeNumber();
		IndexedInputGate reader = getEnvironment().getInputGate(i);
		switch (inputType) {
			case 1:
				inputList1.add(reader);
				break;
			case 2:
				inputList2.add(reader);
				break;
			default:
				throw new RuntimeException("Invalid input type number: " + inputType);
		}
	}

	createInputProcessor(inputList1, inputList2, inputDeserializer1, inputDeserializer2);

	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge);
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_1_WATERMARK, input1WatermarkGauge);
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_2_WATERMARK, input2WatermarkGauge);
	// wrap watermark gauge since registered metrics must be unique
	getEnvironment().getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge::getValue);
}
 
Example 6
Source File: MultipleInputStreamTask.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void init() throws Exception {
	StreamConfig configuration = getConfiguration();
	ClassLoader userClassLoader = getUserCodeClassLoader();

	TypeSerializer<?>[] inputDeserializers = configuration.getTypeSerializersIn(userClassLoader);

	ArrayList<IndexedInputGate>[] inputLists = new ArrayList[inputDeserializers.length];
	WatermarkGauge[] watermarkGauges = new WatermarkGauge[inputDeserializers.length];

	for (int i = 0; i < inputDeserializers.length; i++) {
		inputLists[i] = new ArrayList<>();
		watermarkGauges[i] = new WatermarkGauge();
		headOperator.getMetricGroup().gauge(MetricNames.currentInputWatermarkName(i + 1), watermarkGauges[i]);
	}

	MinWatermarkGauge minInputWatermarkGauge = new MinWatermarkGauge(watermarkGauges);
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge);

	List<StreamEdge> inEdges = configuration.getInPhysicalEdges(userClassLoader);
	int numberOfInputs = configuration.getNumberOfInputs();

	for (int i = 0; i < numberOfInputs; i++) {
		int inputType = inEdges.get(i).getTypeNumber();
		IndexedInputGate reader = getEnvironment().getInputGate(i);
		inputLists[inputType - 1].add(reader);
	}

	createInputProcessor(inputLists, inputDeserializers, watermarkGauges);

	// wrap watermark gauge since registered metrics must be unique
	getEnvironment().getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge::getValue);
}
 
Example 7
Source File: TwoInputStreamTask.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void init() throws Exception {
	StreamConfig configuration = getConfiguration();
	ClassLoader userClassLoader = getUserCodeClassLoader();

	TypeSerializer<IN1> inputDeserializer1 = configuration.getTypeSerializerIn1(userClassLoader);
	TypeSerializer<IN2> inputDeserializer2 = configuration.getTypeSerializerIn2(userClassLoader);

	int numberOfInputs = configuration.getNumberOfInputs();

	ArrayList<InputGate> inputList1 = new ArrayList<InputGate>();
	ArrayList<InputGate> inputList2 = new ArrayList<InputGate>();

	List<StreamEdge> inEdges = configuration.getInPhysicalEdges(userClassLoader);

	for (int i = 0; i < numberOfInputs; i++) {
		int inputType = inEdges.get(i).getTypeNumber();
		InputGate reader = getEnvironment().getInputGate(i);
		switch (inputType) {
			case 1:
				inputList1.add(reader);
				break;
			case 2:
				inputList2.add(reader);
				break;
			default:
				throw new RuntimeException("Invalid input type number: " + inputType);
		}
	}

	this.inputProcessor = new StreamTwoInputProcessor<>(
			inputList1, inputList2,
			inputDeserializer1, inputDeserializer2,
			this,
			configuration.getCheckpointMode(),
			getCheckpointLock(),
			getEnvironment().getIOManager(),
			getEnvironment().getTaskManagerInfo().getConfiguration(),
			getStreamStatusMaintainer(),
			this.headOperator,
			getEnvironment().getMetricGroup().getIOMetricGroup(),
			input1WatermarkGauge,
			input2WatermarkGauge);

	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge);
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_1_WATERMARK, input1WatermarkGauge);
	headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_2_WATERMARK, input2WatermarkGauge);
	// wrap watermark gauge since registered metrics must be unique
	getEnvironment().getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, minInputWatermarkGauge::getValue);
}