Class HectorCassandraClient
java.lang.Object
org.openspaces.persistency.cassandra.HectorCassandraClient
A wrapper around the Cassandra Hector client library.
- Since:
- 9.1.1
- Author:
- Dan Kilman
-
Constructor Summary
ConstructorsConstructorDescriptionHectorCassandraClient(me.prettyprint.cassandra.service.CassandraHostConfigurator config, String keyspaceName, String clusterName, Integer columnFamilyGcGraceSeconds, CassandraConsistencyLevel readConsistencyLevel, CassandraConsistencyLevel writeConsistencyLevel) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIndexesToColumnFamily(String typeName, List<String> columnNames, SpaceDocumentColumnFamilyMapper mapper) Adds a secondary index to the provided columns in the column family matching the provided typeName.voidclose()Closes hector's connection pool.voidcreateColumnFamilyIfNecessary(ColumnFamilyMetadata metadata, boolean shouldPersist) Creates a column family on the configured keyspace if one does not already exist.voidfetchColumnFamilyMetadata(String typeName, SpaceDocumentColumnFamilyMapper mapper) Tries to read from the internal metadata column family, theColumnFamilyMetadatametadata matching the given type name.getColumnFamilyMetadata(String typeName) Reads from cache theColumnFamilyMetadatainstance matching the provided typeNamevoidWrites the givenColumnFamilyRow's in a mutate operation to the configured keyspace.Reads all the column families metadata for the internal metadata column family into cache.readDocumentByKey(SpaceDocumentColumnFamilyMapper mapper, String typeName, Object keyValue) Reads the entry matching the typeName and key value from the matching column family.readDocumentsByKeys(SpaceDocumentColumnFamilyMapper mapper, String typeName, Object[] keyValues) Reads the entries matching the typeName and key values from the matching column family.
-
Constructor Details
-
HectorCassandraClient
public HectorCassandraClient(me.prettyprint.cassandra.service.CassandraHostConfigurator config, String keyspaceName, String clusterName, Integer columnFamilyGcGraceSeconds, CassandraConsistencyLevel readConsistencyLevel, CassandraConsistencyLevel writeConsistencyLevel) - See Also:
-
-
Method Details
-
close
public void close()Closes hector's connection pool. -
createMetadataColumnFamilyColumnFamilyIfNecessary
public void createMetadataColumnFamilyColumnFamilyIfNecessary() -
performBatchOperation
Writes the givenColumnFamilyRow's in a mutate operation to the configured keyspace.- Parameters:
rows- TheColumnFamilyRow'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
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 theColumnFamilyMetadatainstance 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, theColumnFamilyMetadatametadata matching the given type name. If found, this metadata is stored in cache and can later be acquired by callinggetColumnFamilyMetadata(String)- Parameters:
typeName- The typeName describing the matching column family.- Returns:
- The
ColumnFamilyMetadatainstance 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
Mapfrom type name to its matchingColumnFamilyMetadata. 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
Reads from cache theColumnFamilyMetadatainstance matching the provided typeName- Parameters:
typeName- The typeName describing the matching column family.- Returns:
- The
ColumnFamilyMetadatainstance if found, null otherwise.
-
getColumnFamiliesMetadata
- Returns:
- All currently available in cache column families metadata.
-
getReadConsistencyLevel
- Returns:
- the readConsistencyLevel
-
getWriteConsistencyLevel
- Returns:
- the writeConsistencyLevel
-