lib/aerospike/client.rb in aerospike-2.12.0 vs lib/aerospike/client.rb in aerospike-2.13.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright 2014-2018 Aerospike, Inc. +# Copyright 2014-2020 Aerospike, Inc. # # Portions may be licensed to Aerospike, Inc. under one or more contributor # license agreements. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -320,15 +320,15 @@ bin_names = nil end if policy.use_batch_direct key_map = BatchItem.generate_map(keys) - execute_batch_direct_commands(keys) do |node, batch| + execute_batch_direct_commands(policy, keys) do |node, batch| BatchDirectCommand.new(node, batch, policy, key_map, bin_names, results, info_flags) end else - execute_batch_index_commands(keys) do |node, batch| + execute_batch_index_commands(policy, keys) do |node, batch| BatchIndexCommand.new(node, batch, policy, bin_names, results, info_flags) end end results @@ -349,15 +349,15 @@ policy = create_policy(options, BatchPolicy, default_batch_policy) results = Array.new(keys.length) if policy.use_batch_direct key_map = BatchItem.generate_map(keys) - execute_batch_direct_commands(keys) do |node, batch| + execute_batch_direct_commands(policy, keys) do |node, batch| BatchDirectExistsCommand.new(node, batch, policy, key_map, results) end else - execute_batch_index_commands(keys) do |node, batch| + execute_batch_index_commands(policy, keys) do |node, batch| BatchIndexExistsCommand.new(node, batch, policy, results) end end results @@ -882,16 +882,16 @@ def execute_command(command) validate_command(command) command.execute end - def execute_batch_index_commands(keys) + def execute_batch_index_commands(policy, keys) if @cluster.nodes.empty? raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_NOT_AVAILABLE, "Executing Batch Index command failed because cluster is empty.") end - batch_nodes = BatchIndexNode.generate_list(@cluster, keys) + batch_nodes = BatchIndexNode.generate_list(@cluster, policy.replica, keys) threads = [] batch_nodes.each do |batch| threads << Thread.new do command = yield batch.node, batch @@ -900,15 +900,15 @@ end threads.each(&:join) end - def execute_batch_direct_commands(keys) + def execute_batch_direct_commands(policy, keys) if @cluster.nodes.empty? raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_NOT_AVAILABLE, "Executing Batch Direct command failed because cluster is empty.") end - batch_nodes = BatchDirectNode.generate_list(@cluster, keys) + batch_nodes = BatchDirectNode.generate_list(@cluster, policy.replica, keys) threads = [] # Use a thread per namespace per node batch_nodes.each do |batch_node| # copy to avoid race condition