class Builder
Cassandra\Cluster
builder allows fluent configuration of the cluster instance.
Methods
Cassandra\Cluster
build
( )Returns a Cassandra\Cluster
Instance.
Configures default consistency for all requests.
Configures default page size for all results. Cassandra\Set
to null
to disable paging altogether.
Configures default timeout for future resolution in blocking operations Cassandra\Set
to null to disable (default).
Configures the initial endpoints. Note that the driver will automatically discover and connect to the rest of the cluster.
Specify a different port to be used when connecting to the cluster.
Cluster\Builder
withRoundRobinLoadBalancingPolicy
( )Configures this cluster to use a round robin load balancing policy.
Cluster\Builder
withDatacenterAwareRoundRobinLoadBalancingPolicy
(string
$localDatacenter, int
$hostPerRemoteDatacenter, bool
$useRemoteDatacenterForLocalConsistencies )
Configures this cluster to use a datacenter aware round robin load balancing policy.
Sets the blacklist hosts. Any host in the blacklist will be ignored and a conneciton will not be established. This is useful for ensuring that the driver will not connection to a predefied set of hosts.
Sets the whitelist hosts. Any host not in the whitelist will be ignored and a connection will not be established. This policy is useful for ensuring that the driver will only connect to a predefined set of hosts.
Sets the blacklist datacenters. Any datacenter in the blacklist will be ignored and a connection will not be established to any host in those datacenters. This policy is useful for ensuring the driver will not connect to any host in a specific datacenter.
Sets the whitelist datacenters. Any host not in a whitelisted datacenter will be ignored. This policy is useful for ensuring the driver will only connect to hosts in specific datacenters.
Enable token aware routing.
Configures plain-text authentication.
Timeout used for establishing TCP connections.
Timeout used for waiting for a response from a node.
Cassandra\Set
up ssl context.
Enable persistent sessions and clusters.
Force the driver to use a specific binary protocol version.
Apache Cassandra
1.2+ supports protocol version 1 Apache Cassandra
2.0+ supports protocol version 2 Apache Cassandra
2.1+ supports protocol version 3 Apache Cassandra
2.2+ supports protocol version 4
NOTE: Apache Cassandra
3.x supports protocol version 3 and 4 only
Total number of IO threads to use for handling the requests.
Note: number of io threads * core connections per host <= total number of connections <= number of io threads * max connections per host
Cassandra\Set
the size of connection pools used by the driver. Pools are fixed when only $core
is given, when a $max
is specified as well, additional connections will be created automatically based on current load until the maximum number of connection has been reached. When request load goes down, extra connections are automatically cleaned up until only the core number of connections is left.
Specify interval in seconds that the driver should wait before attempting to re-establish a closed connection.
Enables/disables latency-aware routing.
Disables nagle algorithm for lower latency.
Enables/disables TCP keepalive.
Configures the retry policy.
Sets the timestamp generator.
Enables/disables Cassandra\Schema
Metadata.
If disabled this allows the driver to skip over retrieving and updating schema metadata, but it also disables the usage of token-aware routing and $session->schema() will always return an empty object. This can be useful for reducing the startup overhead of short-lived sessions.
Enables/disables Hostname Resolution.
If enabled the driver will resolve hostnames for IP addresses using reverse IP lookup. This is useful for authentication (Kerberos) or encryption SSL services that require a valid hostname for verification.
Enables/disables Randomized Contact Points.
If enabled this allows the driver randomly use contact points in order to evenly spread the load across the cluster and prevent hotspots/load spikes during notifications (e.g. massive schema change).
Note: This setting should only be disabled for debugging and testing.
Specify interval in seconds that the driver should wait before attempting to send heartbeat messages and control the amount of time the connection must be idle before sending heartbeat messages. This is useful for preventing intermediate network devices from dropping connections.