Class: Aerospike::RackParser
- Inherits:
-
Object
- Object
- Aerospike::RackParser
- Defined in:
- lib/aerospike/cluster/rack_parser.rb
Overview
:nodoc:
Constant Summary collapse
- REBALANCE_GENERATION =
"rebalance-generation"
- RACK_IDS =
"rack-ids"
Instance Attribute Summary collapse
-
#racks ⇒ Object
Returns the value of attribute racks.
-
#rebalance_generation ⇒ Object
Returns the value of attribute rebalance_generation.
Instance Method Summary collapse
-
#initialize(node, conn) ⇒ RackParser
constructor
A new instance of RackParser.
- #update_racks ⇒ Object
Constructor Details
#initialize(node, conn) ⇒ RackParser
Returns a new instance of RackParser.
29 30 31 32 33 |
# File 'lib/aerospike/cluster/rack_parser.rb', line 29 def initialize(node, conn) @node = node @conn = conn @racks = nil end |
Instance Attribute Details
#racks ⇒ Object
Returns the value of attribute racks.
24 25 26 |
# File 'lib/aerospike/cluster/rack_parser.rb', line 24 def racks @racks end |
#rebalance_generation ⇒ Object
Returns the value of attribute rebalance_generation.
24 25 26 |
# File 'lib/aerospike/cluster/rack_parser.rb', line 24 def rebalance_generation @rebalance_generation end |
Instance Method Details
#update_racks ⇒ Object
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 |
# File 'lib/aerospike/cluster/rack_parser.rb', line 35 def update_racks # Use low-level info methods and parse byte array directly for maximum performance. # Receive format: rack-ids\t # <ns1>:<rack-id>...; # <ns2>:<rack-id>...; ... info_map = Info.request(@conn, REBALANCE_GENERATION, RACK_IDS) @rebalance_generation = info_map[REBALANCE_GENERATION].to_i info = info_map[RACK_IDS] if !info || info.length == 0 raise Aerospike::Exceptions::Connection.new("#{RACK_IDS} response for node #{@node.name} is empty") end @buffer = info @length = info.length @offset = 0 while @offset < @length && @buffer[@offset] != '\n' namespace = parse_name rack_id = parse_rack_id @racks = {} if !@racks @racks[namespace] = rack_id end @racks end |