Class: LucidWorks::Cluster::Node

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serializers::JSON
Defined in:
lib/lucid_works/cluster.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster, solr_url, state) ⇒ Node

Returns a new instance of Node.



12
13
14
15
16
17
18
19
# File 'lib/lucid_works/cluster.rb', line 12

def initialize(cluster, solr_url, state)
  @cluster, @solr_url, @state = cluster, solr_url, state
  uri = URI(solr_url)
  @host, @port = uri.host, uri.port
  @id = "#{host}_#{port}"
  @api_url = solr_url.sub uri.path, '/api'
  @shards = []
end

Instance Attribute Details

#api_urlObject (readonly)

Returns the value of attribute api_url.



9
10
11
# File 'lib/lucid_works/cluster.rb', line 9

def api_url
  @api_url
end

#clusterObject (readonly)

Returns the value of attribute cluster.



9
10
11
# File 'lib/lucid_works/cluster.rb', line 9

def cluster
  @cluster
end

#hostObject (readonly)

Returns the value of attribute host.



9
10
11
# File 'lib/lucid_works/cluster.rb', line 9

def host
  @host
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/lucid_works/cluster.rb', line 9

def id
  @id
end

#portObject (readonly)

Returns the value of attribute port.



9
10
11
# File 'lib/lucid_works/cluster.rb', line 9

def port
  @port
end

#shardsObject

Returns the value of attribute shards.



10
11
12
# File 'lib/lucid_works/cluster.rb', line 10

def shards
  @shards
end

#solr_urlObject (readonly)

Returns the value of attribute solr_url.



9
10
11
# File 'lib/lucid_works/cluster.rb', line 9

def solr_url
  @solr_url
end

#stateObject (readonly)

Returns the value of attribute state.



9
10
11
# File 'lib/lucid_works/cluster.rb', line 9

def state
  @state
end

Instance Method Details

#as_json(options = {}) ⇒ Object



21
22
23
# File 'lib/lucid_works/cluster.rb', line 21

def as_json(options = {})
  {'id' => id, 'host' => host, 'port' => port, 'state' => state, 'solr_url' => solr_url, 'api_url' => api_url, 'shards' => shards}
end