I need to write a stormy nose to read data from a port. I wanted to know if this is possible logically.
With that in mind, I developed a simple topology designed for the same nose and one bolt. The spout will collect the HTTP requests sent using wget, and the bolt will display the request. Exactly this.
My nose structure is as follows:
public class ProxySpout extends BaseRichSpout{
I also used the rest of the methods.
When I turn this into a topology and run it, I get an error when sending the first request:
java.lang.RuntimeException: java.io.NotSerializableException: java.net.Socket
You just need to know that something is wrong with the way I implement this nose. Is it even possible for the spout to collect data from the port? Or for a nose to act as an instance of a proxy?
Edit
It worked.
Code:
public class ProxySpout extends BaseRichSpout{
As suggested by @Shaw, I tried to initialize _serverSocket in the open() method, and _clientSocket works in the nextTuple() method to listen for requests.
I don't know the performance metrics for this, but it works .. :-)
source share