spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillermo Ortiz <konstt2...@gmail.com>
Subject Re: Read data from SparkStreaming from Java socket.
Date Sat, 13 Dec 2014 11:56:05 GMT
I got it, thanks,, a silly question,, why if I do:
out.write("hello " + System.currentTimeMillis() + "\n"); it doesn't
detect anything and if I do
out.println("hello " + System.currentTimeMillis());  it works??

I'm doing with spark
val errorLines = lines.filter(_.contains("hello"))


2014-12-13 8:12 GMT+01:00 Tathagata Das <tathagata.das1565@gmail.com>:
> Yes, socketTextStream starts a TCP client that tries to connect to a
> TCP server (localhost:9999 in your case). If there is a server running
> on that port that can send data to connected TCP connections, then you
> will receive data in the stream.
>
> Did you check out the quick example in the streaming programming guide?
> http://spark.apache.org/docs/latest/streaming-programming-guide.html
> That has instructions to start a netcat server on port 9999 and send
> data to spark streaming through that.
>
> TD
>
> On Fri, Dec 12, 2014 at 9:54 PM, Akhil Das <akhil@sigmoidanalytics.com> wrote:
>> socketTextStream is Socket client which will read from a TCP ServerSocket.
>>
>> Thanks
>> Best Regards
>>
>> On Fri, Dec 12, 2014 at 7:21 PM, Guillermo Ortiz <konstt2000@gmail.com>
>> wrote:
>>>
>>> I dont' understand what spark streaming socketTextStream is waiting...
>>> is it like a server so you just have to send data from a client?? or
>>> what's it excepting?
>>>
>>> 2014-12-12 14:19 GMT+01:00 Akhil Das <akhil@sigmoidanalytics.com>:
>>> > I have created a Serversocket program which you can find over here
>>> > https://gist.github.com/akhld/4286df9ab0677a555087 It simply listens to
>>> > the
>>> > given port and when the client connects, it will send the contents of
>>> > the
>>> > given file. I'm attaching the executable jar also, you can run the jar
>>> > as:
>>> >
>>> > java -jar SocketBenchmark.jar student 12345 io
>>> >
>>> > Here student is the file which will be sent to the client whoever
>>> > connects
>>> > on 12345, i have it tested and is working with SparkStreaming
>>> > (socketTextStream).
>>> >
>>> >
>>> > Thanks
>>> > Best Regards
>>> >
>>> > On Fri, Dec 12, 2014 at 6:25 PM, Guillermo Ortiz <konstt2000@gmail.com>
>>> > wrote:
>>> >>
>>> >> Hi,
>>> >>
>>> >> I'm a newbie with Spark,, I'm just trying to use SparkStreaming and
>>> >> filter some data sent with a Java Socket but it's not working... it
>>> >> works when I use ncat
>>> >>
>>> >> Why is it not working??
>>> >>
>>> >> My sparkcode is just this:
>>> >>     val sparkConf = new
>>> >> SparkConf().setMaster("local[2]").setAppName("Test")
>>> >>     val ssc = new StreamingContext(sparkConf, Seconds(5))
>>> >>     val lines = ssc.socketTextStream("localhost", 9999)
>>> >>     val errorLines = lines.filter(_.contains("hello"))
>>> >>     errorLines.print()
>>> >>
>>> >> I created a client socket which sends data to that port, but it could
>>> >> connect any address, I guess that Spark doesn't work like a
>>> >> serverSocket... what's the way to send data from a socket with Java
to
>>> >> be able to read from socketTextStream??
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
>>> >> For additional commands, e-mail: user-help@spark.apache.org
>>> >>
>>> >

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org


Mime
View raw message