flink观看更新
This commit is contained in:
parent
1f674b6b56
commit
6e66e33c27
|
|
@ -1,9 +1,9 @@
|
|||
package day01.scala
|
||||
|
||||
//import org.apache.flink.api.common.functions.FlatMapFunction
|
||||
//import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator
|
||||
import org.apache.flink.api.common.functions.FlatMapFunction
|
||||
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator
|
||||
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
|
||||
//import org.apache.flink.util.Collector
|
||||
import org.apache.flink.util.Collector
|
||||
|
||||
object Example_scala1 {
|
||||
|
||||
|
|
|
|||
|
|
@ -58,35 +58,35 @@ public class Example2 {
|
|||
.print();
|
||||
|
||||
//匿名内部类的方式
|
||||
// env
|
||||
// .addSource(new SourceFunction<Integer>() {
|
||||
//
|
||||
// private boolean running = true;
|
||||
// private Random random = new Random();
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void run(SourceContext<Integer> ctx) throws Exception {
|
||||
//
|
||||
// while (running) {
|
||||
// ctx.collect(random.nextInt(1000));
|
||||
// Thread.sleep(1000L);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void cancel() {
|
||||
// running = false;
|
||||
//
|
||||
// }
|
||||
// })
|
||||
// .map(new MapFunction<Integer, Tuple2<Integer, Integer>>() {
|
||||
// @Override
|
||||
// public Tuple2<Integer, Integer> map(Integer value) throws Exception {
|
||||
// return Tuple2.of(value, value);
|
||||
// }
|
||||
// }).print();
|
||||
env
|
||||
.addSource(new SourceFunction<Integer>() {
|
||||
|
||||
private boolean running = true;
|
||||
private Random random = new Random();
|
||||
|
||||
|
||||
@Override
|
||||
public void run(SourceContext<Integer> ctx) throws Exception {
|
||||
|
||||
while (running) {
|
||||
ctx.collect(random.nextInt(1000));
|
||||
Thread.sleep(1000L);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
running = false;
|
||||
|
||||
}
|
||||
})
|
||||
.map(new MapFunction<Integer, Tuple2<Integer, Integer>>() {
|
||||
@Override
|
||||
public Tuple2<Integer, Integer> map(Integer value) throws Exception {
|
||||
return Tuple2.of(value, value);
|
||||
}
|
||||
}).print();
|
||||
|
||||
|
||||
//外部类的方式
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
|
|||
import org.apache.flink.streaming.api.functions.KeyedProcessFunction;
|
||||
import org.apache.flink.streaming.api.functions.source.SourceFunction;
|
||||
import org.apache.flink.util.Collector;
|
||||
import sun.awt.SunHints;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
|
|||
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
|
||||
import org.apache.flink.streaming.api.functions.KeyedProcessFunction;
|
||||
import org.apache.flink.util.Collector;
|
||||
import sun.awt.geom.AreaOp;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue