cassandra-driver 1.0.0.beta.2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +4 -0
- data/README.md +125 -0
- data/lib/cassandra/auth/providers/password.rb +73 -0
- data/lib/cassandra/auth/providers.rb +16 -0
- data/lib/cassandra/auth.rb +97 -0
- data/lib/cassandra/client/batch.rb +212 -0
- data/lib/cassandra/client/client.rb +591 -0
- data/lib/cassandra/client/column_metadata.rb +54 -0
- data/lib/cassandra/client/connection_manager.rb +72 -0
- data/lib/cassandra/client/connector.rb +277 -0
- data/lib/cassandra/client/execute_options_decoder.rb +59 -0
- data/lib/cassandra/client/null_logger.rb +37 -0
- data/lib/cassandra/client/peer_discovery.rb +50 -0
- data/lib/cassandra/client/prepared_statement.rb +314 -0
- data/lib/cassandra/client/query_result.rb +230 -0
- data/lib/cassandra/client/request_runner.rb +71 -0
- data/lib/cassandra/client/result_metadata.rb +48 -0
- data/lib/cassandra/client/void_result.rb +78 -0
- data/lib/cassandra/client.rb +144 -0
- data/lib/cassandra/cluster/client.rb +768 -0
- data/lib/cassandra/cluster/connector.rb +244 -0
- data/lib/cassandra/cluster/control_connection.rb +425 -0
- data/lib/cassandra/cluster/metadata.rb +124 -0
- data/lib/cassandra/cluster/options.rb +42 -0
- data/lib/cassandra/cluster/registry.rb +198 -0
- data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +47 -0
- data/lib/cassandra/cluster/schema/partitioners/ordered.rb +37 -0
- data/lib/cassandra/cluster/schema/partitioners/random.rb +37 -0
- data/lib/cassandra/cluster/schema/partitioners.rb +21 -0
- data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +92 -0
- data/lib/cassandra/cluster/schema/replication_strategies/none.rb +39 -0
- data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +44 -0
- data/lib/cassandra/cluster/schema/replication_strategies.rb +21 -0
- data/lib/cassandra/cluster/schema/type_parser.rb +138 -0
- data/lib/cassandra/cluster/schema.rb +340 -0
- data/lib/cassandra/cluster.rb +215 -0
- data/lib/cassandra/column.rb +92 -0
- data/lib/cassandra/compression/compressors/lz4.rb +72 -0
- data/lib/cassandra/compression/compressors/snappy.rb +66 -0
- data/lib/cassandra/compression.rb +66 -0
- data/lib/cassandra/driver.rb +111 -0
- data/lib/cassandra/errors.rb +79 -0
- data/lib/cassandra/execution/info.rb +51 -0
- data/lib/cassandra/execution/options.rb +80 -0
- data/lib/cassandra/execution/trace.rb +152 -0
- data/lib/cassandra/future.rb +675 -0
- data/lib/cassandra/host.rb +79 -0
- data/lib/cassandra/keyspace.rb +133 -0
- data/lib/cassandra/listener.rb +87 -0
- data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +149 -0
- data/lib/cassandra/load_balancing/policies/round_robin.rb +132 -0
- data/lib/cassandra/load_balancing/policies/token_aware.rb +119 -0
- data/lib/cassandra/load_balancing/policies/white_list.rb +90 -0
- data/lib/cassandra/load_balancing/policies.rb +19 -0
- data/lib/cassandra/load_balancing.rb +113 -0
- data/lib/cassandra/protocol/cql_byte_buffer.rb +307 -0
- data/lib/cassandra/protocol/cql_protocol_handler.rb +323 -0
- data/lib/cassandra/protocol/frame_decoder.rb +128 -0
- data/lib/cassandra/protocol/frame_encoder.rb +48 -0
- data/lib/cassandra/protocol/request.rb +38 -0
- data/lib/cassandra/protocol/requests/auth_response_request.rb +47 -0
- data/lib/cassandra/protocol/requests/batch_request.rb +76 -0
- data/lib/cassandra/protocol/requests/credentials_request.rb +47 -0
- data/lib/cassandra/protocol/requests/execute_request.rb +103 -0
- data/lib/cassandra/protocol/requests/options_request.rb +39 -0
- data/lib/cassandra/protocol/requests/prepare_request.rb +50 -0
- data/lib/cassandra/protocol/requests/query_request.rb +153 -0
- data/lib/cassandra/protocol/requests/register_request.rb +38 -0
- data/lib/cassandra/protocol/requests/startup_request.rb +49 -0
- data/lib/cassandra/protocol/requests/void_query_request.rb +24 -0
- data/lib/cassandra/protocol/response.rb +38 -0
- data/lib/cassandra/protocol/responses/auth_challenge_response.rb +41 -0
- data/lib/cassandra/protocol/responses/auth_success_response.rb +41 -0
- data/lib/cassandra/protocol/responses/authenticate_response.rb +41 -0
- data/lib/cassandra/protocol/responses/detailed_error_response.rb +60 -0
- data/lib/cassandra/protocol/responses/error_response.rb +50 -0
- data/lib/cassandra/protocol/responses/event_response.rb +39 -0
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +64 -0
- data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +43 -0
- data/lib/cassandra/protocol/responses/ready_response.rb +44 -0
- data/lib/cassandra/protocol/responses/result_response.rb +48 -0
- data/lib/cassandra/protocol/responses/rows_result_response.rb +139 -0
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +60 -0
- data/lib/cassandra/protocol/responses/schema_change_result_response.rb +57 -0
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +42 -0
- data/lib/cassandra/protocol/responses/status_change_event_response.rb +44 -0
- data/lib/cassandra/protocol/responses/supported_response.rb +41 -0
- data/lib/cassandra/protocol/responses/topology_change_event_response.rb +34 -0
- data/lib/cassandra/protocol/responses/void_result_response.rb +39 -0
- data/lib/cassandra/protocol/type_converter.rb +384 -0
- data/lib/cassandra/protocol.rb +93 -0
- data/lib/cassandra/reconnection/policies/constant.rb +48 -0
- data/lib/cassandra/reconnection/policies/exponential.rb +79 -0
- data/lib/cassandra/reconnection/policies.rb +20 -0
- data/lib/cassandra/reconnection.rb +49 -0
- data/lib/cassandra/result.rb +215 -0
- data/lib/cassandra/retry/policies/default.rb +47 -0
- data/lib/cassandra/retry/policies/downgrading_consistency.rb +71 -0
- data/lib/cassandra/retry/policies/fallthrough.rb +39 -0
- data/lib/cassandra/retry/policies.rb +21 -0
- data/lib/cassandra/retry.rb +142 -0
- data/lib/cassandra/session.rb +202 -0
- data/lib/cassandra/statement.rb +22 -0
- data/lib/cassandra/statements/batch.rb +95 -0
- data/lib/cassandra/statements/bound.rb +48 -0
- data/lib/cassandra/statements/prepared.rb +81 -0
- data/lib/cassandra/statements/simple.rb +58 -0
- data/lib/cassandra/statements/void.rb +33 -0
- data/lib/cassandra/statements.rb +23 -0
- data/lib/cassandra/table.rb +299 -0
- data/lib/cassandra/time_uuid.rb +142 -0
- data/lib/cassandra/util.rb +167 -0
- data/lib/cassandra/uuid.rb +104 -0
- data/lib/cassandra/version.rb +21 -0
- data/lib/cassandra.rb +428 -0
- data/lib/cassandra_murmur3.jar +0 -0
- metadata +211 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 2013-2014 DataStax, Inc.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#++
|
|
18
|
+
|
|
19
|
+
module Cassandra
|
|
20
|
+
module Execution
|
|
21
|
+
class Info
|
|
22
|
+
# @return [String] keyspace used for the query
|
|
23
|
+
attr_reader :keyspace
|
|
24
|
+
# @return [Cassandra::Statement] original statement
|
|
25
|
+
attr_reader :statement
|
|
26
|
+
# @return [Cassandra::Execution::Options] original execution options
|
|
27
|
+
attr_reader :options
|
|
28
|
+
# @return [Array<Cassandra::Host>] a list of attempted hosts
|
|
29
|
+
attr_reader :hosts
|
|
30
|
+
# Actual consistency used, it can differ from consistency in {Cassandra::Execution::Info#options} if a retry policy modified it.
|
|
31
|
+
# @return [Symbol] one of {Cassandra::CONSISTENCIES}
|
|
32
|
+
attr_reader :consistency
|
|
33
|
+
# @return [Integer] number of retries
|
|
34
|
+
attr_reader :retries
|
|
35
|
+
# Returns {Cassandra::Execution::Trace} if `trace: true` was passed to {Cassandra::Session#execute} or {Cassandra::Session#execute_async}
|
|
36
|
+
# @return [Cassandra::Execution::Trace, nil] a Trace if it has been enabled for request
|
|
37
|
+
attr_reader :trace
|
|
38
|
+
|
|
39
|
+
# @private
|
|
40
|
+
def initialize(keyspace, statement, options, hosts, consistency, retries, trace)
|
|
41
|
+
@keyspace = keyspace
|
|
42
|
+
@statement = statement
|
|
43
|
+
@options = options
|
|
44
|
+
@hosts = hosts
|
|
45
|
+
@consistency = consistency
|
|
46
|
+
@retries = retries
|
|
47
|
+
@trace = trace
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 2013-2014 DataStax, Inc.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#++
|
|
18
|
+
|
|
19
|
+
module Cassandra
|
|
20
|
+
module Execution
|
|
21
|
+
class Options
|
|
22
|
+
# @return [Symbol] consistency for request. Must be one of
|
|
23
|
+
# {Cassandra::CONSISTENCIES}
|
|
24
|
+
attr_reader :consistency
|
|
25
|
+
# @return [Symbol] consistency for request with conditional updates
|
|
26
|
+
# (lightweight - compare-and-set, CAS - transactions). Must be one of
|
|
27
|
+
# {Cassandra::SERIAL_CONSISTENCIES}
|
|
28
|
+
attr_reader :serial_consistency
|
|
29
|
+
# @return [Integer] requested page size
|
|
30
|
+
attr_reader :page_size
|
|
31
|
+
# @return [Numeric] request timeout interval
|
|
32
|
+
attr_reader :timeout
|
|
33
|
+
|
|
34
|
+
# @private
|
|
35
|
+
def initialize(options)
|
|
36
|
+
consistency = options[:consistency]
|
|
37
|
+
page_size = options[:page_size]
|
|
38
|
+
trace = options[:trace]
|
|
39
|
+
timeout = options[:timeout]
|
|
40
|
+
serial_consistency = options[:serial_consistency]
|
|
41
|
+
|
|
42
|
+
raise ::ArgumentError, ":consistency must be one of #{CONSISTENCIES.inspect}, #{consistency.inspect} given" unless CONSISTENCIES.include?(consistency)
|
|
43
|
+
raise ::ArgumentError, ":serial_consistency must be one of #{SERIAL_CONSISTENCIES.inspect}, #{serial_consistency.inspect} given" if serial_consistency && !SERIAL_CONSISTENCIES.include?(serial_consistency)
|
|
44
|
+
|
|
45
|
+
page_size = page_size && Integer(page_size)
|
|
46
|
+
timeout = timeout && Integer(timeout)
|
|
47
|
+
|
|
48
|
+
raise ::ArgumentError, ":page_size must be greater than 0, #{page_size.inspect} given" if page_size && page_size <= 0
|
|
49
|
+
raise ::ArgumentError, ":timeout must be greater than 0, #{timeout.inspect} given" if timeout && timeout <= 0
|
|
50
|
+
|
|
51
|
+
@consistency = consistency
|
|
52
|
+
@page_size = page_size
|
|
53
|
+
@trace = !!trace
|
|
54
|
+
@timeout = timeout
|
|
55
|
+
@serial_consistency = serial_consistency
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @return [Boolean] whether request tracing was enabled
|
|
59
|
+
def trace?
|
|
60
|
+
@trace
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @private
|
|
64
|
+
def override(options)
|
|
65
|
+
Options.new(to_h.merge!(options))
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# @private
|
|
69
|
+
def to_h
|
|
70
|
+
{
|
|
71
|
+
:consistency => @consistency,
|
|
72
|
+
:page_size => @page_size,
|
|
73
|
+
:trace => @trace,
|
|
74
|
+
:timeout => @timeout,
|
|
75
|
+
:serial_consistency => @serial_consistency
|
|
76
|
+
}
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 2013-2014 DataStax, Inc.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#++
|
|
18
|
+
|
|
19
|
+
module Cassandra
|
|
20
|
+
module Execution
|
|
21
|
+
class Trace
|
|
22
|
+
class Event
|
|
23
|
+
# @return [Cassandra::Uuid] event uuid
|
|
24
|
+
attr_reader :id
|
|
25
|
+
|
|
26
|
+
# @return [String] description of activity
|
|
27
|
+
attr_reader :activity
|
|
28
|
+
|
|
29
|
+
attr_reader :source
|
|
30
|
+
attr_reader :source_elapsed
|
|
31
|
+
attr_reader :thread
|
|
32
|
+
|
|
33
|
+
# @private
|
|
34
|
+
def initialize(id, activity, source, source_elapsed, thread)
|
|
35
|
+
@id = id
|
|
36
|
+
@activity = activity
|
|
37
|
+
@source = source
|
|
38
|
+
@source_elapsed = source_elapsed
|
|
39
|
+
@thread = thread
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def ==(other)
|
|
43
|
+
other == @id
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
alias :eql? :==
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
include MonitorMixin
|
|
50
|
+
|
|
51
|
+
# @return [Cassandra::Uuid] trace id
|
|
52
|
+
attr_reader :id
|
|
53
|
+
|
|
54
|
+
# @private
|
|
55
|
+
def initialize(id, client)
|
|
56
|
+
@id = id
|
|
57
|
+
@client = client
|
|
58
|
+
|
|
59
|
+
mon_initialize
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Returns the ip of coordinator node. Typically the same as {Cassandra::Execution::Info#hosts}`.last`
|
|
63
|
+
#
|
|
64
|
+
# @return [IPAddr] ip of the coordinator node
|
|
65
|
+
def coordinator
|
|
66
|
+
load unless @coordinator
|
|
67
|
+
|
|
68
|
+
@coordinator
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def duration
|
|
72
|
+
load unless @duration
|
|
73
|
+
|
|
74
|
+
@duration
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def parameters
|
|
78
|
+
load unless @parameters
|
|
79
|
+
|
|
80
|
+
@parameters
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def request
|
|
84
|
+
load unless @request
|
|
85
|
+
|
|
86
|
+
@request
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def started_at
|
|
90
|
+
load unless @started_at
|
|
91
|
+
|
|
92
|
+
@started_at
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Returns all trace events
|
|
96
|
+
#
|
|
97
|
+
# @return [Array<Cassandra::Execution::Trace::Event>] events
|
|
98
|
+
def events
|
|
99
|
+
load_events unless @events
|
|
100
|
+
|
|
101
|
+
@events
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def inspect
|
|
105
|
+
"#<#{self.class.name}:0x#{self.object_id.to_s(16)} @id=#{@id.inspect}>"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
109
|
+
|
|
110
|
+
# @private
|
|
111
|
+
SELECT_SESSION = "SELECT * FROM system_traces.sessions WHERE session_id = ?"
|
|
112
|
+
# @private
|
|
113
|
+
SELECT_EVENTS = "SELECT * FROM system_traces.events WHERE session_id = ?"
|
|
114
|
+
|
|
115
|
+
# @private
|
|
116
|
+
def load
|
|
117
|
+
synchronize do
|
|
118
|
+
return if @loaded
|
|
119
|
+
|
|
120
|
+
data = @client.query(Statements::Simple.new(SELECT_SESSION, @id), VOID_OPTIONS).get.first
|
|
121
|
+
raise ::RuntimeError, "unable to load trace #{@id}" if data.nil?
|
|
122
|
+
|
|
123
|
+
@coordinator = data['coordinator']
|
|
124
|
+
@duration = data['duration']
|
|
125
|
+
@parameters = data['parameters']
|
|
126
|
+
@request = data['request']
|
|
127
|
+
@started_at = data['started_at']
|
|
128
|
+
@loaded = true
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
nil
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# @private
|
|
135
|
+
def load_events
|
|
136
|
+
synchronize do
|
|
137
|
+
return if @loaded_events
|
|
138
|
+
|
|
139
|
+
@events = []
|
|
140
|
+
|
|
141
|
+
@client.query(Statements::Simple.new(SELECT_EVENTS, @id), VOID_OPTIONS).get.each do |row|
|
|
142
|
+
@events << Event.new(row['event_id'], row['activity'], row['source'], row['source_elapsed'], row['thread'])
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
@events.freeze
|
|
146
|
+
|
|
147
|
+
@loaded_events = true
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|