Class: RedisFailover::NodeStrategy::Majority

Inherits:
RedisFailover::NodeStrategy show all
Defined in:
lib/redis_failover/node_strategy/majority.rb

Overview

Majority strategy only marks the node as unavailable if a majority of the snapshot indicates that the node is down.

Constant Summary

Constants included from Util

Util::CONNECTIVITY_ERRORS, Util::DEFAULT_ROOT_ZNODE_PATH, Util::REDIS_ERRORS, Util::REDIS_READ_OPS, Util::UNSUPPORTED_OPS, Util::ZK_ERRORS

Instance Method Summary collapse

Methods inherited from RedisFailover::NodeStrategy

for, #log_unavailable

Methods included from Util

#decode, #different?, #encode, logger, #logger, logger=, #symbolize_keys

Instance Method Details

#determine_state(node, snapshots) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/redis_failover/node_strategy/majority.rb', line 7

def determine_state(node, snapshots)
  snapshot = snapshots[node]
  if snapshot.unavailable_count > snapshot.available_count
    log_unavailable(node, snapshot)
    :unavailable
  else
    :available
  end
end