Navigation Menu

Skip to content

Commit

Permalink
Move CatalogModifier and CatalogFetcher under the namespace Catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 15, 2015
1 parent a3d2c8b commit b3dadb5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
Expand Up @@ -21,7 +21,8 @@
require "droonga/catalog/dataset"

module Droonga
class CatalogFetcher
module Catalog
class Fetcher
class EmptyResponse < StandardError
end

Expand Down Expand Up @@ -59,4 +60,5 @@ def default_options
}
end
end
end
end
Expand Up @@ -20,7 +20,8 @@
require "droonga/safe_file_writer"

module Droonga
class CatalogModifier
module Catalog
class Modifier
def initialize(source_catalog)
@generator = Catalog::Generator.new
@generator.load(source_catalog)
Expand All @@ -33,4 +34,5 @@ def modify
end
end
end
end
end
22 changes: 11 additions & 11 deletions lib/droonga/command/remote.rb
Expand Up @@ -20,8 +20,8 @@
require "droonga/node_name"
require "droonga/node_metadata"
require "droonga/catalog/generator"
require "droonga/catalog_modifier"
require "droonga/catalog_fetcher"
require "droonga/catalog/modifier"
require "droonga/catalog/fetcher"
require "droonga/data_absorber"
require "droonga/safe_file_writer"
require "droonga/service_installation"
Expand Down Expand Up @@ -217,10 +217,10 @@ def replica_hosts
end

def fetch_catalog
fetcher = CatalogFetcher.new(:host => source_host,
:port => port,
:tag => tag,
:receiver_host => host)
fetcher = Catalog::Fetcher.new(:host => source_host,
:port => port,
:tag => tag,
:receiver_host => host)
fetcher.fetch(:dataset => dataset)
end

Expand All @@ -229,7 +229,7 @@ def join_to_cluster
@serf.join(*@other_hosts)

log("update catalog.json from fetched catalog")
CatalogModifier.new(catalog).modify do |modifier, file|
Catalog::Modifier.new(catalog).modify do |modifier, file|
modifier.datasets[dataset].replicas.hosts += [joining_host]
modifier.datasets[dataset].replicas.hosts.uniq!
@service_installation.ensure_correct_file_permission(file)
Expand Down Expand Up @@ -266,7 +266,7 @@ def process
@serf.join(*hosts)

log("setting replicas to the cluster")
CatalogModifier.new(catalog).modify do |modifier, file|
Catalog::Modifier.new(catalog).modify do |modifier, file|
modifier.datasets[dataset].replicas.hosts = hosts
@service_installation.ensure_correct_file_permission(file)
end
Expand All @@ -286,7 +286,7 @@ def process
@serf.join(*added_hosts)

log("adding replicas to the cluster")
CatalogModifier.new(catalog).modify do |modifier, file|
Catalog::Modifier.new(catalog).modify do |modifier, file|
modifier.datasets[dataset].replicas.hosts += added_hosts
modifier.datasets[dataset].replicas.hosts.uniq!
@service_installation.ensure_correct_file_permission(file)
Expand All @@ -302,7 +302,7 @@ def process
log("removing replicas: #{hosts.join(",")}")

log("removing replicas from the cluster")
CatalogModifier.new(catalog).modify do |modifier, file|
Catalog::Modifier.new(catalog).modify do |modifier, file|
modifier.datasets[dataset].replicas.hosts -= hosts
@service_installation.ensure_correct_file_permission(file)
end
Expand All @@ -317,7 +317,7 @@ def process
log("unjoining replicas: #{hosts.join(",")}")

log("unjoining from the cluster")
CatalogModifier.new(catalog).modify do |modifier, file|
Catalog::Modifier.new(catalog).modify do |modifier, file|
if unjoining_node?
modifier.datasets[dataset].replicas.hosts = hosts
else
Expand Down
10 changes: 5 additions & 5 deletions lib/droonga/data_absorber_client.rb
Expand Up @@ -18,7 +18,7 @@
require "droonga/catalog/dataset"
require "droonga/client"
require "droonga/catalog/generator"
require "droonga/catalog_fetcher"
require "droonga/catalog/fetcher"

module Droonga
class DataAbsorberClient
Expand Down Expand Up @@ -165,10 +165,10 @@ def source_catalog
end

def fetch_source_catalog
fetcher = CatalogFetcher.new(:host => @source_host,
:port => @source_port,
:tag => @source_tag,
:receiver_host => @receiver_host)
fetcher = Catalog::Fetcher.new(:host => @source_host,
:port => @source_port,
:tag => @source_tag,
:receiver_host => @receiver_host)
fetcher.fetch(:dataset => @source_dataset)
end

Expand Down

0 comments on commit b3dadb5

Please sign in to comment.