aerospike 2.6.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +3 -1
  4. data/lib/aerospike.rb +9 -5
  5. data/lib/aerospike/client.rb +101 -83
  6. data/lib/aerospike/cluster.rb +11 -50
  7. data/lib/aerospike/cluster/create_connection.rb +1 -1
  8. data/lib/aerospike/cluster/find_nodes_to_remove.rb +66 -0
  9. data/lib/aerospike/cluster/partition.rb +5 -2
  10. data/lib/aerospike/command/batch_direct_command.rb +104 -0
  11. data/lib/aerospike/command/batch_direct_exists_command.rb +51 -0
  12. data/lib/aerospike/command/batch_direct_node.rb +40 -0
  13. data/lib/aerospike/command/batch_index_command.rb +119 -0
  14. data/lib/aerospike/command/batch_index_exists_command.rb +45 -0
  15. data/lib/aerospike/command/batch_index_node.rb +52 -0
  16. data/lib/aerospike/command/batch_item.rb +18 -47
  17. data/lib/aerospike/command/command.rb +6 -65
  18. data/lib/aerospike/command/field_type.rb +13 -10
  19. data/lib/aerospike/command/{batch_command.rb → multi_command.rb} +29 -9
  20. data/lib/aerospike/command/read_command.rb +4 -2
  21. data/lib/aerospike/command/single_command.rb +6 -9
  22. data/lib/aerospike/connection/create.rb +3 -3
  23. data/lib/aerospike/host/parse.rb +28 -2
  24. data/lib/aerospike/node.rb +6 -2
  25. data/lib/aerospike/node/refresh/friends.rb +1 -1
  26. data/lib/aerospike/node/refresh/peers.rb +1 -1
  27. data/lib/aerospike/node_validator.rb +3 -3
  28. data/lib/aerospike/peers.rb +4 -0
  29. data/lib/aerospike/peers/parse.rb +26 -6
  30. data/lib/aerospike/policy/batch_policy.rb +25 -15
  31. data/lib/aerospike/policy/client_policy.rb +2 -2
  32. data/lib/aerospike/policy/query_policy.rb +25 -12
  33. data/lib/aerospike/policy/scan_policy.rb +39 -16
  34. data/lib/aerospike/query/stream_command.rb +6 -5
  35. data/lib/aerospike/record.rb +4 -3
  36. data/lib/aerospike/socket/ssl.rb +13 -13
  37. data/lib/aerospike/socket/tcp.rb +8 -1
  38. data/lib/aerospike/utils/string_parser.rb +7 -3
  39. data/lib/aerospike/version.rb +1 -1
  40. metadata +11 -7
  41. data/lib/aerospike/command/batch_command_exists.rb +0 -93
  42. data/lib/aerospike/command/batch_command_get.rb +0 -84
  43. data/lib/aerospike/command/batch_node.rb +0 -82
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cf4004182c5166b136433e8be338b9187718684c2783808d18b3ed31f1dbd17
4
- data.tar.gz: 3a18cdde5294fb88ee0d4d710fb870c29db3273f5e29bd2d2ea92fd824857f00
3
+ metadata.gz: 2351767e50e34f9aec1da0eb58c6d5fb5b8a39f83d3aa2d2f9c88ed5d446b15a
4
+ data.tar.gz: 7104f9494a571dcf34a4809f0e4331acc76981649a53df06dd5f5c3ceddbcd0d
5
5
  SHA512:
6
- metadata.gz: ab75f0c1d0d57c37f3d3f16966a27017b706067e414306c25a3388ad4a02571cdb18b1f019d67472e35386ad659db1d23d8685664ea6a7f2279e904b4c52383b
7
- data.tar.gz: 501dabb13c9eb471e83cbda40aa22f2df7ae7e2c6083d447917a02e71017b9b64abe4bbff37798ef2517bced052c17347a109c842b97ab6b16f921939c6ebe23
6
+ metadata.gz: a48674b7bf187a0660d0a2b0e9c070f1b9f270d31dda522a2264cb2821470c193d2714944f35e4c65c2f05ee06fc299894d4721e348b8c986d5124f8d95ae2ef
7
+ data.tar.gz: febaffccf38b34e5b6653ce078630eacf73fead0d2cd840d09a87016a3adc3a8ff26a00460031a18d52d8a3bda6e9def1c7259917291f79857e020212812ebb1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ v2.7.0 / 2018-04-12
2
+ ===================
3
+
4
+ * **New Features**
5
+ * Batch Index protocol support. Thanks to [@deenbandhu-agarwal](https://github.com/deenbandhu-agarwal)! [[#61](https://github.com/aerospike/aerospike-client-ruby/pull/61)]
6
+ * Memory optimization: Avoid easy allocations. Thanks to [@wallin](https://github.com/wallin)! [[#62](https://github.com/aerospike/aerospike-client-ruby/pull/62)]
7
+ * New node removal strategy. Thanks to [@wallin](https://github.com/wallin)! [[#63](https://github.com/aerospike/aerospike-client-ruby/pull/63)]
8
+ * Support for IPv6. Requires Aerospike Enterprise Edition v3.10 or later. Thanks to [@wallin](https://github.com/wallin)! [[#65](https://github.com/aerospike/aerospike-client-ruby/pull/65)]
9
+
1
10
  v2.6.0 / 2018-03-27
2
11
  ===================
3
12
 
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # Aerospike Ruby Client [![travis][travis-image]][travis-url] [![gem][gem-image]][gem-url]
1
+ # Aerospike Ruby Client [![travis][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url] [![gem][gem-image]][gem-url]
2
2
 
3
3
  [travis-image]: https://travis-ci.org/aerospike/aerospike-client-ruby.svg?branch=master
4
4
  [travis-url]: https://travis-ci.org/aerospike/aerospike-client-ruby
5
+ [codecov-image]: https://codecov.io/gh/aerospike/aerospike-client-ruby/branch/master/graph/badge.svg
6
+ [codecov-url]: https://codecov.io/gh/aerospike/aerospike-client-ruby
5
7
  [gem-image]: https://img.shields.io/gem/v/aerospike.svg
6
8
  [gem-url]: https://rubygems.org/gems/aerospike
7
9
 
data/lib/aerospike.rb CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # Copyright 2014-2018 Aerospike, Inc.
3
2
  #
4
3
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
@@ -41,7 +40,8 @@ require 'aerospike/version'
41
40
  require 'aerospike/value/particle_type'
42
41
  require 'aerospike/value/value'
43
42
  require 'aerospike/command/single_command'
44
- require 'aerospike/command/batch_node'
43
+ require 'aerospike/command/batch_direct_node'
44
+ require 'aerospike/command/batch_index_node'
45
45
  require 'aerospike/command/field_type'
46
46
  require 'aerospike/command/command'
47
47
  require 'aerospike/command/execute_command'
@@ -49,11 +49,13 @@ require 'aerospike/command/write_command'
49
49
  require 'aerospike/command/batch_item'
50
50
  require 'aerospike/command/operate_command'
51
51
  require 'aerospike/command/exists_command'
52
- require 'aerospike/command/batch_command_get'
53
- require 'aerospike/command/batch_command'
52
+ require 'aerospike/command/multi_command'
53
+ require 'aerospike/command/batch_direct_command'
54
+ require 'aerospike/command/batch_direct_exists_command'
55
+ require 'aerospike/command/batch_index_command'
56
+ require 'aerospike/command/batch_index_exists_command'
54
57
  require 'aerospike/command/read_header_command'
55
58
  require 'aerospike/command/touch_command'
56
- require 'aerospike/command/batch_command_exists'
57
59
  require 'aerospike/command/read_command'
58
60
  require 'aerospike/command/delete_command'
59
61
  require 'aerospike/command/admin_command'
@@ -74,6 +76,7 @@ require 'aerospike/policy/priority'
74
76
  require 'aerospike/policy/record_exists_action'
75
77
  require 'aerospike/policy/generation_policy'
76
78
  require 'aerospike/policy/policy'
79
+ require 'aerospike/policy/batch_policy'
77
80
  require 'aerospike/policy/write_policy'
78
81
  require 'aerospike/policy/scan_policy'
79
82
  require 'aerospike/policy/query_policy'
@@ -91,6 +94,7 @@ require 'aerospike/connection/create'
91
94
  require 'aerospike/cluster'
92
95
  require 'aerospike/cluster/create_connection'
93
96
  require 'aerospike/cluster/partition'
97
+ require 'aerospike/cluster/find_nodes_to_remove'
94
98
  require 'aerospike/cluster/find_node'
95
99
  require 'aerospike/cluster/partition_tokenizer_new'
96
100
  require 'aerospike/cluster/partition_tokenizer_old'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # Copyright 2014-2018 Aerospike, Inc.
3
2
  #
4
3
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
@@ -112,7 +111,7 @@ module Aerospike
112
111
  #
113
112
  # client.put key, {'bin', 'value string'}, :timeout => 0.001
114
113
 
115
- def put(key, bins, options={})
114
+ def put(key, bins, options = nil)
116
115
  policy = create_policy(options, WritePolicy)
117
116
  command = WriteCommand.new(@cluster, policy, key, hash_to_bins(bins), Aerospike::Operation::WRITE)
118
117
  execute_command(command)
@@ -135,7 +134,7 @@ module Aerospike
135
134
  #
136
135
  # client.append key, {'bin', 'value to append'}, :timeout => 0.001
137
136
 
138
- def append(key, bins, options={})
137
+ def append(key, bins, options = nil)
139
138
  policy = create_policy(options, WritePolicy)
140
139
  command = WriteCommand.new(@cluster, policy, key, hash_to_bins(bins), Aerospike::Operation::APPEND)
141
140
  execute_command(command)
@@ -154,7 +153,7 @@ module Aerospike
154
153
  #
155
154
  # client.prepend key, {'bin', 'value to prepend'}, :timeout => 0.001
156
155
 
157
- def prepend(key, bins, options={})
156
+ def prepend(key, bins, options = nil)
158
157
  policy = create_policy(options, WritePolicy)
159
158
  command = WriteCommand.new(@cluster, policy, key, hash_to_bins(bins), Aerospike::Operation::PREPEND)
160
159
  execute_command(command)
@@ -177,7 +176,7 @@ module Aerospike
177
176
  #
178
177
  # client.add key, {'bin', -1}, :timeout => 0.001
179
178
 
180
- def add(key, bins, options={})
179
+ def add(key, bins, options = nil)
181
180
  policy = create_policy(options, WritePolicy)
182
181
  command = WriteCommand.new(@cluster, policy, key, hash_to_bins(bins), Aerospike::Operation::ADD)
183
182
  execute_command(command)
@@ -199,7 +198,7 @@ module Aerospike
199
198
  #
200
199
  # existed = client.delete key, :timeout => 0.001
201
200
 
202
- def delete(key, options={})
201
+ def delete(key, options = nil)
203
202
  policy = create_policy(options, WritePolicy)
204
203
  command = DeleteCommand.new(@cluster, policy, key)
205
204
  execute_command(command)
@@ -247,7 +246,7 @@ module Aerospike
247
246
  #
248
247
  # client.touch key, :timeout => 0.001
249
248
 
250
- def touch(key, options={})
249
+ def touch(key, options = nil)
251
250
  policy = create_policy(options, WritePolicy)
252
251
  command = TouchCommand.new(@cluster, policy, key)
253
252
  execute_command(command)
@@ -260,38 +259,20 @@ module Aerospike
260
259
  ##
261
260
  # Determines if a record key exists.
262
261
  # The policy can be used to specify timeouts.
263
- def exists(key, options={})
262
+ def exists(key, options = nil)
264
263
  policy = create_policy(options, Policy)
265
264
  command = ExistsCommand.new(@cluster, policy, key)
266
265
  execute_command(command)
267
266
  command.exists
268
267
  end
269
268
 
270
- # Check if multiple record keys exist in one batch call.
271
- # The returned array bool is in positional order with the original key array order.
272
- # The policy can be used to specify timeouts.
273
- def batch_exists(keys, options={})
274
- policy = create_policy(options, Policy)
275
-
276
- # same array can be used without sychronization;
277
- # when a key exists, the corresponding index will be marked true
278
- exists_array = Array.new(keys.length)
279
-
280
- key_map = BatchItem.generate_map(keys)
281
-
282
- batch_execute(keys) do |node, bns|
283
- BatchCommandExists.new(node, bns, policy, key_map, exists_array)
284
- end
285
- exists_array
286
- end
287
-
288
269
  #-------------------------------------------------------
289
270
  # Read Record Operations
290
271
  #-------------------------------------------------------
291
272
 
292
273
  # Read record header and bins for specified key.
293
274
  # The policy can be used to specify timeouts.
294
- def get(key, bin_names=[], options={})
275
+ def get(key, bin_names = nil, options = nil)
295
276
  policy = create_policy(options, Policy)
296
277
 
297
278
  command = ReadCommand.new(@cluster, policy, key, bin_names)
@@ -301,7 +282,7 @@ module Aerospike
301
282
 
302
283
  # Read record generation and expiration only for specified key. Bins are not read.
303
284
  # The policy can be used to specify timeouts.
304
- def get_header(key, options={})
285
+ def get_header(key, options = nil)
305
286
  policy = create_policy(options, Policy)
306
287
  command = ReadHeaderCommand.new(@cluster, policy, key)
307
288
  execute_command(command)
@@ -315,48 +296,62 @@ module Aerospike
315
296
  # Read multiple record headers and bins for specified keys in one batch call.
316
297
  # The returned records are in positional order with the original key array order.
317
298
  # If a key is not found, the positional record will be nil.
318
- # The policy can be used to specify timeouts.
319
- def batch_get(keys, bin_names=[], options={})
320
- policy = create_policy(options, Policy)
321
-
322
- # wait until all migrations are finished
323
- # TODO: implement
324
- # @cluster.WaitUntillMigrationIsFinished(policy.timeout)
325
-
326
- # same array can be used without sychronization;
327
- # when a key exists, the corresponding index will be set to record
328
- records = Array.new(keys.length)
329
-
330
- key_map = BatchItem.generate_map(keys)
299
+ # The policy can be used to specify timeouts and protocol type.
300
+ def batch_get(keys, bin_names = nil, options = nil)
301
+ policy = create_policy(options, BatchPolicy)
302
+ results = Array.new(keys.length)
303
+ info_flags = INFO1_READ
304
+
305
+ case bin_names
306
+ when :all, nil, []
307
+ info_flags |= INFO1_GET_ALL
308
+ bin_names = nil
309
+ when :none
310
+ info_flags |= INFO1_NOBINDATA
311
+ bin_names = nil
312
+ end
331
313
 
332
- batch_execute(keys) do |node, bns|
333
- BatchCommandGet.new(node, bns, policy, key_map, bin_names.uniq, records, INFO1_READ)
314
+ if policy.use_batch_direct
315
+ key_map = BatchItem.generate_map(keys)
316
+ execute_batch_direct_commands(keys) do |node, batch|
317
+ BatchDirectCommand.new(node, batch, policy, key_map, bin_names, results, info_flags)
318
+ end
319
+ else
320
+ execute_batch_index_commands(keys) do |node, batch|
321
+ BatchIndexCommand.new(node, batch, policy, bin_names, results, info_flags)
322
+ end
334
323
  end
335
- records
324
+
325
+ results
336
326
  end
337
327
 
338
328
  # Read multiple record header data for specified keys in one batch call.
339
329
  # The returned records are in positional order with the original key array order.
340
330
  # If a key is not found, the positional record will be nil.
341
- # The policy can be used to specify timeouts.
342
- def batch_get_header(keys, options={})
343
- policy = create_policy(options, Policy)
344
-
345
- # wait until all migrations are finished
346
- # TODO: Fix this and implement
347
- # @cluster.WaitUntillMigrationIsFinished(policy.timeout)
348
-
349
- # same array can be used without sychronization;
350
- # when a key exists, the corresponding index will be set to record
351
- records = Array.new(keys.length)
352
-
353
- key_map = BatchItem.generate_map(keys)
331
+ # The policy can be used to specify timeouts and protocol type.
332
+ def batch_get_header(keys, options = nil)
333
+ batch_get(keys, :none, options)
334
+ end
354
335
 
355
- batch_execute(keys) do |node, bns|
356
- BatchCommandGet.new(node, bns, policy, key_map, nil, records, INFO1_READ | INFO1_NOBINDATA)
336
+ # Check if multiple record keys exist in one batch call.
337
+ # The returned boolean array is in positional order with the original key array order.
338
+ # The policy can be used to specify timeouts and protocol type.
339
+ def batch_exists(keys, options = nil)
340
+ policy = create_policy(options, BatchPolicy)
341
+ results = Array.new(keys.length)
342
+
343
+ if policy.use_batch_direct
344
+ key_map = BatchItem.generate_map(keys)
345
+ execute_batch_direct_commands(keys) do |node, batch|
346
+ BatchDirectExistsCommand.new(node, batch, policy, key_map, results)
347
+ end
348
+ else
349
+ execute_batch_index_commands(keys) do |node, batch|
350
+ BatchIndexExistsCommand.new(node, batch, policy, results)
351
+ end
357
352
  end
358
353
 
359
- records
354
+ results
360
355
  end
361
356
 
362
357
  #-------------------------------------------------------
@@ -367,7 +362,7 @@ module Aerospike
367
362
  # An example would be to add an integer value to an existing record and then
368
363
  # read the result, all in one database call. Operations are executed in
369
364
  # the order they are specified.
370
- def operate(key, operations, options={})
365
+ def operate(key, operations, options = nil)
371
366
  policy = create_policy(options, WritePolicy)
372
367
 
373
368
  command = OperateCommand.new(@cluster, policy, key, operations)
@@ -385,7 +380,7 @@ module Aerospike
385
380
  # RegisterTask instance.
386
381
  #
387
382
  # This method is only supported by Aerospike 3 servers.
388
- def register_udf_from_file(client_path, server_path, language, options={})
383
+ def register_udf_from_file(client_path, server_path, language, options = nil)
389
384
  udf_body = File.read(client_path)
390
385
  register_udf(udf_body, server_path, language, options)
391
386
  end
@@ -396,7 +391,7 @@ module Aerospike
396
391
  # RegisterTask instance.
397
392
  #
398
393
  # This method is only supported by Aerospike 3 servers.
399
- def register_udf(udf_body, server_path, language, options={})
394
+ def register_udf(udf_body, server_path, language, options = nil)
400
395
  content = Base64.strict_encode64(udf_body).force_encoding('binary')
401
396
 
402
397
  str_cmd = "udf-put:filename=#{server_path};content=#{content};"
@@ -426,7 +421,7 @@ module Aerospike
426
421
  # RemoveTask instance.
427
422
  #
428
423
  # This method is only supported by Aerospike 3 servers.
429
- def remove_udf(udf_name, options={})
424
+ def remove_udf(udf_name, options = nil)
430
425
  str_cmd = "udf-remove:filename=#{udf_name};"
431
426
 
432
427
  # Send command to one node. That node will distribute it to other nodes.
@@ -443,7 +438,7 @@ module Aerospike
443
438
 
444
439
  # ListUDF lists all packages containing user defined functions in the server.
445
440
  # This method is only supported by Aerospike 3 servers.
446
- def list_udf(options={})
441
+ def list_udf(options = nil)
447
442
  str_cmd = 'udf-list'
448
443
 
449
444
  # Send command to one node. That node will distribute it to other nodes.
@@ -479,7 +474,7 @@ module Aerospike
479
474
  # udf file = <server udf dir>/<package name>.lua
480
475
  #
481
476
  # This method is only supported by Aerospike 3 servers.
482
- def execute_udf(key, package_name, function_name, args=[], options={})
477
+ def execute_udf(key, package_name, function_name, args=[], options = nil)
483
478
  policy = create_policy(options, WritePolicy)
484
479
 
485
480
  command = ExecuteCommand.new(@cluster, policy, key, package_name, function_name, args)
@@ -508,7 +503,7 @@ module Aerospike
508
503
  #
509
504
  # This method is only supported by Aerospike 3 servers.
510
505
  # If the policy is nil, the default relevant policy will be used.
511
- def execute_udf_on_query(statement, package_name, function_name, function_args=[], options={})
506
+ def execute_udf_on_query(statement, package_name, function_name, function_args=[], options = nil)
512
507
  policy = create_policy(options, QueryPolicy)
513
508
 
514
509
  nodes = @cluster.nodes
@@ -545,7 +540,7 @@ module Aerospike
545
540
  # This method is only supported by Aerospike 3 servers.
546
541
  # index_type should be :string, :numeric or :geo2dsphere (requires server version 3.7 or later)
547
542
  # collection_type should be :list, :mapkeys or :mapvalues
548
- def create_index(namespace, set_name, index_name, bin_name, index_type, collection_type=nil, options={})
543
+ def create_index(namespace, set_name, index_name, bin_name, index_type, collection_type=nil, options = nil)
549
544
  if options.nil? && collection_type.is_a?(Hash)
550
545
  options, collection_type = collection_type, nil
551
546
  end
@@ -574,7 +569,7 @@ module Aerospike
574
569
 
575
570
  # Delete secondary index.
576
571
  # This method is only supported by Aerospike 3 servers.
577
- def drop_index(namespace, set_name, index_name, options={})
572
+ def drop_index(namespace, set_name, index_name, options = nil)
578
573
  policy = create_policy(options, WritePolicy)
579
574
  str_cmd = "sindex-delete:ns=#{namespace}"
580
575
  str_cmd << ";set=#{set_name}" unless set_name.to_s.strip.empty?
@@ -598,7 +593,7 @@ module Aerospike
598
593
  # Scan Operations
599
594
  #-------------------------------------------------------
600
595
 
601
- def scan_all(namespace, set_name, bin_names=[], options={})
596
+ def scan_all(namespace, set_name, bin_names = nil, options = nil)
602
597
  policy = create_policy(options, ScanPolicy)
603
598
 
604
599
  # wait until all migrations are finished
@@ -654,7 +649,7 @@ module Aerospike
654
649
 
655
650
  # ScanNode reads all records in specified namespace and set, from one node only.
656
651
  # The policy can be used to specify timeouts.
657
- def scan_node(node, namespace, set_name, bin_names=[], options={})
652
+ def scan_node(node, namespace, set_name, bin_names = nil, options = nil)
658
653
  policy = create_policy(options, ScanPolicy)
659
654
  # wait until all migrations are finished
660
655
  # TODO: implement
@@ -696,7 +691,7 @@ module Aerospike
696
691
  #
697
692
  # This method is only supported by Aerospike 3 servers.
698
693
  # If the policy is nil, a default policy will be generated.
699
- def query(statement, options={})
694
+ def query(statement, options = nil)
700
695
  policy = create_policy(options, QueryPolicy)
701
696
  new_policy = policy.clone
702
697
 
@@ -732,7 +727,7 @@ module Aerospike
732
727
 
733
728
  # Create user with password and roles. Clear-text password will be hashed using bcrypt
734
729
  # before sending to server.
735
- def create_user(user, password, roles, options={})
730
+ def create_user(user, password, roles, options = nil)
736
731
  policy = create_policy(options, AdminPolicy)
737
732
  hash = AdminCommand.hash_password(password)
738
733
  command = AdminCommand.new
@@ -740,14 +735,14 @@ module Aerospike
740
735
  end
741
736
 
742
737
  # Remove user from cluster.
743
- def drop_user(user, options={})
738
+ def drop_user(user, options = nil)
744
739
  policy = create_policy(options, AdminPolicy)
745
740
  command = AdminCommand.new
746
741
  command.drop_user(@cluster, policy, user)
747
742
  end
748
743
 
749
744
  # Change user's password. Clear-text password will be hashed using bcrypt before sending to server.
750
- def change_password(user, password, options={})
745
+ def change_password(user, password, options = nil)
751
746
  raise Aerospike::Exceptions::Aerospike.new(INVALID_USER) unless @cluster.user && @cluster.user != ""
752
747
  policy = create_policy(options, AdminPolicy)
753
748
 
@@ -766,28 +761,28 @@ module Aerospike
766
761
  end
767
762
 
768
763
  # Add roles to user's list of roles.
769
- def grant_roles(user, roles, options={})
764
+ def grant_roles(user, roles, options = nil)
770
765
  policy = create_policy(options, AdminPolicy)
771
766
  command = AdminCommand.new
772
767
  command.grant_roles(@cluster, policy, user, roles)
773
768
  end
774
769
 
775
770
  # Remove roles from user's list of roles.
776
- def revoke_roles(user, roles, options={})
771
+ def revoke_roles(user, roles, options = nil)
777
772
  policy = create_policy(options, AdminPolicy)
778
773
  command = AdminCommand.new
779
774
  command.revoke_roles(@cluster, policy, user, roles)
780
775
  end
781
776
 
782
777
  # Retrieve roles for a given user.
783
- def query_user(user, options={})
778
+ def query_user(user, options = nil)
784
779
  policy = create_policy(options, AdminPolicy)
785
780
  command = AdminCommand.new
786
781
  command.query_user(@cluster, policy, user)
787
782
  end
788
783
 
789
784
  # Retrieve all users and their roles.
790
- def query_users(options={})
785
+ def query_users(options = nil)
791
786
  policy = create_policy(options, AdminPolicy)
792
787
  command = AdminCommand.new
793
788
  command.query_users(@cluster, policy)
@@ -862,18 +857,41 @@ module Aerospike
862
857
  command.execute
863
858
  end
864
859
 
865
- def batch_execute(keys)
866
- batch_nodes = BatchNode.generate_list(@cluster, keys)
860
+ def execute_batch_index_commands(keys)
861
+ if @cluster.nodes.empty?
862
+ raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_NOT_AVAILABLE, "Executing Batch Index command failed because cluster is empty.")
863
+ end
864
+
865
+ batch_nodes = BatchIndexNode.generate_list(@cluster, keys)
866
+ threads = []
867
+
868
+ batch_nodes.each do |batch|
869
+ threads << Thread.new do
870
+ Thread.current.abort_on_exception = true
871
+ command = yield batch.node, batch
872
+ execute_command(command)
873
+ end
874
+ end
875
+
876
+ threads.each(&:join)
877
+ end
878
+
879
+ def execute_batch_direct_commands(keys)
880
+ if @cluster.nodes.empty?
881
+ raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_NOT_AVAILABLE, "Executing Batch Direct command failed because cluster is empty.")
882
+ end
883
+
884
+ batch_nodes = BatchDirectNode.generate_list(@cluster, keys)
867
885
  threads = []
868
886
 
869
887
  # Use a thread per namespace per node
870
888
  batch_nodes.each do |batch_node|
871
889
  # copy to avoid race condition
872
890
  bn = batch_node
873
- bn.batch_namespaces.each do |bns|
891
+ bn.batch_namespaces.each do |batch|
874
892
  threads << Thread.new do
875
893
  Thread.current.abort_on_exception = true
876
- command = yield bn.node, bns
894
+ command = yield batch_node.node, batch
877
895
  execute_command(command)
878
896
  end
879
897
  end