Class: LucidWorks::Cluster
- Inherits:
-
Object
- Object
- LucidWorks::Cluster
- Defined in:
- lib/lucid_works/cluster.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#initialize(solr_uri) ⇒ Cluster
constructor
A new instance of Cluster.
Constructor Details
#initialize(solr_uri) ⇒ Cluster
Returns a new instance of Cluster.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/lucid_works/cluster.rb', line 52 def initialize(solr_uri) zk_uri = "#{solr_uri}/zookeeper?detail=true&path=" @zk_clusterstate = JSON.parse(JSON.parse(RestClient.get(zk_uri + "/clusterstate.json"))['znode']['data']) @zk_live_nodes = JSON.parse(RestClient.get(zk_uri + "/live_nodes/"))['tree'].first['children']. map {|child| child['data']['title'] } rescue [] @nodes = [] @zk_clusterstate.each do |slice| slice[1]['shards'].each do |shard_name, shard_description| unless shard_description.empty? # A shard's description can come back as empty when the shard is in trouble shard_description['replicas'].values.each do |node_json| node = nodes.find {|node| node.solr_url == node_json['base_url'] } nodes << (node = Node.new(self, node_json['base_url'], determine_node_state(node_json))) unless node new_shard = Shard.new(node, node_json['shard'], node_json['collection'], node_json['leader'] == 'true') node.shards << new_shard unless node.shards.include?(new_shard) end end end end end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
50 51 52 |
# File 'lib/lucid_works/cluster.rb', line 50 def nodes @nodes end |