Hi, Alex!
There is no special method addBolt in the API TopologyBuilder for . I
have used the topologyBuilder.setBolt("myId", new TimeSeriesStatefulBolt())
without parallelism_hint declared and the API dismiss the statefulness.
I did NOT get any errors in the Logs.
What I have found is the topologyBuilder.setBolt(String id, IStatefulBolt
bolt, Number parallelism_hint) is considering the statefulness of the bolt,
but now I'm facing a different issue that seems to be related with some
constraints of the stareful bolts:
java.lang.RuntimeException: java.lang.UnsupportedOperationException: Bolts
in a stateful topology must emit anchored tuples.
Thank you for your support.
Florin
On Fri, Apr 15, 2016 at 11:36 AM, Alexander T <[email protected]>
wrote:
> 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" <[email protected]> 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;
>> }
>>
>