What kind of "some output"?
In my code, the job read data from Kafka, and then sink to outer storage.
Whether System.out.println() in RichSinkFunction.class is considered to "return some output" ?
KafkaSource<String> source = KafkaSource.<String>builder()
.setBootstrapServers(kafkaBrokers)
.setTopics(topicName)
.setGroupId(consumerGroup)
.setStartingOffsets(OffsetsInitializer.committedOffsets(OffsetResetStrategy.LATEST))
.setValueOnlyDeserializer(new SimpleStringSchema())
.build();
env.enableCheckpointing(1000 * 1 * 1, CheckpointingMode.EXACTLY_ONCE);
DataStream<String> stream = env.fromSource(source, WatermarkStrategy.noWatermarks(), "Kafka-reco-Source");
stream.addSink(new RichSinkFunction<String>() {
public Logger debugLogger = LogManager.getLogger(KafkaTest.class.getName());
public ObjectStoreBondColumnTableAsyncClient<UserColumnKey> osclient = null;
@Override
public void setRuntimeContext(RuntimeContext t) {
super.setRuntimeContext(t);
}
@Override
public RuntimeContext getRuntimeContext() {
return super.getRuntimeContext();
}
@Override
public IterationRuntimeContext getIterationRuntimeContext() {
return super.getIterationRuntimeContext();
}
@Override
public void open(Configuration parameters) throws Exception {
osclient = OSClientUtils.buildUserTabelClient(params);
System.out.println("Open connection to other storage.");
super.open(parameters);
}
@Override
public void close() throws Exception {
IOUtils.closeQuietly(osclient);
System.out.println("Close connection to other storage.");
}
@Override
public void invoke(String value, Context context) throws Exception {
boolean logTag = false;
if(Math.random()<0.1) {
logTag=true;
}
if( !value.contains("xxxxxxx")) return ;
Map<String,Object> jsonobj = new ObjectMapper().readValue(value, Map.class);
MsnFeedbackEvent msnclick = DeserializeUtils.createMsnFeedbackEvent(jsonobj);
if(!FilterUtils.msnArticleClick(msnclick)) return;
System.out.println(value);
Map<String, Map<String, Float>> osInput = OSClientUtils.BuildOSInput(new ArrayList<MsnFeedbackEvent>() {{add(msnclick);}});
try {
OSClientUtils.BatchUpdateGeneralInfos(osclient, osInput, params);
} catch (Exception e) {
System.out.println("BatchUpdateGeneralInfos except: " + ExceptionUtils.getFullStackTrace(e));
}
}
}).name("os-reco-sink");
env.execute("reco-flink-0224");
System.out.println("reco-flink-0224");