Class: Aerospike::Node::Rebalance

Inherits:
Object
  • Object
show all
Defined in:
lib/aerospike/node/rebalance.rb

Overview

generic class for representing changes in eg. peer and partition generation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(generation = -1)) ⇒ Rebalance

Returns a new instance of Rebalance.



26
27
28
29
# File 'lib/aerospike/node/rebalance.rb', line 26

def initialize(generation = -1)
  @generation = ::Aerospike::Atomic.new(generation)
  @changed = ::Aerospike::Atomic.new(false)
end

Instance Attribute Details

#generationObject (readonly)

Returns the value of attribute generation.



24
25
26
# File 'lib/aerospike/node/rebalance.rb', line 24

def generation
  @generation
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/aerospike/node/rebalance.rb', line 31

def changed?
  @changed.value == true
end

#eql?(generation) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/aerospike/node/rebalance.rb', line 35

def eql?(generation)
  @generation.value == generation
end

#reset_changed!Object



39
40
41
# File 'lib/aerospike/node/rebalance.rb', line 39

def reset_changed!
  @changed.value = false
end

#update(new_generation) ⇒ Object



43
44
45
46
47
# File 'lib/aerospike/node/rebalance.rb', line 43

def update(new_generation)
  return if @generation.value == new_generation
  @generation.value = new_generation
  @changed.value = true
end