Builder
final class Builder (View source)
Cluster builder allows fluent configuration of the cluster instance.
Methods
Configures default consistency for all requests.
Configures default page size for all results.
Configures default timeout for future resolution in blocking operations 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.
Configures this cluster to use a round robin load balancing policy.
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 connection 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.
Enable persistent sessions and clusters.
Force the driver to use a specific binary protocol version.
Total number of IO threads to use for handling the requests.
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.
Enables/disables Schema Metadata.
Enables/disables Hostname Resolution.
Enables/disables Randomized Contact Points.
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.
Details
Cluster
build()
Returns a Cluster Instance.
Builder
withDefaultConsistency(int $consistency)
Configures default consistency for all requests.
Builder
withDefaultPageSize(int|null $pageSize)
Configures default page size for all results.
Set to null
to disable paging altogether.
Builder
withDefaultTimeout(float|null $timeout)
Configures default timeout for future resolution in blocking operations Set to null to disable (default).
Builder
withContactPoints(string ...$host)
Configures the initial endpoints. Note that the driver will automatically discover and connect to the rest of the cluster.
Builder
withPort(int $port)
Specify a different port to be used when connecting to the cluster.
Builder
withRoundRobinLoadBalancingPolicy()
Configures this cluster to use a round robin load balancing policy.
Builder
withDatacenterAwareRoundRobinLoadBalancingPolicy(string $localDatacenter, int $hostPerRemoteDatacenter, bool $useRemoteDatacenterForLocalConsistencies)
Configures this cluster to use a datacenter aware round robin load balancing policy.
Builder
withBlackListHosts(string $hosts)
Sets the blacklist hosts. Any host in the blacklist will be ignored and a connection will not be established. This is useful for ensuring that the driver will not connection to a predefied set of hosts.
Builder
withWhiteListHosts(string $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.
Builder
withBlackListDCs(string $dcs)
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.
Builder
withWhiteListDCs(string $dcs)
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.
Builder
withTokenAwareRouting(bool $enabled)
Enable token aware routing.
Builder
withCredentials(string $username, string $password)
Configures plain-text authentication.
Builder
withConnectTimeout(float $timeout)
Timeout used for establishing TCP connections.
Builder
withRequestTimeout(float $timeout)
Timeout used for waiting for a response from a node.
Builder
withSSL(SSLOptions $options)
Set up ssl context.
Builder
withPersistentSessions(bool $enabled)
Enable persistent sessions and clusters.
Builder
withProtocolVersion(int $version)
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
Builder
withIOThreads(int $count)
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
Builder
withConnectionsPerHost(int $core, int $max)
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.
Builder
withReconnectInterval(float $interval)
Specify interval in seconds that the driver should wait before attempting to re-establish a closed connection.
Builder
withLatencyAwareRouting(bool $enabled)
Enables/disables latency-aware routing.
Builder
withTCPNodelay(bool $enabled)
Disables nagle algorithm for lower latency.
Builder
withTCPKeepalive(float|null $delay)
Enables/disables TCP keepalive.
Builder
withRetryPolicy(RetryPolicy $policy)
Configures the retry policy.
Builder
withTimestampGenerator(TimestampGenerator $generator)
Sets the timestamp generator.
Builder
withSchemaMetadata(bool $enabled)
Enables/disables 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.
Builder
withHostnameResolution(bool $enabled)
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.
Important: It's possible that the underlying C/C++ driver does not support hostname resolution. A PHP warning will be emitted if the driver does not support hostname resolution.
Builder
withRandomizedContactPoints(bool $enabled)
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.
Builder
withConnectionHeartbeatInterval(float $interval)
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.