HBASE-1092 shell tools -> close_region does not work for regions that did not deploy properly on startup

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@730056 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-12-30 07:02:24 +00:00
parent 10ee76be96
commit 9f9198e21e
4 changed files with 24 additions and 14 deletions

View File

@ -122,6 +122,8 @@ Release 0.19.0 - Unreleased
HBASE-1098 IllegalStateException: Cannot set a region to be closed it it
was not already marked as closing
HBASE-1100 HBASE-1062 broke TestForceSplit
HBASE-1191 shell tools -> close_region does not work for regions that did
not deploy properly on startup
IMPROVEMENTS
HBASE-901 Add a limit to key length, check key and value length on client side

View File

@ -116,7 +116,6 @@ class ChangeTableState extends TableOperation {
}
// Cause regions being served to be taken off-line and disabled
for (HRegionInfo i: e.getValue()) {
if (LOG.isDebugEnabled()) {
LOG.debug("adding region " + i.getRegionNameAsString() + " to kill list");

View File

@ -792,6 +792,7 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
LOG.info("modifyTable(SET_HTD): " + htd);
new ModifyTableMeta(this, tableName, htd).process();
break;
case MODIFY_TABLE_SPLIT:
case MODIFY_TABLE_COMPACT:
if (args != null && args.length > 0) {
@ -833,7 +834,7 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
LOG.info("Marking " + hri.getRegionNameAsString() +
" as closed on " + servername + "; cleaning SERVER + STARTCODE; " +
"master will tell regionserver to close region on next heartbeat");
this.regionManager.setClosing(servername, hri, false);
this.regionManager.setClosing(servername, hri, hri.isOffline(), false);
MetaRegion meta = this.regionManager.getMetaRegionForRow(regionname);
HRegionInterface srvr = getMETAServer(meta);
HRegion.cleanRegionInMETA(srvr, meta.getRegionName(), hri);

View File

@ -405,12 +405,10 @@ class RegionManager implements HConstants {
private void unassignSomeRegions(final String serverName,
final HServerLoad load, final double avgLoad,
final HRegionInfo[] mostLoadedRegions, ArrayList<HMsg> returnMsgs) {
int numRegionsToClose = load.getNumberOfRegions() - (int)Math.ceil(avgLoad);
LOG.debug("Choosing to reassign " + numRegionsToClose
+ " regions. mostLoadedRegions has " + mostLoadedRegions.length
+ " regions in it.");
int regionIdx = 0;
int regionsClosed = 0;
int skipped = 0;
@ -422,14 +420,12 @@ class RegionManager implements HConstants {
if (currentRegion.isRootRegion() || currentRegion.isMetaTable()) {
continue;
}
byte[] regionName = currentRegion.getRegionName();
if (isClosing(regionName) || isUnassigned(currentRegion) ||
isAssigned(regionName) || isPending(regionName)) {
skipped++;
continue;
}
LOG.debug("Going to close region " +
currentRegion.getRegionNameAsString());
// make a message to close the region
@ -788,21 +784,33 @@ class RegionManager implements HConstants {
* @param regionInfo
* @param setOffline
*/
public void setClosing(String serverName, HRegionInfo regionInfo,
boolean setOffline) {
synchronized (regionsInTransition) {
RegionState s = regionsInTransition.get(regionInfo.getRegionName());
if (s != null) {
public void setClosing(final String serverName, final HRegionInfo regionInfo,
final boolean setOffline) {
setClosing(serverName, regionInfo, setOffline, true);
}
/**
* Mark a region as closing
* @param serverName
* @param regionInfo
* @param setOffline
* @param check False if we are to skip state transition check.
*/
void setClosing(final String serverName, final HRegionInfo regionInfo,
final boolean setOffline, final boolean check) {
synchronized (this.regionsInTransition) {
RegionState s = this.regionsInTransition.get(regionInfo.getRegionName());
if (check && s != null) {
if (!s.isClosing()) {
throw new IllegalStateException(
"Cannot transition to closing from any other state. Region: " +
Bytes.toString(regionInfo.getRegionName()));
"Cannot transition to closing from any other state. Region: " +
Bytes.toString(regionInfo.getRegionName()));
}
return;
}
s = new RegionState(regionInfo);
s.setClosing(serverName, setOffline);
regionsInTransition.put(regionInfo.getRegionName(), s);
this.regionsInTransition.put(regionInfo.getRegionName(), s);
}
}