public abstract class AbstractCluster extends Object implements Cluster
//get a cluster:
Cluster cluster = getOrCreateCluster("MyCluster", new CassandraHostConfigurator("127.0.0.1:9170"));
//get a keyspace from this cluster:
Keyspace ko = createKeyspace("Keyspace1", cluster);
//Create a mutator:
Mutator m = createMutator(ko);
// Make a mutation:
MutationResult mr = m.insert("key", cf, createColumn("name", "value", serializer, serializer));
THREAD SAFETY: This class is thread safe.| Modifier and Type | Field and Description |
|---|---|
protected HConnectionManager |
connectionManager |
static int |
RING_DELAY
Linked to Cassandra StorageProxy.
|
static int |
WAIT_FOR_SCHEMA_AGREEMENT_SLEEP_TIME |
protected ExceptionsTranslator |
xtrans |
| Constructor and Description |
|---|
AbstractCluster(String clusterName,
CassandraHostConfigurator cassandraHostConfigurator) |
AbstractCluster(String clusterName,
CassandraHostConfigurator cassandraHostConfigurator,
Map<String,String> credentials) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHost(CassandraHost cassandraHost,
boolean skipApplyConfig)
Adds the host to this Cluster.
|
String |
describeClusterName() |
KeyspaceDefinition |
describeKeyspace(String keyspace) |
List<KeyspaceDefinition> |
describeKeyspaces() |
String |
describePartitioner() |
String |
describeThriftVersion() |
String |
dropColumnFamily(String keyspaceName,
String columnFamily)
Drops a column family and does not wait for schema agreement.
|
String |
dropColumnFamily(String keyspaceName,
String columnFamily,
boolean waitForSchemaAgreement)
Drops a column family and waits for schema cluster agreement if
waitForSchemaAgreement
is set to true. |
String |
dropKeyspace(String keyspace)
Drops the Keyspace from the cluster.
|
String |
dropKeyspace(String keyspace,
boolean waitForSchemaAgreement)
Drops a Keyspace and waits for schema cluster agreement if
waitForSchemaAgreement
is set to true. |
String |
getClusterName() |
CassandraHostConfigurator |
getConfigurator() |
HConnectionManager |
getConnectionManager() |
Map<String,String> |
getCredentials() |
Set<CassandraHost> |
getKnownPoolHosts(boolean refresh) |
String |
getName()
Descriptive name of the cluster.
|
void |
onStartup()
called after the cluster has been initialized.
|
void |
truncate(String keyspaceName,
String columnFamily) |
protected static void |
waitForSchemaAgreement(org.apache.cassandra.thrift.Cassandra.Client cassandra) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddColumnFamily, addColumnFamily, addKeyspace, addKeyspace, describeRing, describeSchemaVersions, updateColumnFamily, updateColumnFamily, updateKeyspace, updateKeyspacepublic static final int RING_DELAY
public static final int WAIT_FOR_SCHEMA_AGREEMENT_SLEEP_TIME
protected final HConnectionManager connectionManager
protected final ExceptionsTranslator xtrans
public AbstractCluster(String clusterName, CassandraHostConfigurator cassandraHostConfigurator)
public AbstractCluster(String clusterName, CassandraHostConfigurator cassandraHostConfigurator, Map<String,String> credentials)
public HConnectionManager getConnectionManager()
getConnectionManager in interface Clusterpublic Set<CassandraHost> getKnownPoolHosts(boolean refresh)
getKnownPoolHosts in interface Clusterpublic void addHost(CassandraHost cassandraHost, boolean skipApplyConfig)
Clusterpublic String getName()
Clusterpublic List<KeyspaceDefinition> describeKeyspaces() throws HectorException
describeKeyspaces in interface ClusterHectorExceptionpublic String describeClusterName() throws HectorException
describeClusterName in interface ClusterHectorExceptionpublic String describeThriftVersion() throws HectorException
describeThriftVersion in interface ClusterHectorExceptionpublic KeyspaceDefinition describeKeyspace(String keyspace) throws HectorException
describeKeyspace in interface ClusterHectorExceptionpublic String getClusterName() throws HectorException
getClusterName in interface ClusterHectorExceptionpublic String dropKeyspace(String keyspace) throws HectorException
ClusterdropKeyspace in interface ClusterHectorExceptionpublic String dropKeyspace(String keyspace, boolean waitForSchemaAgreement) throws HectorException
ClusterwaitForSchemaAgreement
is set to true. Otherwise it behaves exactly like: Cluster.dropKeyspace(String)dropKeyspace in interface ClusterHectorExceptionpublic String describePartitioner() throws HectorException
describePartitioner in interface ClusterHectorExceptionpublic String dropColumnFamily(String keyspaceName, String columnFamily) throws HectorException
ClusterdropColumnFamily in interface ClusterHectorExceptionpublic String dropColumnFamily(String keyspaceName, String columnFamily, boolean waitForSchemaAgreement) throws HectorException
ClusterwaitForSchemaAgreement
is set to true. Otherwise it behaves exactly like: Cluster.dropColumnFamily(String, String)dropColumnFamily in interface ClusterHectorExceptionpublic Map<String,String> getCredentials()
getCredentials in interface Clusterpublic void truncate(String keyspaceName, String columnFamily) throws HectorException
truncate in interface ClusterHectorExceptionpublic void onStartup()
Clusterpublic CassandraHostConfigurator getConfigurator()
protected static void waitForSchemaAgreement(org.apache.cassandra.thrift.Cassandra.Client cassandra)
throws org.apache.cassandra.thrift.InvalidRequestException,
org.apache.thrift.TException,
InterruptedException
org.apache.cassandra.thrift.InvalidRequestExceptionorg.apache.thrift.TExceptionInterruptedExceptionCopyright © 2014. All Rights Reserved.