HBASE-4005 close_region bugs

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1138246 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-06-21 23:29:28 +00:00
parent a6ef251118
commit 7e87980347
4 changed files with 31 additions and 19 deletions

View File

@ -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

View File

@ -742,34 +742,36 @@ public class HBaseAdmin implements Abortable, Closeable {
* 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 Abortable, Closeable {
}
}
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());

View File

@ -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
#----------------------------------------------------------------------------------------------

View File

@ -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