Class: Riddle::Configuration::DistributedIndex

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ DistributedIndex

Returns a new instance of DistributedIndex.



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

def initialize(name)
  @name             = name
  @local_indexes    = []
  @remote_indexes   = []
  @agent_blackhole  = []
end

Instance Attribute Details

#agent_blackholeObject

Returns the value of attribute agent_blackhole.



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

def agent_blackhole
  @agent_blackhole
end

#agent_connect_timeoutObject

Returns the value of attribute agent_connect_timeout.



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

def agent_connect_timeout
  @agent_connect_timeout
end

#agent_query_timeoutObject

Returns the value of attribute agent_query_timeout.



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

def agent_query_timeout
  @agent_query_timeout
end

#local_indexesObject

Returns the value of attribute local_indexes.



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

def local_indexes
  @local_indexes
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#remote_indexesObject

Returns the value of attribute remote_indexes.



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

def remote_indexes
  @remote_indexes
end

Instance Method Details

#agentObject



25
26
27
28
29
30
31
32
# File 'lib/riddle/configuration/distributed_index.rb', line 25

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

#localObject



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

def local
  self.local_indexes
end

#renderObject

Raises:



34
35
36
37
38
39
40
41
42
# File 'lib/riddle/configuration/distributed_index.rb', line 34

def render
  raise ConfigurationError unless valid?
  
  (
    ["index #{name}", "{"] +
    settings_body +
    ["}", ""]
  ).join("\n")
end

#typeObject



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

def type
  "distributed"
end

#valid?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/riddle/configuration/distributed_index.rb', line 44

def valid?
  @local_indexes.length > 0 || @remote_indexes.length > 0
end