Click or drag to resize

DseClusterBuilder Class

Helper class to build DseCluster instances.
Inheritance Hierarchy
SystemObject
  DseBuilder
    DseDseClusterBuilder

Namespace:  Dse
Assembly:  Dse (in Dse.dll) Version: 2.9.0
Syntax
C#
public class DseClusterBuilder : Builder

The DseClusterBuilder type exposes the following members.

Constructors
  NameDescription
Public methodDseClusterBuilder
Creates a new instance of DseClusterBuilder.
Top
Properties
  NameDescription
Public propertyApplicationName
The name of the application using the created cluster instance.
Public propertyApplicationVersion
The version of the application using the created cluster instance.
Public propertyClusterId
A unique identifier for the created cluster instance.
Public propertyGraphOptions
Gets the DSE Graph options.
Top
Methods
  NameDescription
Public methodAddContactPoint(IPAddress)
Add contact point. See AddContactPoint(String) for more details on contact points.
Public methodAddContactPoint(IPEndPoint)
Add contact point. See AddContactPoint(String) for more details on contact points.
Public methodAddContactPoint(String)
Adds a contact point. Contact points are addresses of Cassandra nodes that the driver uses to discover the cluster topology. Only one contact point is required (the driver will retrieve the address of the other nodes automatically), but it is usually a good idea to provide more than one contact point, as if that unique contact point is not available, the driver won't be able to initialize itself correctly.
Public methodAddContactPoints(IEnumerableIPAddress)
Add contact points. See Builder.AddContactPoint for more details on contact points.
Public methodAddContactPoints(IEnumerableIPEndPoint)
Add contact points. See Builder.AddContactPoint for more details on contact points.
Public methodAddContactPoints(IEnumerableString)
Add contact points. See Builder.AddContactPoint for more details on contact points.
Public methodAddContactPoints(IPAddress)
Add contact points. See Builder.AddContactPoint for more details on contact points.
Public methodAddContactPoints(IPEndPoint)
Add contact points. See Builder.AddContactPoint for more details on contact points.
Public methodAddContactPoints(String)
Add contact points. See AddContactPoint(String) for more details on contact points.
Public methodBuild
Builds the cluster with the configured set of initial contact points and policies.
Public methodWithAddressTranslator
Configures the address translater to use for the new cluster.
Public methodWithApplicationName

An optional configuration identifying the name of the application using this cluster instance.

This value is passed to DSE and is useful as metadata for describing a client connection.
Public methodWithApplicationVersion

An optional configuration identifying the version of the application using this cluster instance.

This value is passed to DSE and is useful as metadata for describing a client connection.
Public methodWithAuthProvider
Use the specified AuthProvider when connecting to Cassandra hosts.

Use this method when a custom authentication scheme is in place. You shouldn't call both this method and {@code withCredentials}' on the same Builder instance as one will supersede the other

Public methodWithCloudSecureConnectionBundle

Configures a DseCluster using the Cloud Secure Connection Bundle. Using this method will configure this builder with specific contact points, SSL options, credentials and load balancing policy. When needed, you can specify custom settings by calling other builder methods.

In case you need to specify a different set of credentials from the one in the bundle, here is an example:

DseCluster.Builder()
          .WithCloudSecureConnectionBundle("/path/to/bundle.zip")
          .WithCredentials("username", "password")
          .Build();

Build will throw InvalidOperationException when an error occurs that is not related to connectivity and NoHostAvailableException when an error occurs while trying to obtain the cluster metadata from the remote endpoint.

Public methodWithClusterId

An optional configuration for providing a unique identifier for the created cluster instance.

If not provided, an id will generated.

This value is passed to DSE and is useful as metadata for describing a client connection.

Public methodWithCompression
Sets the compression to use for the transport.
Public methodWithConnectionString
Configure the cluster by applying settings from ConnectionString.
Public methodWithCredentials
Uses the provided credentials when connecting to Cassandra hosts.

This should be used if the Cassandra cluster has been configured to use the PasswordAuthenticator. If the the default * AllowAllAuthenticator is used instead, using this method has no effect.

Public methodWithCustomCompressor
Sets a custom compressor to be used for the compression type. If specified, the compression type is mandatory. If not specified the driver default compressor will be use for the compression type.
Public methodWithDefaultKeyspace
Sets default keyspace name for the created cluster.
Public methodWithExecutionProfiles

Adds Execution Profiles to the DseCluster instance.

Execution profiles are like configuration presets, multiple methods of the driver accept an execution profile name which is like telling the driver which settings to use for that particular request. This makes it easier to change settings like ConsistencyLevel and ReadTimeoutMillis on a per request basis.

Note that subsequent calls to this method will override the previously provided profiles.

To add execution profiles you can use WithProfile(String, ActionIExecutionProfileBuilder):

DseCluster.Builder()
        .WithExecutionProfiles(options => options
            .WithProfile("profile1", profileBuilder => profileBuilder
                .WithReadTimeoutMillis(10000)
                .WithConsistencyLevel(ConsistencyLevel.LocalQuorum))
            .WithProfile("profile-graph", profileBuilder => profileBuilder
                .WithReadTimeoutMillis(10000)
                .WithGraphOptions(new GraphOptions().SetName("name"))))
        .Build();

Public methodWithGraphOptions
Sets the DSE Graph options.
Public methodWithLoadBalancingPolicy
Configures the load balancing policy to use for the new cluster.

If no load balancing policy is set through this method, DseLoadBalancingPolicy will be used instead.

To specify the local datacenter, use the following method CreateDefault(String) to create an instance of the default policy with a specific local datacenter.

Public methodWithMaxProtocolVersion

Limits the maximum protocol version used to connect to the nodes, when it is not set protocol version used between the driver and the Cassandra cluster is negotiated upon establishing the first connection.

Useful for using the driver against a cluster that contains nodes with different major/minor versions of Cassandra. For example, preparing for a rolling upgrade of the Cluster.

Public methodWithMaxSchemaAgreementWaitSeconds
Sets the maximum time to wait for schema agreement before returning from a DDL query.

DDL queries introduce schema changes that need to be propagated to all nodes in the cluster. Once they have settled on a common version, we say that they are in agreement.

If not set through this method, the default value (10 seconds) will be used.

Public methodWithMetadataSyncOptions

If not set through this method, the default value options will be used (metadata synchronization is enabled by default). The api reference of MetadataSyncOptions specifies what is the default for each option.

In case you disable Metadata synchronization, please ensure you invoke RefreshSchemaAsync(String, String) in order to keep the token metadata up to date otherwise you will not be getting everything you can out of token aware routing, i.e. TokenAwarePolicy, which is used by DseLoadBalancingPolicy and is the default.

Disabling this feature has the following impact:

  • Token metadata will not be computed and stored. This means that token aware routing (TokenAwarePolicy, which is used by DseLoadBalancingPolicy and is the default) will only work correctly if you keep the token metadata up to date using the RefreshSchemaAsync(String, String) method. If you wish to go this route of manually refreshing the metadata then it's recommended to refresh only the keyspaces that this application will use, by passing the
    keyspace
    parameter.
  • Keyspace metadata will not be cached by the driver. Every time you call methods like GetTable(String, String), GetKeyspace(String) and other similar methods of the Metadata class, the driver will query that data on demand and will not cache it.
  • The driver will not handle
    SCHEMA_CHANGED
    responses. This means that when you execute schema changing statements through the driver, it will not update the schema or topology metadata automatically before returning.

Public methodWithMetrics(IDriverMetricsProvider)

Enables metrics. DataStax provides an implementation based on a third party library (App.Metrics) on a separate NuGet package: Dse.AppMetrics Alternatively, you can implement your own provider that implements IDriverMetricsProvider.

This method enables all individual metrics without a bucket prefix. To customize these options, use WithMetrics(IDriverMetricsProvider, DriverMetricsOptions).

Public methodWithMetrics(IDriverMetricsProvider, DriverMetricsOptions)

Enables metrics. DataStax provides an implementation based on a third party library (App.Metrics) on a separate NuGet package: Dse.AppMetrics Alternatively, you can implement your own provider that implements IDriverMetricsProvider.

This method enables all individual metrics without a bucket prefix. To customize these settings, use WithMetrics(IDriverMetricsProvider, DriverMetricsOptions). For explanations on these settings, see the API docs of the DriverMetricsOptions class.

The AppMetrics provider also has some settings that can be customized, check out the API docs of Dse.AppMetrics.DriverAppMetricsOptions.

Here is an example:

var cluster = 
    DseCluster.Builder()
           .WithMetrics(
               metrics.CreateDriverMetricsProvider(new DriverAppMetricsOptions()),
               new DriverMetricsOptions()
                   .SetEnabledNodeMetrics(NodeMetric.DefaultNodeMetrics.Except(new [] { NodeMetric.Meters.BytesSent }))
                   .SetEnabledSessionMetrics(
                       SessionMetric.DefaultSessionMetrics.Except(new[] { SessionMetric.Meters.BytesReceived }))
                   .SetBucketPrefix("web.app"))
           .Build();

Public methodWithMonitorReporting
Configures options related to Monitor Reporting for the new cluster. By default, Monitor Reporting is enabled.
Public methodWithNoCompact
Enables the NO_COMPACT startup option.

When this option is set, SELECT, UPDATE, DELETE, and BATCH statements on COMPACT STORAGE tables function in "compatibility" mode which allows seeing these tables as if they were "regular" CQL tables.

This option only affects interactions with tables using COMPACT STORAGE and it is only supported by DSE 5.1 and 6.0+.

Public methodWithPoolingOptions
Sets the pooling options for the cluster.
Public methodWithPort
The port to use to connect to all Cassandra hosts. If not set through this method, the default port (9042) will be used instead.
Public methodWithQueryOptions
Sets the QueryOptions to use for the newly created Cluster. If no query options are set through this method, default query options will be used.
Public methodWithQueryTimeout
Specifies the number of milliseconds that the driver should wait for the response before the query times out in a synchronous operation.

This will cause that synchronous operations like Execute(String) to throw a TimeoutException after the specified number of milliseconds.

Default timeout value is set to
20,000
(20 seconds).
Public methodWithReconnectionPolicy
Configure the reconnection policy to use for the new cluster.

If no reconnection policy is set through this method, Policies.DefaultReconnectionPolicy will be used instead.

Public methodWithRetryPolicy
Configure the retry policy to use for the new cluster.

If no retry policy is set through this method, IdempotenceAwareRetryPolicy will be used instead.

Public methodWithSessionName
IDseSession objects created through the IDseCluster built from this builder will have SessionName set to the value provided in this method. The first session created by this cluster instance will have its name set exactly as it is provided in this method. Any session created by the IDseCluster built from this builder after the first one will have its name set as a concatenation of the provided value plus a counter.
var cluster = DseCluster.Builder().WithSessionName("main-session").Build();
var session = cluster.Connect(); // session.SessionName == "main-session"
var session1 = cluster.Connect(); // session1.SessionName == "main-session1"
var session2 = cluster.Connect(); // session2.SessionName == "main-session2"
If this setting is not set, the default session names will be "s0", "s1", "s2", etc.
var cluster = DseCluster.Builder().Build();
var session = cluster.Connect(); // session.SessionName == "s0"
var session1 = cluster.Connect(); // session1.SessionName == "s1"
var session2 = cluster.Connect(); // session2.SessionName == "s2"
Public methodWithSocketOptions
Configures the socket options that are going to be used to create the connections to the hosts.
Public methodWithSpeculativeExecutionPolicy
Configure the speculative execution to use for the new cluster.

If no speculative execution policy is set through this method, DefaultSpeculativeExecutionPolicy will be used instead.

Public methodWithSSL
Enables the use of SSL for the created Cluster. Calling this method will use default SSL options.
Public methodWithSSL(SSLOptions)
Enables the use of SSL for the created Cluster using the provided options.
Public methodWithTimestampGenerator
Configures the generator that will produce the client-side timestamp sent with each query.

This feature is only available with protocol version 3 or above of the native protocol. With earlier versions, timestamps are always generated server-side, and setting a generator through this method will have no effect.

If no generator is set through this method, the driver will default to client-side timestamps by using AtomicMonotonicTimestampGenerator.

Public methodWithTypeSerializers
Top
Fields
  NameDescription
Public fieldStatic memberDefaultApplicationName
Top
See Also

Reference