com.netflix.astyanax.test
Class TestKeyspace

java.lang.Object
  extended by com.netflix.astyanax.test.TestKeyspace
All Implemented Interfaces:
Keyspace

public class TestKeyspace
extends java.lang.Object
implements Keyspace


Constructor Summary
TestKeyspace(java.lang.String name)
           
 
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 columnFamily, 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.
 void setTokenRange(java.util.List<com.netflix.astyanax.connectionpool.TokenRange> tokens)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestKeyspace

public TestKeyspace(java.lang.String name)
Method Detail

setTokenRange

public void setTokenRange(java.util.List<com.netflix.astyanax.connectionpool.TokenRange> tokens)

getKeyspaceName

public java.lang.String getKeyspaceName()
Description copied from interface: Keyspace
Returns keyspace name

Specified by:
getKeyspaceName in interface Keyspace

describeRing

public java.util.List<com.netflix.astyanax.connectionpool.TokenRange> describeRing()
                                                                            throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Description copied from interface: Keyspace
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);

Specified by:
describeRing in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

prepareMutationBatch

public MutationBatch prepareMutationBatch()
Description copied from interface: Keyspace
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.

Specified by:
prepareMutationBatch in interface Keyspace

prepareQuery

public <K,C> ColumnFamilyQuery<K,C> prepareQuery(ColumnFamily<K,C> cf)
Description copied from interface: Keyspace
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.

Specified by:
prepareQuery in interface Keyspace
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

public <K,C> ColumnMutation prepareColumnMutation(ColumnFamily<K,C> columnFamily,
                                                  K rowKey,
                                                  C column)
Description copied from interface: Keyspace
Mutation for a single column

Specified by:
prepareColumnMutation in interface Keyspace

getConfig

public AstyanaxConfiguration getConfig()
Description copied from interface: Keyspace
Return the configuration object used to set up this keyspace

Specified by:
getConfig in interface Keyspace

describeKeyspace

public com.netflix.astyanax.ddl.KeyspaceDefinition describeKeyspace()
                                                             throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Description copied from interface: Keyspace
Return a complete description of the keyspace and its column families

Specified by:
describeKeyspace in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

getSerializerPackage

public SerializerPackage getSerializerPackage(java.lang.String columnFamily,
                                              boolean ignoreErrors)
Description copied from interface: Keyspace
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.

Specified by:
getSerializerPackage in interface Keyspace

testOperation

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

Specified by:
testOperation in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

truncateColumnFamily

public <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
Description copied from interface: Keyspace
Delete all rows in a column family

Specified by:
truncateColumnFamily in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.OperationException
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

testOperation

public 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
Description copied from interface: Keyspace
This method is used for testing purposes only. It is used to inject errors in the connection pool.

Specified by:
testOperation in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describeRing

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

Specified by:
describeRing in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describeRing

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

Specified by:
describeRing in interface Keyspace
Parameters:
dc - - null for all dcs
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

describeRing

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

Specified by:
describeRing in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

truncateColumnFamily

public com.netflix.astyanax.connectionpool.OperationResult<java.lang.Void> truncateColumnFamily(java.lang.String columnFamily)
                                                                                         throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Description copied from interface: Keyspace
Delete all rows in a column family

Specified by:
truncateColumnFamily in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException
com.netflix.astyanax.connectionpool.exceptions.OperationException

describePartitioner

public java.lang.String describePartitioner()
                                     throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Description copied from interface: Keyspace
Describe the partitioner used by the cluster

Specified by:
describePartitioner in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

dropColumnFamily

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

Specified by:
dropColumnFamily in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

dropColumnFamily

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

Specified by:
dropColumnFamily in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

dropKeyspace

public com.netflix.astyanax.connectionpool.OperationResult<com.netflix.astyanax.ddl.SchemaChangeResult> dropKeyspace()
                                                                                                              throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Description copied from interface: Keyspace
Drop this keyspace from cassandra

Specified by:
dropKeyspace in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

createColumnFamily

public <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
Description copied from interface: Keyspace
Create a column family in this keyspace

Specified by:
createColumnFamily in interface Keyspace
options - - For list of options see http://www.datastax.com/docs/1.0/configuration/storage_configuration
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

updateColumnFamily

public <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
Description copied from interface: Keyspace
Update the column family in cassandra

Specified by:
updateColumnFamily in interface Keyspace
options - - For list of options see http://www.datastax.com/docs/1.0/configuration/storage_configuration
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

createKeyspace

public 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
Description copied from interface: Keyspace
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.

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

updateKeyspace

public 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
Description copied from interface: Keyspace
Update the keyspace in cassandra.

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

createColumnFamily

public <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
Description copied from interface: Keyspace
Create a column family from the provied options

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

describeSchemaVersions

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

Specified by:
describeSchemaVersions in interface Keyspace
Returns:
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

getConnectionPool

public com.netflix.astyanax.connectionpool.ConnectionPool<?> getConnectionPool()
                                                                        throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Description copied from interface: Keyspace
Exposes the internal connection pool to the client.

Specified by:
getConnectionPool in interface Keyspace
Returns:
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

prepareCqlStatement

public CqlStatement prepareCqlStatement()
Description copied from interface: Keyspace
Prepare a CQL Statement on the keyspace

Specified by:
prepareCqlStatement in interface Keyspace
Returns:

getPartitioner

public com.netflix.astyanax.partitioner.Partitioner getPartitioner()
                                                            throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
Description copied from interface: Keyspace
Return the partitioner for this keyspace. The partitioner is mainly used for reading all rows.

Specified by:
getPartitioner in interface Keyspace
Returns:
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException

createKeyspace

public 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
Description copied from interface: Keyspace
Bulk create for a keyspace and a bunch of column famlies

Specified by:
createKeyspace in interface Keyspace
Throws:
com.netflix.astyanax.connectionpool.exceptions.ConnectionException