Its distributed with the fat jar and you need to reload it when the jar on the supervisor starts up. You might be able to serialize the config when it distributes and it may auto distribute it.
---Sent from Boxer | http://getboxer.com On December 28, 2018 at 8:25:57 PM CST, ChenBo <[email protected]> wrote:Yes, but how could I keep user, url and password information when submit the topology? ------------------ 原始邮件 ------------------ 发件人: "Jacob Johansen"<[email protected]>; 发送时间: 2018年12月29日(星期六) 上午10:24 收件人: "[email protected]"<[email protected]>; 主题: Re: How to keep information when submit topology You need to reinitialize the configuration if its null/uninitialized ---Sent from Boxer | http://getboxer.comOn December 28, 2018 at 8:12:27 PM CST, ChenBo <[email protected]> wrote:Hi All, I use storm-core 1.2.2, there is my problem. I keep some information in Class static field before submit topology to Storm. But after I found when topology run, all those information lost. I think maybe it's because all class will be reload after submit. So Is there anyway to store some information before submit topology and also can get back those infor when topolog run? And there is my code. /** * the class is used to init mysql connection pool */public class DataBaseManger { private static final Logger logger = LoggerFactory.getLogger(DataBaseManger.class); private static BoneCP comboPooledDataSource; public static boolean init(String url, String user, String password) { try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { logger.error(e.getMessage()); return false; } try { BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl(url); config.setUsername(user); config.setPassword(password); config.setMinConnectionsPerPartition(5); config.setMaxConnectionsPerPartition(15); config.setPartitionCount(1); comboPooledDataSource = new BoneCP(config); } catch (SQLException e) { logger.error(e.getMessage()); return false; } return true; } public static synchronized Connection getConnection() throws SQLException { return comboPooledDataSource.getConnection(); }} /** * submit topology, and before that use local information to init the mysql connection pool */ public static void main(String[] args) throws Exception { LocalConfig localConfig = new LocalConfig(args); DataBaseManger.init(LocalConfig.getDbUrl(), LocalConfig.getDbUser(), LocalConfig.getDbPw()); StormTopology topology = createTopology(localConfig); Config config = getTopologyConfig(localConfig); StormSubmitter.submitTopology(localConfig.getTopologyName(), config, topology); } In Blot use DataBaseManger.getConnection() to get connection. But it's get NullPointException. that turns out comboPooledDataSource is null. So I am wounder is there anyway to keep mysql connection information after submit topology? Any help is appreciated. Thanks, ChenBo
