Cluster represents a cassandra cluster. It serves as a session factory factory and a collection of metadata.
- See Also:
-
Inherits
Object
Extends
Methods
Return cluster’s name
-
Returns:
-
| Type |
Details |
String |
cluster’s name
|
Return replicas for a given statement and keyspace
- Note
- an empty list is returned when statement/keyspace information is
not enough to determine replica list.
-
Parameters:
-
| Name |
Type |
Details |
| keyspace |
String |
keyspace name
|
| statement |
Statement |
statement for which to find
replicas
|
-
Returns:
-
| Type |
Details |
Array<Host> |
a list of replicas
|
Register a cluster state listener. State listener will start receiving
notifications about topology and schema changes
-
Parameters:
-
| Name |
Type |
Details |
| listener |
Listener |
cluster state listener
|
-
Returns:
-
Unregister a cluster state listener. State listener will stop receiving
notifications about topology and schema changes
-
Parameters:
-
| Name |
Type |
Details |
| listener |
Listener |
cluster state listener
|
-
Returns:
-
Yield or enumerate each member of this cluster
- Overloads:
-
Returns self
-
Yield Parameters:
-
| Name |
Type |
Details |
| host |
Host |
current host
|
-
Returns:
-
Returns a list of hosts
-
Returns:
-
| Type |
Details |
Array<Host> |
a list of hosts
|
Find a host by its address
-
Parameters:
-
| Name |
Type |
Details |
| address |
(IPAddr or String) |
ip address
|
-
Returns:
-
| Type |
Details |
(Host or nil) |
host or nil
|
Determine if a host by a given address exists
-
Parameters:
-
| Name |
Type |
Details |
| address |
(IPAddr or String) |
ip address
|
-
Returns:
-
| Type |
Details |
Boolean |
true or false
|
Yield or enumerate each keyspace defined in this cluster
- Overloads:
-
Returns self
-
Yield Parameters:
-
| Name |
Type |
Details |
| keyspace |
Keyspace |
current keyspace
|
-
Returns:
-
Returns a list of keyspaces
-
Returns:
-
| Type |
Details |
Array<Keyspace> |
a list of keyspaces
|
Find a keyspace by name
-
Parameters:
-
| Name |
Type |
Details |
| name |
String |
keyspace name
|
-
Returns:
-
| Type |
Details |
(Keyspace or nil) |
keyspace or nil
|
Determine if a keyspace by a given name exists
-
Parameters:
-
| Name |
Type |
Details |
| name |
String |
keyspace name
|
-
Returns:
-
| Type |
Details |
Boolean |
true or false
|
Trigger an asynchronous schema metadata refresh
-
Returns:
-
| Type |
Details |
Future<nil> |
a future that will be fulfilled when
schema metadata has been refreshed
|
Synchronously refresh schema metadata
-
Returns:
-
-
Raises:
-
- See Also:
-
Asynchronously create a new session, optionally scoped to a keyspace
-
Parameters:
-
| Name |
Type |
Details |
| keyspace |
String |
(defaults to: nil)
optional keyspace to scope session to
|
-
Returns:
-
| Type |
Details |
Future<Session> |
a future new session that
can prepare and execute statements
|
- See Also:
-
- Specifications:
-
-
Cluster#connect_async registers a new session listener
cluster.connect_async.get
expect(cluster_registry).to have(1).listeners
-
Cluster#connect_async removes session listener on close
cluster.connect_async
cluster_registry.listeners.first.close
expect(cluster_registry).to have(0).listeners
-
Cluster#connect_async uses given keyspace
future = Future::Value.new(nil)
Session.stub(:new) { session }
expect(session).to receive(:execute_async).once.with('USE foo').and_return(future)
cluster.connect_async('foo').get
-
Cluster#connect_async quotes given keyspace name
future = Future::Value.new(nil)
Session.stub(:new) { session }
expect(session).to receive(:execute_async).once.with('USE "FooBar"').and_return(future)
cluster.connect_async('FooBar').get
Synchronously create a new session, optionally scoped to a keyspace
-
Parameters:
-
| Name |
Type |
Details |
| keyspace |
String |
(defaults to: nil)
optional keyspace to scope the session to
|
-
Returns:
-
| Type |
Details |
Session |
a new session that can prepare and execute
statements
|
-
Raises:
-
- See Also:
-
Asynchronously closes all sessions managed by this cluster
-
Returns:
-
| Type |
Details |
Future<Cluster> |
a future that resolves to
self once closed
|
- Specifications:
-
-
Cluster#close_async closes control connection
expect(control_connection).to receive(:close_async).once.and_return(Ione::Future.resolved)
expect(cluster.close_async).to eq(promise)
expect(promise).to have_received(:fulfill).once.with(cluster)
Synchronously closes all sessions managed by this cluster
-
Returns:
-
| Type |
Details |
self |
this cluster
|
- See Also:
-
Returns a CLI-friendly cluster representation
-
Returns:
-
| Type |
Details |
String |
a CLI-friendly cluster representation
|