HBASE-548 Tool to online single region

M    branches/0.1/src/java/org/apache/hadoop/hbase/util/MetaUtils.java
M    trunk/src/java/org/apache/hadoop/hbase/util/MetaUtils.java
    (changeOnlineStatus): Added.



git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@643486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-04-01 17:52:46 +00:00
parent f15048d4d0
commit 6c124cd285
2 changed files with 33 additions and 1 deletions

View File

@ -7,6 +7,9 @@ Hbase Change Log
HBASE-505 Region assignments should never time out so long as the region
server reports that it is processing the open request
NEW FEATURES
HBASE-548 Tool to online single region
Release 0.1.0
INCOMPATIBLE CHANGES

View File

@ -40,6 +40,7 @@ import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HScannerInterface;
import org.apache.hadoop.hbase.HStoreKey;
import org.apache.hadoop.hbase.HTable;
/**
* Contains utility methods for manipulating HBase meta tables
@ -295,4 +296,32 @@ public class MetaUtils {
meta.compactStores();
return meta;
}
}
/**
* Set a single region on/offline.
* This is a tool to repair tables that have offlined tables in their midst.
* Can happen on occasion. Use at your own risk. Call from a bit of java
* or jython script. This method is 'expensive' in that it creates a
* {@link HTable} instance per invocation to go against <code>.META.</code>
* @param c A configuration that has its <code>hbase.master</code>
* properly set.
* @param row Row in the catalog .META. table whose HRegionInfo's offline
* status we want to change.
* @param onlineOffline Pass <code>true</code> to online the region.
* @throws IOException
*/
public static void changeOnlineStatus (final HBaseConfiguration c,
final Text row, final boolean onlineOffline)
throws IOException {
HTable t = new HTable(c, HConstants.META_TABLE_NAME);
byte [] cell = t.get(row, HConstants.COL_REGIONINFO);
// Throws exception if null.
HRegionInfo info = Writables.getHRegionInfo(cell);
long id = t.startUpdate(row);
info.setOffline(onlineOffline);
t.put(id, HConstants.COL_REGIONINFO, Writables.getBytes(info));
t.delete(id, HConstants.COL_SERVER);
t.delete(id, HConstants.COL_STARTCODE);
t.commit(id);
}
}