HADOOP-2686 Removed tables stick around in .META.
git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@614588 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
af3ca76470
commit
52b268a09c
|
@ -145,6 +145,7 @@ Trunk (unreleased changes)
|
|||
hadoop instead
|
||||
HADOOP-2668 Documentation and improved logging so fact that hbase now
|
||||
requires migration comes as less of a surprise
|
||||
HADOOP-2686 Removed tables stick around in .META.
|
||||
|
||||
IMPROVEMENTS
|
||||
HADOOP-2401 Add convenience put method that takes writable
|
||||
|
|
|
@ -149,6 +149,12 @@ public interface HConstants {
|
|||
|
||||
/** the upper half of a split region */
|
||||
static final Text COL_SPLITB = new Text(COLUMN_FAMILY_STR + "splitB");
|
||||
|
||||
/** All the columns in the catalog -ROOT- and .META. tables.
|
||||
*/
|
||||
static final Text[] ALL_META_COLUMNS = {COL_REGIONINFO, COL_SERVER,
|
||||
COL_STARTCODE, COL_SPLITA, COL_SPLITB};
|
||||
|
||||
// Other constants
|
||||
|
||||
/**
|
||||
|
|
|
@ -332,19 +332,13 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
|
||||
if (!hasReferencesA && !hasReferencesB) {
|
||||
LOG.info("Deleting region " + parent.getRegionName() +
|
||||
" because daughter splits no longer hold references");
|
||||
" because daughter splits no longer hold references");
|
||||
if (!HRegion.deleteRegion(fs, rootdir, parent)) {
|
||||
LOG.warn("Deletion of " + parent.getRegionName() + " failed");
|
||||
}
|
||||
|
||||
BatchUpdate b = new BatchUpdate(rand.nextLong());
|
||||
long lockid = b.startUpdate(parent.getRegionName());
|
||||
b.delete(lockid, COL_REGIONINFO);
|
||||
b.delete(lockid, COL_SERVER);
|
||||
b.delete(lockid, COL_STARTCODE);
|
||||
b.delete(lockid, COL_SPLITA);
|
||||
b.delete(lockid, COL_SPLITB);
|
||||
srvr.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
|
||||
HRegion.removeRegionFromMETA(srvr, metaRegionName,
|
||||
parent.getRegionName());
|
||||
result = true;
|
||||
} else if (LOG.isDebugEnabled()) {
|
||||
// If debug, note we checked and current state of daughters.
|
||||
|
@ -2069,7 +2063,7 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
break;
|
||||
}
|
||||
LOG.info(info.getRegionName() + " was on shutdown server <" +
|
||||
serverName + "> (or server is null). Marking unassigned if " +
|
||||
serverName + "> (or server is null). Marking unassigned in " +
|
||||
"meta and clearing pendingRegions");
|
||||
|
||||
if (info.isMetaTable()) {
|
||||
|
@ -2126,19 +2120,13 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
}
|
||||
}
|
||||
|
||||
// Remove server from root/meta entries
|
||||
// Update server in root/meta entries
|
||||
for (ToDoEntry e: toDoList) {
|
||||
BatchUpdate b = new BatchUpdate(rand.nextLong());
|
||||
long lockid = b.startUpdate(e.row);
|
||||
if (e.deleteRegion) {
|
||||
b.delete(lockid, COL_REGIONINFO);
|
||||
} else if (e.regionOffline) {
|
||||
e.info.setOffline(true);
|
||||
b.put(lockid, COL_REGIONINFO, Writables.getBytes(e.info));
|
||||
HRegion.removeRegionFromMETA(server, regionName, e.row);
|
||||
} else {
|
||||
HRegion.offlineRegionInMETA(server, regionName, e.info);
|
||||
}
|
||||
b.delete(lockid, COL_SERVER);
|
||||
b.delete(lockid, COL_STARTCODE);
|
||||
server.batchUpdate(regionName, System.currentTimeMillis(), b);
|
||||
}
|
||||
|
||||
// Get regions reassigned
|
||||
|
@ -2384,22 +2372,14 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
return true;
|
||||
}
|
||||
|
||||
HRegionInterface server = getMetaServer();
|
||||
try {
|
||||
BatchUpdate b = new BatchUpdate(rand.nextLong());
|
||||
long lockid = b.startUpdate(regionInfo.getRegionName());
|
||||
|
||||
if (deleteRegion) {
|
||||
b.delete(lockid, COL_REGIONINFO);
|
||||
|
||||
} else if (!reassignRegion ) {
|
||||
regionInfo.setOffline(true);
|
||||
b.put(lockid, COL_REGIONINFO, Writables.getBytes(regionInfo));
|
||||
HRegion.removeRegionFromMETA(getMetaServer(), metaRegionName,
|
||||
regionInfo.getRegionName());
|
||||
} else {
|
||||
HRegion.offlineRegionInMETA(getMetaServer(), metaRegionName,
|
||||
regionInfo);
|
||||
}
|
||||
b.delete(lockid, COL_SERVER);
|
||||
b.delete(lockid, COL_STARTCODE);
|
||||
server.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
|
||||
|
||||
break;
|
||||
|
||||
} catch (IOException e) {
|
||||
|
@ -3012,9 +2992,11 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
|
||||
@Override
|
||||
protected void updateRegionInfo(BatchUpdate b,
|
||||
@SuppressWarnings("unused") HRegionInfo i) {
|
||||
|
||||
b.delete(lockid, COL_REGIONINFO);
|
||||
@SuppressWarnings("unused") HRegionInfo info) {
|
||||
for (int i = 0; i < ALL_META_COLUMNS.length; i++) {
|
||||
// Be sure to clean all columns
|
||||
b.delete(lockid, ALL_META_COLUMNS[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1816,6 +1816,7 @@ public class HRegion implements HConstants {
|
|||
* @param r HRegion to add to <code>meta</code>
|
||||
*
|
||||
* @throws IOException
|
||||
* @see {@link #removeRegionFromMETA(HRegion, HRegion)}
|
||||
*/
|
||||
static void addRegionToMETA(HRegion meta, HRegion r) throws IOException {
|
||||
meta.checkResources();
|
||||
|
@ -1833,7 +1834,52 @@ public class HRegion implements HConstants {
|
|||
meta.releaseRowLock(row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a region's meta information from the passed
|
||||
* <code>meta</code> region.
|
||||
*
|
||||
* @param srvr META server to be updated
|
||||
* @param metaRegionName Meta region name
|
||||
* @param regionNmae HRegion to remove from <code>meta</code>
|
||||
*
|
||||
* @throws IOException
|
||||
* @see {@link #addRegionToMETA(HRegion, HRegion)}
|
||||
*/
|
||||
static void removeRegionFromMETA(final HRegionInterface srvr,
|
||||
final Text metaRegionName, final Text regionName)
|
||||
throws IOException {
|
||||
BatchUpdate b = new BatchUpdate(rand.nextLong());
|
||||
long lockid = b.startUpdate(regionName);
|
||||
for (int i = 0; i < ALL_META_COLUMNS.length; i++) {
|
||||
b.delete(lockid, ALL_META_COLUMNS[i]);
|
||||
}
|
||||
srvr.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method used by HMaster marking regions offlined.
|
||||
* @param srvr META server to be updated
|
||||
* @param metaRegionName Meta region name
|
||||
* @param info HRegion to update in <code>meta</code>
|
||||
*
|
||||
* @throws IOException
|
||||
* @see {@link #addRegionToMETA(HRegion, HRegion)}
|
||||
*/
|
||||
static void offlineRegionInMETA(final HRegionInterface srvr,
|
||||
final Text metaRegionName, final HRegionInfo info)
|
||||
throws IOException {
|
||||
BatchUpdate b = new BatchUpdate(rand.nextLong());
|
||||
long lockid = b.startUpdate(info.getRegionName());
|
||||
info.setOffline(true);
|
||||
b.put(lockid, COL_REGIONINFO, Writables.getBytes(info));
|
||||
b.delete(lockid, COL_SERVER);
|
||||
b.delete(lockid, COL_STARTCODE);
|
||||
// If carrying splits, they'll be in place when we show up on new
|
||||
// server.
|
||||
srvr.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all the files for a HRegion
|
||||
*
|
||||
|
|
|
@ -252,7 +252,7 @@ public class HRegionInfo implements WritableComparable {
|
|||
public String toString() {
|
||||
return "regionname: " + this.regionName.toString() + ", startKey: <" +
|
||||
this.startKey.toString() + ">, endKey: <" + this.endKey.toString() +
|
||||
">, encodedName(" + getEncodedName() + ")" +
|
||||
">, encodedName: " + getEncodedName() + "," +
|
||||
(isOffline()? " offline: true,": "") + (isSplit()? " split: true,": "") +
|
||||
" tableDesc: {" + this.tableDesc.toString() + "}";
|
||||
}
|
||||
|
|
|
@ -132,6 +132,9 @@ public class HTableDescriptor implements WritableComparable {
|
|||
* @param family HColumnDescriptor of familyto add.
|
||||
*/
|
||||
public void addFamily(HColumnDescriptor family) {
|
||||
if (family.getName() == null || family.getName().getLength() <= 0) {
|
||||
throw new NullPointerException("Family name cannot be null or empty");
|
||||
}
|
||||
families.put(family.getName(), family);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class TestToString extends TestCase {
|
|||
HRegionInfo hri = HRegionInfo.rootRegionInfo;
|
||||
System.out.println(hri.toString());
|
||||
assertEquals("HRegionInfo",
|
||||
"regionname: -ROOT-,,0, startKey: <>, endKey: <>, encodedName(70236052) tableDesc: " +
|
||||
"regionname: -ROOT-,,0, startKey: <>, endKey: <>, encodedName: 70236052, tableDesc: " +
|
||||
"{name: -ROOT-, families: {info:={name: info, max versions: 1, " +
|
||||
"compression: NONE, in memory: false, max length: 2147483647, bloom " +
|
||||
"filter: none}}}", hri.toString());
|
||||
|
|
Loading…
Reference in New Issue