• Like
Hector v2: The Second Version of the Popular High-Level Java Client for Apache Cassandra
Upcoming SlideShare
Loading in...5
×

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

  • 5,711 views
Uploaded 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 …

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.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,711
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
104
Comments
0
Likes
8

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    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

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