Class: ElasticBoard::Summary

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_board/summary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*servers) ⇒ Summary

Returns a new instance of Summary.



6
7
8
9
10
11
12
# File 'lib/elastic_board/summary.rb', line 6

def initialize(*servers)
  if servers.first.is_a?(ElasticSearch::Client)
    self.connection = servers.first
  else
    self.connection = ElasticSearch.new(servers)
  end
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



4
5
6
# File 'lib/elastic_board/summary.rb', line 4

def connection
  @connection
end

Instance Method Details

#active_primary_shardsObject



78
79
80
# File 'lib/elastic_board/summary.rb', line 78

def active_primary_shards
  cluster_health['active_primary_shards']
end

#active_shardsObject



74
75
76
# File 'lib/elastic_board/summary.rb', line 74

def active_shards
  cluster_health['active_shards']
end

#cluster_healthObject

Health Functions =



58
59
60
# File 'lib/elastic_board/summary.rb', line 58

def cluster_health
  @cluster_health ||= self.connection.cluster_health
end

#cluster_health_noticeObject



90
91
92
93
94
95
96
# File 'lib/elastic_board/summary.rb', line 90

def cluster_health_notice
  if unassigned_shards.to_i > 0
    "Unassigned Shards Greater than Zero"
  else
    return nil
  end
end

#cluster_nameObject



62
63
64
# File 'lib/elastic_board/summary.rb', line 62

def cluster_name
  cluster_health['cluster_name']
end

#cluster_stateObject

State Functions =



18
19
20
# File 'lib/elastic_board/summary.rb', line 18

def cluster_state
  @cluster_state ||= self.connection.cluster_state
end

#cluster_statusObject



66
67
68
# File 'lib/elastic_board/summary.rb', line 66

def cluster_status
  cluster_health['status']
end

#index_statusObject

Index Functions =



46
47
48
# File 'lib/elastic_board/summary.rb', line 46

def index_status
  @index_status ||= self.connection.index_status
end

#indicesObject



50
51
52
# File 'lib/elastic_board/summary.rb', line 50

def indices
  index_status['indices']
end

#nodesObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/elastic_board/summary.rb', line 30

def nodes
  nodes = [ ]
  nodes_info['nodes'].each do |key, node_details|
    nodes << {
      :name    => node_details['name'],
      :address => extract_ip_from_address(node_details['transport_address'])
    }
  end
  
  return nodes
end

#nodes_infoObject

Node Functions =



26
27
28
# File 'lib/elastic_board/summary.rb', line 26

def nodes_info
  @nodes_info ||= self.connection.nodes_info
end

#number_of_nodesObject



70
71
72
# File 'lib/elastic_board/summary.rb', line 70

def number_of_nodes
  cluster_health['number_of_nodes']
end

#unassigned_shardsObject



86
87
88
# File 'lib/elastic_board/summary.rb', line 86

def unassigned_shards
  cluster_health['unassigned_shards']
end