Class: DruidConfig::Entities::Tier

Inherits:
Object
  • Object
show all
Defined in:
lib/druid_config/entities/tier.rb

Overview

Tier class

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/tier.rb', line 8

def name
  @name
end

#nodesObject (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

#freeObject



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

#historicalsObject



37
38
39
# File 'lib/druid_config/entities/tier.rb', line 37

def historicals
  nodes.select { |node| node.type == :historical }
end

#max_sizeObject



23
24
25
# File 'lib/druid_config/entities/tier.rb', line 23

def max_size
  @max_size ||= nodes.map(&:max_size).inject(:+)
end

#segmentsObject



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_countObject



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_dropObject



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_countObject



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_sizeObject



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_loadObject



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_countObject



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_sizeObject



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

#sizeObject 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_percentObject



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