• DataStax C# Driver for Apache Cassandra API Documentation
Search Results for

    Show / Hide Table of Contents
    • Cassandra
      • AesColumnEncryptionPolicy
      • AesColumnEncryptionPolicy.AesKeyAndIV
      • AggregateMetadata
      • AlreadyExistsException
      • AtomicMonotonicTimestampGenerator
      • AtomicMonotonicWinApiTimestampGenerator
      • AuthenticationException
      • BaseColumnEncryptionPolicy<TKey>
      • BaseColumnEncryptionPolicy<TKey>.ColMetadataKey
      • BatchStatement
      • BatchType
      • BigIntegerTypeAdapter
      • BoundStatement
      • Builder
      • BusyPoolException
      • CassandraConnectionStringBuilder
      • ClientOptions
      • Cluster
      • ColumnDesc
      • ColumnEncryptionInvalidTypeError
      • ColumnEncryptionMetadata
      • ColumnTypeCode
      • CompressionType
      • Configuration
      • ConsistencyLevel
      • ConstantReconnectionPolicy
      • ConstantSpeculativeExecutionPolicy
      • CqlColumn
      • CqlVector<T>
      • CustomColumnInfo
      • DCAwareRoundRobinPolicy
      • DataCollectionMetadata
      • DataCollectionMetadata.SortOrder
      • DecimalTypeAdapter
      • DefaultLoadBalancingPolicy
      • DefaultRetryPolicy
      • Diagnostics
      • DowngradingConsistencyRetryPolicy
      • DriverException
      • DriverInternalError
      • Duration
      • DynamicCompositeTypeAdapter
      • EC2MultiRegionTranslator
      • EncryptedValue
      • ExecutionException
      • ExecutionInfo
      • ExponentialReconnectionPolicy
      • Extensions
      • FallthroughRetryPolicy
      • FixedReconnectionPolicy
      • FunctionFailureException
      • FunctionMetadata
      • GraphProtocol
      • Host
      • HostDistance
      • HostsEventArgs
      • HostsEventArgs.Kind
      • HostsEventHandler
      • IAddressTranslator
      • IAuthProvider
      • IAuthenticator
      • ICluster
      • IColumnEncryptionPolicy
      • IColumnInfo
      • IExecutionProfile
      • IExecutionProfileBuilder
      • IExecutionProfileOptions
      • IExtendedRetryPolicy
      • IFrameCompressor
      • IInitializer
      • ILoadBalancingPolicy
      • IReconnectionPolicy
      • IReconnectionSchedule
      • IRequestTracker
      • IRetryPolicy
      • ISession
      • ISessionState
      • ISpeculativeExecutionPlan
      • ISpeculativeExecutionPolicy
      • IStatement
      • ITimestampGenerator
      • ITypeAdapter
      • IdempotenceAwareRetryPolicy
      • IndexMetadata
      • IndexMetadata.IndexKind
      • InitFatalErrorException
      • InvalidConfigurationInQueryException
      • InvalidQueryException
      • InvalidTypeException
      • IsBootstrappingException
      • KeyType
      • KeyspaceMetadata
      • ListColumnInfo
      • LocalDate
      • LocalTime
      • Logger
      • LoggingRetryPolicy
      • MapColumnInfo
      • MaterializedViewMetadata
      • Metadata
      • MetadataSyncOptions
      • MetricsExtensions
      • MonitorReportingOptions
      • NoHostAvailableException
      • NoSpeculativeExecutionPolicy
      • NodeRequestInfo
      • NoneAuthProvider
      • NullTypeAdapter
      • OperationTimedOutException
      • OverloadedException
      • PlainTextAuthProvider
      • Policies
      • PoolingOptions
      • PrepareRequest
      • PreparedQueryNotFoundException
      • PreparedStatement
      • PreparedStatementIdMismatchException
      • ProtocolErrorException
      • ProtocolOptions
      • ProtocolVersion
      • QueryExecutionException
      • QueryOptions
      • QueryProtocolOptions
      • QueryProtocolOptions.QueryFlags
      • QueryTimeoutException
      • QueryTrace
      • QueryTrace.Event
      • QueryValidationException
      • ReadFailureException
      • ReadTimeoutException
      • RegularStatement
      • ReplicationStrategies
      • RequestInvalidException
      • RetryDecision
      • RetryDecision.RetryDecisionType
      • RetryLoadBalancingPolicy
      • RetryLoadBalancingPolicyEventArgs
      • RoundRobinPolicy
      • RoutingKey
      • Row
      • RowSet
      • RowSetMetadata
      • SSLOptions
      • SchemaChangedEventArgs
      • SchemaChangedEventArgs.Kind
      • SchemaChangedEventHandler
      • ServerErrorException
      • Session
      • SessionRequestInfo
      • SetColumnInfo
      • SimpleStatement
      • SocketOptions
      • Statement
      • SyntaxError
      • TableColumn
      • TableMetadata
      • TableOptions
      • TimeUuid
      • ToManyConnectionsPerHost
      • TokenAwarePolicy
      • TraceRetrievalException
      • TruncateException
      • TupleColumnInfo
      • TypeAdapters
      • UdtColumnInfo
      • UdtMap
      • UdtMap<T>
      • UdtMappingDefinitions
      • UnauthorizedException
      • UnavailableException
      • Unset
      • VectorColumnInfo
      • WriteFailureException
      • WriteTimeoutException
    • Cassandra.AppMetrics
      • DriverAppMetricsOptions
    • Cassandra.AppMetrics.MetricTypes
      • IAppMetricsCounter
      • IAppMetricsGauge
      • IAppMetricsMeter
      • IAppMetricsMetric
      • IAppMetricsTimer
    • Cassandra.AppMetrics.MetricValues
      • IAppMetricsHistogramValue
      • IAppMetricsMeterValue
      • IAppMetricsMetricWithValue<T>
      • IAppMetricsTimerValue
    • Cassandra.Data
      • CqlBatchTransaction
      • CqlCommand
      • CqlConnection
      • CqlDataAdapter
      • CqlParameter
      • CqlParameterCollection
      • CqlProviderFactory
      • CqlReader
    • Cassandra.Data.Linq
      • AllowFilteringAttribute
      • Batch
      • ClusteringKeyAttribute
      • ColumnAttribute
      • CompactStorageAttribute
      • CounterAttribute
      • CqlArgumentException
      • CqlCommand
      • CqlConditionalCommand<TEntity>
      • CqlDelete
      • CqlFunction
      • CqlInsert<TEntity>
      • CqlLinqNotSupportedException
      • CqlOperator
      • CqlQueryBase<TEntity>
      • CqlQueryExtensions
      • CqlQuerySingleElement<TEntity>
      • CqlQuery<TEntity>
      • CqlScalar<TEntity>
      • CqlToken
      • CqlUpdate
      • ITable
      • IgnoreAttribute
      • PartitionKeyAttribute
      • SecondaryIndexAttribute
      • SessionExtensions
      • StaticColumnAttribute
      • TableAttribute
      • TableType
      • Table<TEntity>
    • Cassandra.DataStax.Auth
      • DseGssapiAuthProvider
      • DsePlainTextAuthProvider
    • Cassandra.DataStax.Auth.Sspi
      • SspiException
    • Cassandra.DataStax.Graph
      • Direction
      • Edge
      • Element
      • ElementMap
      • EnumWrapper
      • FluentGraphStatement
      • GraphNode
      • GraphOptions
      • GraphResultSet
      • GraphStatement
      • IEdge
      • IElement
      • IGraphNode
      • IGraphStatement
      • IPath
      • IProperty
      • IPropertyWithElement
      • IVertex
      • IVertexProperty
      • Path
      • SimpleGraphStatement
      • TEnum
      • Traverser
      • Vertex
    • Cassandra.DataStax.Graph.Internal
      • IGraphSONDeserializer
      • IGraphSONReader
      • IGraphSONSerializer
      • IGraphSONWriter
    • Cassandra.DataStax.Search
      • DateRange
      • DateRangeBound
      • DateRangePrecision
    • Cassandra.Geometry
      • GeometryBase
      • LineString
      • Point
      • Polygon
    • Cassandra.Mapping
      • AppliedInfo<T>
      • ColumnMap
      • Cql
      • CqlQueryOptions
      • IColumnDefinition
      • ICqlBatch
      • ICqlQueryAsyncClient
      • ICqlQueryClient
      • ICqlWriteAsyncClient
      • ICqlWriteClient
      • IMapper
      • IPage<T>
      • ITypeDefinition
      • Map<TPoco>
      • Mapper
      • MappingConfiguration
      • Mappings
      • PrimaryKeyAttribute
      • SortOrder
      • TableNameAttribute
    • Cassandra.Mapping.Attributes
      • ClusteringKeyAttribute
      • ColumnAttribute
      • CounterAttribute
      • FrozenAttribute
      • FrozenKeyAttribute
      • FrozenValueAttribute
      • IgnoreAttribute
      • PartitionKeyAttribute
      • SecondaryIndexAttribute
      • StaticColumnAttribute
      • TableAttribute
    • Cassandra.Mapping.TypeConversion
      • DefaultTypeConverter
      • EnumStringMapper<T>
      • NullableEnumStringMapper<T>
      • TypeConverter
    • Cassandra.Mapping.Utils
      • MemberInfoExtensions
    • Cassandra.Metrics
      • DriverMetricsOptions
      • IDriverMetrics
      • IMetric
      • IMetricsRegistry<TMetric>
      • NodeMetric
      • NodeMetric.Counters
      • NodeMetric.Gauges
      • NodeMetric.Meters
      • NodeMetric.Timers
      • SessionMetric
      • SessionMetric.Counters
      • SessionMetric.Gauges
      • SessionMetric.Meters
      • SessionMetric.Timers
    • Cassandra.Metrics.Abstractions
      • IDriverCounter
      • IDriverGauge
      • IDriverMeter
      • IDriverMetric
      • IDriverMetricsProvider
      • IDriverTimer
    • Cassandra.OpenTelemetry
      • BuilderExtensions
      • CassandraActivitySourceHelper
      • CassandraInstrumentationOptions
      • OpenTelemetryRequestTracker
    • Cassandra.Serialization
      • CustomTypeSerializer<T>
      • TypeSerializer
      • TypeSerializerDefinitions
      • TypeSerializer<T>
      • UdtSerializer
    • Cassandra.Serialization.Primitive
      • DecimalSerializer

    Class PoolingOptions

    Represents the options related to connection pooling.

    For each host selected by the load balancing policy, the driver keeps a core amount of connections open at all times (GetCoreConnectionsPerHost(HostDistance)). If the use of those connections reaches a configurable threshold (GetMaxSimultaneousRequestsPerConnectionTreshold(HostDistance)), more connections are created up to the configurable maximum number of connections (GetMaxConnectionPerHost(HostDistance)).

    The driver uses connections in an asynchronous manner and multiple requests can be submitted on the same connection at the same time without waiting for a response. This means that the driver only needs to maintain a relatively small number of connections to each Cassandra host. The PoolingOptions allows you to to control how many connections are kept per host.

    Each of these parameters can be separately set for Local and Remote hosts. For Ignored hosts, the default for all those settings is 0 and cannot be changed.

    The default amount of connections depend on the Cassandra version of the Cluster, as newer versions of Cassandra (2.1 and above) support a higher number of in-flight requests.

    For Cassandra 2.1 and above, the default amount of connections per host are:

    • Local datacenter: 1 core connection per host, with 2 connections as maximum when the simultaneous requests threshold is reached.
    • Remote datacenter: 1 core connection per host (being 1 also max).

    For older Cassandra versions (1.2 and 2.0), the default amount of connections per host are:

    • Local datacenter: 2 core connection per host, with 8 connections as maximum when the simultaneous requests threshold is reached.
    • Remote datacenter: 1 core connection per host (being 2 the maximum).
    Inheritance
    object
    PoolingOptions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Cassandra
    Assembly: Cassandra.dll
    Syntax
    public class PoolingOptions

    Constructors

    PoolingOptions()

    DEPRECATED: It will be removed in future versions. Use Create(ProtocolVersion) instead.

    Creates a new instance of PoolingOptions using defaults suitable for old server versions (Apache Cassandra 2.0 and below) for compatibility reasons. It's recommended that you use Create(ProtocolVersion) providing the server protocol version.

    Declaration
    public PoolingOptions()

    Fields

    DefaultHeartBeatInterval

    The default heartbeat interval in milliseconds: 30000.

    Declaration
    public const int DefaultHeartBeatInterval = 30000
    Field Value
    Type Description
    int

    DefaultMaxRequestsPerConnection

    Default maximum amount of requests that can be in-flight on a single connection at the same time after which the connection will start rejecting requests: 2048.

    Declaration
    public const int DefaultMaxRequestsPerConnection = 2048
    Field Value
    Type Description
    int

    Methods

    Create(ProtocolVersion)

    Creates a new instance of PoolingOptions using the default amount of connections and settings based on the protocol version.

    For modern server versions (Apache Cassandra 2.1+) the amount of core connections are set to 1, setting 2 for max local connections.

    Declaration
    public static PoolingOptions Create(ProtocolVersion protocolVersion = ProtocolVersion.DseV2)
    Parameters
    Type Name Description
    ProtocolVersion protocolVersion
    Returns
    Type Description
    PoolingOptions

    A new instance of PoolingOptions

    See Also
    ProtocolVersion

    GetCoreConnectionsPerHost(HostDistance)

    The core number of connections per host.

    For the provided HostDistance, this correspond to the number of connections initially created and kept open to each host of that distance.

    Declaration
    public int GetCoreConnectionsPerHost(HostDistance distance)
    Parameters
    Type Name Description
    HostDistance distance

    The HostDistance for which to return this threshold.

    Returns
    Type Description
    int

    the core number of connections per host at distance HostDistance.

    GetHeartBeatInterval()

    Gets the amount of idle time in milliseconds that has to pass before the driver issues a request on an active connection to avoid idle time disconnections. A value of 0 or null means that the heartbeat functionality at connection level is disabled.

    Declaration
    public int? GetHeartBeatInterval()
    Returns
    Type Description
    int?

    GetMaxConnectionPerHost(HostDistance)

    The maximum number of connections per host.

    For the provided distance, this correspond to the maximum number of connections that can be created per host at that distance.

    Declaration
    public int GetMaxConnectionPerHost(HostDistance distance)
    Parameters
    Type Name Description
    HostDistance distance

    the HostDistance for which to return this threshold.

    Returns
    Type Description
    int

    the maximum number of connections per host at distance distance.

    GetMaxRequestsPerConnection()

    Gets the maximum amount of requests that can be in-flight on a single connection at the same time.

    This setting acts as a fixed maximum, once this value is reached for a host the pool will start rejecting requests, throwing BusyPoolException instances.

    This setting should not be mistaken with GetMaxSimultaneousRequestsPerConnectionTreshold(HostDistance).

    Declaration
    public int GetMaxRequestsPerConnection()
    Returns
    Type Description
    int

    GetMaxSimultaneousRequestsPerConnectionTreshold(HostDistance)

    Number of simultaneous requests on each connections to a host after which more connections are created.

    If all the connections opened to a host are handling more than this number of simultaneous requests and there is less than GetMaxConnectionPerHost(HostDistance) connections open to this host, a new connection is open.

    Declaration
    public int GetMaxSimultaneousRequestsPerConnectionTreshold(HostDistance distance)
    Parameters
    Type Name Description
    HostDistance distance

    the HostDistance for which to return this threshold.

    Returns
    Type Description
    int

    the configured threshold, or the default one if none have been set.

    GetMinSimultaneousRequestsPerConnectionTreshold(HostDistance)

    Number of simultaneous requests on a connection below which connections in excess are reclaimed.

    If an opened connection to an host at distance distance handles less than this number of simultaneous requests and there is more than #GetCoreConnectionsPerHost connections open to this host, the connection is closed.

    The default value for this option is 25 for Local and Remote hosts.

    Declaration
    public int GetMinSimultaneousRequestsPerConnectionTreshold(HostDistance distance)
    Parameters
    Type Name Description
    HostDistance distance

    the HostDistance for which to return this threshold.

    Returns
    Type Description
    int

    the configured threshold, or the default one if none have been set.

    GetWarmup()

    Gets whether all connections to hosts in the local datacenter must be opened on connect. Default: true.

    Declaration
    public bool GetWarmup()
    Returns
    Type Description
    bool

    SetCoreConnectionsPerHost(HostDistance, int)

    Sets the core number of connections per host.

    Declaration
    public PoolingOptions SetCoreConnectionsPerHost(HostDistance distance, int coreConnections)
    Parameters
    Type Name Description
    HostDistance distance

    the HostDistance for which to set this threshold.

    int coreConnections

    the value to set

    Returns
    Type Description
    PoolingOptions

    this PoolingOptions.

    SetHeartBeatInterval(int)

    Sets the amount of idle time in milliseconds that has to pass before the driver issues a request on an active connection to avoid idle time disconnections. When set to 0 the heartbeat functionality at connection level is disabled.

    Declaration
    public PoolingOptions SetHeartBeatInterval(int value)
    Parameters
    Type Name Description
    int value
    Returns
    Type Description
    PoolingOptions

    SetMaxConnectionsPerHost(HostDistance, int)

    Sets the maximum number of connections per host.

    Declaration
    public PoolingOptions SetMaxConnectionsPerHost(HostDistance distance, int maxConnections)
    Parameters
    Type Name Description
    HostDistance distance

    the HostDistance for which to set this threshold.

    int maxConnections

    the value to set

    Returns
    Type Description
    PoolingOptions

    this PoolingOptions.

    SetMaxRequestsPerConnection(int)

    Sets the maximum amount of requests that can be in-flight on a single connection at the same time.

    This setting acts as a fixed maximum, once this value is reached for a host the pool will start rejecting requests, throwing BusyPoolException instances.

    This setting should not be mistaken with SetMaxSimultaneousRequestsPerConnectionTreshold(HostDistance, int).

    Declaration
    public PoolingOptions SetMaxRequestsPerConnection(int value)
    Parameters
    Type Name Description
    int value
    Returns
    Type Description
    PoolingOptions

    SetMaxSimultaneousRequestsPerConnectionTreshold(HostDistance, int)

    Sets number of simultaneous requests on all connections to an host after which more connections are created.

    Declaration
    public PoolingOptions SetMaxSimultaneousRequestsPerConnectionTreshold(HostDistance distance, int maxSimultaneousRequests)
    Parameters
    Type Name Description
    HostDistance distance

    The HostDistance for which to configure this threshold.

    int maxSimultaneousRequests

    the value to set.

    Returns
    Type Description
    PoolingOptions

    this PoolingOptions.

    SetMinSimultaneousRequestsPerConnectionTreshold(HostDistance, int)

    Sets the number of simultaneous requests on a connection below which connections in excess are reclaimed.

    Declaration
    public PoolingOptions SetMinSimultaneousRequestsPerConnectionTreshold(HostDistance distance, int minSimultaneousRequests)
    Parameters
    Type Name Description
    HostDistance distance

    the HostDistance for which to configure this threshold.

    int minSimultaneousRequests

    the value to set.

    Returns
    Type Description
    PoolingOptions

    this PoolingOptions.

    SetWarmup(bool)

    Sets whether all connections to hosts in the local datacenter must be opened on connect. Default: true.

    Declaration
    public PoolingOptions SetWarmup(bool doWarmup)
    Parameters
    Type Name Description
    bool doWarmup
    Returns
    Type Description
    PoolingOptions
    Back to top © DataStax, All rights reserved.