//环境设置
StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
//设置并行度
env.setParallelism(1);
//自定义数据源
GeneratorFunction<Long, Demo1> generatorFunction = new GeneratorFunction<Long, Demo1>(){
@Override
public Demo1 map(Long aLong) throws Exception {
String[]users="Mary,Alice,Bob,Cary".split(",");
String[]urls="./home,./cart,./fav,./prod?id=1,./prod?id=2".split(",");
//生成随机数
Random random = new Random();
Demo1 demo1 = new Demo1();
demo1.setUser(users[random.nextInt(users.length)]);
demo1.setUrl(urls[random.nextInt(urls.length)]);
//System.currentTimeMillis():当前时间戳
demo1.setTs(System.currentTimeMillis());
return demo1;
}
};
//