cassandra-driver 3.0.0.beta.1 → 3.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +90 -38
  3. data/ext/cassandra_murmur3/cassandra_murmur3.c +1 -1
  4. data/lib/cassandra.rb +327 -130
  5. data/lib/cassandra/address_resolution.rb +1 -1
  6. data/lib/cassandra/address_resolution/policies/ec2_multi_region.rb +1 -1
  7. data/lib/cassandra/address_resolution/policies/none.rb +1 -1
  8. data/lib/cassandra/aggregate.rb +21 -7
  9. data/lib/cassandra/argument.rb +2 -2
  10. data/lib/cassandra/auth.rb +4 -4
  11. data/lib/cassandra/auth/providers.rb +1 -1
  12. data/lib/cassandra/auth/providers/password.rb +9 -5
  13. data/lib/cassandra/cassandra_logger.rb +80 -0
  14. data/lib/cassandra/cluster.rb +38 -9
  15. data/lib/cassandra/cluster/client.rb +801 -205
  16. data/lib/cassandra/cluster/connection_pool.rb +2 -2
  17. data/lib/cassandra/cluster/connector.rb +74 -25
  18. data/lib/cassandra/cluster/control_connection.rb +217 -82
  19. data/lib/cassandra/cluster/failed_connection.rb +1 -1
  20. data/lib/cassandra/cluster/metadata.rb +12 -4
  21. data/lib/cassandra/cluster/options.rb +60 -11
  22. data/lib/cassandra/cluster/registry.rb +69 -16
  23. data/lib/cassandra/cluster/schema.rb +25 -7
  24. data/lib/cassandra/cluster/schema/cql_type_parser.rb +15 -10
  25. data/lib/cassandra/cluster/schema/fetchers.rb +263 -106
  26. data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +41 -36
  27. data/lib/cassandra/cluster/schema/partitioners.rb +1 -1
  28. data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +3 -3
  29. data/lib/cassandra/cluster/schema/partitioners/ordered.rb +1 -1
  30. data/lib/cassandra/cluster/schema/partitioners/random.rb +1 -1
  31. data/lib/cassandra/cluster/schema/replication_strategies.rb +1 -1
  32. data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +19 -18
  33. data/lib/cassandra/cluster/schema/replication_strategies/none.rb +1 -1
  34. data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +1 -1
  35. data/lib/cassandra/column.rb +3 -3
  36. data/lib/cassandra/compression.rb +1 -1
  37. data/lib/cassandra/compression/compressors/lz4.rb +4 -3
  38. data/lib/cassandra/compression/compressors/snappy.rb +4 -3
  39. data/lib/cassandra/driver.rb +103 -41
  40. data/lib/cassandra/errors.rb +265 -30
  41. data/lib/cassandra/execution/info.rb +16 -5
  42. data/lib/cassandra/execution/options.rb +99 -54
  43. data/lib/cassandra/execution/trace.rb +16 -9
  44. data/lib/cassandra/executors.rb +1 -1
  45. data/lib/cassandra/function.rb +19 -13
  46. data/lib/cassandra/function_collection.rb +85 -0
  47. data/lib/cassandra/future.rb +106 -48
  48. data/lib/cassandra/host.rb +10 -4
  49. data/lib/cassandra/keyspace.rb +90 -33
  50. data/lib/cassandra/listener.rb +1 -1
  51. data/lib/cassandra/load_balancing.rb +2 -2
  52. data/lib/cassandra/load_balancing/policies.rb +1 -1
  53. data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +18 -18
  54. data/lib/cassandra/load_balancing/policies/round_robin.rb +1 -1
  55. data/lib/cassandra/load_balancing/policies/token_aware.rb +15 -13
  56. data/lib/cassandra/load_balancing/policies/white_list.rb +11 -5
  57. data/lib/cassandra/null_logger.rb +27 -6
  58. data/lib/cassandra/protocol.rb +1 -1
  59. data/lib/cassandra/protocol/coder.rb +78 -39
  60. data/lib/cassandra/protocol/cql_byte_buffer.rb +50 -33
  61. data/lib/cassandra/protocol/cql_protocol_handler.rb +44 -45
  62. data/lib/cassandra/protocol/request.rb +2 -2
  63. data/lib/cassandra/protocol/requests/auth_response_request.rb +3 -3
  64. data/lib/cassandra/protocol/requests/batch_request.rb +16 -7
  65. data/lib/cassandra/protocol/requests/credentials_request.rb +3 -3
  66. data/lib/cassandra/protocol/requests/execute_request.rb +41 -20
  67. data/lib/cassandra/protocol/requests/options_request.rb +1 -1
  68. data/lib/cassandra/protocol/requests/prepare_request.rb +5 -5
  69. data/lib/cassandra/protocol/requests/query_request.rb +27 -22
  70. data/lib/cassandra/protocol/requests/register_request.rb +2 -2
  71. data/lib/cassandra/protocol/requests/startup_request.rb +6 -4
  72. data/lib/cassandra/protocol/requests/void_query_request.rb +1 -1
  73. data/lib/cassandra/protocol/response.rb +2 -2
  74. data/lib/cassandra/protocol/responses/already_exists_error_response.rb +12 -2
  75. data/lib/cassandra/protocol/responses/auth_challenge_response.rb +1 -1
  76. data/lib/cassandra/protocol/responses/auth_success_response.rb +1 -1
  77. data/lib/cassandra/protocol/responses/authenticate_response.rb +1 -1
  78. data/lib/cassandra/protocol/responses/error_response.rb +101 -13
  79. data/lib/cassandra/protocol/responses/event_response.rb +1 -1
  80. data/lib/cassandra/protocol/responses/function_failure_error_response.rb +13 -2
  81. data/lib/cassandra/protocol/responses/prepared_result_response.rb +11 -5
  82. data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +14 -9
  83. data/lib/cassandra/protocol/responses/read_failure_error_response.rb +26 -4
  84. data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +22 -3
  85. data/lib/cassandra/protocol/responses/ready_response.rb +3 -3
  86. data/lib/cassandra/protocol/responses/result_response.rb +4 -2
  87. data/lib/cassandra/protocol/responses/rows_result_response.rb +5 -3
  88. data/lib/cassandra/protocol/responses/schema_change_event_response.rb +5 -4
  89. data/lib/cassandra/protocol/responses/schema_change_result_response.rb +16 -9
  90. data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +2 -2
  91. data/lib/cassandra/protocol/responses/status_change_event_response.rb +2 -2
  92. data/lib/cassandra/protocol/responses/supported_response.rb +1 -1
  93. data/lib/cassandra/protocol/responses/topology_change_event_response.rb +1 -1
  94. data/lib/cassandra/protocol/responses/unavailable_error_response.rb +20 -3
  95. data/lib/cassandra/protocol/responses/unprepared_error_response.rb +11 -2
  96. data/lib/cassandra/protocol/responses/void_result_response.rb +1 -1
  97. data/lib/cassandra/protocol/responses/write_failure_error_response.rb +26 -4
  98. data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +22 -3
  99. data/lib/cassandra/protocol/v1.rb +101 -36
  100. data/lib/cassandra/protocol/v3.rb +124 -51
  101. data/lib/cassandra/protocol/v4.rb +172 -68
  102. data/lib/cassandra/reconnection.rb +1 -1
  103. data/lib/cassandra/reconnection/policies.rb +1 -1
  104. data/lib/cassandra/reconnection/policies/constant.rb +2 -4
  105. data/lib/cassandra/reconnection/policies/exponential.rb +6 -6
  106. data/lib/cassandra/result.rb +53 -19
  107. data/lib/cassandra/retry.rb +8 -8
  108. data/lib/cassandra/retry/policies.rb +1 -1
  109. data/lib/cassandra/retry/policies/default.rb +1 -1
  110. data/lib/cassandra/retry/policies/downgrading_consistency.rb +7 -3
  111. data/lib/cassandra/retry/policies/fallthrough.rb +1 -1
  112. data/lib/cassandra/session.rb +22 -16
  113. data/lib/cassandra/statement.rb +1 -1
  114. data/lib/cassandra/statements.rb +1 -1
  115. data/lib/cassandra/statements/batch.rb +16 -10
  116. data/lib/cassandra/statements/bound.rb +10 -3
  117. data/lib/cassandra/statements/prepared.rb +59 -15
  118. data/lib/cassandra/statements/simple.rb +23 -10
  119. data/lib/cassandra/statements/void.rb +1 -1
  120. data/lib/cassandra/table.rb +79 -30
  121. data/lib/cassandra/time.rb +11 -6
  122. data/lib/cassandra/time_uuid.rb +7 -7
  123. data/lib/cassandra/tuple.rb +16 -8
  124. data/lib/cassandra/types.rb +20 -9
  125. data/lib/cassandra/udt.rb +32 -36
  126. data/lib/cassandra/util.rb +20 -13
  127. data/lib/cassandra/uuid.rb +22 -15
  128. data/lib/cassandra/uuid/generator.rb +7 -5
  129. data/lib/cassandra/version.rb +2 -2
  130. data/lib/datastax/cassandra.rb +1 -1
  131. metadata +5 -3
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -26,7 +26,12 @@ module Cassandra
26
26
  attr_reader :type, :timestamp, :payload
27
27
  attr_accessor :consistency, :retries
28
28
 
29
- def initialize(type, consistency, trace=false, serial_consistency = nil, timestamp = nil, payload = nil)
29
+ def initialize(type,
30
+ consistency,
31
+ trace = false,
32
+ serial_consistency = nil,
33
+ timestamp = nil,
34
+ payload = nil)
30
35
  super(0x0D, trace)
31
36
  @type = type
32
37
  @parts = []
@@ -60,7 +65,11 @@ module Cassandra
60
65
  buffer.append_short(@parts.size)
61
66
 
62
67
  @parts.each do |(statement_kind, *arguments)|
63
- __send__(:"write_#{statement_kind}", buffer, protocol_version, encoder, *arguments)
68
+ __send__(:"write_#{statement_kind}",
69
+ buffer,
70
+ protocol_version,
71
+ encoder,
72
+ *arguments)
64
73
  end
65
74
 
66
75
  buffer.append_consistency(@consistency)
@@ -80,10 +89,10 @@ module Cassandra
80
89
 
81
90
  def to_s
82
91
  type_str = case @type
83
- when LOGGED_TYPE then 'LOGGED'
84
- when UNLOGGED_TYPE then 'UNLOGGED'
85
- when COUNTER_TYPE then 'COUNTER'
86
- end
92
+ when LOGGED_TYPE then 'LOGGED'
93
+ when UNLOGGED_TYPE then 'UNLOGGED'
94
+ when COUNTER_TYPE then 'COUNTER'
95
+ end
87
96
  %(BATCH #{type_str} #{@parts.size} #{@consistency.to_s.upcase})
88
97
  end
89
98
 
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -35,9 +35,9 @@ module Cassandra
35
35
  end
36
36
 
37
37
  def eql?(rq)
38
- self.class === rq && rq.credentials.eql?(@credentials)
38
+ rq.is_a?(self.class) && rq.credentials.eql?(@credentials)
39
39
  end
40
- alias_method :==, :eql?
40
+ alias == eql?
41
41
 
42
42
  def hash
43
43
  @h ||= begin
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -19,14 +19,34 @@
19
19
  module Cassandra
20
20
  module Protocol
21
21
  class ExecuteRequest < Request
22
- attr_reader :metadata, :values, :request_metadata, :serial_consistency, :page_size, :paging_state, :timestamp, :payload
23
- attr_accessor :consistency, :retries, :id
22
+ attr_reader :metadata, :request_metadata, :page_size, :paging_state, :payload,
23
+ :serial_consistency, :timestamp, :values
24
+ attr_accessor :consistency, :id, :retries
24
25
 
25
- def initialize(id, metadata, values, request_metadata, consistency, serial_consistency=nil, page_size=nil, paging_state=nil, trace=false, timestamp = nil, payload = nil)
26
- raise ArgumentError, "Metadata for #{metadata.size} columns, but #{values.size} values given" if metadata.size != values.size
27
- raise ArgumentError, %(No such consistency: #{consistency.inspect}) if consistency.nil? || !CONSISTENCIES.include?(consistency)
28
- raise ArgumentError, %(No such consistency: #{serial_consistency.inspect}) unless serial_consistency.nil? || CONSISTENCIES.include?(serial_consistency)
29
- raise ArgumentError, %(Paging state given but no page size) if paging_state && !page_size
26
+ def initialize(id,
27
+ metadata,
28
+ values,
29
+ request_metadata,
30
+ consistency,
31
+ serial_consistency = nil,
32
+ page_size = nil,
33
+ paging_state = nil,
34
+ trace = false,
35
+ timestamp = nil,
36
+ payload = nil)
37
+ if metadata.size != values.size
38
+ raise ArgumentError, "Metadata for #{metadata.size} columns, but " \
39
+ "#{values.size} values given"
40
+ end
41
+ if consistency.nil? || !CONSISTENCIES.include?(consistency)
42
+ raise ArgumentError, %(No such consistency: #{consistency.inspect})
43
+ end
44
+ unless serial_consistency.nil? || CONSISTENCIES.include?(serial_consistency)
45
+ raise ArgumentError, %(No such consistency: #{serial_consistency.inspect})
46
+ end
47
+ if paging_state && !page_size
48
+ raise ArgumentError, %(Paging state given but no page size)
49
+ end
30
50
  super(10, trace)
31
51
  @id = id
32
52
  @metadata = metadata
@@ -54,19 +74,13 @@ module Cassandra
54
74
  flags |= 0x04 if @page_size
55
75
  flags |= 0x08 if @paging_state
56
76
  flags |= 0x10 if @serial_consistency
57
- if protocol_version > 2
58
- flags |= 0x20 if @timestamp
59
- end
77
+ flags |= 0x20 if protocol_version > 2 && @timestamp
60
78
  buffer.append(flags.chr)
61
- if @values.size > 0
62
- encoder.write_parameters(buffer, @values, @metadata)
63
- end
79
+ encoder.write_parameters(buffer, @values, @metadata) if @values.size > 0
64
80
  buffer.append_int(@page_size) if @page_size
65
81
  buffer.append_bytes(@paging_state) if @paging_state
66
82
  buffer.append_consistency(@serial_consistency) if @serial_consistency
67
- if protocol_version > 2
68
- buffer.append_timestamp(@timestamp) if @timestamp
69
- end
83
+ buffer.append_timestamp(@timestamp) if protocol_version > 2 && @timestamp
70
84
  else
71
85
  encoder.write_parameters(buffer, @values, @metadata)
72
86
  buffer.append_consistency(@consistency)
@@ -76,13 +90,20 @@ module Cassandra
76
90
 
77
91
  def to_s
78
92
  id = @id.each_byte.map { |x| x.to_s(16) }.join('')
79
- %(EXECUTE #{id} #@values #{@consistency.to_s.upcase})
93
+ %(EXECUTE #{id} #{@values} #{@consistency.to_s.upcase})
80
94
  end
81
95
 
82
96
  def eql?(rq)
83
- self.class === rq && rq.id == self.id && rq.metadata == self.metadata && rq.values == self.values && rq.consistency == self.consistency && rq.serial_consistency == self.serial_consistency && rq.page_size == self.page_size && rq.paging_state == self.paging_state
97
+ rq.is_a?(self.class) &&
98
+ rq.id == id &&
99
+ rq.metadata == metadata &&
100
+ rq.values == values &&
101
+ rq.consistency == consistency &&
102
+ rq.serial_consistency == serial_consistency &&
103
+ rq.page_size == page_size &&
104
+ rq.paging_state == paging_state
84
105
  end
85
- alias_method :==, :eql?
106
+ alias == eql?
86
107
 
87
108
  def hash
88
109
  @h ||= begin
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ module Cassandra
22
22
  attr_reader :cql, :payload
23
23
  attr_accessor :consistency, :retries
24
24
 
25
- def initialize(cql, trace=false, payload = nil)
25
+ def initialize(cql, trace = false, payload = nil)
26
26
  raise ArgumentError, 'No CQL given!' unless cql
27
27
  super(9, trace)
28
28
  @cql = cql
@@ -39,13 +39,13 @@ module Cassandra
39
39
  end
40
40
 
41
41
  def to_s
42
- %(PREPARE "#@cql")
42
+ %(PREPARE "#{@cql}")
43
43
  end
44
44
 
45
45
  def eql?(rq)
46
- self.class === rq && rq.cql == self.cql
46
+ rq.is_a?(self.class) && rq.cql == cql
47
47
  end
48
- alias_method :==, :eql?
48
+ alias == eql?
49
49
 
50
50
  def hash
51
51
  @h ||= begin
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -19,10 +19,21 @@
19
19
  module Cassandra
20
20
  module Protocol
21
21
  class QueryRequest < Request
22
- attr_reader :cql, :values, :type_hints, :serial_consistency, :page_size, :paging_state, :timestamp, :payload
22
+ attr_reader :cql, :page_size, :paging_state, :payload, :serial_consistency,
23
+ :timestamp, :type_hints, :values
23
24
  attr_accessor :consistency, :retries
24
25
 
25
- def initialize(cql, values, type_hints, consistency, serial_consistency = nil, page_size = nil, paging_state = nil, trace = false, names = EMPTY_LIST, timestamp = nil, payload = nil)
26
+ def initialize(cql,
27
+ values,
28
+ type_hints,
29
+ consistency,
30
+ serial_consistency = nil,
31
+ page_size = nil,
32
+ paging_state = nil,
33
+ trace = false,
34
+ names = EMPTY_LIST,
35
+ timestamp = nil,
36
+ payload = nil)
26
37
  super(7, trace)
27
38
  @cql = cql
28
39
  @values = values
@@ -48,14 +59,10 @@ module Cassandra
48
59
  flags |= 0x04 if @page_size
49
60
  flags |= 0x08 if @paging_state
50
61
  flags |= 0x10 if @serial_consistency
51
- if protocol_version > 2
52
- flags |= 0x20 if @timestamp
53
- end
62
+ flags |= 0x20 if protocol_version > 2 && @timestamp
54
63
  if @values && @values.size > 0
55
64
  flags |= 0x01
56
- if protocol_version > 2
57
- flags |= 0x40 unless @names.empty?
58
- end
65
+ flags |= 0x40 if protocol_version > 2 && !@names.empty?
59
66
  buffer.append(flags.chr)
60
67
  encoder.write_parameters(buffer, @values, @type_hints, @names)
61
68
  else
@@ -64,28 +71,26 @@ module Cassandra
64
71
  buffer.append_int(@page_size) if @page_size
65
72
  buffer.append_bytes(@paging_state) if @paging_state
66
73
  buffer.append_consistency(@serial_consistency) if @serial_consistency
67
- if protocol_version > 2
68
- buffer.append_timestamp(@timestamp) if @timestamp
69
- end
74
+ buffer.append_timestamp(@timestamp) if protocol_version > 2 && @timestamp
70
75
  end
71
76
  buffer
72
77
  end
73
78
 
74
79
  def to_s
75
- %(QUERY "#@cql" #{@consistency.to_s.upcase})
80
+ %(QUERY "#{@cql}" #{@consistency.to_s.upcase})
76
81
  end
77
82
 
78
83
  def eql?(rq)
79
- self.class === rq &&
80
- rq.cql == self.cql &&
81
- rq.values == self.values &&
82
- rq.type_hints == self.type_hints &&
83
- rq.consistency == self.consistency &&
84
- rq.serial_consistency == self.serial_consistency &&
85
- rq.page_size == self.page_size &&
86
- rq.paging_state == self.paging_state
84
+ rq.is_a?(self.class) &&
85
+ rq.cql == cql &&
86
+ rq.values == values &&
87
+ rq.type_hints == type_hints &&
88
+ rq.consistency == consistency &&
89
+ rq.serial_consistency == serial_consistency &&
90
+ rq.page_size == page_size &&
91
+ rq.paging_state == paging_state
87
92
  end
88
- alias_method :==, :eql?
93
+ alias == eql?
89
94
 
90
95
  def hash
91
96
  @h ||= begin
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ module Cassandra
31
31
  end
32
32
 
33
33
  def to_s
34
- %(REGISTER #@events)
34
+ %(REGISTER #{@events})
35
35
  end
36
36
  end
37
37
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -21,9 +21,11 @@ module Cassandra
21
21
  class StartupRequest < Request
22
22
  attr_reader :options
23
23
 
24
- def initialize(cql_version, compression=nil)
24
+ def initialize(cql_version, compression = nil)
25
25
  super(1)
26
- raise ArgumentError, "Invalid CQL version: #{cql_version.inspect}" unless cql_version
26
+ unless cql_version
27
+ raise ArgumentError, "Invalid CQL version: #{cql_version.inspect}"
28
+ end
27
29
  @options = {CQL_VERSION => cql_version}
28
30
  @options[COMPRESSION] = compression if compression
29
31
  end
@@ -37,7 +39,7 @@ module Cassandra
37
39
  end
38
40
 
39
41
  def to_s
40
- %(STARTUP #@options)
42
+ %(STARTUP #{@options})
41
43
  end
42
44
 
43
45
  private
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -26,4 +26,4 @@ module Cassandra
26
26
  ]
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -29,7 +29,17 @@ module Cassandra
29
29
  end
30
30
 
31
31
  def to_error(keyspace, statement, options, hosts, consistency, retries)
32
- Errors::AlreadyExistsError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries, @keyspace, @table)
32
+ Errors::AlreadyExistsError.new(@message,
33
+ @custom_payload,
34
+ @warnings,
35
+ keyspace,
36
+ statement,
37
+ options,
38
+ hosts,
39
+ consistency,
40
+ retries,
41
+ @keyspace,
42
+ @table)
33
43
  end
34
44
 
35
45
  def to_s
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
4
+ # Copyright 2013-2016 DataStax, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -27,23 +27,111 @@ module Cassandra
27
27
 
28
28
  def to_s
29
29
  hex_code = @code.to_s(16).rjust(4, '0').upcase
30
- %(ERROR 0x#{hex_code} "#@message")
30
+ %(ERROR 0x#{hex_code} "#{@message}")
31
31
  end
32
32
 
33
33
  def to_error(keyspace, statement, options, hosts, consistency, retries)
34
34
  case @code
35
- when 0x0000 then Errors::ServerError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
36
- when 0x000A then Errors::ProtocolError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
37
- when 0x0100 then Errors::AuthenticationError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
38
- when 0x1001 then Errors::OverloadedError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
39
- when 0x1002 then Errors::IsBootstrappingError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
40
- when 0x1003 then Errors::TruncateError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
41
- when 0x2000 then Errors::SyntaxError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
42
- when 0x2100 then Errors::UnauthorizedError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
43
- when 0x2200 then Errors::InvalidError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
44
- when 0x2300 then Errors::ConfigurationError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
35
+ when 0x0000 then Errors::ServerError.new(@message,
36
+ @custom_payload,
37
+ @warnings,
38
+ keyspace,
39
+ statement,
40
+ options,
41
+ hosts,
42
+ consistency,
43
+ retries)
44
+ when 0x000A then Errors::ProtocolError.new(@message,
45
+ @custom_payload,
46
+ @warnings,
47
+ keyspace,
48
+ statement,
49
+ options,
50
+ hosts,
51
+ consistency,
52
+ retries)
53
+ when 0x0100 then Errors::AuthenticationError.new(@message,
54
+ @custom_payload,
55
+ @warnings,
56
+ keyspace,
57
+ statement,
58
+ options,
59
+ hosts,
60
+ consistency,
61
+ retries)
62
+ when 0x1001 then Errors::OverloadedError.new(@message,
63
+ @custom_payload,
64
+ @warnings,
65
+ keyspace,
66
+ statement,
67
+ options,
68
+ hosts,
69
+ consistency,
70
+ retries)
71
+ when 0x1002 then Errors::IsBootstrappingError.new(@message,
72
+ @custom_payload,
73
+ @warnings,
74
+ keyspace,
75
+ statement,
76
+ options,
77
+ hosts,
78
+ consistency,
79
+ retries)
80
+ when 0x1003 then Errors::TruncateError.new(@message,
81
+ @custom_payload,
82
+ @warnings,
83
+ keyspace,
84
+ statement,
85
+ options,
86
+ hosts,
87
+ consistency,
88
+ retries)
89
+ when 0x2000 then Errors::SyntaxError.new(@message,
90
+ @custom_payload,
91
+ @warnings,
92
+ keyspace,
93
+ statement,
94
+ options,
95
+ hosts,
96
+ consistency,
97
+ retries)
98
+ when 0x2100 then Errors::UnauthorizedError.new(@message,
99
+ @custom_payload,
100
+ @warnings,
101
+ keyspace,
102
+ statement,
103
+ options,
104
+ hosts,
105
+ consistency,
106
+ retries)
107
+ when 0x2200 then Errors::InvalidError.new(@message,
108
+ @custom_payload,
109
+ @warnings,
110
+ keyspace,
111
+ statement,
112
+ options,
113
+ hosts,
114
+ consistency,
115
+ retries)
116
+ when 0x2300 then Errors::ConfigurationError.new(@message,
117
+ @custom_payload,
118
+ @warnings,
119
+ keyspace,
120
+ statement,
121
+ options,
122
+ hosts,
123
+ consistency,
124
+ retries)
45
125
  else
46
- Errors::ServerError.new(@message, @custom_payload, @warnings, keyspace, statement, options, hosts, consistency, retries)
126
+ Errors::ServerError.new(@message,
127
+ @custom_payload,
128
+ @warnings,
129
+ keyspace,
130
+ statement,
131
+ options,
132
+ hosts,
133
+ consistency,
134
+ retries)
47
135
  end
48
136
  end
49
137