package org.hnsw
import org.apache.spark.SparkConf
import org.apache.spark.streaming.{Seconds, StreamingContext}
object SparkLearn {
def main(args: Array[String]): Unit = {
//1、初始化Context上下文
val conf = new SparkConf().setAppName("jxq").setMaster("local[*]")
val sc = new StreamingContext(conf, Seconds(1))
//2、指定采集服务器ip和端口
val dStream = sc.socketTextStream("192.168.3.66",8888)
//3、业务逻辑
val dStream_win = dStream.window(Seconds(5), Seconds(2)) //指定窗口大小 和 滑动频率 必须是批处理时间的整数倍
dStream_win.print()
//4、启动stream
sc.start()
//5、挂起stream
sc.awaitTermination()
}
}