aerospike 2.13.0 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -1
- data/lib/aerospike.rb +14 -0
- data/lib/aerospike/cdt/bit_operation.rb +376 -0
- data/lib/aerospike/cdt/bit_overflow_action.rb +46 -0
- data/lib/aerospike/cdt/bit_policy.rb +36 -0
- data/lib/aerospike/cdt/bit_resize_flags.rb +44 -0
- data/lib/aerospike/cdt/bit_write_flags.rb +51 -0
- data/lib/aerospike/cdt/context.rb +113 -0
- data/lib/aerospike/cdt/hll_operation.rb +200 -0
- data/lib/aerospike/cdt/hll_policy.rb +34 -0
- data/lib/aerospike/cdt/hll_write_flags.rb +53 -0
- data/lib/aerospike/cdt/list_operation.rb +155 -96
- data/lib/aerospike/cdt/list_order.rb +7 -0
- data/lib/aerospike/cdt/list_sort_flags.rb +10 -2
- data/lib/aerospike/cdt/map_operation.rb +179 -92
- data/lib/aerospike/cdt/map_order.rb +3 -3
- data/lib/aerospike/client.rb +24 -7
- data/lib/aerospike/cluster.rb +47 -0
- data/lib/aerospike/cluster/rack_parser.rb +117 -0
- data/lib/aerospike/command/batch_direct_command.rb +1 -0
- data/lib/aerospike/command/batch_index_command.rb +1 -0
- data/lib/aerospike/command/command.rb +76 -7
- data/lib/aerospike/command/multi_command.rb +44 -1
- data/lib/aerospike/command/read_command.rb +34 -2
- data/lib/aerospike/command/touch_command.rb +34 -1
- data/lib/aerospike/features.rb +5 -0
- data/lib/aerospike/node.rb +18 -1
- data/lib/aerospike/node/rebalance.rb +50 -0
- data/lib/aerospike/node/refresh/info.rb +4 -1
- data/lib/aerospike/node/refresh/racks.rb +47 -0
- data/lib/aerospike/node/refresh/reset.rb +1 -0
- data/lib/aerospike/node/verify/rebalance_generation.rb +43 -0
- data/lib/aerospike/operation.rb +7 -2
- data/lib/aerospike/policy/client_policy.rb +15 -0
- data/lib/aerospike/policy/policy.rb +11 -3
- data/lib/aerospike/policy/replica.rb +7 -0
- data/lib/aerospike/result_code.rb +102 -0
- data/lib/aerospike/socket/base.rb +3 -2
- data/lib/aerospike/utils/buffer.rb +13 -3
- data/lib/aerospike/utils/unpacker.rb +2 -2
- data/lib/aerospike/value/particle_type.rb +1 -1
- data/lib/aerospike/value/value.rb +107 -5
- data/lib/aerospike/version.rb +1 -1
- metadata +15 -2
@@ -24,7 +24,7 @@ module Aerospike
|
|
24
24
|
class Policy
|
25
25
|
|
26
26
|
attr_accessor :priority, :timeout, :max_retries, :sleep_between_retries, :consistency_level,
|
27
|
-
:predexp, :fail_on_filtered_out, :replica
|
27
|
+
:predexp, :fail_on_filtered_out, :replica, :use_compression
|
28
28
|
|
29
29
|
def initialize(opt={})
|
30
30
|
# Container object for transaction policy attributes used in all database
|
@@ -89,9 +89,17 @@ module Aerospike
|
|
89
89
|
# to the node containing the key's master partition.
|
90
90
|
#
|
91
91
|
# Default to sending read commands to the node containing the key's master partition.
|
92
|
-
@replica = opt[:replica] || Aerospike::Replica::MASTER
|
92
|
+
@replica = opt[:replica] || Aerospike::Replica::MASTER
|
93
93
|
|
94
|
-
|
94
|
+
# Use zlib compression on write or batch read commands when the command buffer size is greater
|
95
|
+
# than 128 bytes. In addition, tell the server to compress its response on read commands.
|
96
|
+
# The server response compression threshold is also 128 bytes.
|
97
|
+
#
|
98
|
+
# This option will increase cpu and memory usage (for extra compressed buffers), but
|
99
|
+
# decrease the size of data sent over the network.
|
100
|
+
@use_compression = opt[:use_compression] || false
|
101
|
+
|
102
|
+
# Transaction timeout.
|
95
103
|
# This timeout is used to set the socket timeout and is also sent to the
|
96
104
|
# server along with the transaction in the wire protocol.
|
97
105
|
# Default to no timeout (0).
|
@@ -28,6 +28,13 @@ module Aerospike
|
|
28
28
|
# Policy#retryOnTimeout is true, try nodes containing prole partition.
|
29
29
|
SEQUENCE = 2
|
30
30
|
|
31
|
+
# Try node on the same rack as the client first. If there are no nodes on the
|
32
|
+
# same rack, use SEQUENCE instead.
|
33
|
+
#
|
34
|
+
# ClientPolicy#rack_aware, ClientPolicy#rack_id, and server rack
|
35
|
+
# configuration must also be set to enable this functionality.
|
36
|
+
PREFER_RACK = 3
|
37
|
+
|
31
38
|
# Distribute reads across all nodes in cluster in round-robin fashion.
|
32
39
|
# This option is useful when the replication factor equals the number
|
33
40
|
# of nodes in the cluster and the overhead of requesting proles is not desired.
|
@@ -60,6 +60,10 @@ module Aerospike
|
|
60
60
|
# exists.
|
61
61
|
KEY_EXISTS_ERROR = 5
|
62
62
|
|
63
|
+
# Bin already exists on a create-only operation.
|
64
|
+
BIN_EXISTS_ERROR = 6
|
65
|
+
|
66
|
+
|
63
67
|
# Expected cluster ID was not received.
|
64
68
|
CLUSTER_KEY_MISMATCH = 7
|
65
69
|
|
@@ -91,6 +95,9 @@ module Aerospike
|
|
91
95
|
# Unsupported Server Feature (e.g. Scan + UDF)
|
92
96
|
UNSUPPORTED_FEATURE = 16
|
93
97
|
|
98
|
+
# Bin not found on update-only operation.
|
99
|
+
BIN_NOT_FOUND = 17
|
100
|
+
|
94
101
|
# Specified bin name does not exist in record.
|
95
102
|
DEVICE_OVERLOAD = 18
|
96
103
|
|
@@ -125,8 +132,13 @@ module Aerospike
|
|
125
132
|
# There are no more records left for query.
|
126
133
|
QUERY_END = 50
|
127
134
|
|
135
|
+
# Security functionality not supported by connected server.
|
128
136
|
SECURITY_NOT_SUPPORTED = 51
|
137
|
+
|
138
|
+
# Security functionality not enabled by connected server.
|
129
139
|
SECURITY_NOT_ENABLED = 52
|
140
|
+
|
141
|
+
# Security scheme not supported.
|
130
142
|
SECURITY_SCHEME_NOT_SUPPORTED = 53
|
131
143
|
|
132
144
|
# Administration command is invalid.
|
@@ -155,6 +167,9 @@ module Aerospike
|
|
155
167
|
# Security credential is invalid.
|
156
168
|
INVALID_CREDENTIAL = 65
|
157
169
|
|
170
|
+
# Expired session token.
|
171
|
+
EXPIRED_SESSION = 66
|
172
|
+
|
158
173
|
# Role name is invalid.
|
159
174
|
INVALID_ROLE = 70
|
160
175
|
|
@@ -164,15 +179,48 @@ module Aerospike
|
|
164
179
|
# Privilege is invalid.
|
165
180
|
INVALID_PRIVILEGE = 72
|
166
181
|
|
182
|
+
# Specified IP whitelist is invalid.
|
183
|
+
INVALID_WHITELIST = 73
|
184
|
+
|
167
185
|
# User must be authentication before performing database operations.
|
168
186
|
NOT_AUTHENTICATED = 80
|
169
187
|
|
170
188
|
# User does not posses the required role to perform the database operation.
|
171
189
|
ROLE_VIOLATION = 81
|
172
190
|
|
191
|
+
# Client IP address is not on the IP whitelist.
|
192
|
+
NOT_WHITELISTED = 82
|
193
|
+
|
194
|
+
# LDAP feature not enabled on server.
|
195
|
+
LDAP_NOT_ENABLED = 90
|
196
|
+
|
197
|
+
# Error in LDAP setup.
|
198
|
+
LDAP_SETUP = 91
|
199
|
+
|
200
|
+
# Error in LDAP TLS setup.
|
201
|
+
LDAP_TLS_SETUP = 92
|
202
|
+
|
203
|
+
# Error authenticating LDAP user.
|
204
|
+
LDAP_AUTHENTICATION = 93
|
205
|
+
|
206
|
+
# Error querying LDAP server.
|
207
|
+
LDAP_QUERY = 94
|
208
|
+
|
173
209
|
# A user defined function returned an error code.
|
174
210
|
UDF_BAD_RESPONSE = 100
|
175
211
|
|
212
|
+
# Batch functionality has been disabled by configuring the batch-index-thread=0.
|
213
|
+
BATCH_DISABLED = 150
|
214
|
+
|
215
|
+
# Batch max requests has been exceeded.
|
216
|
+
BATCH_MAX_REQUESTS = 151
|
217
|
+
|
218
|
+
# All batch queues are full.
|
219
|
+
BATCH_QUEUES_FULL = 152
|
220
|
+
|
221
|
+
# GeoJSON is malformed or not supported.
|
222
|
+
INVALID_GEOJSON = 160
|
223
|
+
|
176
224
|
# Secondary index already exists.
|
177
225
|
INDEX_FOUND = 200
|
178
226
|
|
@@ -206,6 +254,12 @@ module Aerospike
|
|
206
254
|
# Generic query error.
|
207
255
|
QUERY_GENERIC = 213
|
208
256
|
|
257
|
+
# Network error. Query is aborted.
|
258
|
+
QUERY_NET_IO = 214
|
259
|
+
|
260
|
+
# Internal error.
|
261
|
+
QUERY_DUPLICATE = 215
|
262
|
+
|
209
263
|
def self.message(code)
|
210
264
|
case code
|
211
265
|
when COMMAND_REJECTED
|
@@ -244,6 +298,9 @@ module Aerospike
|
|
244
298
|
when KEY_EXISTS_ERROR
|
245
299
|
"Key already exists"
|
246
300
|
|
301
|
+
when BIN_EXISTS_ERROR
|
302
|
+
"Bin already exists on a create-only operation"
|
303
|
+
|
247
304
|
when CLUSTER_KEY_MISMATCH
|
248
305
|
"Cluster key mismatch"
|
249
306
|
|
@@ -274,6 +331,9 @@ module Aerospike
|
|
274
331
|
when UNSUPPORTED_FEATURE
|
275
332
|
"Unsupported Server Feature"
|
276
333
|
|
334
|
+
when BIN_NOT_FOUND
|
335
|
+
"Bin not found on update-only operation"
|
336
|
+
|
277
337
|
when DEVICE_OVERLOAD
|
278
338
|
"Device overload"
|
279
339
|
|
@@ -343,6 +403,9 @@ module Aerospike
|
|
343
403
|
when INVALID_CREDENTIAL
|
344
404
|
"Invalid credential"
|
345
405
|
|
406
|
+
when EXPIRED_SESSION
|
407
|
+
"Expired session token"
|
408
|
+
|
346
409
|
when INVALID_ROLE
|
347
410
|
"Invalid role"
|
348
411
|
|
@@ -352,15 +415,48 @@ module Aerospike
|
|
352
415
|
when INVALID_PRIVILEGE
|
353
416
|
"Invalid privilege"
|
354
417
|
|
418
|
+
when INVALID_WHITELIST
|
419
|
+
"Specified IP whitelist is invalid"
|
420
|
+
|
355
421
|
when NOT_AUTHENTICATED
|
356
422
|
"Not authenticated"
|
357
423
|
|
358
424
|
when ROLE_VIOLATION
|
359
425
|
"Role violation"
|
360
426
|
|
427
|
+
when NOT_WHITELISTED
|
428
|
+
"Client IP address is not on the IP whitelist"
|
429
|
+
|
430
|
+
when LDAP_NOT_ENABLED
|
431
|
+
"LDAP feature not enabled on server"
|
432
|
+
|
433
|
+
when LDAP_SETUP
|
434
|
+
"Error in LDAP setup"
|
435
|
+
|
436
|
+
when LDAP_TLS_SETUP
|
437
|
+
"Error in LDAP TLS setup"
|
438
|
+
|
439
|
+
when LDAP_AUTHENTICATION
|
440
|
+
"Error authenticating LDAP user"
|
441
|
+
|
442
|
+
when LDAP_QUERY
|
443
|
+
"Error querying LDAP server"
|
444
|
+
|
361
445
|
when UDF_BAD_RESPONSE
|
362
446
|
"UDF d error"
|
363
447
|
|
448
|
+
when BATCH_DISABLED
|
449
|
+
"Batch functionality has been disabled by configuring the batch-index-thread=0"
|
450
|
+
|
451
|
+
when BATCH_MAX_REQUESTS
|
452
|
+
"Batch max requests has been exceeded"
|
453
|
+
|
454
|
+
when BATCH_QUEUES_FULL
|
455
|
+
"All batch queues are full"
|
456
|
+
|
457
|
+
when INVALID_GEOJSON
|
458
|
+
"GeoJSON is malformed or not supported"
|
459
|
+
|
364
460
|
when INDEX_FOUND
|
365
461
|
"Index already exists"
|
366
462
|
|
@@ -394,6 +490,12 @@ module Aerospike
|
|
394
490
|
when QUERY_GENERIC
|
395
491
|
"Query error"
|
396
492
|
|
493
|
+
when QUERY_NET_IO
|
494
|
+
"Network error. Query is aborted"
|
495
|
+
|
496
|
+
when QUERY_DUPLICATE
|
497
|
+
"Internal query error"
|
498
|
+
|
397
499
|
else
|
398
500
|
"ResultCode #{code} unknown in the client. Please file a github issue."
|
399
501
|
end # case
|
@@ -25,13 +25,14 @@ module Aerospike
|
|
25
25
|
@timeout = nil
|
26
26
|
end
|
27
27
|
|
28
|
-
def read(buffer, length)
|
28
|
+
def read(buffer, length, offset = 0)
|
29
29
|
bytes_read = 0
|
30
30
|
until bytes_read >= length
|
31
31
|
result = read_from_socket(length - bytes_read)
|
32
|
-
buffer.write_binary(result, bytes_read)
|
32
|
+
buffer.write_binary(result, offset + bytes_read)
|
33
33
|
bytes_read += result.bytesize
|
34
34
|
end
|
35
|
+
bytes_read
|
35
36
|
end
|
36
37
|
|
37
38
|
def read_from_socket(length)
|
@@ -42,9 +42,9 @@ module Aerospike
|
|
42
42
|
DEFAULT_BUFFER_SIZE = 16 * 1024
|
43
43
|
MAX_BUFFER_SIZE = 10 * 1024 * 1024
|
44
44
|
|
45
|
-
def initialize(size=DEFAULT_BUFFER_SIZE)
|
46
|
-
@buf = "%0#{size}d" % 0
|
47
|
-
|
45
|
+
def initialize(size=DEFAULT_BUFFER_SIZE, buf = nil)
|
46
|
+
@buf = (buf ? buf : ("%0#{size}d" % 0))
|
47
|
+
@buf.force_encoding('binary')
|
48
48
|
@slice_end = @buf.bytesize
|
49
49
|
end
|
50
50
|
|
@@ -61,6 +61,10 @@ module Aerospike
|
|
61
61
|
end
|
62
62
|
alias_method :length, :size
|
63
63
|
|
64
|
+
def eat!(n)
|
65
|
+
@buf.replace(@buf[n..-1])
|
66
|
+
end
|
67
|
+
|
64
68
|
def resize(length)
|
65
69
|
if @buf.bytesize < length
|
66
70
|
@buf.concat("%0#{length - @buf.bytesize}d" % 0)
|
@@ -156,6 +160,12 @@ module Aerospike
|
|
156
160
|
@buf[0..@slice_end-1]
|
157
161
|
end
|
158
162
|
|
163
|
+
def reset
|
164
|
+
for i in 0..@buf.size-1
|
165
|
+
@buf[i] = ' '
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
159
169
|
def dump(from=nil, to=nil)
|
160
170
|
from ||= 0
|
161
171
|
to ||= @slice_end - 1
|
@@ -23,14 +23,24 @@ module Aerospike
|
|
23
23
|
# Polymorphic value classes used to efficiently serialize objects into the wire protocol.
|
24
24
|
class Value #:nodoc:
|
25
25
|
|
26
|
-
def self.of(value)
|
26
|
+
def self.of(value, allow_64bits = false)
|
27
27
|
case value
|
28
28
|
when Integer
|
29
|
-
if
|
30
|
-
|
29
|
+
if !allow_64bits
|
30
|
+
if value.bit_length < 64
|
31
|
+
res = IntegerValue.new(value)
|
32
|
+
else
|
33
|
+
# big nums > 2**63 are not supported
|
34
|
+
raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported with more than 64 bits.")
|
35
|
+
end
|
31
36
|
else
|
32
|
-
#
|
33
|
-
|
37
|
+
# used in bitwise operations
|
38
|
+
if value.bit_length <= 64
|
39
|
+
res = IntegerValue.new(value)
|
40
|
+
else
|
41
|
+
# nums with more than 64 bits are not supported
|
42
|
+
raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported with more than 64 bits.")
|
43
|
+
end
|
34
44
|
end
|
35
45
|
when Float
|
36
46
|
res = FloatValue.new(value)
|
@@ -48,6 +58,8 @@ module Aerospike
|
|
48
58
|
res = GeoJSONValue.new(value)
|
49
59
|
when nil
|
50
60
|
res = NULL
|
61
|
+
when TrueClass, FalseClass
|
62
|
+
res = BoolValue.new(value)
|
51
63
|
else
|
52
64
|
# throw an exception for anything that is not supported.
|
53
65
|
raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported.")
|
@@ -526,6 +538,49 @@ module Aerospike
|
|
526
538
|
|
527
539
|
end
|
528
540
|
|
541
|
+
# #######################################/
|
542
|
+
|
543
|
+
# HLLValue value. Encapsulates a HyperLogLog value.
|
544
|
+
# Supported by Aerospike server version 4.9 and later.
|
545
|
+
class HLLValue < Value #:nodoc:
|
546
|
+
|
547
|
+
def initialize(value)
|
548
|
+
@bytes = value
|
549
|
+
@bytes.force_encoding('binary')
|
550
|
+
|
551
|
+
self
|
552
|
+
end
|
553
|
+
|
554
|
+
def type
|
555
|
+
Aerospike::ParticleType::HLL
|
556
|
+
end
|
557
|
+
|
558
|
+
def get
|
559
|
+
self
|
560
|
+
end
|
561
|
+
|
562
|
+
def to_s
|
563
|
+
@bytes.to_s
|
564
|
+
end
|
565
|
+
|
566
|
+
def to_bytes
|
567
|
+
@bytes
|
568
|
+
end
|
569
|
+
|
570
|
+
def estimate_size
|
571
|
+
@bytes.bytesize
|
572
|
+
end
|
573
|
+
|
574
|
+
def write(buffer, offset)
|
575
|
+
buffer.write_binary(@bytes, offset)
|
576
|
+
end
|
577
|
+
|
578
|
+
def pack(packer)
|
579
|
+
packer.write(Aerospike::ParticleType::BLOB.chr + @bytes)
|
580
|
+
end
|
581
|
+
|
582
|
+
end
|
583
|
+
|
529
584
|
#######################################
|
530
585
|
|
531
586
|
def self.encoding
|
@@ -572,6 +627,10 @@ module Aerospike
|
|
572
627
|
hdrsz = 1 + 2 + (ncells * 8)
|
573
628
|
Aerospike::GeoJSON.new(buf.read(offset + hdrsz, length - hdrsz))
|
574
629
|
|
630
|
+
when Aerospike::ParticleType::HLL
|
631
|
+
bytes = buf.read(offset,length)
|
632
|
+
Aerospike::HLLValue.new(bytes)
|
633
|
+
|
575
634
|
else
|
576
635
|
nil
|
577
636
|
end
|
@@ -593,4 +652,47 @@ module Aerospike
|
|
593
652
|
nil
|
594
653
|
end
|
595
654
|
end
|
655
|
+
|
656
|
+
private
|
657
|
+
|
658
|
+
#######################################
|
659
|
+
|
660
|
+
# Boolean value.
|
661
|
+
# This is private, and only used internally for bitwise CDTs
|
662
|
+
class BoolValue < Value #:nodoc:
|
663
|
+
|
664
|
+
def initialize(val)
|
665
|
+
@value = val || false
|
666
|
+
self
|
667
|
+
end
|
668
|
+
|
669
|
+
def estimate_size
|
670
|
+
1
|
671
|
+
end
|
672
|
+
|
673
|
+
def write(buffer, offset)
|
674
|
+
raise Exception.new("Unreachable")
|
675
|
+
end
|
676
|
+
|
677
|
+
def pack(packer)
|
678
|
+
packer.write(@value)
|
679
|
+
end
|
680
|
+
|
681
|
+
def type
|
682
|
+
raise Exception.new("Unreachable")
|
683
|
+
end
|
684
|
+
|
685
|
+
def get
|
686
|
+
@value
|
687
|
+
end
|
688
|
+
|
689
|
+
def to_bytes
|
690
|
+
raise Exception.new("Unreachable")
|
691
|
+
end
|
692
|
+
|
693
|
+
def to_s
|
694
|
+
@value.to_s
|
695
|
+
end
|
696
|
+
|
697
|
+
end # BoolValue
|
596
698
|
end # module
|