Modules
Classes
Constants
A list of all supported request consistencies
- See Also:
[:any, :one, :two, :three, :quorum, :all, :local_quorum,
:each_quorum, :serial, :local_serial, :local_one].freeze
A list of all supported serial consistencies
- See Also:
[:serial, :local_serial].freeze
A list of all possible write types that a
Errors::WriteTimeoutError can have.
[:simple, :batch, :unlogged_batch, :counter, :batch_log].freeze
[
:address_resolution,
:address_resolution_policy,
:allow_beta_protocol,
:auth_provider,
:client_cert,
:client_timestamps,
:compression,
:compressor,
:connect_timeout,
:connections_per_local_node,
:connections_per_remote_node,
:consistency,
:credentials,
:custom_types,
:datacenter,
:execution_profiles,
:futures_factory,
:heartbeat_interval,
:hosts,
:idle_timeout,
:listeners,
:load_balancing_policy,
:logger,
:nodelay,
:reconnection_policy,
:retry_policy,
:page_size,
:passphrase,
:password,
:port,
:private_key,
:protocol_version,
:requests_per_connection,
:schema_refresh_delay,
:schema_refresh_timeout,
:server_cert,
:shuffle_replicas,
:ssl,
:synchronize_schema,
:timeout,
:trace,
:username
].freeze
Methods
Creates a Cluster instance.
- Examples:
-
- Connecting to localhost
cluster = Cassandra.cluster- Configuring
Cluster cluster = Cassandra.cluster( username: username, password: password, hosts: ['10.0.1.1', '10.0.1.2', '10.0.1.3'] )
- Parameters:
-
Name Type Details options Hash(defaults to: {}) a customizable set of options - Keys for options:
-
Key Type Details :hosts Array<String,IPAddr>default: ['127.0.0.1']a list of initial addresses. Note that the entire list of cluster members will be discovered automatically once a connection to any hosts from the original list is successful.:port Integerdefault: 9042cassandra native protocol port.:nodelay Booleandefault: truewhen set totrue, disables nagle algorithm.:datacenter Stringdefault: nilname of current datacenter. First datacenter found will be assumed current by default. Note that you can skip this option if you specify only hosts from the local datacenter in:hostsoption.:shuffle_replicas Booleandefault: truewhether replicas list found by the default Token-Aware Load Balancing Policy should be shuffled. SeeToken-Aware Load Balancing Policy.:execution_profiles Hash<String|Symbol,ExecutionProfile>default: nilHash ofExecution::Profiles that are available for client use (e.g.Session#execute,Session#execute_async,Session#prepare, andSession#prepare_async).:connect_timeout Numericdefault: 10connection timeout in seconds. Setting value tonilwill reset it to 5 seconds.:timeout Numericdefault: 12request execution timeout in seconds. Setting value tonilwill remove request timeout.:heartbeat_interval Numericdefault: 30how often should a heartbeat be sent to determine if a connection is alive. Several things to note about this option. Only one heartbeat request will ever be outstanding on a given connection. Each heatbeat will be sent in at least:heartbeat_intervalseconds after the last request has been sent on a given connection. Setting value tonilwill remove connection timeout.:idle_timeout Numericdefault: 60period of inactivity after which a connection is considered dead. Note that this value should be at least a few times larger than:heartbeat_interval. Setting value tonilwill remove automatic connection termination.:username Stringdefault: noneusername to use for authentication to cassandra. Note that you must also specify:password.:password Stringdefault: nonepassword to use for authentication to cassandra. Note that you must also specify:username.:ssl ( BooleanorOpenSSL::SSL::SSLContext)default: falseenable default ssl authentication iftrue(not recommended). Also accepts an initializedOpenSSL::SSL::SSLContext. Note that this option should be ignored if:server_cert,:client_cert,:private_keyor:passphraseare given.:server_cert Stringdefault: nonepath to server certificate or certificate authority file.:client_cert Stringdefault: nonepath to client certificate file. Note that this option is only required when encryption is configured to require client authentication.:private_key Stringdefault: nonepath to client private key. Note that this option is only required when encryption is configured to require client authentication.:passphrase Stringdefault: nonepassphrase for private key.:compression Symboldefault: nonecompression to use. Must be either:snappyor:lz4. Also note, that in order for compression to work, you must install ‘snappy’ or ‘lz4-ruby’ gems.:load_balancing_policy LoadBalancing::Policydefault: token aware data center aware round robin. :address_resolution Symboldefault: :nonea pre-configured address resolver to use. Must be one of:noneor:ec2_multi_region.:connections_per_local_node Integerdefault: nilNumber of connections to open to each local node; the value of this option directly correlates to the number of requests the client can make to the local node concurrently. Whennil, the setting is1for nodes that use the v3 or later protocol, and2for nodes that use the v2 or earlier protocol.:connections_per_remote_node Integerdefault: 1Number of connections to open to each remote node; the value of this option directly correlates to the number of requests the client can make to the remote node concurrently.:requests_per_connection Integerdefault: nilNumber of outstanding requests to support on one connection. Depending on the types of requests, some may get processed in parallel in the Cassandra node. Whennil, the setting is1024for nodes that use the v3 or later protocol, and128for nodes that use the v2 or earlier protocol.:protocol_version Integerdefault: nilVersion of protocol to speak to nodes. By default, this is auto-negotiated to the highest common protocol version that all nodes in:hostsspeak.:allow_beta_protocol Booleandefault: falsewhether the driver should attempt to speak to nodes with a beta version of the newest protocol (which is still under development). USE WITH CAUTION!:client_timestamps ( BooleanorTimestampGenerator)default: falsewhether the driver should send timestamps for each executed statement and possibly which timestamp generator to use. Enabling this setting helps mitigate Cassandra cluster clock skew because the timestamp of the client machine will be used. This does not help mitigate application cluster clock skew. Also accepts an initializedTimestampGenerator,:simple(indicating an instance ofTimestampGenerator::Simple), or:monotonic(indicating an instance ofTimestampGenerator::TickingOnDuplicate). If set to true, it defaults toTimestampGenerator::Simplefor all Ruby flavors except JRuby. On JRuby, it defaults toTimestampGenerator::TickingOnDuplicate.:synchronize_schema Booleandefault: truewhether the driver should automatically keep schema metadata synchronized. When enabled, the driver updates schema metadata after receiving schema change notifications from Cassandra. Setting this setting tofalsedisables automatic schema updates. Schema metadata is used by the driver to determine cluster partitioners as well as to find partition keys and replicas of prepared statements, this information makes token aware load balancing possible. One can stillrefresh schema manually.:schema_refresh_delay Numericdefault: 1the driver will wait for:schema_refresh_delaybefore fetching metadata after receiving a schema change event. This timer is restarted every time a new schema change event is received. Finally, when the timer expires or a maximum wait time of:schema_refresh_timeouthas been reached, a schema refresh attempt will be made and the timeout is reset.:schema_refresh_timeout Numericdefault: 10the maximum delay before automatically refreshing schema. Such delay can occur whenever multiple schema change events are continuously arriving within:schema_refresh_delayinterval.:reconnection_policy Reconnection::Policydefault: Exponential. Note that the default policy is configured with(0.5, 30, 2).:retry_policy Retry::Policydefault: Default Retry Policy.:logger Loggerdefault: nonelogger. aLoggerinstance from the standard library or any object responding to standard log methods (#debug,#info,#warn,#errorand#fatal).:listeners Enumerable<Listener>default: noneinitial listeners. A list of initial cluster state listeners. Note that a:load_balancingpolicy is automatically registered with the cluster.:consistency Symboldefault: :local_onedefault consistency to use for all requests. Must be one ofCONSISTENCIES.:trace Booleandefault: falsewhether or not to trace all requests by default.:page_size Integerdefault: 10000default page size for all select queries. Set this value tonilto disable paging.:credentials Hash{String=>String}default: nonea hash of credentials - to be used with credentials authentication in cassandra 1.2. Note that if you specified:usernameand:passwordoptions, those credentials are configured automatically.:auth_provider Auth::Providerdefault: nonea custom auth provider to be used with SASL authentication in cassandra 2.0. Note that if you have specified:usernameand:password, then aPassword Providerwill be used automatically.:compressor Compression::Compressordefault: nonea custom compressor. Note that if you have specified:compression, an appropriate compressor will be provided automatically.:address_resolution_policy AddressResolution::Policydefault: No Resolution Policya custom address resolution policy. Note that if you have specified:address_resolution, an appropriate address resolution policy will be provided automatically.:futures_factory Object<#all,#error,#value,#promise>default: Futurea futures factory to assist with integration into existing futures library. Note that promises returned by this object must conform toPromiseapi, which is not yet public. Things may change, use at your own risk. - Returns:
-
Type Details Clustera cluster instance
Creates a Cluster instance.