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-3995 HBASE-3946 broke TestMasterFailover
HBASE-2077 NullPointerException with an open scanner that expired causing HBASE-2077 NullPointerException with an open scanner that expired causing
an immediate region server shutdown -- part 2. an immediate region server shutdown -- part 2.
HBASE-4005 close_region bugs
IMPROVEMENT 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 * Close a region. For expert-admins. Runs close on the regionserver. The
* master will not be informed of the close. * master will not be informed of the close.
* @param regionname region name to 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> * the one currently in <code>.META.</code>
* @throws IOException if a remote or network exception occurs * @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 { throws IOException {
closeRegion(Bytes.toBytes(regionname), hostAndPort); closeRegion(Bytes.toBytes(regionname), serverName);
} }
/** /**
* Close a region. For expert-admins Runs close on the regionserver. The * Close a region. For expert-admins Runs close on the regionserver. The
* master will not be informed of the close. * master will not be informed of the close.
* @param regionname region name to close * @param regionname region name to close
* @param hostAndPort If supplied, we'll use this location rather than * @param serverName The servername of the regionserver. If passed null we
* the one currently in <code>.META.</code> * 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 * @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 { throws IOException {
CatalogTracker ct = getCatalogTracker(); CatalogTracker ct = getCatalogTracker();
try { try {
if (hostAndPort != null) { if (serverName != null) {
Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct, regionname); Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct, regionname);
if (pair == null || pair.getSecond() == null) { if (pair == null || pair.getFirst() == null) {
LOG.info("No server in .META. for " + LOG.info("No region in .META. for " +
Bytes.toStringBinary(regionname) + "; pair=" + pair); Bytes.toStringBinary(regionname) + "; pair=" + pair);
} else { } else {
closeRegion(pair.getSecond(), pair.getFirst()); closeRegion(new ServerName(serverName), pair.getFirst());
} }
} else { } else {
Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct, regionname); 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 { throws IOException {
HRegionInterface rs = HRegionInterface rs =
this.connection.getHRegionConnection(sn.getHostname(), sn.getPort()); this.connection.getHRegionConnection(sn.getHostname(), sn.getPort());

View File

@ -189,7 +189,7 @@ module Hbase
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------
# Closes a region # Closes a region
def close_region(region_name, server = nil) def close_region(region_name, server = nil)
@admin.closeRegion(region_name, server ? [server].to_java : nil) @admin.closeRegion(region_name, server)
end end
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------

View File

@ -23,15 +23,17 @@ module Shell
class CloseRegion < Command class CloseRegion < Command
def help def help
return <<-EOF return <<-EOF
Close a single region. Optionally specify regionserver. Connects to the Close a single region. Optionally specify regionserver 'servername' where
regionserver and runs close on hosting regionserver. The close is done A server name is its host, port plus startcode. For example:
without the master's involvement (It will not know of the close). Once host187.example.com,60020,1289493121758 (find servername in master ui or
closed, region will stay closed. Use assign to reopen/reassign. Use when you do detailed status in shell). Connects to the regionserver and
unassign or move to assign the region elsewhere on cluster. Use with runs close on hosting regionserver. The close is done without the master's
caution. For experts only. Examples: 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'
hbase> close_region 'REGIONNAME', 'REGIONSERVER_IP:PORT' hbase> close_region 'REGIONNAME', 'SERVER_NAME'
EOF EOF
end end