public class StatefulTopology extends Object
An example topology that demonstrates the use of IStatefulBolt
to manage state. To run the example,
$ storm jar examples/storm-starter/storm-starter-topologies-*.jar storm.starter.StatefulTopology statetopologyThe default state used is ‘InMemoryKeyValueState’ which does not persist the state across restarts. You could use ‘RedisKeyValueState’ to test state persistence by setting below property in conf/storm.yaml
topology.state.provider: org.apache.storm.redis.state.RedisKeyValueStateProviderYou should also start a local redis instance before running the ‘storm jar’ command. The default RedisKeyValueStateProvider parameters can be overridden in conf/storm.yaml, for e.g.
topology.state.provider.config: ‘{“keyClass”:“…”, “valueClass”:“…”, “keySerializerClass”:“…”, “valueSerializerClass”:“…”, “jedisPoolConfig”:{“host”:“localhost”, “port”:6379, “timeout”:2000, “database”:0, “password”:“xyz”}}’
Modifier and Type | Class and Description |
---|---|
static class |
StatefulTopology.PrinterBolt |
Constructor and Description |
---|
StatefulTopology() |
Copyright © 2019 The Apache Software Foundation. All Rights Reserved.