Class: Riddle::Configuration::DistributedIndex

Inherits:
Section
  • Object
show all
Defined in:
lib/riddle/configuration/distributed_index.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ DistributedIndex

Returns a new instance of DistributedIndex.



16
17
18
19
20
21
# File 'lib/riddle/configuration/distributed_index.rb', line 16

def initialize(name)
  @name             = name
  @local_indices    = []
  @remote_indices   = []
  @agent_blackhole  = []
end

Instance Attribute Details

#agent_blackholeObject

Returns the value of attribute agent_blackhole.



13
14
15
# File 'lib/riddle/configuration/distributed_index.rb', line 13

def agent_blackhole
  @agent_blackhole
end

#agent_connect_timeoutObject

Returns the value of attribute agent_connect_timeout.



13
14
15
# File 'lib/riddle/configuration/distributed_index.rb', line 13

def agent_connect_timeout
  @agent_connect_timeout
end

#agent_query_timeoutObject

Returns the value of attribute agent_query_timeout.



13
14
15
# File 'lib/riddle/configuration/distributed_index.rb', line 13

def agent_query_timeout
  @agent_query_timeout
end

#local_indicesObject

Returns the value of attribute local_indices.



13
14
15
# File 'lib/riddle/configuration/distributed_index.rb', line 13

def local_indices
  @local_indices
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/riddle/configuration/distributed_index.rb', line 13

def name
  @name
end

#remote_indicesObject

Returns the value of attribute remote_indices.



13
14
15
# File 'lib/riddle/configuration/distributed_index.rb', line 13

def remote_indices
  @remote_indices
end

Class Method Details

.settingsObject



6
7
8
9
10
11
# File 'lib/riddle/configuration/distributed_index.rb', line 6

def self.settings
  [
    :type, :local, :agent, :agent_blackhole,
    :agent_connect_timeout, :agent_query_timeout
  ]
end

Instance Method Details

#agentObject



31
32
33
34
35
36
37
38
# File 'lib/riddle/configuration/distributed_index.rb', line 31

def agent
  agents = remote_indices.collect { |index| index.remote }.uniq
  agents.collect { |agent|
    agent + ":" + remote_indices.select { |index|
      index.remote == agent
    }.collect { |index| index.name }.join(",")
  }
end

#localObject



27
28
29
# File 'lib/riddle/configuration/distributed_index.rb', line 27

def local
  self.local_indices
end

#renderObject

Raises:



40
41
42
43
44
45
46
47
48
# File 'lib/riddle/configuration/distributed_index.rb', line 40

def render
  raise ConfigurationError unless valid?

  (
    ["index #{name}", "{"] +
    settings_body +
    ["}", ""]
  ).join("\n")
end

#typeObject



23
24
25
# File 'lib/riddle/configuration/distributed_index.rb', line 23

def type
  "distributed"
end

#valid?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/riddle/configuration/distributed_index.rb', line 50

def valid?
  @local_indices.length > 0 || @remote_indices.length > 0
end