Hi Eyal,

I had the similar issue earlier. Static objects are not a good way of
passing the variables around in Storm due to clustered nature of the Storm.
You will see null for all the static variables.

This is how I implemented mine, for instance I wanted to pass around the
server properties such and host name and username/password. I read the
properties file and then created a map of these properties then set it into
the Config object. Like below.

*In topology:*

Map<Stirng, Stirng> map = new HashMap();
map.put("hostname", "localhost");
map.put("username", "testuser");
map.put("password", "testpassord");
map.put("port", "1234");

Config config = new Config();

config.put("MY_MAP", map)
*In Bolts:*

public void prepare(Map stormConf, TopologyContext context) {

HashMap<Stirng, Stirng> map = stormConfig.get("MY_MAP");

}
This how i resolved my problem.Try that if that helps.
--
Kushan Maskey
817.403.7500
M. Miller & Associates <http://mmillerassociates.com/>
[email protected]

On Thu, Dec 4, 2014 at 1:01 PM, Eyal Golan <[email protected]> wrote:

> Hi all,
> I am newbie with Storm and having some issues with static objects in the
> topology.
> In the main class, where I set the topology, I also set a static object.
> It's actually a wrapper for a collection of strings.
> This object needs to he shared between different bolts.
> It's big so I want it to be only one instance.
>
> The problem is that when a bolt tries to get this static instance: example
> - MyMain.Shared... It's null. Although I instantiated it in the main method.
>
> I guess I'm doing something wrong.
>
> Thanks for any assistance.
>
> Eyal
>
> Sent from my Android phone
>

Reply via email to