GigaSpaces XAP 10.0.1 API

org.openspaces.persistency.cassandra
Class HectorCassandraClient

java.lang.Object
  extended by 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 Summary
HectorCassandraClient(CassandraHostConfigurator config, String keyspaceName, String clusterName, Integer columnFamilyGcGraceSeconds, CassandraConsistencyLevel readConsistencyLevel, CassandraConsistencyLevel writeConsistencyLevel)
           
 
Method Summary
 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.
 void close()
          Closes hector's connection pool.
 void createColumnFamilyIfNecessary(ColumnFamilyMetadata metadata, boolean shouldPersist)
          Creates a column family on the configured keyspace if one does not already exist.
 void createMetadataColumnFamilyColumnFamilyIfNecessary()
           
 ColumnFamilyMetadata fetchColumnFamilyMetadata(String typeName, SpaceDocumentColumnFamilyMapper mapper)
          Tries to read from the internal metadata column family, the ColumnFamilyMetadata metadata matching the given type name.
 Map<String,ColumnFamilyMetadata> getColumnFamiliesMetadata()
           
 ColumnFamilyMetadata getColumnFamilyMetadata(String typeName)
          Reads from cache the ColumnFamilyMetadata instance matching the provided typeName
 CassandraConsistencyLevel getReadConsistencyLevel()
           
 CassandraConsistencyLevel getWriteConsistencyLevel()
           
 void performBatchOperation(List<ColumnFamilyRow> rows)
          Writes the given ColumnFamilyRow's in a mutate operation to the configured keyspace.
 Map<String,ColumnFamilyMetadata> populateColumnFamiliesMetadata(SpaceDocumentColumnFamilyMapper mapper)
          Reads all the column families metadata for the internal metadata column family into cache.
 SpaceDocument readDocmentByKey(SpaceDocumentColumnFamilyMapper mapper, String typeName, Object keyValue)
          Reads the entry matching the typeName and key value from the matching column family.
 Map<Object,SpaceDocument> readDocumentsByKeys(SpaceDocumentColumnFamilyMapper mapper, String typeName, Object[] keyValues)
          Reads the entries matching the typeName and key values from the matching column family.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HectorCassandraClient

public HectorCassandraClient(CassandraHostConfigurator config,
                             String keyspaceName,
                             String clusterName,
                             Integer columnFamilyGcGraceSeconds,
                             CassandraConsistencyLevel readConsistencyLevel,
                             CassandraConsistencyLevel writeConsistencyLevel)
See Also:
HectorCassandraClientConfigurer.create()
Method Detail

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.
mapper -

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 aquired by calling getColumnFamilyMetadata(String)

Parameters:
typeName - The typeName describing the matching column family.
mapper -
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.

Parameters:
mapper -
Returns:
A Map from type name to its matching ColumnFamilyMetadata. Of all the currently known column families.

readDocmentByKey

public SpaceDocument readDocmentByKey(SpaceDocumentColumnFamilyMapper mapper,
                                      String typeName,
                                      Object keyValue)
Reads the entry matching the typeName and key value from the matching column family.

Parameters:
mapper -
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:
mapper -
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

GigaSpaces XAP 10.0.1 API

Copyright © GigaSpaces.