HBASE-6327 HLog can be null when create table (ShiXing)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1364629 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2144415141
commit
53ac5a3f8f
|
@ -152,16 +152,12 @@ public class CreateTableHandler extends EventHandler {
|
|||
List<HRegionInfo> regionInfos = new ArrayList<HRegionInfo>();
|
||||
final int batchSize =
|
||||
this.conf.getInt("hbase.master.createtable.batchsize", 100);
|
||||
HLog hlog = null;
|
||||
for (int regionIdx = 0; regionIdx < this.newRegions.length; regionIdx++) {
|
||||
HRegionInfo newRegion = this.newRegions[regionIdx];
|
||||
// 1. Create HRegion
|
||||
HRegion region = HRegion.createHRegion(newRegion,
|
||||
this.fileSystemManager.getRootDir(), this.conf,
|
||||
this.hTableDescriptor, hlog, false);
|
||||
if (hlog == null) {
|
||||
hlog = region.getLog();
|
||||
}
|
||||
this.hTableDescriptor, null, false, true);
|
||||
|
||||
regionInfos.add(region.getRegionInfo());
|
||||
if (regionIdx % batchSize == 0) {
|
||||
|
@ -173,7 +169,6 @@ public class CreateTableHandler extends EventHandler {
|
|||
// 3. Close the new region to flush to disk. Close log file too.
|
||||
region.close();
|
||||
}
|
||||
hlog.closeAndDelete();
|
||||
if (regionInfos.size() > 0) {
|
||||
MetaEditor.addRegionsToMeta(this.catalogTracker, regionInfos);
|
||||
}
|
||||
|
|
|
@ -3778,6 +3778,34 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
final HLog hlog,
|
||||
final boolean initialize)
|
||||
throws IOException {
|
||||
return createHRegion(info, rootDir, conf, hTableDescriptor,
|
||||
hlog, initialize, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method creating new HRegions. Used by createTable.
|
||||
* The {@link HLog} for the created region needs to be closed
|
||||
* explicitly, if it is not null.
|
||||
* Use {@link HRegion#getLog()} to get access.
|
||||
*
|
||||
* @param info Info for region to create.
|
||||
* @param rootDir Root directory for HBase instance
|
||||
* @param conf
|
||||
* @param hTableDescriptor
|
||||
* @param hlog shared HLog
|
||||
* @param boolean initialize - true to initialize the region
|
||||
* @param boolean ignoreHLog
|
||||
- true to skip generate new hlog if it is null, mostly for createTable
|
||||
* @return new HRegion
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static HRegion createHRegion(final HRegionInfo info, final Path rootDir,
|
||||
final Configuration conf,
|
||||
final HTableDescriptor hTableDescriptor,
|
||||
final HLog hlog,
|
||||
final boolean initialize, final boolean ignoreHLog)
|
||||
throws IOException {
|
||||
LOG.info("creating HRegion " + info.getTableNameAsString()
|
||||
+ " HTD == " + hTableDescriptor + " RootDir = " + rootDir +
|
||||
" Table name == " + info.getTableNameAsString());
|
||||
|
@ -3788,7 +3816,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
FileSystem fs = FileSystem.get(conf);
|
||||
fs.mkdirs(regionDir);
|
||||
HLog effectiveHLog = hlog;
|
||||
if (hlog == null) {
|
||||
if (hlog == null && !ignoreHLog) {
|
||||
effectiveHLog = new HLog(fs, new Path(regionDir, HConstants.HREGION_LOGDIR_NAME),
|
||||
new Path(regionDir, HConstants.HREGION_OLDLOGDIR_NAME), conf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue