Class: Gizzard::Nameserver

Inherits:
Object
  • Object
show all
Includes:
ParallelMap
Defined in:
lib/gizzard/nameserver.rb

Defined Under Namespace

Classes: Manifest

Constant Summary collapse

DEFAULT_PORT =
7920
DEFAULT_RETRIES =
10
PARALLELISM =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ParallelMap

#parallel_map

Constructor Details

#initialize(*hosts) ⇒ Nameserver

Returns a new instance of Nameserver.



104
105
106
107
108
109
110
111
# File 'lib/gizzard/nameserver.rb', line 104

def initialize(*hosts)
  options = hosts.last.is_a?(Hash) ? hosts.pop : {}
  @retries = options[:retries] || DEFAULT_RETRIES
  @logfile = options[:log]     || "/tmp/gizzmo.log"
  @dryrun  = options[:dry_run] || false
  @framed  = options[:framed]  || false
  @hosts   = hosts.flatten
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



148
149
150
151
152
153
154
# File 'lib/gizzard/nameserver.rb', line 148

def method_missing(method, *args, &block)
  if client.respond_to?(method)
    with_retry { client.send(method, *args, &block) }
  else
    super
  end
end

Instance Attribute Details

#dryrunObject (readonly) Also known as: dryrun?

Returns the value of attribute dryrun.



101
102
103
# File 'lib/gizzard/nameserver.rb', line 101

def dryrun
  @dryrun
end

#framedObject (readonly)

Returns the value of attribute framed.



101
102
103
# File 'lib/gizzard/nameserver.rb', line 101

def framed
  @framed
end

#hostsObject (readonly)

Returns the value of attribute hosts.



101
102
103
# File 'lib/gizzard/nameserver.rb', line 101

def hosts
  @hosts
end

#logfileObject (readonly)

Returns the value of attribute logfile.



101
102
103
# File 'lib/gizzard/nameserver.rb', line 101

def logfile
  @logfile
end

Instance Method Details

#copy_shard(*shards) ⇒ Object



129
130
131
132
# File 'lib/gizzard/nameserver.rb', line 129

def copy_shard(*shards)
  c = random_client
  with_retry { c.copy_shard(*shards) }
end

#diff_shards(*shards) ⇒ Object



139
140
141
142
# File 'lib/gizzard/nameserver.rb', line 139

def diff_shards(*shards)
  c = random_client
  with_retry { c.diff_shards(*shards) }
end

#get_shards(ids) ⇒ Object



113
114
115
# File 'lib/gizzard/nameserver.rb', line 113

def get_shards(ids)
  ids.map {|id| with_retry { client.get_shard(id) } }
end

#manifest(*table_ids) ⇒ Object



156
157
158
# File 'lib/gizzard/nameserver.rb', line 156

def manifest(*table_ids)
  Manifest.new(self, table_ids)
end

#reload_configObject



123
124
125
126
127
# File 'lib/gizzard/nameserver.rb', line 123

def reload_config
  parallel_map all_clients do |c|
    with_retry { c.reload_config }
  end
end

#reload_updated_forwardingsObject



117
118
119
120
121
# File 'lib/gizzard/nameserver.rb', line 117

def reload_updated_forwardings
  parallel_map all_clients do |c|
    with_retry { c.reload_updated_forwardings }
  end
end

#repair_shards(*shards) ⇒ Object



134
135
136
137
# File 'lib/gizzard/nameserver.rb', line 134

def repair_shards(*shards)
  c = random_client
  with_retry { c.repair_shard(*shards) }
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/gizzard/nameserver.rb', line 144

def respond_to?(method)
  client.respond_to? method or super
end