0
Hector v2 The Second Version of the Popular High-Level Java Client for  Apache Cassandra [email_address]
Background  <ul><ul><li>Originated from abandoned Googlecode project </li></ul></ul><ul><ul><li>Made to fit immediate need...
Current Capabilities <ul><ul><li>Solid set of features typically found in datastore connectors </li></ul></ul><ul><ul><ul>...
Current Status <ul><ul><li>First in market means we have a lot of users </li></ul></ul><ul><ul><ul><li>47 closed issues on...
Initial Assumptions About API  <ul><ul><li>  Getting involved early meant you got comfortable with Thrift </li></ul></ul><...
Pelops Released <ul><ul><li>Pelops got popular for the very features we thought were less important </li></ul></ul><ul><ul...
Enter v2: Design Goals <ul><ul><li>Familiar access patterns for for most common users (Spring Framework, Hibernate, etc)  ...
v2 Continued: Misc Changes <ul><ul><li>Examples become real  </li></ul></ul><ul><ul><ul><li>were being used as such anyway...
Full Example <ul><li>// Create a cluster Cluster c  =  HFactory. getOrCreateCluster ( &quot;MyCluster&quot; ,  &quot;cassa...
Full Example Part 1 <ul><li>Cluster c  =  HFactory. getOrCreateCluster ( &quot;MyCluster&quot; ,  &quot;cassandra1:9160&qu...
Full Example Part 2 <ul><li>Mutator m  =  HFactory. createMutator ( keyspaceOperator ) ; </li></ul><ul><li>m. insert ( &qu...
Full Example Part 3 <ul><li>ColumnQuery < String, String >  q  =   </li></ul><ul><li>     HFactory. createColumnQuery ( ke...
Full Example Part 4 <ul><li>HColumn < String, String >  c  =  r. get () ;   </li></ul><ul><li>String  value  =  c. getValu...
Simple Example (IoC Required) <ul><li>simpleCassandraDao. insert ( &quot;key1&quot; , &quot;column1&quot; ,  &quot;value1&...
Immediate(ish) Future <ul><ul><li>  More refactoring on internals </li></ul></ul><ul><ul><ul><li>unwind constructor comple...
Feedback Please <ul><li>[email_address] </li></ul><ul><li>[email_address] </li></ul><ul><li>http://github.com/rantav/hecto...
Upcoming SlideShare
Loading in...5
×

Hector v2: The Second Version of the Popular High-Level Java Client for Apache Cassandra

5,832

Published on

This presentation will provide a preview of our new high-level API designed around community feedback and built on the solid foundation of Hector client internals currently in use by a number of production systems. A brief introduction to the existing Hector client will be included to accomadate new users.

Published in: Technology
0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,832
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
105
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide
  • Ran wrote the EmbeddedCassandraService in cassandra proper Not personally verified OSGi
  • Extractor interface: - type safety for column names and column values - String and Long default types
  •     Because names and values in cassandra are byte[], we added extractors Extractors provide type safety and separation of concerns Extractors have no state and are purely functional
  • Transcript of "Hector v2: The Second Version of the Popular High-Level Java Client for Apache Cassandra"

    1. 1. Hector v2 The Second Version of the Popular High-Level Java Client for  Apache Cassandra [email_address]
    2. 2. Background <ul><ul><li>Originated from abandoned Googlecode project </li></ul></ul><ul><ul><li>Made to fit immediate needs </li></ul></ul><ul><ul><li>Focus was on the plumbing </li></ul></ul><ul><ul><li>&quot;First to market&quot; advantage in adoption </li></ul></ul><ul><ul><li>Developers familiar with Apache Cassandra internals </li></ul></ul>
    3. 3. Current Capabilities <ul><ul><li>Solid set of features typically found in datastore connectors </li></ul></ul><ul><ul><ul><li>Robust monitoring via JMX </li></ul></ul></ul><ul><ul><ul><li>Optional performance counters  </li></ul></ul></ul><ul><ul><ul><li>Configurable logging </li></ul></ul></ul><ul><ul><ul><li>Failover </li></ul></ul></ul><ul><ul><ul><li>Reliable pooling geared towards a &quot;cluster&quot; </li></ul></ul></ul><ul><ul><ul><li>OSGi compatible bundle </li></ul></ul></ul><ul><ul><li>Client-side validation </li></ul></ul><ul><ul><li>Test-ability  </li></ul></ul><ul><ul><ul><li>Utility classes for testing </li></ul></ul></ul><ul><ul><ul><li>Base test class for easy setup </li></ul></ul></ul>
    4. 4. Current Status <ul><ul><li>First in market means we have a lot of users </li></ul></ul><ul><ul><ul><li>47 closed issues on github </li></ul></ul></ul><ul><ul><ul><li>helpful archive of user and developer mail list traffic </li></ul></ul></ul><ul><ul><li>Lots of experience with operational behavior over time </li></ul></ul>
    5. 5. Initial Assumptions About API <ul><ul><li>  Getting involved early meant you got comfortable with Thrift </li></ul></ul><ul><ul><li>  Several early threads asked directly for thrift encapsulation </li></ul></ul><ul><ul><ul><li>decided to focus on the plumbing </li></ul></ul></ul><ul><ul><li>Thought we made the right choice given the number of projects built on top </li></ul></ul>
    6. 6. Pelops Released <ul><ul><li>Pelops got popular for the very features we thought were less important </li></ul></ul><ul><ul><ul><li>Thrift encapsulation </li></ul></ul></ul><ul><ul><ul><li>High-level abstractions </li></ul></ul></ul><ul><ul><li>Competition is a good thing (choice validates a market) </li></ul></ul>
    7. 7. Enter v2: Design Goals <ul><ul><li>Familiar access patterns for for most common users (Spring Framework, Hibernate, etc)  </li></ul></ul><ul><ul><li>Keep the simplest operations simple </li></ul></ul><ul><ul><li>Thrift encapsulation </li></ul></ul><ul><ul><li>API version hiding </li></ul></ul><ul><ul><li>Clear distinction between cluster and data operations </li></ul></ul><ul><ul><li>Support multiple clusters in same JVM </li></ul></ul><ul><ul><li>Type safety </li></ul></ul><ul><ul><li>Extractor interface </li></ul></ul><ul><ul><li>Exception Translation </li></ul></ul><ul><ul><li>Support method chaining </li></ul></ul><ul><ul><li>Properties on Result (op timers) </li></ul></ul>
    8. 8. v2 Continued: Misc Changes <ul><ul><li>Examples become real  </li></ul></ul><ul><ul><ul><li>were being used as such anyway </li></ul></ul></ul><ul><ul><ul><li>actually had test coverage </li></ul></ul></ul><ul><ul><li>Removal of redundant operations </li></ul></ul><ul><ul><li>Few changes to current &quot;low level&quot; API as possible </li></ul></ul><ul><ul><ul><li>Direct Thrift access supported </li></ul></ul></ul>
    9. 9. Full Example <ul><li>// Create a cluster Cluster c = HFactory. getOrCreateCluster ( &quot;MyCluster&quot; , &quot;cassandra1:9160&quot; ) ; // Choose a keyspace KeyspaceOperator keyspaceOperator = HFactory. createKeyspaceOperator ( &quot;Keyspace1&quot; , c ) ; // create a string extractor StringExtractor se = StringExtractor. get () ; // insert value Mutator m = HFactory. createMutator ( keyspaceOperator ) ; m. insert ( &quot;key1&quot; , &quot;ColumnFamily1&quot; , HFactory.createColumn ( &quot;column1&quot; , &quot;value1&quot; , se, se )) ;   // Now read a value ColumnQuery < String, String > q = HFactory. createColumnQuery ( keyspaceOperator, se, se ) ;   </li></ul><ul><li>// set key, name, cf and execute Result < HColumn < String, String >> r = q. setKey ( &quot;key1&quot; ) .setName ( &quot;column1&quot; ) .setColumnFamily ( &quot;ColumnFamily1&quot; ) .execute () ; // read value from the result HColumn < String, String > c = r. get () ; String value = c. getValue () ; </li></ul><ul><li>// information about result execution </li></ul><ul><li>long executionTime = r.getExecutionTimeMicro(); </li></ul><ul><li>CassandraHost host = r.getHostUsed(); </li></ul>
    10. 10. Full Example Part 1 <ul><li>Cluster c = HFactory. getOrCreateCluster ( &quot;MyCluster&quot; , &quot;cassandra1:9160&quot; ) ;   </li></ul><ul><li>  </li></ul><ul><li>KeyspaceOperator ko = HFactory. createKeyspaceOperator ( &quot;Keyspace1&quot; , c ) ;   </li></ul><ul><li>  </li></ul><ul><li>StringExtractor se = StringExtractor. get () ; </li></ul>
    11. 11. Full Example Part 2 <ul><li>Mutator m = HFactory. createMutator ( keyspaceOperator ) ; </li></ul><ul><li>m. insert ( &quot;key1&quot; ,  </li></ul><ul><li>              &quot;ColumnFamily1&quot; ,  </li></ul><ul><li>              HFactory.createColumn ( &quot;column1&quot; , &quot;value1&quot; , se, se )) ; </li></ul><ul><li>  </li></ul><ul><li>  </li></ul><ul><li>  </li></ul><ul><li>  - OR - </li></ul><ul><li>  </li></ul><ul><li>m.addInsertion ( &quot;key1&quot; ,  </li></ul><ul><li>                         &quot;ColumnFamily1&quot; ,  </li></ul><ul><li>                         HFactory.createColumn ( &quot;column1&quot; , &quot;value1&quot; , se, se )); </li></ul><ul><li>... </li></ul><ul><li>m.execute(); </li></ul><ul><li>  </li></ul>
    12. 12. Full Example Part 3 <ul><li>ColumnQuery < String, String > q =   </li></ul><ul><li>    HFactory. createColumnQuery ( keyspaceOperator, se, se ) ;   </li></ul><ul><li>  </li></ul><ul><li>Result < HColumn < String, String >> r = q. setKey ( &quot;key1&quot; ) .setName ( &quot;column1&quot; ) .setColumnFamily ( &quot;ColumnFamily1&quot; ) .execute () ; </li></ul>
    13. 13. Full Example Part 4 <ul><li>HColumn < String, String > c = r. get () ;   </li></ul><ul><li>String value = c. getValue () ; </li></ul><ul><li>long executionTime = r.getExecutionTimeMicro(); </li></ul><ul><li>  </li></ul><ul><li>CassandraHost host = r.getHostUsed(); </li></ul>
    14. 14. Simple Example (IoC Required) <ul><li>simpleCassandraDao. insert ( &quot;key1&quot; , &quot;column1&quot; , &quot;value1&quot; ) ;   </li></ul><ul><li>String value = simpleCassandraDao. get ( &quot;key1&quot; , &quot;column1&quot; ) ; </li></ul><ul><li>  </li></ul><ul><li>     <bean id=&quot;cassandraHostConfigurator&quot; class=&quot;me.prettyprint.cassandra.service.CassandraHostConfigurator&quot;> </li></ul><ul><li>        <constructor-arg value=&quot;localhost:9170&quot;/>     </bean>     <bean id=&quot;cluster&quot; class=&quot;me.prettyprint.cassandra.service.Cluster&quot;>         <constructor-arg value=&quot;TestCluster&quot;/>         <constructor-arg ref=&quot;cassandraHostConfigurator&quot;/>     </bean>         <bean id=&quot;keyspaceOperator&quot; class=&quot;me.prettyprint.cassandra.model.HFactory&quot; factory-method=&quot;createKeyspaceOperator&quot;>         <constructor-arg value=&quot;Keyspace1&quot;/>         <constructor-arg ref=&quot;cluster&quot;/>     </bean>     <bean id=&quot;simpleCassandraDao&quot; class=&quot;me.prettyprint.cassandra.dao.SimpleCassandraDao&quot;>         <property name=&quot;keyspaceOperator&quot; ref=&quot;keyspaceOperator&quot;/>         <property name=&quot;keyspaceName&quot; value=&quot;Keyspace1&quot;/>         <property name=&quot;columnFamilyName&quot; value=&quot;Standard1&quot;/>     </bean> </li></ul><ul><li>  </li></ul>
    15. 15. Immediate(ish) Future <ul><ul><li>  More refactoring on internals </li></ul></ul><ul><ul><ul><li>unwind constructor complexity </li></ul></ul></ul><ul><ul><li>  v0.7 support  </li></ul></ul><ul><ul><ul><li>key changes  </li></ul></ul></ul><ul><ul><ul><li>authentication </li></ul></ul></ul><ul><ul><ul><li>new methods: column indexes, multi-get count </li></ul></ul></ul><ul><ul><li>Avro support(?) </li></ul></ul><ul><ul><li>Threshold-triggered per-thread monitoring (all the pieces in place) </li></ul></ul><ul><ul><li>Back-off and retry for host pools marked dead </li></ul></ul><ul><ul><li>Configuarble client mediated selects </li></ul></ul><ul><ul><li>JPA Annotations </li></ul></ul><ul><ul><li>Load balancing </li></ul></ul>
    16. 16. Feedback Please <ul><li>[email_address] </li></ul><ul><li>[email_address] </li></ul><ul><li>http://github.com/rantav/hector </li></ul>
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×