aerospike 2.19.0 → 2.21.0
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 +4 -4
- data/CHANGELOG.md +24 -0
- data/lib/aerospike/client.rb +56 -7
- data/lib/aerospike/cluster/create_connection.rb +1 -1
- data/lib/aerospike/cluster.rb +35 -1
- data/lib/aerospike/command/admin_command.rb +367 -51
- data/lib/aerospike/command/batch_index_command.rb +4 -8
- data/lib/aerospike/command/batch_index_exists_command.rb +1 -1
- data/lib/aerospike/command/command.rb +29 -12
- data/lib/aerospike/command/field_type.rb +1 -0
- data/lib/aerospike/command/login_command.rb +162 -0
- data/lib/aerospike/command/multi_command.rb +17 -0
- data/lib/aerospike/connection/authenticate.rb +35 -3
- data/lib/aerospike/policy/auth_mode.rb +36 -0
- data/lib/aerospike/policy/client_policy.rb +4 -1
- data/lib/aerospike/privilege.rb +133 -0
- data/lib/aerospike/query/query_command.rb +21 -11
- data/lib/aerospike/query/scan_command.rb +3 -2
- data/lib/aerospike/query/stream_command.rb +3 -0
- data/lib/aerospike/result_code.rb +4 -4
- data/lib/aerospike/role.rb +55 -0
- data/lib/aerospike/user_role.rb +25 -0
- data/lib/aerospike/utils/buffer.rb +25 -0
- data/lib/aerospike/value/particle_type.rb +1 -12
- data/lib/aerospike/value/value.rb +9 -4
- data/lib/aerospike/version.rb +1 -1
- data/lib/aerospike.rb +4 -0
- metadata +7 -4
- data/lib/aerospike/command/roles.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75981b3dd2a5778a1937b7c5cd77abd97487be03d95d98e64b0fad0fb8e62080
|
4
|
+
data.tar.gz: 728a4593e675c15923798c352b33f01c4b0349b630a4a210dd6661346ff47ca8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7daa97ca23927f6132ad3a939c003872f7c6a0de538f99aea28b4a9624b23452cfec82b1a4243db4efa4fbb2c9f10085b338ce84223d309dd6fd8645ab3b61af
|
7
|
+
data.tar.gz: 97951b75f58a8cd750c27c77c37949e0d49dbfea3688e353496822f354c93124bae4749241f24d9e5f6508a6f1fcf6213bdfdf3bba371fa0e3d2a734aed45d78
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,30 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [2.21.0] - 2022-06-07
|
6
|
+
|
7
|
+
* **New Features**
|
8
|
+
* Add support for new user management features. Adds `Client#query_role`, `Client#query_roles`, `Client#create_role`, `Client#drop_role`, `Client#grant_privileges`, `Client#revoke_privileges`. Adds the 'Role' class. Adds `UserRoles#read_info`, `UserRoles#write_info`, `UserRoles#conns_in_use` to the `UserRoles` class.
|
9
|
+
|
10
|
+
* **Improvements**
|
11
|
+
* Do not run PredExp tests for server v6+.
|
12
|
+
|
13
|
+
## [2.20.1] - 2022-05-11
|
14
|
+
|
15
|
+
* **Improvements**
|
16
|
+
* Add basic support for the new authentication protocol.
|
17
|
+
|
18
|
+
## [2.20.0] - 2021-11-08
|
19
|
+
|
20
|
+
Notice: This version of the client only supports Aerospike Server v4.9 and later. Some features will work for the older server versions, but they are not tested, nor officially supported.
|
21
|
+
|
22
|
+
* **New Features**
|
23
|
+
* [CLIENT-1467] Support native Boolean type for server v5.6+.
|
24
|
+
|
25
|
+
* **Improvements**
|
26
|
+
* Add basic support for server v4.9+ scan/queries.
|
27
|
+
* Don't check for key equality in Batch command results.
|
28
|
+
|
5
29
|
## [2.19.0] - 2020-02-09
|
6
30
|
|
7
31
|
* **Improvements**
|
data/lib/aerospike/client.rb
CHANGED
@@ -543,10 +543,11 @@ module Aerospike
|
|
543
543
|
|
544
544
|
# Use a thread per node
|
545
545
|
nodes.each do |node|
|
546
|
+
partitions = node.cluster.node_partitions(node, statement.namespace)
|
546
547
|
Thread.new do
|
547
548
|
Thread.current.abort_on_exception = true
|
548
549
|
begin
|
549
|
-
command = QueryCommand.new(node, policy, statement, nil)
|
550
|
+
command = QueryCommand.new(node, policy, statement, nil, partitions)
|
550
551
|
execute_command(command)
|
551
552
|
rescue => e
|
552
553
|
Aerospike.logger.error(e)
|
@@ -644,9 +645,10 @@ module Aerospike
|
|
644
645
|
if policy.concurrent_nodes
|
645
646
|
# Use a thread per node
|
646
647
|
nodes.each do |node|
|
648
|
+
partitions = node.cluster.node_partitions(node, namespace)
|
647
649
|
Thread.new do
|
648
650
|
Thread.current.abort_on_exception = true
|
649
|
-
command = ScanCommand.new(node, new_policy, namespace, set_name, bin_names, recordset)
|
651
|
+
command = ScanCommand.new(node, new_policy, namespace, set_name, bin_names, recordset, partitions)
|
650
652
|
begin
|
651
653
|
execute_command(command)
|
652
654
|
rescue => e
|
@@ -661,7 +663,8 @@ module Aerospike
|
|
661
663
|
Thread.new do
|
662
664
|
Thread.current.abort_on_exception = true
|
663
665
|
nodes.each do |node|
|
664
|
-
|
666
|
+
partitions = node.cluster.node_partitions(node, namespace)
|
667
|
+
command = ScanCommand.new(node, new_policy, namespace, set_name, bin_names, recordset, partitions)
|
665
668
|
begin
|
666
669
|
execute_command(command)
|
667
670
|
rescue => e
|
@@ -694,9 +697,10 @@ module Aerospike
|
|
694
697
|
|
695
698
|
recordset = Recordset.new(policy.record_queue_size, 1, :scan)
|
696
699
|
|
700
|
+
partitions = node.cluster.node_partitions(node, namespace)
|
697
701
|
Thread.new do
|
698
702
|
Thread.current.abort_on_exception = true
|
699
|
-
command = ScanCommand.new(node, new_policy, namespace, set_name, bin_names, recordset)
|
703
|
+
command = ScanCommand.new(node, new_policy, namespace, set_name, bin_names, recordset, partitions)
|
700
704
|
begin
|
701
705
|
execute_command(command)
|
702
706
|
rescue => e
|
@@ -734,9 +738,10 @@ module Aerospike
|
|
734
738
|
|
735
739
|
# Use a thread per node
|
736
740
|
nodes.each do |node|
|
741
|
+
partitions = node.cluster.node_partitions(node, statement.namespace)
|
737
742
|
Thread.new do
|
738
743
|
Thread.current.abort_on_exception = true
|
739
|
-
command = QueryCommand.new(node, new_policy, statement, recordset)
|
744
|
+
command = QueryCommand.new(node, new_policy, statement, recordset, partitions)
|
740
745
|
begin
|
741
746
|
execute_command(command)
|
742
747
|
rescue => e
|
@@ -759,7 +764,7 @@ module Aerospike
|
|
759
764
|
# before sending to server.
|
760
765
|
def create_user(user, password, roles, options = nil)
|
761
766
|
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
762
|
-
hash =
|
767
|
+
hash = LoginCommand.hash_password(password)
|
763
768
|
command = AdminCommand.new
|
764
769
|
command.create_user(@cluster, policy, user, hash, roles)
|
765
770
|
end
|
@@ -776,7 +781,7 @@ module Aerospike
|
|
776
781
|
raise Aerospike::Exceptions::Aerospike.new(INVALID_USER) unless @cluster.user && @cluster.user != ""
|
777
782
|
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
778
783
|
|
779
|
-
hash =
|
784
|
+
hash = LoginCommand.hash_password(password)
|
780
785
|
command = AdminCommand.new
|
781
786
|
|
782
787
|
if user == @cluster.user
|
@@ -818,6 +823,50 @@ module Aerospike
|
|
818
823
|
command.query_users(@cluster, policy)
|
819
824
|
end
|
820
825
|
|
826
|
+
# Retrieve privileges for a given role.
|
827
|
+
def query_role(role, options = nil)
|
828
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
829
|
+
command = AdminCommand.new
|
830
|
+
command.query_role(@cluster, policy, role)
|
831
|
+
end
|
832
|
+
|
833
|
+
# Retrieve all roles and their privileges.
|
834
|
+
def query_roles(options = nil)
|
835
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
836
|
+
command = AdminCommand.new
|
837
|
+
command.query_roles(@cluster, policy)
|
838
|
+
end
|
839
|
+
|
840
|
+
# Create a user-defined role.
|
841
|
+
# Quotas require server security configuration "enable-quotas" to be set to true.
|
842
|
+
# Pass 0 for quota values for no limit.
|
843
|
+
def create_role(role_name, privileges = [], allowlist = [], read_quota = 0, write_quota = 0, options = nil)
|
844
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
845
|
+
command = AdminCommand.new
|
846
|
+
command.create_role(@cluster, policy, role_name, privileges, allowlist, read_quota, write_quota)
|
847
|
+
end
|
848
|
+
|
849
|
+
# Remove a user-defined role.
|
850
|
+
def drop_role(role_name, options = nil)
|
851
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
852
|
+
command = AdminCommand.new
|
853
|
+
command.drop_role(@cluster, policy, role_name)
|
854
|
+
end
|
855
|
+
|
856
|
+
# Grant privileges to a user-defined role.
|
857
|
+
def grant_privileges(role_name, privileges, options = nil)
|
858
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
859
|
+
command = AdminCommand.new
|
860
|
+
command.grant_privileges(@cluster, policy, role_name, privileges)
|
861
|
+
end
|
862
|
+
|
863
|
+
# Revoke privileges from a user-defined role.
|
864
|
+
def revoke_privileges(role_name, privileges, options = nil)
|
865
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
866
|
+
command = AdminCommand.new
|
867
|
+
command.revoke_privileges(@cluster, policy, role_name, privileges)
|
868
|
+
end
|
869
|
+
|
821
870
|
private
|
822
871
|
|
823
872
|
def set_default_policies(policies)
|
@@ -32,7 +32,7 @@ module Aerospike
|
|
32
32
|
).tap do |conn|
|
33
33
|
if cluster.credentials_given?
|
34
34
|
# Authenticate will raise and close connection if invalid credentials
|
35
|
-
Connection::
|
35
|
+
Connection::AuthenticateNew.(conn, cluster)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/aerospike/cluster.rb
CHANGED
@@ -27,9 +27,12 @@ module Aerospike
|
|
27
27
|
attr_reader :features, :tls_options
|
28
28
|
attr_reader :cluster_id, :aliases
|
29
29
|
attr_reader :cluster_name
|
30
|
+
attr_reader :client_policy
|
30
31
|
attr_accessor :rack_aware, :rack_id
|
32
|
+
attr_accessor :session_token, :session_expiration
|
31
33
|
|
32
34
|
def initialize(policy, hosts)
|
35
|
+
@client_policy = policy
|
33
36
|
@cluster_seeds = hosts
|
34
37
|
@fail_if_not_connected = policy.fail_if_not_connected
|
35
38
|
@connection_queue_size = policy.connection_queue_size
|
@@ -56,7 +59,7 @@ module Aerospike
|
|
56
59
|
# setup auth info for cluster
|
57
60
|
if policy.requires_authentication
|
58
61
|
@user = policy.user
|
59
|
-
@password =
|
62
|
+
@password = LoginCommand.hash_password(policy.password)
|
60
63
|
end
|
61
64
|
|
62
65
|
initialize_tls_host_names(hosts) if tls_enabled?
|
@@ -78,6 +81,15 @@ module Aerospike
|
|
78
81
|
!(@user.nil? || @user.empty?)
|
79
82
|
end
|
80
83
|
|
84
|
+
def session_valid?
|
85
|
+
@session_token && @session_expiration && @session_expiration.to_i < Time.now.to_i
|
86
|
+
end
|
87
|
+
|
88
|
+
def reset_session_info
|
89
|
+
@session_token = nil
|
90
|
+
@session_expiration = nil
|
91
|
+
end
|
92
|
+
|
81
93
|
def tls_enabled?
|
82
94
|
!tls_options.nil? && tls_options[:enable] != false
|
83
95
|
end
|
@@ -230,6 +242,27 @@ module Aerospike
|
|
230
242
|
batch_read_node(partition, replica_policy)
|
231
243
|
end
|
232
244
|
|
245
|
+
# Returns partitions pertaining to a node
|
246
|
+
def node_partitions(node, namespace)
|
247
|
+
res = []
|
248
|
+
|
249
|
+
partition_map = partitions
|
250
|
+
replica_array = partition_map[namespace]
|
251
|
+
raise Aerospike::Exceptions::InvalidNamespace("namespace not found in the partition map") if !replica_array
|
252
|
+
|
253
|
+
node_array = (replica_array.get)[0]
|
254
|
+
raise Aerospike::Exceptions::InvalidNamespace("namespace not found in the partition map") if !node_array
|
255
|
+
|
256
|
+
|
257
|
+
pid = 0
|
258
|
+
for tnode in node_array.get
|
259
|
+
res << pid if node == tnode
|
260
|
+
pid+=1
|
261
|
+
end
|
262
|
+
|
263
|
+
res
|
264
|
+
end
|
265
|
+
|
233
266
|
# Returns a random node on the cluster
|
234
267
|
def random_node
|
235
268
|
# Must copy array reference for copy on write semantics to work.
|
@@ -415,6 +448,7 @@ module Aerospike
|
|
415
448
|
cluster_config_changed = true
|
416
449
|
end
|
417
450
|
|
451
|
+
|
418
452
|
cluster_config_changed
|
419
453
|
end
|
420
454
|
|