Giter VIP home page Giter VIP logo

dropwizard-cassandra's Introduction

dropwizard-cassandra

Build Quality Gate Status Maven Central

Provides easy integration for Dropwizard applications with the Datastax Cassandra java driver..

This bundle comes with out-of-the-box support for:

  • YAML-based configuration and built-in strongly typed configuration validation
  • Cluster connection lifecycle management
  • Cluster health checks
  • Metrics integration for Cassandra driver stats using your applications MetricRegistry

Future improvements

  • Schema migrations functionality, similar to what flyway and liquibase offer for SQL databases.

Dropwizard Version Support Matrix

dropwizard-cassandra Dropwizard v1.3.x Dropwizard v2.0.x
v1.3.x
v1.4.x
v2.0.x

Usage

Add dependency on library.

Maven:

<dependency>
  <groupId>io.dropwizard.modules</groupId>
  <artifactId>dropwizard-cassandra</artifactId>
  <version>2.0.0</version>
</dependency>

Gradle:

compile "io.dropwizard.modules:dropwizard-cassandra:2.0.0"

Usage

Minimal
cassandra:
  type: basic
  contactPoints:
    - host: localhost
      port: 9041
  loadBalancingPolicy:
    type: default
    localDataCenter: DC1

Comprehensive

cassandra:
  type: basic
  sessionName: name
  sessionKeyspaceName: keyspace
  requestOptionsFactory:
    requestTimeout:5s
    requestConsistency: local
    requestPageSize: 12
    requestSerialConsistency: local
    requestDefaultIdempotence: true
  metricsEnabled: true
  protocolVersion: DEFAULT
  ssl:
    type: default
    cipherSuites: ["a", "b"]
    hostValidation: true
    keyStorePassword: keyStorePassword
    keyStorePath: keyStorePath
    trustStorePassword: trustStorePassword
    trustStorePath: trustStorePath
  compression: lz4
  contactPoints:
    - host: localhost
      port: 9041
  authProvider:
    type: plain-text
    username: admin
    password: hunter2
  retryPolicy:
    type: default
  speculativeExecutionPolicy:
    type: constant
    delay: 1s
    maxSpeculativeExecutions: 3
  poolingOptions:
    maxRequestsPerConnection: 5
    maxRemoteConnections: 10
    maxLocalConnections: 20
    heartbeatInterval: 5s
    connectionConnectTimeout: 10s
  addressTranslator:
    type: ec2-multi-region
  timestampGenerator:
    type: atomic
  reconnectionPolicyFactory:
    type: exponential
    baseConnectionDelay: 10s
    maxReconnectionDelay: 30s
  loadBalancingPolicy:
    type: default
    localDataCenter: local
    dataCenterFailoverAllowLocalConsistencyLevels: true
    slowAvoidance: true
    dcFailoverMaxNodesPerRemoteDc: 2
  cassandraOptions: # to add options which are not supported by default. Full list can be found at https://docs.datastax.com/en/developer/java-driver/4.11/manual/core/
    - type: long
      name: advanced.protocol.max-frame-length
      value: 12
  sessionMetrics:
    - continuous-cql-requests
  nodeMetrics:
    - bytes-sent

Note on Multi-Environment Configuration

If you have different contact points per deployment environment your application runs in, it may be easier to avoid having to define multiple YAML files per environment by inserting a placeholder in your YAML file that you then override in each environment (via whatever means you normally override config values, whether that's properties, environment variables, or whatever else), and then override that placeholder with a single entry JSON string defining all contact points, to avoid having to deal with YAML lists.

contactPoints: [${commaSeparatedContactPoints}]

commaSeparatedContactPoints = {"host": "host1", "port": "9142"}, {"host": "host2", "port": "9142"}

Acknowledgements

This library was originally built to extend https://github.com/composable-systems/dropwizard-cassandra, but was forked due to some needs that were unmet (for instance, being able to define different CassandraFactory implementations, if a modified client is used), and due to lack of maintenance. Big thanks to @stuartgunter for his module, which inspired this one heavily, and for which this module borrows a lot of ideas and code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.