storm-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Johansen <johansenj...@gmail.com>
Subject Re: How to keep information when submit topology
Date Sat, 29 Dec 2018 02:24:39 GMT
You need to reinitialize the configuration if its null/uninitialized 

---Sent from Boxer | http://getboxer.com

On December 28, 2018 at 8:12:27 PM CST, ChenBo <mrchenbo@qq.com> 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  
    
Mime
View raw message