HBASE-1342 Add to filesystem info needed to rebuild .META.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@770844 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-05-01 22:34:03 +00:00
parent dc3e57659d
commit c8cdf88bf3
6 changed files with 52 additions and 4 deletions

View File

@ -14,6 +14,7 @@ Release 0.20.0 - Unreleased
HBASE-1234 Change HBase StoreKey format
HBASE-1348 Move 0.20.0 targeted TRUNK to 0.20.0 hadoop
(Ryan Rawson and Stack)
HBASE-1342 Add to filesystem info needed to rebuild .META.
BUG FIXES
HBASE-1140 "ant clean test" fails (Nitay Joffe via Stack)

View File

@ -279,7 +279,8 @@ public class HColumnDescriptor implements ISerializable, WritableComparable<HCol
* @return <code>b</code>
* @throws IllegalArgumentException If not null and not a legitimate family
* name: i.e. 'printable' and ends in a ':' (Null passes are allowed because
* <code>b</code> can be null when deserializing).
* <code>b</code> can be null when deserializing). Cannot start with a '.'
* either.
*/
public static byte [] isLegalFamilyName(final byte [] b) {
if (b == null) {
@ -289,6 +290,10 @@ public class HColumnDescriptor implements ISerializable, WritableComparable<HCol
throw new IllegalArgumentException("Family names must end in a colon: " +
Bytes.toString(b));
}
if (b[0] == '.') {
throw new IllegalArgumentException("Family names cannot start with a " +
"period: " + Bytes.toString(b));
}
for (int i = 0; i < (b.length - 1); i++) {
if (Character.isISOControl(b[i])) {
throw new IllegalArgumentException("Illegal character <" + b[i] +

View File

@ -191,7 +191,7 @@ public class HMsg implements Writable {
// If null or empty region, don't bother printing it out.
if (this.info != null && this.info.getRegionName().length > 0) {
sb.append(": ");
sb.append(this.info.getRegionNameAsString());
sb.append(this.info.toString());
}
if (this.message != null && this.message.length > 0) {
sb.append(": " + Bytes.toString(this.message));

View File

@ -259,7 +259,8 @@ abstract class BaseScanner extends Chore implements HConstants {
parent.getRegionName(), rowContent, COL_SPLITB);
if (!hasReferencesA && !hasReferencesB) {
LOG.info("Deleting region " + parent.getRegionNameAsString() +
" because daughter splits no longer hold references");
" (encoded=" + parent.getEncodedName() +
") because daughter splits no longer hold references");
HRegion.deleteRegion(this.master.fs, this.master.rootdir, parent);
HRegion.removeRegionFromMETA(srvr, metaRegionName,
parent.getRegionName());

View File

@ -40,6 +40,7 @@ import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@ -196,6 +197,17 @@ public class HRegion implements HConstants {
private final Object splitLock = new Object();
private long minSequenceId;
final AtomicInteger activeScannerCount = new AtomicInteger(0);
/**
* Name of the region info file that resides just under the region directory.
*/
public final static String REGIONINFO_FILE = ".regioninfo";
/**
* REGIONINFO_FILE as byte array.
*/
public final static byte [] REGIONINFO_FILE_BYTES =
Bytes.toBytes(REGIONINFO_FILE);
/**
* HRegion constructor.
@ -261,6 +273,9 @@ public class HRegion implements HConstants {
public void initialize( Path initialFiles, final Progressable reporter)
throws IOException {
Path oldLogFile = new Path(regiondir, HREGION_OLDLOGFILE_NAME);
// Write HRI to a file in case we need to recover .META.
checkRegioninfoOnFilesystem();
// Move prefab HStore files into place (if any). This picks up split files
// and any merges from splits and merges dirs.
@ -316,6 +331,32 @@ public class HRegion implements HConstants {
" available");
}
/*
* Write out an info file under the region directory. Useful recovering
* mangled regions.
* @throws IOException
*/
private void checkRegioninfoOnFilesystem() throws IOException {
// Name of this file has two leading and trailing underscores so it doesn't
// clash w/ a store/family name. There is possibility, but assumption is
// that its slim (don't want to use control character in filename because
//
Path regioninfo = new Path(this.regiondir, REGIONINFO_FILE);
if (this.fs.exists(regioninfo) &&
this.fs.getFileStatus(regioninfo).getLen() > 0) {
return;
}
FSDataOutputStream out = this.fs.create(regioninfo, true);
try {
this.regionInfo.write(out);
out.write('\n');
out.write('\n');
out.write(Bytes.toBytes(this.regionInfo.toString()));
} finally {
out.close();
}
}
/**
* @return Updates to this region need to have a sequence id that is >= to
* the this number.

View File

@ -1280,7 +1280,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
void reportSplit(HRegionInfo oldRegion, HRegionInfo newRegionA,
HRegionInfo newRegionB) {
outboundMsgs.add(new HMsg(HMsg.Type.MSG_REPORT_SPLIT, oldRegion,
(oldRegion.getRegionNameAsString() + " split; daughters: " +
("Daughters; " +
newRegionA.getRegionNameAsString() + ", " +
newRegionB.getRegionNameAsString()).getBytes()));
outboundMsgs.add(new HMsg(HMsg.Type.MSG_REPORT_OPEN, newRegionA));