Class: Droonga::CatalogGenerator::Replicas
- Inherits:
-
Object
- Object
- Droonga::CatalogGenerator::Replicas
- Defined in:
- lib/droonga/catalog_generator.rb
Instance Attribute Summary collapse
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#n_slices ⇒ Object
readonly
Returns the value of attribute n_slices.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Replicas
constructor
A new instance of Replicas.
- #load(catalog_replicas) ⇒ Object
- #to_catalog ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Replicas
Returns a new instance of Replicas.
174 175 176 177 178 179 |
# File 'lib/droonga/catalog_generator.rb', line 174 def initialize(={}) @hosts = [:hosts] || DEFAULT_HOSTS @port = [:port] @tag = [:tag] @n_slices = [:n_slices] end |
Instance Attribute Details
#hosts ⇒ Object
Returns the value of attribute hosts.
171 172 173 |
# File 'lib/droonga/catalog_generator.rb', line 171 def hosts @hosts end |
#n_slices ⇒ Object (readonly)
Returns the value of attribute n_slices.
172 173 174 |
# File 'lib/droonga/catalog_generator.rb', line 172 def n_slices @n_slices end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
172 173 174 |
# File 'lib/droonga/catalog_generator.rb', line 172 def port @port end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
172 173 174 |
# File 'lib/droonga/catalog_generator.rb', line 172 def tag @tag end |
Instance Method Details
#load(catalog_replicas) ⇒ Object
181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/droonga/catalog_generator.rb', line 181 def load(catalog_replicas) dataset = Catalog::Dataset.new("temporary", "replicas" => catalog_replicas) @hosts = dataset.replicas.collect do |replica| replica.slices.first.volume.address.host end collection_volume = dataset.replicas.first slices = collection_volume.slices @n_slices = slices.size single_volume_address = slices.first.volume.address @port = single_volume_address.port @tag = single_volume_address.tag end |
#to_catalog ⇒ Object
195 196 197 198 199 200 201 202 203 204 |
# File 'lib/droonga/catalog_generator.rb', line 195 def to_catalog catalog_replicas = [] @hosts.each do |host| replica = Replica.new(host, :port => @port, :tag => @tag, :n_slices => @n_slices) catalog_replicas << replica.to_catalog end catalog_replicas end |