(Re)Introducing Hector: A Java-based Client for Apache Cassandra
Hector is a client for the obsolete Thrift API. New applications should use the DataStax Java Driver.
Hector, the first actively supported Java client for Apache Cassandra, was initially written to provide developers coming from J2EE backgrounds with a set of features traditionally found useful in connecting to a datastore:
- Pooled connections with configurable settings
- JMX integration for general monitoring and optional performance counters
- Extensive logging
In providing these features, we made the assumption that users are comfortable working with the Thrift API. Some minor abstractions were made to the most confusing portions of the API, notably column vs. super column and batch mutation. Very few new concepts were introduced specifically so that new users could easily learn the library in a way that facilitated using Cassandra’s Thrift API documentation as an additional point of reference. We instead focused our efforts on getting the features listed above to a point where they could be building blocks used as plumbing for higher level abstractions.
To a degree this worked, as evidenced by the number of projects currently using Hector. But from the traffic on the mailing lists, the number of issues we received and the arrival of competition (always a good thing as it only serves to validate a market), it became clear to us that we really missed the point. People do not want to “learn Thrift” – they want to interact with a datastore in a way that is familiar to them.
This is the inspiration behind the higher level API we are calling “v2”. It builds on the same robust hector plumbing currently in use in a number of production systems by adding an easier, more intuitive API. The original API remains largely unchanged (including direct access to Thrift should you want it). There has been some refactoring to enforce the separation of operations against a Keyspace versus a cluster as well as some cleanup, but these changes are minimal and were done against an extensive set of pre-existing unit tests.
I will be doing a short presentation of this new high-level Hector API at the upcoming Cassandra Summit in San Francisco. For some additional background, and to help further understanding of the core API, I have attached a document which was created as a foundation for both new and experienced users. It is an attempt by myself (with a number of valuable suggestions from Hector’s founder and project lead Ran Tavory) to document Hector’s settings and configuration and to provide some sample code for the most common uses.
Over next couple of weeks, this document will be updated to reflect the higher level API as we gather feedback from the community. Feel free to participate in the process by sending any suggestions for the API to: firstname.lastname@example.org
You can find the document here: Hector a Java Client for Apache Cassandra (PDF)