Database Reference
In-Depth Information
while (true) {
val socket = listener.accept()
new Thread() {
override def run = {
println("Got client connected from: " +
socket.getInetAddress)
val out = new
PrintWriter(socket.getOutputStream(), true)
while (true) {
Thread.sleep(1000)
val num = random.nextInt(MaxEvents)
val data = generateNoisyData(num)
data.foreach { case (y, x) =>
val xStr = x.data.mkString(",")
val eventStr = s"$y\t$xStr"
out.write(eventStr)
out.write("\n")
}
out.flush()
println(s"Created $num events...")
}
socket.close()
}
}.start()
}
}
}
You can start the producer using sbt run , followed by choosing to execute the
StreamingModelProducer main method. This should result in the following output,
thus indicating that the producer program is waiting for connections from our streaming
regression application:
[info] Running StreamingModelProducer
Listening on port: 9999
Search WWH ::




Custom Search