You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jm...@apache.org on 2012/07/07 00:12:21 UTC

svn commit: r1358450 - in /hbase/branches/0.92: CHANGES.txt bin/region_mover.rb

Author: jmhsieh
Date: Fri Jul  6 22:12:21 2012
New Revision: 1358450

URL: http://svn.apache.org/viewvc?rev=1358450&view=rev
Log:
HBASE-6283 [region_mover.rb] Add option to exclude list of hosts on unload instead of just assuming the source node

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/bin/region_mover.rb

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1358450&r1=1358449&r2=1358450&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Fri Jul  6 22:12:21 2012
@@ -113,6 +113,7 @@ Release 0.92.2 - Unreleased
    HBASE-6067  HBase won't start when hbase.rootdir uses ViewFileSystem
    HBASE-6173  hbck check specified tables only
    HBASE-5360  [uberhbck] Add options for how to handle offline split parents. 
+   HBASE-6283  [region_mover.rb] Add option to exclude list of hosts on unload instead of just assuming the source node
 
   NEW FEATURE
    HBASE-5128  [uber hbck] Online automated repair of table integrity and region consistency problems

Modified: hbase/branches/0.92/bin/region_mover.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/bin/region_mover.rb?rev=1358450&r1=1358449&r2=1358450&view=diff
==============================================================================
--- hbase/branches/0.92/bin/region_mover.rb (original)
+++ hbase/branches/0.92/bin/region_mover.rb Fri Jul  6 22:12:21 2012
@@ -213,6 +213,16 @@ def stripServer(servers, hostname)
   return servername
 end
 
+# Returns a new serverlist that excludes the servername whose hostname portion
+# matches from the passed array of servers.
+def stripExcludes(servers, excludefile)
+  excludes = readExcludes(excludefile)
+  servers =  servers.find_all{|server| !excludes.contains(getHostnameFromServerName(server)) }
+  # return updated servers list
+  return servers
+end
+
+
 # Return servername that matches passed hostname
 def getServerName(servers, hostname)
   servername = nil
@@ -309,6 +319,10 @@ def unloadRegions(options, hostname)
   # Remove the server we are unloading from from list of servers.
   # Side-effect is the servername that matches this hostname 
   servername = stripServer(servers, hostname)
+
+  # Remove the servers in our exclude list from list of servers.
+  servers = stripExcludes(servers, options[:excludesFile])
+  puts "Valid region move targets: ", servers
   movedRegions = java.util.ArrayList.new()
   while true
     rs = getRegions(config, servername)
@@ -383,6 +397,29 @@ def loadRegions(options, hostname)
   end
 end
 
+# Returns an array of hosts to exclude as region move targets
+def readExcludes(filename)
+  if filename == nil
+    return java.util.ArrayList.new()
+  end 
+  if ! File.exist?(filename)  
+      puts "Error: Unable to read host exclude file: ", filename
+      raise RuntimeError
+  end 
+
+  f = File.new(filename, "r")
+  # Read excluded hosts list
+  excludes = java.util.ArrayList.new()
+  while (line = f.gets)
+    line.strip! # do an inplace drop of pre and post whitespaces
+    excludes.add(line) unless line.empty? # exclude empty lines
+  end
+  puts "Excluding hosts as region move targets: ", excludes
+  f.close
+  
+  return excludes
+end
+
 def getFilename(options, targetServer)
   filename = options[:file]
   if not filename
@@ -409,6 +446,9 @@ optparse = OptionParser.new do |opts|
   opts.on('-d', '--debug', 'Display extra debug logging') do
     options[:debug] = true
   end
+  opts.on('-x', '--excludefile=FILE', 'File with hosts-per-line to exclude as unload targets; default excludes only target host; useful for rack decommisioning.') do |file|
+    options[:excludesFile] = file
+  end
 end
 optparse.parse!