Database Reference
In-Depth Information
To get Hector, clone it from its GitHub site at http://github.com/rantav/hector . Use the git com-
mand if you want the source, or just download the binary from the Downloads tab.
Features
Hector is a well-supported and full-featured Cassandra client, with many users and an active
community. It offers the following:
Hiigh--level o
l objjectt--oriientted A
d API
Java developers should find the interfaces that Hector offers, such as Keyspace and Column,
very natural to use.
Faiil o
l over s
r supportt
Thrift does not provide support for failed clients. This is because Cassandra is intended to
be used in a highly distributed fashion and has good support for failed nodes in the database
ring. But if your client connects to a node that has gone down, it would be nice to have your
client failover—to automatically search for another node to use to complete your request.
Happily, Hector provides this.
Connecttiion p
in poolliing
Cassandra is specifically built for very high scalability, and it therefore also becomes a re-
quirement on the client side to support connection pools so that your application doesn't
become a bottleneck that robs you of Cassandra's speed. It's expensive to open and close
connections, just as it is in JDBC. Hector's connection pooling uses Apache's GenericOb-
jectPool .
JMX s
MX supportt
Cassandra makes liberal use of JMX, which comes in very handy for monitoring. Hector dir-
ectly supports JMX by exposing metrics such as bad connections, available connections, idle
connections, and more.
The Hector API
The following is an example from Ran Tavory's blog ( http://prettyprint.me ) illustrating how
Hector simplifies working with Cassandra:
// Create a cluster
Cluster c = HFactory.getOrCreateCluster("MyCluster", "cassandra1:9160");
// Choose a keyspace
KeyspaceOperator ko = HFactory.createKeyspaceOperator("Keyspace1", c);
// create an string extractor.
Search WWH ::




Custom Search