com.netflix.astyanax
Interface Keyspace

All Known Implementing Classes:
TestKeyspace

public interface Keyspace

Interface providing access to mutate and query columns from a cassandra keyspace.


Method Summary
<K,C> com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult>
createColumnFamily(ColumnFamily<K,C> columnFamily, java.util.Map<java.lang.String,java.lang.Object> options)
          Create a column family in this keyspace
<K,C> com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult>
createColumnFamily(java.util.Map<java.lang.String,java.lang.Object> options)
          Create a column family from the provied options
 com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> createKeyspace(java.util.Map<java.lang.String,java.lang.Object> options)
          Create the keyspace in cassandra.
 com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> createKeyspace(java.util.Map<java.lang.String,java.lang.Object> options, java.util.Map<ColumnFamily,java.util.Map<java.lang.String,java.lang.Object>> cfs)
          Bulk create for a keyspace and a bunch of column famlies
 com.netflix.astyanax.ddl.KeyspaceDefinition describeKeyspace()
          Return a complete description of the keyspace and its column families
 java.lang.String describePartitioner()
          Describe the partitioner used by the cluster
 java.util.List<com.netflix.astyanax.connectionpool.TokenRange> describeRing()
          Get a list of all tokens and their endpoints.
 java.util.List<com.netflix.astyanax.connectionpool.TokenRange> describeRing(boolean cached)
          Describe the ring but use the last locally cached version if available.
 java.util.List<com.netflix.astyanax.connectionpool.TokenRange> describeRing(java.lang.String dc)
          Get a list of all tokens and their endpoints for a specific dc only.
 java.util.List<com.netflix.astyanax.connectionpool.TokenRange> describeRing(java.lang.String dc, java.lang.String rack)
          Get a list of tokens and their endpoints for a specific dc/rack combination.
 java.util.Map<java.lang.String,java.util.List<java.lang.String>> describeSchemaVersions()
          List all schema versions in the cluster.
<K,C> com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult>
dropColumnFamily(ColumnFamily<K,C> columnFamily)
          Drop a column family from this keyspace
 com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> dropColumnFamily(java.lang.String columnFamilyName)
          Drop a column family from this keyspace
 com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> dropKeyspace()
          Drop this keyspace from cassandra
 AstyanaxConfiguration getConfig()
          Return the configuration object used to set up this keyspace
 com.netflix.astyanax.connectionpool.ConnectionPool<?> getConnectionPool()
          Exposes the internal connection pool to the client.
 java.lang.String getKeyspaceName()
          Returns keyspace name
 com.netflix.astyanax.partitioner.Partitioner getPartitioner()
          Return the partitioner for this keyspace.
 SerializerPackage getSerializerPackage(java.lang.String cfName, boolean ignoreErrors)
          Return the serializer package for a specific column family.
<K,C> ColumnMutation
prepareColumnMutation(ColumnFamily<K,C> columnFamily, K rowKey, C column)
          Mutation for a single column
 CqlStatement prepareCqlStatement()
          Prepare a CQL Statement on the keyspace
 MutationBatch prepareMutationBatch()
          Prepare a batch mutation object.
<K,C> ColumnFamilyQuery<K,C>
prepareQuery(ColumnFamily<K,C> cf)
          Starting point for constructing a query.
 com.netflix.astyanax.connectionpool.OperationResult<java.lang.Void> testOperation(com.netflix.astyanax.connectionpool.Operation<?,?> operation)
          This method is used for testing purposes only.
 com.netflix.astyanax.connectionpool.OperationResult<java.lang.Void> testOperation(com.netflix.astyanax.connectionpool.Operation<?,?> operation, com.netflix.astyanax.retry.RetryPolicy retry)
          This method is used for testing purposes only.
<K,C> com.netflix.astyanax.connectionpool.OperationResult<java.lang.Void>
truncateColumnFamily(ColumnFamily<K,C> columnFamily)
          Delete all rows in a column family
 com.netflix.astyanax.connectionpool.OperationResult<java.lang.Void> truncateColumnFamily(java.lang.String columnFamily)
          Delete all rows in a column family
<K,C> com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult>
updateColumnFamily(ColumnFamily<K,C> columnFamily, java.util.Map<java.lang.String,java.lang.Object> options)
          Update the column family in cassandra
 com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> updateKeyspace(java.util.Map<java.lang.String,java.lang.Object> options)
          Update the keyspace in cassandra.
 

Method Detail

getConfig

AstyanaxConfiguration getConfig()
Return the configuration object used to set up this keyspace


getKeyspaceName

java.lang.String getKeyspaceName()
Returns keyspace name


getPartitioner

com.netflix.astyanax.partitioner.Partitioner getPartitioner()
                                                            throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Return the partitioner for this keyspace. The partitioner is mainly used for reading all rows.

Returns:
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describePartitioner

java.lang.String describePartitioner()
                                     throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Describe the partitioner used by the cluster

Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describeRing

java.util.List<com.netflix.astyanax.connectionpool.TokenRange> describeRing()
                                                                            throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Get a list of all tokens and their endpoints. This call will return this list of ALL nodes in the cluster, including other regions. If you are only interested in the subset of nodes for a specific region then use describeRing(dc);

Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describeRing

java.util.List<com.netflix.astyanax.connectionpool.TokenRange> describeRing(java.lang.String dc)
                                                                            throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Get a list of all tokens and their endpoints for a specific dc only.

Parameters:
dc - - null for all dcs
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describeRing

java.util.List<com.netflix.astyanax.connectionpool.TokenRange> describeRing(java.lang.String dc,
                                                                            java.lang.String rack)
                                                                            throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Get a list of tokens and their endpoints for a specific dc/rack combination.

Parameters:
dc -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describeRing

java.util.List<com.netflix.astyanax.connectionpool.TokenRange> describeRing(boolean cached)
                                                                            throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Describe the ring but use the last locally cached version if available.

Parameters:
cached -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describeKeyspace

com.netflix.astyanax.ddl.KeyspaceDefinition describeKeyspace()
                                                             throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Return a complete description of the keyspace and its column families

Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

getSerializerPackage

SerializerPackage getSerializerPackage(java.lang.String cfName,
                                       boolean ignoreErrors)
                                       throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException,
                                              UnknownComparatorException
Return the serializer package for a specific column family. This requires a call to the Cassandra cluster and is therefore cached to reduce load on Cassandra and since this data rarely changes.

Parameters:
columnFamily -
ignoreErrors -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException
UnknownComparatorException

prepareMutationBatch

MutationBatch prepareMutationBatch()
Prepare a batch mutation object. It is possible to create multiple batch mutations and later merge them into a single mutation by calling mergeShallow on a batch mutation object.

Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

prepareQuery

<K,C> ColumnFamilyQuery<K,C> prepareQuery(ColumnFamily<K,C> cf)
Starting point for constructing a query. From the column family the client can perform all 4 types of queries: get column, get key slice, get key range and and index query.

Type Parameters:
K -
C -
Parameters:
cf - Column family to be used for the query. The key and column serializers in the ColumnFamily are automatically used while constructing the query and the response.

prepareColumnMutation

<K,C> ColumnMutation prepareColumnMutation(ColumnFamily<K,C> columnFamily,
                                           K rowKey,
                                           C column)
Mutation for a single column

Type Parameters:
K -
C -
Parameters:
columnFamily -

truncateColumnFamily

<K,C> com.netflix.astyanax.connectionpool.OperationResult<java.lang.Void> truncateColumnFamily(ColumnFamily<K,C> columnFamily)
                                                                                         throws com.netflix.astyanax.connectionpool.exceptions.OperationException,
                                                                                                com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Delete all rows in a column family

Type Parameters:
K -
C -
Parameters:
columnFamily -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException
com.netflix.astyanax.connectionpool.exceptions.OperationException

truncateColumnFamily

com.netflix.astyanax.connectionpool.OperationResult<java.lang.Void> truncateColumnFamily(java.lang.String columnFamily)
                                                                                         throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Delete all rows in a column family

Parameters:
columnFamily -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException
com.netflix.astyanax.connectionpool.exceptions.OperationException

testOperation

com.netflix.astyanax.connectionpool.OperationResult<java.lang.Void> testOperation(com.netflix.astyanax.connectionpool.Operation<?,?> operation)
                                                                                  throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
This method is used for testing purposes only. It is used to inject errors in the connection pool.

Parameters:
operation -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

testOperation

com.netflix.astyanax.connectionpool.OperationResult<java.lang.Void> testOperation(com.netflix.astyanax.connectionpool.Operation<?,?> operation,
                                                                                  com.netflix.astyanax.retry.RetryPolicy retry)
                                                                                  throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
This method is used for testing purposes only. It is used to inject errors in the connection pool.

Parameters:
operation -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

createColumnFamily

<K,C> com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> createColumnFamily(ColumnFamily<K,C> columnFamily,
                                                                                                                          java.util.Map<java.lang.String,java.lang.Object> options)
                                                                                                                    throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Create a column family in this keyspace

Parameters:
columnFamily -
options - - For list of options see http://www.datastax.com/docs/1.0/configuration/storage_configuration
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

createColumnFamily

<K,C> com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> createColumnFamily(java.util.Map<java.lang.String,java.lang.Object> options)
                                                                                                                    throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Create a column family from the provied options

Parameters:
options - - For list of options see http://www.datastax.com/docs/1.0/configuration/storage_configuration
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

updateColumnFamily

<K,C> com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> updateColumnFamily(ColumnFamily<K,C> columnFamily,
                                                                                                                          java.util.Map<java.lang.String,java.lang.Object> options)
                                                                                                                    throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Update the column family in cassandra

Parameters:
columnFamily -
options - - For list of options see http://www.datastax.com/docs/1.0/configuration/storage_configuration
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

dropColumnFamily

com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> dropColumnFamily(java.lang.String columnFamilyName)
                                                                                                                  throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Drop a column family from this keyspace

Parameters:
columnFamilyName -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

dropColumnFamily

<K,C> com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> dropColumnFamily(ColumnFamily<K,C> columnFamily)
                                                                                                                  throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Drop a column family from this keyspace

Parameters:
columnFamily -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

createKeyspace

com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> createKeyspace(java.util.Map<java.lang.String,java.lang.Object> options)
                                                                                                                throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Create the keyspace in cassandra. This call will only create the keyspace and not any column families. Once the keyspace has been created then call createColumnFamily for each CF you want to create.

Parameters:
options - - For list of options see http://www.datastax.com/docs/1.0/configuration/storage_configuration
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

createKeyspace

com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> createKeyspace(java.util.Map<java.lang.String,java.lang.Object> options,
                                                                                                                java.util.Map<ColumnFamily,java.util.Map<java.lang.String,java.lang.Object>> cfs)
                                                                                                                throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Bulk create for a keyspace and a bunch of column famlies

Parameters:
options -
cfs -
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

updateKeyspace

com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> updateKeyspace(java.util.Map<java.lang.String,java.lang.Object> options)
                                                                                                                throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Update the keyspace in cassandra.

Parameters:
options - - For list of options see http://www.datastax.com/docs/1.0/configuration/storage_configuration
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

dropKeyspace

com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> dropKeyspace()
                                                                                                              throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Drop this keyspace from cassandra

Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describeSchemaVersions

java.util.Map<java.lang.String,java.util.List<java.lang.String>> describeSchemaVersions()
                                                                                        throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
List all schema versions in the cluster. Under normal conditions there should only be one schema.

Returns:
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

prepareCqlStatement

CqlStatement prepareCqlStatement()
Prepare a CQL Statement on the keyspace

Returns:

getConnectionPool

com.netflix.astyanax.connectionpool.ConnectionPool<?> getConnectionPool()
                                                                        throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Exposes the internal connection pool to the client.

Returns:
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException