Author: stack
Date: Tue Jun 21 23:29:28 2011
New Revision: 1138246
URL: http://svn.apache.org/viewvc?rev=1138246&view=rev
Log:
HBASE-4005 close_region bugs
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
hbase/trunk/src/main/ruby/hbase/admin.rb
hbase/trunk/src/main/ruby/shell/commands/close_region.rb
Modified: hbase/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1138246&r1=1138245&r2=1138246&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Tue Jun 21 23:29:28 2011
@@ -347,6 +347,7 @@ Release 0.90.4 - Unreleased
HBASE-3995 HBASE-3946 broke TestMasterFailover
HBASE-2077 NullPointerException with an open scanner that expired causing
an immediate region server shutdown -- part 2.
+ HBASE-4005 close_region bugs
IMPROVEMENT
Modified:
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1138246&r1=1138245&r2=1138246&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
Tue Jun 21 23:29:28 2011
@@ -742,34 +742,36 @@ public class HBaseAdmin implements Abort
* Close a region. For expert-admins. Runs close on the regionserver. The
* master will not be informed of the close.
* @param regionname region name to close
- * @param hostAndPort If supplied, we'll use this location rather than
+ * @param serverName If supplied, we'll use this location rather than
* the one currently in <code>.META.</code>
* @throws IOException if a remote or network exception occurs
*/
- public void closeRegion(final String regionname, final String hostAndPort)
+ public void closeRegion(final String regionname, final String serverName)
throws IOException {
- closeRegion(Bytes.toBytes(regionname), hostAndPort);
+ closeRegion(Bytes.toBytes(regionname), serverName);
}
/**
* Close a region. For expert-admins Runs close on the regionserver. The
* master will not be informed of the close.
* @param regionname region name to close
- * @param hostAndPort If supplied, we'll use this location rather than
- * the one currently in <code>.META.</code>
+ * @param serverName The servername of the regionserver. If passed null we
+ * will use servername found in the .META. table. A server name
+ * is made of host, port and startcode. Here is an example:
+ * <code> host187.example.com,60020,1289493121758</code>
* @throws IOException if a remote or network exception occurs
*/
- public void closeRegion(final byte [] regionname, final String hostAndPort)
+ public void closeRegion(final byte [] regionname, final String serverName)
throws IOException {
CatalogTracker ct = getCatalogTracker();
try {
- if (hostAndPort != null) {
+ if (serverName != null) {
Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct,
regionname);
- if (pair == null || pair.getSecond() == null) {
- LOG.info("No server in .META. for " +
+ if (pair == null || pair.getFirst() == null) {
+ LOG.info("No region in .META. for " +
Bytes.toStringBinary(regionname) + "; pair=" + pair);
} else {
- closeRegion(pair.getSecond(), pair.getFirst());
+ closeRegion(new ServerName(serverName), pair.getFirst());
}
} else {
Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct,
regionname);
@@ -785,7 +787,14 @@ public class HBaseAdmin implements Abort
}
}
- private void closeRegion(final ServerName sn, final HRegionInfo hri)
+ /**
+ * Close a region. For expert-admins Runs close on the regionserver. The
+ * master will not be informed of the close.
+ * @param sn
+ * @param hri
+ * @throws IOException
+ */
+ public void closeRegion(final ServerName sn, final HRegionInfo hri)
throws IOException {
HRegionInterface rs =
this.connection.getHRegionConnection(sn.getHostname(), sn.getPort());
Modified: hbase/trunk/src/main/ruby/hbase/admin.rb
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/ruby/hbase/admin.rb?rev=1138246&r1=1138245&r2=1138246&view=diff
==============================================================================
--- hbase/trunk/src/main/ruby/hbase/admin.rb (original)
+++ hbase/trunk/src/main/ruby/hbase/admin.rb Tue Jun 21 23:29:28 2011
@@ -189,7 +189,7 @@ module Hbase
#----------------------------------------------------------------------------------------------
# Closes a region
def close_region(region_name, server = nil)
- @admin.closeRegion(region_name, server ? [server].to_java : nil)
+ @admin.closeRegion(region_name, server)
end
#----------------------------------------------------------------------------------------------
Modified: hbase/trunk/src/main/ruby/shell/commands/close_region.rb
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/ruby/shell/commands/close_region.rb?rev=1138246&r1=1138245&r2=1138246&view=diff
==============================================================================
--- hbase/trunk/src/main/ruby/shell/commands/close_region.rb (original)
+++ hbase/trunk/src/main/ruby/shell/commands/close_region.rb Tue Jun 21
23:29:28 2011
@@ -23,15 +23,17 @@ module Shell
class CloseRegion < Command
def help
return <<-EOF
-Close a single region. Optionally specify regionserver. Connects to the
-regionserver and runs close on hosting regionserver. The close is done
-without the master's involvement (It will not know of the close). Once
-closed, region will stay closed. Use assign to reopen/reassign. Use
-unassign or move to assign the region elsewhere on cluster. Use with
-caution. For experts only. Examples:
+Close a single region. Optionally specify regionserver 'servername' where
+A server name is its host, port plus startcode. For example:
+host187.example.com,60020,1289493121758 (find servername in master ui or
+when you do detailed status in shell). Connects to the regionserver and
+runs close on hosting regionserver. The close is done without the master's
+involvement (It will not know of the close). Once closed, region will stay
+closed. Use assign to reopen/reassign. Use unassign or move to assign the
+region elsewhere on cluster. Use with caution. For experts only. Examples:
hbase> close_region 'REGIONNAME'
- hbase> close_region 'REGIONNAME', 'REGIONSERVER_IP:PORT'
+ hbase> close_region 'REGIONNAME', 'SERVER_NAME'
EOF
end