lib/zold/commands/remote.rb in zold-0.11.5 vs lib/zold/commands/remote.rb in zold-0.11.6
- old
+ new
@@ -56,10 +56,12 @@
Restore it back to the default list of nodes
#{Rainbow('remote add').green} host [port]
Add a new remote node
#{Rainbow('remote remove').green} host [port]
Remove the remote node
+ #{Rainbow('remote trim').green}
+ Remote the least reliable nodes
#{Rainbow('remote update').green}
Check each registered remote node for availability
Available options:"
o.bool '--ignore-score-weakness',
'Don\'t complain when their score is too weak',
@@ -84,10 +86,12 @@
reset
when 'add'
add(mine[1], mine[2] ? mine[2].to_i : Remotes::PORT, opts)
when 'remove'
remove(mine[1], mine[2] ? mine[2].to_i : Remotes::PORT, opts)
+ when 'trim'
+ trim(opts)
when 'update'
update(opts)
update(opts, false)
else
raise "Unknown command '#{command}'"
@@ -131,9 +135,15 @@
else
raise "#{host}:#{port} is not in the list" unless opts['force']
@log.info("#{host}:#{port} is not in the list")
end
@log.info("There are #{@remotes.all.count} remote nodes in the list")
+ end
+
+ def trim(opts)
+ @remotes.all.each do |r|
+ remove(r[:host], r[:port], opts) if r[:errors] > 20
+ end
end
def update(opts, deep = true)
capacity = []
@remotes.iterate(@log, farm: @farm) do |r|