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


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

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

Instance Attribute Details

#agent_blackholeObject

Returns the value of attribute agent_blackhole


11
12
13
# File 'lib/riddle/configuration/distributed_index.rb', line 11

def agent_blackhole
  @agent_blackhole
end

#agent_connect_timeoutObject

Returns the value of attribute agent_connect_timeout


11
12
13
# File 'lib/riddle/configuration/distributed_index.rb', line 11

def agent_connect_timeout
  @agent_connect_timeout
end

#agent_query_timeoutObject

Returns the value of attribute agent_query_timeout


11
12
13
# File 'lib/riddle/configuration/distributed_index.rb', line 11

def agent_query_timeout
  @agent_query_timeout
end

#local_indicesObject

Returns the value of attribute local_indices


11
12
13
# File 'lib/riddle/configuration/distributed_index.rb', line 11

def local_indices
  @local_indices
end

#nameObject

Returns the value of attribute name


11
12
13
# File 'lib/riddle/configuration/distributed_index.rb', line 11

def name
  @name
end

#remote_indicesObject

Returns the value of attribute remote_indices


11
12
13
# File 'lib/riddle/configuration/distributed_index.rb', line 11

def remote_indices
  @remote_indices
end

Class Method Details

.settingsObject


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

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

Instance Method Details

#agentObject


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

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


25
26
27
# File 'lib/riddle/configuration/distributed_index.rb', line 25

def local
  self.local_indices
end

#renderObject

Raises:


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

def render
  raise ConfigurationError unless valid?

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

#typeObject


21
22
23
# File 'lib/riddle/configuration/distributed_index.rb', line 21

def type
  "distributed"
end

#valid?Boolean

Returns:

  • (Boolean)

48
49
50
# File 'lib/riddle/configuration/distributed_index.rb', line 48

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