Class: Aerospike::PartitionTokenizerOld
- Inherits:
-
Object
- Object
- Aerospike::PartitionTokenizerOld
- Defined in:
- lib/aerospike/cluster/partition_tokenizer_old.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(conn) ⇒ PartitionTokenizerOld
constructor
A new instance of PartitionTokenizerOld.
- #update_partition(nmap, node) ⇒ Object
Constructor Details
#initialize(conn) ⇒ PartitionTokenizerOld
Returns a new instance of PartitionTokenizerOld.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/aerospike/cluster/partition_tokenizer_old.rb', line 25 def initialize(conn) # Use low-level info methods and parse byte array directly for maximum performance. # Send format: replicas-master\n # Receive format: replicas-master\t<ns1>:<base 64 encoded bitmap>;<ns2>:<base 64 encoded bitmap>... \n info_map = Info.request(conn, REPLICAS_NAME) info = info_map[REPLICAS_NAME] @length = info ? info.length : 0 if !info || @length == 0 raise Aerospike::Exceptions::Connection.new("#{replicas_name} is empty") end @buffer = info @offset = 0 self end |
Instance Method Details
#update_partition(nmap, node) ⇒ Object
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 |
# File 'lib/aerospike/cluster/partition_tokenizer_old.rb', line 45 def update_partition(nmap, node) amap = nil copied = false while partition = get_next node_array = nmap[partition.namespace] if !node_array if !copied # Make shallow copy of map. amap = {} nmap.each {|k, v| amap[k] = v} copied = true end node_array = Atomic.new(Array.new(Aerospike::Node::PARTITIONS)) amap[partition.namespace] = node_array end Aerospike.logger.debug("#{partition.to_s}, #{node.name}") node_array.update{|v| v[partition.partition_id] = node; v } end copied ? amap : nil end |