com.datastax.driver.core
Class Metadata

java.lang.Object
  extended by com.datastax.driver.core.Metadata

public class Metadata
extends Object

Keeps metadata on the connected cluster, including known nodes and schema definitions.


Method Summary
 String exportSchemaAsString()
          Returns a String containing CQL queries representing the schema of this cluster.
 Set<Host> getAllHosts()
          Returns the known hosts of this cluster.
 String getClusterName()
          Returns the Cassandra name for the cluster connect to.
 KeyspaceMetadata getKeyspace(String keyspace)
          Returns the metadata of a keyspace given its name.
 List<KeyspaceMetadata> getKeyspaces()
          Returns a list of all the defined keyspaces.
 Set<Host> getReplicas(ByteBuffer partitionKey)
          Returns the set of hosts that are replica for a given partition key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getReplicas

public Set<Host> getReplicas(ByteBuffer partitionKey)
Returns the set of hosts that are replica for a given partition key.

Note that this method is a best effort method. Consumers should not rely too heavily on the result of this method not being stale (or even empty).

Parameters:
partitionKey - the partition key for which to find the set of replica.
Returns:
the (immutable) set of replicas for partitionKey as know by the driver. No strong guarantee is provided on the stalelessness of this information. It is also not guarantee that the returned set won't be empty (which is then some form of staleness).

getClusterName

public String getClusterName()
Returns the Cassandra name for the cluster connect to.

Returns:
the Cassandra name for the cluster connect to.

getAllHosts

public Set<Host> getAllHosts()
Returns the known hosts of this cluster.

Returns:
A set will all the know host of this cluster.

getKeyspace

public KeyspaceMetadata getKeyspace(String keyspace)
Returns the metadata of a keyspace given its name.

Parameters:
keyspace - the name of the keyspace for which metadata should be returned.
Returns:
the metadata of the requested keyspace or null if keyspace is not a known keyspace.

getKeyspaces

public List<KeyspaceMetadata> getKeyspaces()
Returns a list of all the defined keyspaces.

Returns:
a list of all the defined keyspaces.

exportSchemaAsString

public String exportSchemaAsString()
Returns a String containing CQL queries representing the schema of this cluster. In other words, this method returns the queries that would allow to recreate the schema of this cluster. Note that the returned String is formatted to be human readable (for some definition of human readable at least).

Returns:
the CQL queries representing this cluster schema as a {code String}.


Copyright © 2013. All Rights Reserved.