Module: Dse
- Defined in:
- lib/dse/util.rb,
lib/dse.rb,
lib/dse/cluster.rb,
lib/dse/session.rb,
lib/dse/version.rb,
lib/dse/graph/edge.rb,
lib/dse/graph/path.rb,
lib/dse/statements.rb,
lib/dse/graph/result.rb,
lib/dse/graph/vertex.rb,
lib/dse/graph/options.rb,
lib/dse/geometry/point.rb,
lib/dse/graph/duration.rb,
lib/dse/graph/statement.rb,
lib/dse/geometry/polygon.rb,
lib/dse/graph/result_set.rb,
lib/dse/util/endian_buffer.rb,
lib/dse/geometry/line_string.rb,
lib/dse/graph/vertex_property.rb,
lib/dse/auth/providers/gss_api.rb,
lib/dse/auth/providers/password.rb,
lib/dse/graph/execution_profile.rb,
lib/dse/statements/host_targeting.rb,
lib/dse/load_balancing/policies/host_targeting.rb
Overview
-- Copyright DataStax, Inc.
This software can be used solely with DataStax Enterprise. Please consult the license at
http://www.datastax.com/terms/datastax-dse-driver-license-terms
++
Defined Under Namespace
Modules: Auth, Geometry, Graph, LoadBalancing Classes: Cluster, Session
Constant Summary collapse
- VERSION =
'2.1.4'.freeze
Class Method Summary collapse
-
.cluster(options = {}) ⇒ Dse::Cluster
Creates a Cluster instance, which extends Cassandra::Cluster.
-
.cluster_async(options = {}) ⇒ Cassandra::Future<Dse::Cluster>
Creates a Cluster instance.
Class Method Details
.cluster(options = {}) ⇒ Dse::Cluster
Creates a Cluster instance, which extends Cassandra::Cluster. The API is identical, except that it returns a Dse::Session (see below). It takes all of the same options as Cassandra.cluster and the following extra options.
44 45 46 |
# File 'lib/dse.rb', line 44 def self.cluster( = {}) cluster_async().get end |
.cluster_async(options = {}) ⇒ Cassandra::Future<Dse::Cluster>
Creates a Cluster instance.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/dse.rb', line 54 def self.cluster_async( = {}) if .key?(:execution_profiles) [:graph_name, :graph_source, :graph_language, :graph_read_consistency, :graph_write_consistency].each do |opt| raise ::ArgumentError, "#{opt} is not allowed when execution profiles are used" if .key?(opt) end end username = [:username] password = [:password] [:custom_types] ||= [] [:custom_types] << Dse::Geometry::Point << Dse::Geometry::LineString << Dse::Geometry::Polygon # validate_and_massage will return a new options hash, with non-C* options removed. Hold onto the original hash # for attributes we still need later. = , hosts = Cassandra.() # Use the DSE plain text authenticator if we have a username and password. The above validation already # raises an error if one is given without the other. [:auth_provider] = Auth::Providers::Password.new(username, password) if username && password rescue => e futures = .fetch(:futures_factory) { return Cassandra::Future::Error.new(e) } futures.error(e) else [:cluster_klass] = Dse::Cluster driver = ::Cassandra::Driver.new() system_defaults = ::Cassandra::Driver.new profile_manager = driver.profile_manager unless profile_manager.profiles.key?(:default_graph) # full_options has the graph options. But we don't want to use other attributes like load_balancing_policy, etc. # in defining our default graph profile. So make a new hash that explicitly sets core profile attributes to # system defaults. graph_profile = Dse::Graph::ExecutionProfile.new( .merge(timeout: 30, load_balancing_policy: system_defaults.load_balancing_policy, retry_policy: system_defaults.retry_policy, consistency: system_defaults.consistency )) profile_manager.add_profile(:default_graph, graph_profile) end unless profile_manager.profiles.key?(:default_graph_system) graph_profile = Dse::Graph::ExecutionProfile.new(graph_read_consistency: [:graph_read_consistency], graph_write_consistency: [:graph_write_consistency], timeout: 180) profile_manager.add_profile(:default_graph_system, graph_profile) end unless profile_manager.profiles.key?(:default_graph_analytics) # Wrap the system default load-balancing policy that we'd otherwise run, with a host-targeting policy, for the # analytics profile. # We do this before driver.connect because driver.connect saves off the policy in the cluster # registry and does a few other things. graph_profile = Dse::Graph::ExecutionProfile.new( graph_source: 'a', graph_name: [:graph_name], graph_read_consistency: [:graph_read_consistency], graph_write_consistency: [:graph_write_consistency], load_balancing_policy: Dse::LoadBalancing::Policies::HostTargeting.new( system_defaults.load_balancing_policy ), timeout: (3600 * 24 * 7) ) profile_manager.add_profile(:default_graph_analytics, graph_profile) end driver.connect(hosts) end |