Question

I'm want to implement a spout as a Socket Listener. To check how blocking process works in storm, I Scanner.in the spout of WordCounter example as folows

public void nextTuple() {
        /**
         * The nextuple it is called forever, so if we have been readed the file
         * we will wait and then return
         */
        Scanner scanner=new Scanner(System.in);
        scanner.next();

        /* Code to read from file */

    }

When I try to run this some error occurs. If I remove the scanner code, the example runs fine. Can someone tell me how blocking processes are handled in storm??

Was it helpful?

Solution

The main method storm uses when emitting tuples is nextTuple. All spout methods are called by the same thread. If anything blocks in nextTuple the spout will be unable to sent heartbeats to assure that its alive. I therefore advice you to use a none blocking function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top