Your SlideShare is downloading. ×
0
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Workshop desarrollo Cassandra con el driver Java
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Workshop desarrollo Cassandra con el driver Java

162

Published on

Workshop desarrollo Cassandra con el driver Java

Workshop desarrollo Cassandra con el driver Java

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
162
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
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

Transcript

  • 1. Workshop desarrollo Cassandra Java José Hernández Isthari jose.Hernandez@isthari.com
  • 2. Dependencias  Maven <dependency> <groupId>com.datastax.cassandra</groupId> <artifactId>cassandra-driver-core</artifactId> <version>2.0.1</version> </dependency>
  • 3. Cluster de cassandra
  • 4. Conexión  Cluster Cluster cluster = Cluster.builder() .addContactPoint(“10.202.203.105") .addContactPoint(“10.202.203.106") .build();
  • 5. Conexión  Cluster Cluster cluster = Cluster.builder() .addContactPoint(“10.202.203.105") .addContactPoint(“10.202.203.106") .build();  Auto – discover New Cassandra host /10.202.203.108 New Cassandra host /10.202.203.109 New Cassandra host /10.202.203.111 …
  • 6. Desconexión  Cluster Cluster cluster = Cluster.builder() .addContactPoint(“10.202.203.105") .addContactPoint(“10.202.203.106") .build();  Desconectar Cluster.close();
  • 7. Statements  Conectar a un keyspace Session session = cluster.connect("webinar");
  • 8. Statements  Conectar a un keyspace Session session = cluster.connect("webinar");  DDL session.execute("create table usuarios ( id uuid , nombre text, primary key (id)) ");
  • 9. Statements  Conectar a un keyspace Session session = cluster.connect("webinar");  DDL session.execute("create table usuarios ( id uuid , nombre text, primary key (id)) ");  DML session.execute("insert into usuarios (id, nombre) values (18c8dfee-…, 'Juan')");
  • 10. Query ResultSet resultSet = session.execute("select * from usuarios");
  • 11. Query ResultSet resultSet = session.execute("select * from usuarios"); for (Row row : resultSet){ … }
  • 12. Query ResultSet resultSet = session.execute("select * from usuarios"); for (Row row : resultSet){ LOGGER.info(row.getUUID("id")+" - "+ row.getString("nombre")); }
  • 13. Bound statement PreparedStatement stmt = session.prepare( "insert into usuarios (id, nombre) values (?,?)");
  • 14. Bound statement PreparedStatement stmt = session.prepare( "insert into usuarios (id, nombre) values (?,?)"); session.execute( stmt.bind(UUID.randomUUID(), "Jose"));
  • 15. Async queries
  • 16. Async queries
  • 17. Async queries ResultSetFuture resultSet1 = session.executeAsync("select … ResultSetFuture resultSet2 = session.executeAsync("select … ResultSetFuture resultSet3 = session.executeAsync("select …
  • 18. Async queries ResultSetFuture resultSet1 = session.executeAsync("select … ResultSetFuture resultSet2 = session.executeAsync("select … ResultSetFuture resultSet3 = session.executeAsync("select … for (Row row : resultSet1.getUninterruptibly()){ ... }
  • 19. Async queries ResultSetFuture resultSet1 = session.executeAsync("select … ResultSetFuture resultSet2 = session.executeAsync("select … ResultSetFuture resultSet3 = session.executeAsync("select … for (Row row : resultSet1.getUninterruptibly()){ ... } for (Row row : resultSet2 .getUninterruptibly(1000, TimeUnit.MILLISECONDS)){ ... }
  • 20. Query builder Statement stmt1 = QueryBuilder .select()
  • 21. Query builder Statement stmt1 = QueryBuilder .select() .from("usuarios")
  • 22. Query builder Statement stmt1 = QueryBuilder .select() .from("usuarios") .where(eq("id", UUID.fromString("0bd4f5c9…")));
  • 23. Query builder Statement stmt1 = QueryBuilder .select() .from("usuarios") .where(eq("id", UUID.fromString("0bd4f5c9…"))); session.execute(stmt1);
  • 24. Query builder Statement stmt = QueryBuilder.insertInto(“usuarios")
  • 25. Query builder Statement stmt = QueryBuilder.insertInto(“usuarios") .value("id", UUID.randomUUID()) .value(“nombre", “Felipe")
  • 26. Query builder Statement stmt = QueryBuilder.insertInto(“usuarios") .value("id", UUID.randomUUID()) .value(“nombre", “Felipe") .setConsistencyLevel(ConsistencyLevel.ANY)
  • 27. Query builder Statement stmt = QueryBuilder.insertInto(“usuarios") .value("id", UUID.randomUUID()) .value(“nombre", “Felipe") .setConsistencyLevel(ConsistencyLevel.ANY); session.execute(stmt);
  • 28. Tracing stmt.enableTracing(); ExecutionInfo info = session.execute(stmt).getExecutionInfo(); QueryTrace trace = info.getQueryTrace ();
  • 29. Load balancing policy  RoundRobinPolicy  DCAwareRoundRobinPolicy  TokenAware
  • 30. Load balancing policy  RoundRobinPolicy  DCAwareRoundRobinPolicy  TokenAware Ejemplo: DCAwareRoundRobinPolicy Cluster cluster = Cluster.builder() … .withLoadBalancingPolicy( new DCAwareRoundRobinPolicy("localDC"))
  • 31. Preguntas y sugerencias Gracias por asistir

×