public class Metadata extends Object
Modifier and Type | Method and Description |
---|---|
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()
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.
|
String |
getPartitioner()
The partitioner in use as reported by the Cassandra nodes.
|
Set<Host> |
getReplicas(String keyspace,
ByteBuffer partitionKey)
Returns the set of hosts that are replica for a given partition key.
|
static String |
quote(String id)
Quote a keyspace, table or column identifier to make it case sensitive.
|
public static String quote(String id)
CQL identifiers, including keyspace, table and column ones, are case insensitive by default. Case sensitive identifiers can however be provided by enclosing the identifier in double quotes (see the CQL documentation for details). If you are using case sensitive identifiers, this method can be used to enclose such identifier in double quotes, making it case sensitive.
id
- the keyspace or table identifier.id
enclosed in double-quotes, for use in methods like
getReplicas(java.lang.String, java.nio.ByteBuffer)
, getKeyspace(java.lang.String)
, KeyspaceMetadata.getTable(java.lang.String)
or even Cluster.connect(String)
.public Set<Host> getReplicas(String keyspace, ByteBuffer partitionKey)
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).
keyspace
- the name of the keyspace to get replicas for.partitionKey
- the partition key for which to find the set of
replica.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).public String getClusterName()
public String getPartitioner()
public Set<Host> getAllHosts()
public KeyspaceMetadata getKeyspace(String keyspace)
keyspace
- the name of the keyspace for which metadata should be
returned.null
if keyspace
is not a known keyspace.public List<KeyspaceMetadata> getKeyspaces()
public String exportSchemaAsString()
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).Copyright © 2014. All rights reserved.