How to pass external configuration properties to storm topology?

How to pass external configuration properties to storm topology?

I want to pass some custom configuration properties to storm topology that are not part of storm yaml, how can I pass it.

https://community.hortonworks.com/questions/36969/how-to-pass-external-configuration-properties-to-s.html

https://stackoverflow.com/questions/18061332/storm-topology-configuration

------------------------------------------------------------------------------------------------------------------------------------------------------

you can use following ways to get the external configuration inside the topplogy

  

1:

pass the arguments like this

storm jar storm-jar topology-name -c sKey=sValue -c key1=value1 -c key2=value2 >/tmp/storm.txt

2:

Create a simple java resource file (properties files) and pass it as arguments to your topology main class, in main method read the properties from the main file

and build the storm configuration object using conf.put()

3:

create separate yaml file read it through the Utils method provided by storm api,look for more documentation https://nathanmarz.github.io/storm/doc/backtype/storm/utils/Utils.html

Utils.findAndReadConfigFile()

--------------------------

You can use

Config conf = new Config();

conf.put(key, val);

conf.put(key1, val1);

e.g redis config, etc.

and then you can use this in prepare method of bolts(in case of trident in functions/ filters, etc).

Hope this helps.

原文地址:https://www.cnblogs.com/oxspirt/p/7410344.html