storm-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arun Mahadevan <ar...@apache.org>
Subject Re: initState method not invoked in Storm 1.0
Date Fri, 15 Apr 2016 08:54:18 GMT
Its the same method (builder.setBolt) that adds stateful bolts to a topology. Heres an example
- https://github.com/apache/storm/blob/master/examples/storm-starter/src/jvm/storm/starter/StatefulTopology.java

Spico,

Do you see any errors in the logs ? You might want to turn on debug logs and see whats happening.
Can you also try running the StatefulTopology in the storm-starter and check if you see the
same behavior ?

Thanks,
Arun

From:  Alexander T
Reply-To:  "user@storm.apache.org"
Date:  Friday, April 15, 2016 at 2:06 PM
To:  "user@storm.apache.org"
Subject:  Re: initState method not invoked in Storm 1.0

Hi Spico,

Are you adding your bolt to the topology with the special methods for stateful bolts? It's
quite easy to use the regular addBolt method and it will in that case be treated as a stateless
one.

Cheers
Alex

On Apr 15, 2016 10:33 AM, "Spico Florin" <spicoflorin@gmail.com> wrote:
Hello! 
  I'm running a topology in LocalCluster that has a stasteful Bolt. Wile debugging, I have
observed that the initState method is not invoked at all. 
The documentation said:
"The initState method is invoked by the framework during the bolt initialization with the
previously saved state of the bolt. This is invoked after prepare but before the bolt starts
processing any tuples".

Due to this, the state field remains null and I get NPE when I populate it with state .put
Any idea why the initState is not invoked?
Regards,
 Florin

Here is my code:

public class TimeSeriesStatefulBolt extends
BaseStatefulBolt<KeyValueState<Long, Map<String, Float>>> {

private KeyValueState<Long, Map<String, Float>> state;
@Override
public void initState(KeyValueState<Long, Map<String, Float>> state) {
this.state = state;
}


Mime
View raw message