Table Of Contents

Previous topic

cassandra.auth - Authentication

Next topic

cassandra.metrics - Performance Metrics

This Page

cassandra.metadata - Schema and Ring Topology

class cassandra.metadata.Metadata[source]

Holds a representation of the cluster schema and topology.

cluster_name = None

The string name of the cluster.

partitioner = None

The string name of the partitioner for the cluster.

token_map = None

A TokenMap instance describing the ring topology.

keyspaces = None

A map from keyspace names to matching KeyspaceMetadata instances.

export_schema_as_string()[source]

Returns a string that can be executed as a query in order to recreate the entire schema. The string is formatted to be human readable.

get_replicas(keyspace, key)[source]

Returns a list of Host instances that are replicas for a given partition key.

all_hosts()[source]

Returns a list of all known Host instances in the cluster.

Schemas

class cassandra.metadata.KeyspaceMetadata[source]

A representation of the schema for a single keyspace.

name = None

The string name of the keyspace.

durable_writes = True

A boolean indicating whether durable writes are enabled for this keyspace or not.

replication_strategy = None

A ReplicationStrategy subclass object.

tables = None

A map from table names to instances of TableMetadata.

class cassandra.metadata.TableMetadata[source]

A representation of the schema for a single table.

primary_key None[source]

A list of ColumnMetadata representing the components of the primary key for this table.

keyspace = None

An instance of KeyspaceMetadata.

name = None

The string name of the table.

partition_key = None

A list of ColumnMetadata instances representing the columns in the partition key for this table. This will always hold at least one column.

clustering_key = None

A list of ColumnMetadata instances representing the columns in the clustering key for this table. These are all of the primary_key columns that are not in the partition_key.

Note that a table may have no clustering keys, in which case this will be an empty list.

columns = None

A dict mapping column names to ColumnMetadata instances.

options = None

A dict mapping table option names to their specific settings for this table.

export_as_string()[source]

Returns a string of CQL queries that can be used to recreate this table along with all indexes on it. The returned string is formatted to be human readable.

as_cql_query(formatted=False)[source]

Returns a CQL query that can be used to recreate this table (index creations are not included). If formatted is set to True, extra whitespace will be added to make the query human readable.

class cassandra.metadata.ColumnMetadata[source]

A representation of a single column in a table.

table = None

The TableMetadata this column belongs to.

name = None

The string name of this column.

index = None

If an index exists on this column, this is an instance of IndexMetadata, otherwise None.

is_static = False

If this column is static (available in Cassandra 2.1+), this will be True, otherwise False.

typestring None[source]

A string representation of the type for this column, such as “varchar” or “map<string, int>”.

class cassandra.metadata.IndexMetadata[source]

A representation of a secondary index on a column.

column = None

The column (ColumnMetadata) this index is on.

name = None

A string name for the index.

index_type = None

A string representing the type of index.

as_cql_query()[source]

Returns a CQL query that can be used to recreate this index.

Tokens and Ring Topology

class cassandra.metadata.TokenMap[source]

Information about the layout of the ring.

token_class = None

A subclass of Token, depending on what partitioner the cluster uses.

ring = None

An ordered list of Token instances in the ring.

token_to_host_owner = None

A map of Token objects to the Host that owns that token.

tokens_to_hosts_by_ks = None

A map of keyspace names to a nested map of Token objects to sets of Host objects.

get_replicas(keyspace, token)[source]

Get a set of Host instances representing all of the replica nodes for a given Token.

class cassandra.metadata.Token[source]

Abstract class representing a token.

class cassandra.metadata.Murmur3Token(token)[source]

A token for Murmur3Partitioner.

token should be an int or string representing the token.

class cassandra.metadata.MD5Token(token)[source]

A token for RandomPartitioner.

token should be an int or string representing the token.

class cassandra.metadata.BytesToken(token_string)[source]

A token for ByteOrderedPartitioner.

token_string should be string representing the token.

class cassandra.metadata.ReplicationStrategy[source]
class cassandra.metadata.SimpleStrategy(replication_factor)[source]
replication_factor = None

The replication factor for this keyspace.

class cassandra.metadata.NetworkTopologyStrategy(dc_replication_factors)[source]
dc_replication_factors = None

A map of datacenter names to the replication factor for that DC.

class cassandra.metadata.LocalStrategy[source]