Richard Richard - 25 days ago 6
Java Question

Sharing resources in Twitter/Apache Storm

I'm using the storm architecture, and I've got a bolt which spawns 5 threads(/tasks, as far as I can tell they're an interchangeable term).

Is there a way for me to set a variable which all threads can read and write to?

Thanks :).

Answer

For understanding parallelism in Storm (and what tasks, executors, workers means), I recommend: Understanding the parallelism of a Storm topology.

In your Bolt, you can have a shared resource (like an instance variable of a Bolt) but you need to synchronise access to it, otherwise you will be in a deep trouble (unsurprisingly). But that shared resource isn't going to be shared between different Bolts.