A Dropwizard bundle that provides health checks, metrics and lifecycle management for Cassandra in a consistent manner across all your Dropwizard applications.

I'm currently working on an IPTV services platform. The architecture follows what is rapidly becoming the standard for scalable internet platforms, using distributed services with heavy focus on performance, resilience and the ability to handle extreme spikes in usage.

We're using Dropwizard for the application I'm currently working on, with Cassandra as our primary data store. To get started, we created some health checks and configuration and hooked things up just as you'd expect with any other Dropwizard feature. But the more we built, the more I realised that this is really very generic functionality that shouldn't have anything to do with our particular application.

So I started using my evening and weekend "free time" to put together a Dropwizard bundle that would provide this sort of thing for use in any future applications I might be involved in building. It also struck me that this must be something that others have done many times over - so I was surprised not to find anything already available. If something does exist, please forgive me for not finding it... but if Google doesn't know about it, neither do I.

What follows is a brief introduction to the bundle and how you can use it in your project. Please do raise issues if you come across them, and also feel free to add your own improvements via pull requests if you prefer. You can see .

Usage

To get started, you need to include the dependency in your build system. Assuming you're using Maven, you'd just add this to your pom.xml and configure the correct version (check ):

Once you've got that part done, the only thing left is to register the bundle in your application. Something along these lines should do the trick:

Of course, you'll need to configure your application accordingly. Defaults are provided for most configuration options, but you'll need to provide values for options that are specific to your environment. The full set of configuration options supported by the DataStax Cassandra driver are available via the familiar YAML config you'd expect of any Dropwizard app. In cases where you may provide one of many implementations (e.g. RetryPolicy , ReconnectionPolicy , etc.), I've followed the same pattern as used in metrics and logging. For example, here are two different ways to specify the reconnection policy:

If you have your own implementation of ReconnectionPolicy , you can plug that in too. Just take a look at the JavaDocs for the relevant interface and that should be enough to get you going.



Published

15 May 2014

Share

submit to reddit