spotify / cassandra-reaper

Software to run automated repairs of cassandra
235 stars 60 forks source link

Support for H2 embedded Java database #73

Open spodkowinski opened 9 years ago

spodkowinski commented 9 years ago

This PR will add support for H2 as another database option. As H2 supports a Postgres combat mode, only minor changes were needed when it comes to SQL and JDBC handling.

Using H2, reaper can be distributed as a self contained package (except for yaml config) without having to rely on the in-memory store. Database files will be created automatically using the schema in the new reaper_h2.sql file.

varjoranta commented 9 years ago

I like the idea of using H2, but I'm not totally sure about the current proposed implementation. I will ponder a bit on this, and think what would happen if a third database implementation was added.

spodkowinski commented 9 years ago

TBH my first plan was to add MySQL or H2 support by implementing the IStorage API. However, that would require to refactor out some common classes out of the postgres package that could be used in new implementations as well. The alternative would be to just duplicate the postgres implemenation and fix all incompatibilities which would result in a lot of duplicated code. It would be great if the storage API JDBI integration could be made more DB agnostic. But the effort should be considerable. Given the postgres compatibility, introducing h2 into the project using the existing postgres storage implementation was a better option that could be done much quicker. In case at some point adding new storage implementations would be easier, I'd be happy to adapt the h2 code for that as well. Until then I think the h2 option lowers barriers and might help people to make up their minds to give the project a test drive.

varjoranta commented 9 years ago

To me it feels like just adding more database implementations doesn't really serve an acute user need, unless it brings in more capabilities for the system. H2 implementation does bring the ease of use in case you don't want to separately maintain a separate database instance. Adding MySQL in addition to Postgres doesn't seem to add anything else except complexity into the code. Thus I'm starting to lean into having a bit custom, as long as it is short and simple as possible, implementation for the H2.