Class: Droonga::Catalog::Generator::Replicas
- Inherits:
-
Object
- Object
- Droonga::Catalog::Generator::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.
175 176 177 178 179 180 |
# File 'lib/droonga/catalog/generator.rb', line 175 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.
172 173 174 |
# File 'lib/droonga/catalog/generator.rb', line 172 def hosts @hosts end |
#n_slices ⇒ Object (readonly)
Returns the value of attribute n_slices.
173 174 175 |
# File 'lib/droonga/catalog/generator.rb', line 173 def n_slices @n_slices end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
173 174 175 |
# File 'lib/droonga/catalog/generator.rb', line 173 def port @port end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
173 174 175 |
# File 'lib/droonga/catalog/generator.rb', line 173 def tag @tag end |
Instance Method Details
#load(catalog_replicas) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/droonga/catalog/generator.rb', line 182 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
196 197 198 199 200 201 202 203 204 205 |
# File 'lib/droonga/catalog/generator.rb', line 196 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 |