HBASE-1215 migration part 7; javadoc and extra setVersion utility
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@796731 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cbc87cd00d
commit
2fc56ed998
|
@ -192,12 +192,25 @@ public class FSUtils {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static void setVersion(FileSystem fs, Path rootdir)
|
public static void setVersion(FileSystem fs, Path rootdir)
|
||||||
|
throws IOException {
|
||||||
|
setVersion(fs, rootdir, HConstants.FILE_SYSTEM_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets version of file system
|
||||||
|
*
|
||||||
|
* @param fs
|
||||||
|
* @param rootdir
|
||||||
|
* @param version
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static void setVersion(FileSystem fs, Path rootdir, String version)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
FSDataOutputStream s =
|
FSDataOutputStream s =
|
||||||
fs.create(new Path(rootdir, HConstants.VERSION_FILE_NAME));
|
fs.create(new Path(rootdir, HConstants.VERSION_FILE_NAME));
|
||||||
s.writeUTF(HConstants.FILE_SYSTEM_VERSION);
|
s.writeUTF(version);
|
||||||
s.close();
|
s.close();
|
||||||
LOG.debug("Created version file to: " + rootdir.toString());
|
LOG.debug("Created version file at " + rootdir.toString() + " set its version at:" + version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,8 +42,6 @@ import org.apache.hadoop.hbase.client.HTable;
|
||||||
import org.apache.hadoop.hbase.client.Put;
|
import org.apache.hadoop.hbase.client.Put;
|
||||||
import org.apache.hadoop.hbase.client.Result;
|
import org.apache.hadoop.hbase.client.Result;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
import org.apache.hadoop.hbase.io.BatchUpdate;
|
|
||||||
import org.apache.hadoop.hbase.io.Cell;
|
|
||||||
import org.apache.hadoop.hbase.regionserver.HLog;
|
import org.apache.hadoop.hbase.regionserver.HLog;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||||
import org.apache.hadoop.hbase.regionserver.InternalScanner;
|
import org.apache.hadoop.hbase.regionserver.InternalScanner;
|
||||||
|
@ -124,7 +122,7 @@ public class MetaUtils {
|
||||||
HRegion meta = metaRegions.get(metaInfo.getRegionName());
|
HRegion meta = metaRegions.get(metaInfo.getRegionName());
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
meta = openMetaRegion(metaInfo);
|
meta = openMetaRegion(metaInfo);
|
||||||
LOG.info("META OPEN " + meta.toString());
|
LOG.info("OPENING META " + meta.toString());
|
||||||
this.metaRegions.put(metaInfo.getRegionName(), meta);
|
this.metaRegions.put(metaInfo.getRegionName(), meta);
|
||||||
}
|
}
|
||||||
return meta;
|
return meta;
|
||||||
|
@ -147,7 +145,7 @@ public class MetaUtils {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
for (HRegion r: metaRegions.values()) {
|
for (HRegion r: metaRegions.values()) {
|
||||||
LOG.info("META CLOSE " + r.toString());
|
LOG.info("CLOSING META " + r.toString());
|
||||||
r.close();
|
r.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -230,6 +228,9 @@ public class MetaUtils {
|
||||||
* TODO: Use Visitor rather than Listener pattern. Allow multiple Visitors.
|
* TODO: Use Visitor rather than Listener pattern. Allow multiple Visitors.
|
||||||
* Use this everywhere we scan meta regions: e.g. in metascanners, in close
|
* Use this everywhere we scan meta regions: e.g. in metascanners, in close
|
||||||
* handling, etc. Have it pass in the whole row, not just HRegionInfo.
|
* handling, etc. Have it pass in the whole row, not just HRegionInfo.
|
||||||
|
* <p>Use for reading meta only. Does not close region when done.
|
||||||
|
* Use {@link #getMetaRegion(HRegionInfo)} instead if writing. Adds
|
||||||
|
* meta region to list that will get a close on {@link #shutdown()}.
|
||||||
*
|
*
|
||||||
* @param metaRegionInfo HRegionInfo for meta region
|
* @param metaRegionInfo HRegionInfo for meta region
|
||||||
* @param listener method to be called for each meta region found
|
* @param listener method to be called for each meta region found
|
||||||
|
@ -255,8 +256,7 @@ public class MetaUtils {
|
||||||
|
|
||||||
Scan scan = new Scan();
|
Scan scan = new Scan();
|
||||||
scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
|
scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
|
||||||
InternalScanner metaScanner =
|
InternalScanner metaScanner = m.getScanner(scan);
|
||||||
m.getScanner(scan);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<KeyValue> results = new ArrayList<KeyValue>();
|
List<KeyValue> results = new ArrayList<KeyValue>();
|
||||||
|
|
|
@ -244,7 +244,6 @@ public class Migrate extends Configured implements Tool {
|
||||||
throw new IOException(msg);
|
throw new IOException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TOOD: Verify all has been brought over from old to new layout.
|
|
||||||
final MetaUtils utils = new MetaUtils(this.conf);
|
final MetaUtils utils = new MetaUtils(this.conf);
|
||||||
final List<HRegionInfo> metas = new ArrayList<HRegionInfo>();
|
final List<HRegionInfo> metas = new ArrayList<HRegionInfo>();
|
||||||
try {
|
try {
|
||||||
|
@ -264,14 +263,14 @@ public class Migrate extends Configured implements Tool {
|
||||||
});
|
});
|
||||||
// Scan meta.
|
// Scan meta.
|
||||||
for (HRegionInfo hri: metas) {
|
for (HRegionInfo hri: metas) {
|
||||||
final HRegionInfo metahri = hri;
|
final HRegion h = utils.getMetaRegion(hri);
|
||||||
utils.scanMetaRegion(hri, new MetaUtils.ScannerListener() {
|
utils.scanMetaRegion(h, new MetaUtils.ScannerListener() {
|
||||||
public boolean processRow(HRegionInfo info) throws IOException {
|
public boolean processRow(HRegionInfo info) throws IOException {
|
||||||
if (check && !migrationNeeded) {
|
if (check && !migrationNeeded) {
|
||||||
migrationNeeded = true;
|
migrationNeeded = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rewriteHRegionInfo(utils.getMetaRegion(metahri), info);
|
rewriteHRegionInfo(h, info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -341,7 +340,7 @@ public class Migrate extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewrite the passed mapfile
|
* Rewrite the passed 0.19 mapfile as a 0.20 file.
|
||||||
* @param fs
|
* @param fs
|
||||||
* @param mf
|
* @param mf
|
||||||
* @throws IOExcepion
|
* @throws IOExcepion
|
||||||
|
|
Loading…
Reference in New Issue