storm-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ChenBo" <>
Subject How to keep information when submit topology
Date Sat, 29 Dec 2018 02:12:27 GMT
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 {
        } catch (ClassNotFoundException e) {
            return false;

        try {
            BoneCPConfig config = new BoneCPConfig();
            comboPooledDataSource = new BoneCP(config);
        } catch (SQLException e) {
            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, 
View raw message