datastax java driver walkthrough

Post on 17-Feb-2017

695 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

DataStax Java Driver Walkthrough

DataStax Java Driver Walkthrough

At

New Delhi Cassandra Users Meetup – November 2014

By: Narinder Kumar

1. Driver Options with different languages2. DataStax Java Driver Highlights3. Key Features

a. Asynchronous I/Ob. Automatic Failoverc. Batch Statementsd. CQL – Java Data Types conversion

4. Code Demosa. Hello World Clientb. Loading & Querying Data in

Cassandrac. PreparedStatement & QueryBuilder

5. Debugging & Testing6. Key Points to keep in mind

Agenda

• DataStax maintained language drivers are available in– C#– Java– Node.js– Python– Ruby– Go

• Other open source implementations also available

Driver Options with different languages

• Current version 2.1.2

• What’s new

– Parameterized Statements

– Batching prepared Statements

– Automatic Result Set Pagination

– Lightweight Transactions

– Latency Aware Policies

– Fewer Dependencies

– Improved Testability

DataStax Java Driver – Highlights

• session.execute(Query) ➔ session.executeAsync(Query)

• Returns ResultSet ➔ ResultSetFuture

• ResultSetFuture

– Implements java.util.concurrent.Future<V> interface

Asynchronous I/O

• In case of one / multiple Node failure, Java driver automatically– Tries other nodes– Schedules reconnections

• Driver behavior is determined by cluster configuration optionsCluster.builder().addContactPoints(192.168.1.1, 192.168.1.5,…).withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE).withReconnectionPolicy(new

ConstantReconnectionPoloicy(100L)).build();

Automatic Failover

• Allows execution of multiple statements in one group

• Works for Simple as well as PreparedStatements

• Can apply timestamp for later queries

• May be used to form mini transaction

Batch Statements

CQL Java

ascii Stringbigint longblob Java.nio.ByteBuffer

counter Longdecimal java.math.BigDecimal

CQL to Java

Code Demos

Refer Github repo : https://github.com/narinder-kumar/cassandrasample

• Debugging– Enable Tracing on server side

• QueryBuilder….enableTracing()• ResultSet.getExecutionInfo()

– Adjust log4j configuration settings– JMX Monitoring

• connectedToHosts(), errorMetrics(), openConnections()

• Testing– In latest release, lot of classes have been implementing

Interfaces. Helps using Mocking frameworks during unit testing

Debugging & Testing

• One cluster instance per cluster per application life-time– Easy Configurability

• One session instance per keyspace– Expensive object, better shared

• If executing one statement multiple times, considerPreparedStatement– Faster execution

• Consider Batch Operations

Key points while coding with Driver

Contact us

Have more queries related to AngularJS?

Talk To Our Experts!

Our Office

Client Location

Click Here To Know More!

Here’s how TOTHENEW helps your customers outsource across the globe using BIG DATA!

top related