Class: Aerospike::ClientPolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/aerospike/policy/client_policy.rb

Overview

Container object for client policy command.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opt = {}) ⇒ ClientPolicy

Returns a new instance of ClientPolicy.

[View source]

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/aerospike/policy/client_policy.rb', line 32

def initialize(opt={})
  # Initial host connection timeout in seconds. The timeout when opening a connection
  # to the server host for the first time.
  @timeout = opt[:timeout] || 1.0 # 1 second

  # Size of the Connection Queue cache.
  @connection_queue_size = opt[:connection_queue_size] || 64

  # Throw exception if host connection fails during add_host.
  @fail_if_not_connected = opt.has_key?(:fail_if_not_connected) ? opt[:fail_if_not_connected] : true

  # Tend interval in milliseconds; determines the interval at
  # which the client checks for cluster state changes. Minimum interval is 10ms.
  self.tend_interval = opt[:tend_interval] || 1000 # 1 second

  # Authentication mode
  @auth_mode = opt[:auth_mode] || AuthMode::INTERNAL

  # user name
  @user = opt[:user]

  # password
  @password = opt[:password]

  # Cluster Name
  @cluster_name = opt[:cluster_name]

  @tls = opt[:tls] || opt[:ssl_options]

  # Default Policies
  @policies = opt.fetch(:policies) { Hash.new }

  # Track server rack data.  This field is useful when directing read commands to the server node
  # that contains the key and exists on the same rack as the client.  This serves to lower cloud
  # provider costs when nodes are distributed across different racks/data centers.
  #
  # ClientPolicy#rack_id, Replica#PREFER_RACK and server rack
  # configuration must also be set to enable this functionality.
  @rack_aware = opt[:rack_aware] || false

  # Rack where this client instance resides.
  #
  # ClientPolicy#rack_aware, Replica#PREFER_RACK and server rack
  # configuration must also be set to enable this functionality.
  @rack_id = opt[:rack_id] || 0

  # Maximum number of synchronous connections allowed per server node.  Transactions will go
  # through retry logic and potentially fail with "ResultCode.NO_MORE_CONNECTIONS" if the maximum
  # number of connections would be exceeded.
  # The number of connections used per node depends on concurrent commands in progress
  # plus sub-commands used for parallel multi-node commands (batch, scan, and query).
  # One connection will be used for each command.
  # Default: 100
  @max_connections_per_node = opt[:max_connections_per_node] || 100

  # MinConnectionsPerNode specifies the minimum number of synchronous connections allowed per server node.
  # Preallocate min connections on client node creation.
  # The client will periodically allocate new connections if count falls below min connections.
  #
  # Server proto-fd-idle-ms may also need to be increased substantially if min connections are defined.
  # The proto-fd-idle-ms default directs the server to close connections that are idle for 60 seconds
  # which can defeat the purpose of keeping connections in reserve for a future burst of activity.
  #
  # Default: 0
  @min_connections_per_node = opt[:min_connections_per_node] || 0
end

Instance Attribute Details

#auth_modeObject

Returns the value of attribute auth_mode.


25
26
27
# File 'lib/aerospike/policy/client_policy.rb', line 25

def auth_mode
  @auth_mode
end

#cluster_nameObject

Returns the value of attribute cluster_name.


27
28
29
# File 'lib/aerospike/policy/client_policy.rb', line 27

def cluster_name
  @cluster_name
end

#connection_queue_sizeObject

Returns the value of attribute connection_queue_size.


26
27
28
# File 'lib/aerospike/policy/client_policy.rb', line 26

def connection_queue_size
  @connection_queue_size
end

#fail_if_not_connectedObject

Returns the value of attribute fail_if_not_connected.


26
27
28
# File 'lib/aerospike/policy/client_policy.rb', line 26

def fail_if_not_connected
  @fail_if_not_connected
end

#max_connections_per_nodeObject

Returns the value of attribute max_connections_per_node.


26
27
28
# File 'lib/aerospike/policy/client_policy.rb', line 26

def max_connections_per_node
  @max_connections_per_node
end

#min_connections_per_nodeObject

Returns the value of attribute min_connections_per_node.


26
27
28
# File 'lib/aerospike/policy/client_policy.rb', line 26

def min_connections_per_node
  @min_connections_per_node
end

#passwordObject

Returns the value of attribute password.


25
26
27
# File 'lib/aerospike/policy/client_policy.rb', line 25

def password
  @password
end

#policiesObject

Returns the value of attribute policies.


29
30
31
# File 'lib/aerospike/policy/client_policy.rb', line 29

def policies
  @policies
end

#rack_awareObject

Returns the value of attribute rack_aware.


30
31
32
# File 'lib/aerospike/policy/client_policy.rb', line 30

def rack_aware
  @rack_aware
end

#rack_idObject

Returns the value of attribute rack_id.


30
31
32
# File 'lib/aerospike/policy/client_policy.rb', line 30

def rack_id
  @rack_id
end

#tend_intervalObject

Returns the value of attribute tend_interval.


26
27
28
# File 'lib/aerospike/policy/client_policy.rb', line 26

def tend_interval
  @tend_interval
end

#timeoutObject

Returns the value of attribute timeout.


26
27
28
# File 'lib/aerospike/policy/client_policy.rb', line 26

def timeout
  @timeout
end

#tlsObject

Returns the value of attribute tls.


28
29
30
# File 'lib/aerospike/policy/client_policy.rb', line 28

def tls
  @tls
end

#userObject

Returns the value of attribute user.


25
26
27
# File 'lib/aerospike/policy/client_policy.rb', line 25

def user
  @user
end

Instance Method Details

#requires_authenticationObject

[View source]

99
100
101
# File 'lib/aerospike/policy/client_policy.rb', line 99

def requires_authentication
  (@user && @user != '') || (@password && @password != '')
end