Class: DruidConfig::Entities::Tier
- Inherits:
-
Object
- Object
- DruidConfig::Entities::Tier
- Defined in:
- lib/druid_config/entities/tier.rb
Overview
Tier class
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Readers.
-
#nodes ⇒ Object
(also: #servers)
readonly
Readers.
Instance Method Summary collapse
- #free ⇒ Object
- #historicals ⇒ Object
-
#initialize(name, nodes) ⇒ Tier
constructor
A new instance of Tier.
- #max_size ⇒ Object
- #segments ⇒ Object
- #segments_count ⇒ Object
- #segments_to_drop ⇒ Object
- #segments_to_drop_count ⇒ Object
- #segments_to_drop_size ⇒ Object
- #segments_to_load ⇒ Object
- #segments_to_load_count ⇒ Object
- #segments_to_load_size ⇒ Object
- #size ⇒ Object (also: #used)
- #used_percent ⇒ Object
Constructor Details
#initialize(name, nodes) ⇒ Tier
Returns a new instance of Tier.
10 11 12 13 |
# File 'lib/druid_config/entities/tier.rb', line 10 def initialize(name, nodes) @name = name @nodes = nodes end |
Instance Attribute Details
#name ⇒ Object (readonly)
Readers
8 9 10 |
# File 'lib/druid_config/entities/tier.rb', line 8 def name @name end |
#nodes ⇒ Object (readonly) Also known as: servers
Readers
8 9 10 |
# File 'lib/druid_config/entities/tier.rb', line 8 def nodes @nodes end |
Instance Method Details
#free ⇒ Object
27 28 29 30 |
# File 'lib/druid_config/entities/tier.rb', line 27 def free return @free if @free @free = (max_size - size) > 0 ? (max_size - size) : 0 end |
#historicals ⇒ Object
37 38 39 |
# File 'lib/druid_config/entities/tier.rb', line 37 def historicals nodes.select { |node| node.type == :historical } end |
#max_size ⇒ Object
23 24 25 |
# File 'lib/druid_config/entities/tier.rb', line 23 def max_size @max_size ||= nodes.map(&:max_size).inject(:+) end |
#segments ⇒ Object
41 42 43 44 |
# File 'lib/druid_config/entities/tier.rb', line 41 def segments @segments ||= nodes.map(&:segments) .flatten.sort_by { |seg| seg.interval.first } end |
#segments_count ⇒ Object
46 47 48 |
# File 'lib/druid_config/entities/tier.rb', line 46 def segments_count @segments_count ||= nodes.map(&:segments_count).inject(:+) end |
#segments_to_drop ⇒ Object
55 56 57 58 |
# File 'lib/druid_config/entities/tier.rb', line 55 def segments_to_drop @segments_to_drop ||= nodes.map(&:segments_to_drop) .flatten.sort_by { |seg| seg.interval.first } end |
#segments_to_drop_count ⇒ Object
65 66 67 68 |
# File 'lib/druid_config/entities/tier.rb', line 65 def segments_to_drop_count @segments_to_drop_count ||= nodes.map(&:segments_to_drop_count).inject(:+) end |
#segments_to_drop_size ⇒ Object
75 76 77 78 |
# File 'lib/druid_config/entities/tier.rb', line 75 def segments_to_drop_size @segments_to_drop_size ||= nodes.map(&:segments_to_drop_size).reduce(:+) end |
#segments_to_load ⇒ Object
50 51 52 53 |
# File 'lib/druid_config/entities/tier.rb', line 50 def segments_to_load @segments_to_load ||= nodes.map(&:segments_to_load) .flatten.sort_by { |seg| seg.interval.first } end |
#segments_to_load_count ⇒ Object
60 61 62 63 |
# File 'lib/druid_config/entities/tier.rb', line 60 def segments_to_load_count @segments_to_load_count ||= nodes.map(&:segments_to_load_count).inject(:+) end |
#segments_to_load_size ⇒ Object
70 71 72 73 |
# File 'lib/druid_config/entities/tier.rb', line 70 def segments_to_load_size @segments_to_load_size ||= nodes.map(&:segments_to_load_size).reduce(:+) end |
#size ⇒ Object Also known as: used
17 18 19 |
# File 'lib/druid_config/entities/tier.rb', line 17 def size @size ||= nodes.map(&:size).inject(:+) end |
#used_percent ⇒ Object
32 33 34 35 |
# File 'lib/druid_config/entities/tier.rb', line 32 def used_percent return 0 unless max_size && max_size != 0 ((size.to_f / max_size) * 100).round(2) end |