Class: Droonga::Catalog::Version1

Inherits:
Base
  • Object
show all
Defined in:
lib/droonga/catalog/version1.rb

Defined Under Namespace

Classes: Dataset

Instance Attribute Summary

Attributes inherited from Base

#base_path, #path

Instance Method Summary collapse

Methods inherited from Base

#cluster_id, #dataset, #have_dataset?

Constructor Details

#initialize(raw, path) ⇒ Version1

Returns a new instance of Version1.

Raises:



26
27
28
29
30
31
32
33
34
# File 'lib/droonga/catalog/version1.rb', line 26

def initialize(raw, path)
  super
  @errors = []

  validate
  raise MultiplexError.new(@errors) unless @errors.empty?

  prepare_data
end

Instance Method Details

#all_nodesObject



75
76
77
# File 'lib/droonga/catalog/version1.rb', line 75

def all_nodes
  @all_nodes ||= collect_all_nodes
end

#datasetsObject



36
37
38
# File 'lib/droonga/catalog/version1.rb', line 36

def datasets
  @datasets
end

#get_partitions(name) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/droonga/catalog/version1.rb', line 44

def get_partitions(name)
  device = @raw["farms"][name]["device"]
  pattern = Regexp.new("^#{name}\.")
  results = {}
  @raw["datasets"].each do |dataset_name, dataset_data|
    dataset = Dataset.new(dataset_name, dataset_data)
    workers = dataset["workers"]
    plugins = dataset["plugins"]
    dataset["ring"].each do |key, part|
      part["partitions"].each do |range, partitions|
        partitions.each do |partition|
          if partition =~ pattern
            database_name = $POSTMATCH
            path = Path.databases(base_path) +
                     device + database_name + "db"
            migrate_database_location(path, device, database_name)
            options = {
              :dataset => dataset_name,
              :database => path.to_s,
              :n_workers => workers,
              :plugins => plugins
            }
            results[partition] = options
          end
        end
      end
    end
  end
  return results
end

#slices(name) ⇒ Object



40
41
42
# File 'lib/droonga/catalog/version1.rb', line 40

def slices(name)
  get_partitions(name)
end