Class HectorCassandraClient

java.lang.Object
org.openspaces.persistency.cassandra.HectorCassandraClient

public class HectorCassandraClient extends Object
A wrapper around the Cassandra Hector client library.
Since:
9.1.1
Author:
Dan Kilman
  • Constructor Details

  • Method Details

    • close

      public void close()
      Closes hector's connection pool.
    • createMetadataColumnFamilyColumnFamilyIfNecessary

      public void createMetadataColumnFamilyColumnFamilyIfNecessary()
    • performBatchOperation

      public void performBatchOperation(List<ColumnFamilyRow> rows)
      Writes the given ColumnFamilyRow's in a mutate operation to the configured keyspace.
      Parameters:
      rows - The ColumnFamilyRow's to perform the mutate operation on. Contract: It is assumed that all the rows in the passed list argument belong to the same column family. Failure to comply with contract will most likely lead to some data corruption.
    • createColumnFamilyIfNecessary

      public void createColumnFamilyIfNecessary(ColumnFamilyMetadata metadata, boolean shouldPersist)
      Creates a column family on the configured keyspace if one does not already exist.
      Parameters:
      metadata - The metadata describing the column family to create.
      shouldPersist - Should the ColumnFamilyMetadata instance be persisted to the internal metadata column family.
    • addIndexesToColumnFamily

      public void addIndexesToColumnFamily(String typeName, List<String> columnNames, SpaceDocumentColumnFamilyMapper mapper)
      Adds a secondary index to the provided columns in the column family matching the provided typeName. Creates the column if it does not already exist.
      Parameters:
      typeName - The type name describing the matchin column family.
      columnNames - the columns to which secondary indexes should be added.
    • fetchColumnFamilyMetadata

      public ColumnFamilyMetadata fetchColumnFamilyMetadata(String typeName, SpaceDocumentColumnFamilyMapper mapper)
      Tries to read from the internal metadata column family, the ColumnFamilyMetadata metadata matching the given type name. If found, this metadata is stored in cache and can later be acquired by calling getColumnFamilyMetadata(String)
      Parameters:
      typeName - The typeName describing the matching column family.
      Returns:
      The ColumnFamilyMetadata instance if found, null otherwise.
    • populateColumnFamiliesMetadata

      public Map<String,ColumnFamilyMetadata> populateColumnFamiliesMetadata(SpaceDocumentColumnFamilyMapper mapper)
      Reads all the column families metadata for the internal metadata column family into cache.
      Returns:
      A Map from type name to its matching ColumnFamilyMetadata. Of all the currently known column families.
    • readDocumentByKey

      public SpaceDocument readDocumentByKey(SpaceDocumentColumnFamilyMapper mapper, String typeName, Object keyValue)
      Reads the entry matching the typeName and key value from the matching column family.
      Parameters:
      typeName - The typeName describing the matching column family.
      keyValue - The key of the requested entry.
      Returns:
      The SpaceDocument matching the key if found, null otherwise.
    • readDocumentsByKeys

      public Map<Object,SpaceDocument> readDocumentsByKeys(SpaceDocumentColumnFamilyMapper mapper, String typeName, Object[] keyValues)
      Reads the entries matching the typeName and key values from the matching column family.
      Parameters:
      typeName - The typeName describing the matching column family.
      keyValues - The keys of the requested entry.
      Returns:
      A map from key to SpaceDocument, including found entries.
    • getColumnFamilyMetadata

      public ColumnFamilyMetadata getColumnFamilyMetadata(String typeName)
      Reads from cache the ColumnFamilyMetadata instance matching the provided typeName
      Parameters:
      typeName - The typeName describing the matching column family.
      Returns:
      The ColumnFamilyMetadata instance if found, null otherwise.
    • getColumnFamiliesMetadata

      public Map<String,ColumnFamilyMetadata> getColumnFamiliesMetadata()
      Returns:
      All currently available in cache column families metadata.
    • getReadConsistencyLevel

      public CassandraConsistencyLevel getReadConsistencyLevel()
      Returns:
      the readConsistencyLevel
    • getWriteConsistencyLevel

      public CassandraConsistencyLevel getWriteConsistencyLevel()
      Returns:
      the writeConsistencyLevel