Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

TDC2016SP - Trilha NoSQL


Published on

Cassandra - Do inferno ao Céu

Published in: Education
  • Be the first to comment

  • Be the first to like this

TDC2016SP - Trilha NoSQL

  1. 1. NOSQL Setup for Java Developers Bruno Tinoco 08.07.2016
  2. 2. AGENDA 1. Introduction 2. Setup 3. Hands-on experience 4. References
  3. 3. GFT Group 03.09.2015 3 Who I am and What I do INTRODUCTION GFT Group is a business change and technology consultancy trusted by the world’s leading financial services institutions bringing together advisory, creative and technology capabilities with innovation culture and specialist knowledge of the finance sector. Bruno Tinoco  Father and Java Developer with more than 15 years of software development experience using the JavaEE platform for different companies from Financial to Travel and Distribution industries.  Currently working as a Software Engineer at GFT Group for DeustcheBank projects. Previously I worked as IT Architect at IBM GBS projects.  Follow us  
  4. 4. GFT Group 03.09.2015 4 What is the thing about Cassandra INTRODUCTION  Distributed Database (CAP)  Fault tolerant cluster  Nominated master  Native JSON  Distributed hash table (Partition Keys)  Replication factor  Tunable consistency (ONE,QUORUM, ALL) SchemaKeyspace Column Family Table ~Row Key (Partition key Clustering column) Primary key  No JOINS  No Foreign keys  No rollback/locking  Eventual/Tunable Consistence SQLCQL
  5. 5. GFT Group 03.09.2015 5 Downloading, Installing, Configuring & Running SETUP (Current latest version 3.7) apache-cassandra-3.7-bin.tar.gz (34MB) cassandra.yaml ./bin/cassandra data logs export JAVA_HOME export MAX_HEAP_SIZE=“1024M” export HEAP_NEWSIZE=“400M” Cassandra = v2.2 – Java 7 Cassandra > v3.0 – Java 8
  6. 6. GFT Group 03.09.2015 6 Setup your project HANDS-ON EXPERIENCE Define your persistence model Kundera Cassandra Driver <dependency> <groupId> com.impetus.kundera.client </groupId> <artifactId> kundera-cassandra </ artifactId > <version> 3.4 </version> </dependency> Native Queries (CQL)JPA DataStax Driver * <dependency> <groupId> com.datastax.cassandra</groupId> <artifactId> cassandra-driver-core </ artifactId > <version> 3.0.0 </version> </dependency> * Also supports object mapping through cassandra-driver-mapping You can starting mapping your entity classes using standard JPA annotations… You must to learn the driver API and create the schema yourself first X Others Hector Pelops Astyanax
  7. 7. GFT Group 03.09.2015 7 Setup your tools HANDS-ON EXPERIENCE  CQLSH  DataStax DevCenter  DataStax OpsCenter (Monitoring)
  8. 8. GFT Group 03.09.2015 8 How about data modelling HANDS-ON EXPERIENCE  Think about sorted Maps  Data Types (List, Json)  N-to-N Relationships SortedMap<RowKey, SortedMap<ColumnKey, ColumnValue>
  9. 9. GFT Group 03.09.2015 9 Keep in mind HANDS-ON EXPERIENCE  First your Use Case (UI needs)  Do not try to normalize data (Hardest part)  Define carefully your partition key (Performance)
  10. 10. GFT Group 03.09.2015 10 More Information... REFERENCES Cassandra Community (Forum, Tutorials) Apache Cassandra Home (Download) Netflix Cassandra benchmark DataStax Documentation (Tutorials, Guide, Sample code)
  11. 11. Thank you Senior Software Engineer GFT Brasil
  12. 12. GFT Group 03.09.2015 12 CREATING OBJECTS  Keyspace  CREATE KEYSPACE demo WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '1' };  Table  CREATE TABLE users ( firstname text, lastname text, age int, email text, city text, PRIMARY KEY (lastname));  Queries  SELECT… / INSERT…  Indexes  CREATE INDEX…  Structure  DESC… BASIC COMMANDS
  13. 13. GFT Group 03.09.2015 13 CQLSH  Interactive mode (shell)  $CASSANDRA_HOME/bin/cqlsh localhost –u user –p user123  clqsh>  Execute mode  $CASSANDRA_HOME/bin/cqlsh localhost –u user –p user123 –e “SELECT * from demo.users”  File mode  $CASSANDRA_HOME/bin/cqlsh localhost –u user –p user123 –f my_cql_commands.cql TOOLS Python script that comes with the default Cassandra a installation
  14. 14. GFT Group 03.09.2015 14 DataStax DevCenter  Free tool GUI for connect on Cassandra clusters TOOLS
  15. 15. GFT Group 03.09.2015 15 DataStax Driver  Support both Binary (CQL) and Thrift Protocols  Connection Pool  Supports Annotation (Tables/Indexes/Types)  Supports Native Cassandra concepts JAVA DRIVERS
  16. 16. GFT Group 03.09.2015 16 Kundera Driver  JPA Compliant  Annotation based  Auto schema creation  Connection Pool  Support other NoSQL databases (ie. Mongo) JAVA DRIVERS
  17. 17. GFT Group 03.09.2015 17 Other Drivers  Hector The most stable of the Java APIs, ready for prime-time.  Astyanax A clean Java API from Netflix. It isn't as widely used as Hector, but it is solid.  Pelops  PlayORM (ORM without the constraints?) It looks like it is trying to solve the impedance mismatch between traditional JPA-based ORMs and NoSQL by introducing JQL. It looks promising. Decision Considerations  Low latency overhead, Asynch API, and reliability/stability for production environment. (e.g. a more user-friendly APIs that can be had in the DAL that wraps the client).  Connection pooling and partition awareness are some other good feature to have.  Able to detect any new nodes that got added.  Good Support as well (as pointed by dean below) JAVA DRIVERS