use of org.apache.beam.runners.flink.translation.wrappers.streaming.io.StreamingImpulseSource in project beam by apache.
the class FlinkStreamingPortablePipelineTranslator method translateStreamingImpulse.
private void translateStreamingImpulse(String id, RunnerApi.Pipeline pipeline, StreamingTranslationContext context) {
RunnerApi.PTransform pTransform = pipeline.getComponents().getTransformsOrThrow(id);
TypeInformation<WindowedValue<byte[]>> typeInfo = new CoderTypeInformation<>(WindowedValue.getFullCoder(ByteArrayCoder.of(), GlobalWindow.Coder.INSTANCE), context.getPipelineOptions());
ObjectMapper objectMapper = new ObjectMapper();
final int intervalMillis;
final int messageCount;
try {
JsonNode config = objectMapper.readTree(pTransform.getSpec().getPayload().toByteArray());
intervalMillis = config.path("interval_ms").asInt(100);
messageCount = config.path("message_count").asInt(0);
} catch (IOException e) {
throw new RuntimeException("Failed to parse configuration for streaming impulse", e);
}
SingleOutputStreamOperator<WindowedValue<byte[]>> source = context.getExecutionEnvironment().addSource(new StreamingImpulseSource(intervalMillis, messageCount), StreamingImpulseSource.class.getSimpleName()).returns(typeInfo);
context.addDataStream(Iterables.getOnlyElement(pTransform.getOutputsMap().values()), source);
}
Aggregations