Class CassandraUtils

java.lang.Object
org.eso.ias.sink.ltdb.CassandraUtils

public class CassandraUtils extends Object
An helper to send commands to cassandra
Author:
acaproni
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    A flag set if the object has been closed
    boolean
    A flag set if the conenction with Cassandra has been correctly established
  • Constructor Summary

    Constructors
    Constructor
    Description
    CassandraUtils(String contactPoints)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    com.datastax.driver.core.ResultSet
    Execute the passed statement
    void
    start(Optional<String> keyspaceOpt)
    Establish the conenction witht the database and, optionall, use the passed keyspace
    void
    Close the connection with cassandra

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • initialized

      public volatile boolean initialized
      A flag set if the conenction with Cassandra has been correctly established
    • closed

      public volatile boolean closed
      A flag set if the object has been closed
  • Constructor Details

    • CassandraUtils

      public CassandraUtils(String contactPoints)
      Constructor
      Parameters:
      contactPoints - the contact points to connect to cassandra DB
  • Method Details

    • start

      public void start(Optional<String> keyspaceOpt) throws Exception
      Establish the conenction witht the database and, optionall, use the passed keyspace
      Parameters:
      keyspaceOpt - The key space
      Throws:
      Exception - in case of error connecting to the cassandra DB
    • stop

      public void stop() throws Exception
      Close the connection with cassandra
      Throws:
      Exception
    • executeStatement

      public com.datastax.driver.core.ResultSet executeStatement(String statement)
      Execute the passed statement
      Parameters:
      statement - The not null nor empty statement to execute
      Returns:
      the result set or null if the connection has been closed