During programmatic initialization, I have to create DataSourceDatabase objects. I end up saving those objects because I have code later on that polls isActive() and logs messages about HA-JDBC node state. Anyway, I noticed DataSourceDatabase.isActive() always returns false during my testing.
While looking for a workaround, I tried switching from cached DataSourceDatabase objects to getting them everytime from DatabaseClusterImpl.getDatabase("dbid"). However, I get the same result from those instances too.
To verify there is a problem, I set a watch point on AbstractDatabase.setActive(). It never gets called with value true. The only time I see it called at all is when I simulate a database loss. However, that just sets the value from false to false, so no change.
This is not a blocking issue for me, but I thought you would like to know if you are tracking issues.
My workaround is to call getActiveDatabases().contains("mydbid") on my cached DatabaseClusterImpl object, instead of calling getDatabase("mydbid").isActive() on the same cached DatabaseClusterImpl object. I get the cached DatabaseClusterImpl object during initialization by calling ProxyFactory.getDatabaseCluster(), and all it well.
Last edit: Justin Cranford 2014-02-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Database.setActive(true) is called by net.sf.hajdbc.DatabaseCluster#activate(net.sf.hajdbc.Database, net.sf.hajdbc.state.StateManager). However, it may be that the value is never initially set correctly during cluster startup. I'll look into it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Moving h2-1.3.175.jar from my webapp to tomcat/common/lib resolved the isActive=false problem too. I am not sure why this is a symptom of jar file misplacement though.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
During programmatic initialization, I have to create DataSourceDatabase objects. I end up saving those objects because I have code later on that polls isActive() and logs messages about HA-JDBC node state. Anyway, I noticed DataSourceDatabase.isActive() always returns false during my testing.
While looking for a workaround, I tried switching from cached DataSourceDatabase objects to getting them everytime from DatabaseClusterImpl.getDatabase("dbid"). However, I get the same result from those instances too.
To verify there is a problem, I set a watch point on AbstractDatabase.setActive(). It never gets called with value true. The only time I see it called at all is when I simulate a database loss. However, that just sets the value from false to false, so no change.
This is not a blocking issue for me, but I thought you would like to know if you are tracking issues.
My workaround is to call getActiveDatabases().contains("mydbid") on my cached DatabaseClusterImpl object, instead of calling getDatabase("mydbid").isActive() on the same cached DatabaseClusterImpl object. I get the cached DatabaseClusterImpl object during initialization by calling ProxyFactory.getDatabaseCluster(), and all it well.
Last edit: Justin Cranford 2014-02-25
Database.setActive(true) is called by net.sf.hajdbc.DatabaseCluster#activate(net.sf.hajdbc.Database, net.sf.hajdbc.state.StateManager). However, it may be that the value is never initially set correctly during cluster startup. I'll look into it.
Moving h2-1.3.175.jar from my webapp to tomcat/common/lib resolved the isActive=false problem too. I am not sure why this is a symptom of jar file misplacement though.
I've committed a fix for the startup issue to the 3.0 branch:
https://github.com/ha-jdbc/ha-jdbc/commit/e17ece09d609270aae11404fd329ec3f511fd26c