PHP Class Cassandra\Cluster\Builder

See also: Cassandra::cluster()
Datei anzeigen Open project: datastax/php-driver Class Usage Examples

Public Methods

Method Description
build ( ) : Cassandra\Cluster Returns a Cluster Instance.
withConnectTimeout ( float $timeout ) : Builder Timeout used for establishing TCP connections.
withConnectionsPerHost ( integer $core = 1, integer $max = 2 ) : Builder 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.
withContactPoints ( $host ) : Builder Configures the initial endpoints. Note that the driver will automatically discover and connect to the rest of the cluster.
withCredentials ( string $username, string $password ) : Builder Configures cassandra authentication.
withDatacenterAwareRoundRobinLoadBalancingPolicy ( string $localDatacenter, integer $hostPerRemoteDatacenter, boolean $useRemoteDatacenterForLocalConsistencies ) : Builder Configures this cluster to use a datacenter aware round robin load balancing policy.
withDefaultConsistency ( integer $consistency ) : Builder Configures default consistency for all requests.
withDefaultPageSize ( integer | null $pageSize ) : Builder Configures default page size for all results.
withDefaultTimeout ( float | null $timeout ) : Builder Configures default timeout for future resolution in blocking operations Set to null to disable (default).
withIOThreads ( integer $count ) : Builder Total number of IO threads to use for handling the requests.
withLatencyAwareRouting ( boolean $enabled = true ) : Builder Enables/disables latency-aware routing.
withPersistentSessions ( boolean $enabled = true ) : Builder Enable persistent sessions and clusters.
withPort ( integer $port ) : Builder Specify a different port to be used when connecting to the cluster.
withProtocolVersion ( integer $version ) : Builder Force the driver to use a specific binary protocol version.
withReconnectInterval ( float $interval ) : Builder Specify interval in seconds that the driver should wait before attempting to re-establish a closed connection.
withRequestTimeout ( float $timeout ) : Builder Timeout used for waiting for a response from a node.
withRetryPolicy ( RetryPolicy $policy ) : Builder Configures the retry policy.
withRoundRobinLoadBalancingPolicy ( ) : Builder Configures this cluster to use a round robin load balancing policy.
withSSL ( Cassandra\SSLOptions $options ) : Builder Set up ssl context.
withSchemaMetadata ( boolean $enable = true ) : Builder Enables/disables Schema Metadata.
withTCPKeepalive ( float | null $delay ) : Builder Enables/disables TCP keepalive.
withTCPNodelay ( boolean $enabled = true ) : Builder Disables nagle algorithm for lower latency.
withTimestampGenerator ( Cassandra\TimestampGenerator $generator ) : Builder Sets the timestamp generator.
withTokenAwareRouting ( boolean $enabled = true ) : Builder Enable token aware routing.

Method Details

build() public method

Returns a Cluster Instance.
public build ( ) : Cassandra\Cluster
return Cassandra\Cluster Cluster instance

withConnectTimeout() public method

Timeout used for establishing TCP connections.
public withConnectTimeout ( float $timeout ) : Builder
$timeout float Timeout value in seconds, can be fractional
return Builder self

withConnectionsPerHost() public method

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.
public withConnectionsPerHost ( integer $core = 1, integer $max = 2 ) : Builder
$core integer minimum connections to keep open to any given host
$max integer maximum connections to keep open to any given host
return Builder self

withContactPoints() public method

Configures the initial endpoints. Note that the driver will automatically discover and connect to the rest of the cluster.
public withContactPoints ( $host ) : Builder
return Builder self

withCredentials() public method

Configures cassandra authentication.
public withCredentials ( string $username, string $password ) : Builder
$username string Username
$password string Password
return Builder self

withDatacenterAwareRoundRobinLoadBalancingPolicy() public method

Configures this cluster to use a datacenter aware round robin load balancing policy.
public withDatacenterAwareRoundRobinLoadBalancingPolicy ( string $localDatacenter, integer $hostPerRemoteDatacenter, boolean $useRemoteDatacenterForLocalConsistencies ) : Builder
$localDatacenter string Name of the local datacenter
$hostPerRemoteDatacenter integer Maximum number of hosts to try in remote datacenters
$useRemoteDatacenterForLocalConsistencies boolean Allow using hosts from remote datacenters to execute statements with local consistencies
return Builder self

withDefaultConsistency() public method

Configures default consistency for all requests.
public withDefaultConsistency ( integer $consistency ) : Builder
$consistency integer A consistency level, must be one of Cassandra::CONSISTENCY_* values
return Builder self

withDefaultPageSize() public method

Set to null to disable paging altogether.
public withDefaultPageSize ( integer | null $pageSize ) : Builder
$pageSize integer | null default page size
return Builder self

withDefaultTimeout() public method

Configures default timeout for future resolution in blocking operations Set to null to disable (default).
public withDefaultTimeout ( float | null $timeout ) : Builder
$timeout float | null Timeout value in seconds, can be fractional
return Builder self

withIOThreads() public method

Note: number of io threads * core connections per host <= total number of connections <= number of io threads * max connections per host
public withIOThreads ( integer $count ) : Builder
$count integer total number of threads.
return Builder self

withLatencyAwareRouting() public method

Enables/disables latency-aware routing.
public withLatencyAwareRouting ( boolean $enabled = true ) : Builder
$enabled boolean whether to actually enable or disable the routing.
return Builder self

withPersistentSessions() public method

Enable persistent sessions and clusters.
public withPersistentSessions ( boolean $enabled = true ) : Builder
$enabled boolean whether to enable persistent sessions and clusters (optional)
return Builder self

withPort() public method

Specify a different port to be used when connecting to the cluster.
public withPort ( integer $port ) : Builder
$port integer a number between 1 and 65535
return Builder self

withProtocolVersion() public method

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
public withProtocolVersion ( integer $version ) : Builder
$version integer the actual protocol version, only `1`, `2`, `3`, or `4` are supported
return Builder self

withReconnectInterval() public method

Specify interval in seconds that the driver should wait before attempting to re-establish a closed connection.
public withReconnectInterval ( float $interval ) : Builder
$interval float interval in seconds
return Builder self

withRequestTimeout() public method

Timeout used for waiting for a response from a node.
public withRequestTimeout ( float $timeout ) : Builder
$timeout float Timeout value in seconds, can be fractional
return Builder self

withRetryPolicy() public method

Configures the retry policy.
public withRetryPolicy ( RetryPolicy $policy ) : Builder
$policy RetryPolicy the retry policy to use.
return Builder self

withRoundRobinLoadBalancingPolicy() public method

Configures this cluster to use a round robin load balancing policy.
public withRoundRobinLoadBalancingPolicy ( ) : Builder
return Builder self

withSSL() public method

Set up ssl context.
public withSSL ( Cassandra\SSLOptions $options ) : Builder
$options Cassandra\SSLOptions a preconfigured ssl context
return Builder self

withSchemaMetadata() public method

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.
public withSchemaMetadata ( boolean $enable = true ) : Builder
$enable boolean whether the driver fetches and maintains schema metadata.
return Builder self

withTCPKeepalive() public method

Enables/disables TCP keepalive.
public withTCPKeepalive ( float | null $delay ) : Builder
$delay float | null the period of inactivity in seconds, after which the keepalive probe should be sent over the connection. If set to `null`, disables keepalive probing.
return Builder self

withTCPNodelay() public method

Disables nagle algorithm for lower latency.
public withTCPNodelay ( boolean $enabled = true ) : Builder
$enabled boolean whether to actually enable or disable nodelay.
return Builder self

withTimestampGenerator() public method

Sets the timestamp generator.
public withTimestampGenerator ( Cassandra\TimestampGenerator $generator ) : Builder
$generator Cassandra\TimestampGenerator A timestamp generator that will be used to generate timestamps for statements.
return Builder self

withTokenAwareRouting() public method

Enable token aware routing.
public withTokenAwareRouting ( boolean $enabled = true ) : Builder
$enabled boolean Whether to enable token aware routing (optional)
return Builder self