Cli deep dive

1,607 views
1,520 views

Published on

How the consistencylevel keyword was added to the cassandra CLI.

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

  • Be the first to like this

No Downloads
Views
Total views
1,607
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cli deep dive

  1. 1. Hacking @ Cassandra CLI Edward Capriolo
  2. 2. Cassandra has multiple consistency levels <ul><li>ANY - Write to any node
  3. 3. ONE - Return as soon as one replica ACK
  4. 4. QUORUM – Most of the nodes ACK
  5. 5. ALL – All replicas must as knowledge
  6. 6. LOCAL_QUORUM - quorum of noes in DC
  7. 7. EACH_QUORUM - quorum of nodes in each DC
  8. 8. TWO – Two nodes – (multi-dc)
  9. 9. THREE – three nodes – (multi-dc) </li></ul>
  10. 10. The Cassandra CLI <ul><li>Always wrote at ONE
  11. 11. Always read at ONE
  12. 12. DOH!! Makes it very hard to test these cool features!
  13. 13. Works using ANTLR
  14. 14. ANTLR used for many domain specific languages HIVE cli, CASSANDRA cli, etc </li></ul>
  15. 15. What we want to Add <ul>[default@football] use football; Authenticated to keyspace: football [d efault@football] set consistencylevel as LOCAL_QUORUM; [default@football] set teams['giants']['qb']='eli manning'; </ul>
  16. 16. Open A ticket
  17. 17. Add a token to the grammer <ul><li>Tokens { ...
  18. 18. NODE_LIST;
  19. 19. NODE_TRUNCATE;
  20. 20. NODE_ASSUME;
  21. 21. + NODE_CONSISTENCY_LEVEL;
  22. 22. Later on in file:
  23. 23. +CONSISTENCYLEVEL: 'CONSISTENCYLEVEL'; </li></ul>
  24. 24. Add a statement to the grammar <ul>statement | listStatement | truncateStatement | assumeStatement + | consistencyLevelStatement | -> ^(NODE_NO_OP) </ul>
  25. 25. How about help? <ul>HelpStatement -> ^(NODE_HELP NODE_TRUNCATE) | HELP ASSUME -> ^(NODE_HELP NODE_ASSUME) + | HELP CONSISTENCYLEVEL + -> ^(NODE_HELP NODE_CONSISTENCY_LEVEL) </ul>
  26. 26. What is grammatically correct for a consistency level statement <ul>+consistencyLevelStatement + : CONSISTENCYLEVEL 'AS' defaultType=Identifier + -> ^(NODE_CONSISTENCY_LEVEL $defaultType) + ; + </ul>
  27. 27. Inside the CliClient.java <ul>Got to change these HARD coded values! int count = thriftClient.get_count(ByteBuffer.wrap(key.getBytes(Charsets.UTF_8)), colParent, predicate, ConsistencyLevel.ONE); private ConsistencyLevel = ConsistencyLevel.ONE </ul>
  28. 28. Add new statement in the case <ul>public void executeCLIStatement(String statement) { Tree tree = CliCompiler.compileQuery(statement); try { switch (tree.getType()) { case CliParser.NODE_EXIT: cleanupAndExit(); break; break; + case CliParser.NODE_CONSISTENCY_LEVEL: + executeConsistencyLevelStatement(tree); + break; </ul>
  29. 29. How does this statement work?
  30. 30. Why Casandra Rocks hard <ul><li>Patch went +1 in < 24 hours
  31. 31. Patch was committed to 0.7.5 < 2 days
  32. 32. Everyone wins! </li></ul>

×