final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final FileSystem fs = mfs.getFileSystem(); final Path tempdir = mfs.getTempDir();
protected static List<RegionInfo> createFsLayout(final MasterProcedureEnv env, final TableDescriptor tableDescriptor, List<RegionInfo> newRegions, final CreateHdfsRegions hdfsRegionHandler) throws IOException { final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final Path tempdir = mfs.getTempDir(); // 1. Create Table Descriptor // using a copy of descriptor, table will be created enabling first final Path tempTableDir = FSUtils.getTableDir(tempdir, tableDescriptor.getTableName()); ((FSTableDescriptors)(env.getMasterServices().getTableDescriptors())) .createTableDescriptorForTableDirectory( tempTableDir, tableDescriptor, false); // 2. Create Regions newRegions = hdfsRegionHandler.createHdfsRegions(env, tempdir, tableDescriptor.getTableName(), newRegions); // 3. Move Table temp directory to the hbase root location moveTempDirectoryToHBaseRoot(env, tableDescriptor, tempTableDir); return newRegions; }
@Override protected Flow executeFromState(MasterProcedureEnv env, MasterProcedureProtos.TruncateTableState state) throws InterruptedException { if (!failOnce && state == MasterProcedureProtos.TruncateTableState.TRUNCATE_TABLE_CREATE_FS_LAYOUT) { try { // To emulate an HDFS failure, create only the first region directory RegionInfo regionInfo = getFirstRegionInfo(); Configuration conf = env.getMasterConfiguration(); MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); Path tempdir = mfs.getTempDir(); Path tableDir = FSUtils.getTableDir(tempdir, regionInfo.getTable()); Path regionDir = FSUtils.getRegionDir(tableDir, regionInfo); FileSystem fs = FileSystem.get(conf); fs.mkdirs(regionDir); failOnce = true; return Flow.HAS_MORE_STATE; } catch (IOException e) { fail("failed to create a region directory: " + e); } } return super.executeFromState(env, state); } }
@Override protected Flow executeFromState(MasterProcedureEnv env, MasterProcedureProtos.CreateTableState state) throws InterruptedException { if (!failOnce && state == MasterProcedureProtos.CreateTableState.CREATE_TABLE_WRITE_FS_LAYOUT) { try { // To emulate an HDFS failure, create only the first region directory RegionInfo regionInfo = getFirstRegionInfo(); Configuration conf = env.getMasterConfiguration(); MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); Path tempdir = mfs.getTempDir(); Path tableDir = FSUtils.getTableDir(tempdir, regionInfo.getTable()); Path regionDir = FSUtils.getRegionDir(tableDir, regionInfo); FileSystem fs = FileSystem.get(conf); fs.mkdirs(regionDir); failOnce = true; return Flow.HAS_MORE_STATE; } catch (IOException e) { fail("failed to create a region directory: " + e); } } return super.executeFromState(env, state); } }
/** * Create region layout in file system. * @param env MasterProcedureEnv * @throws IOException */ private List<RegionInfo> createFsLayout( final MasterProcedureEnv env, final TableDescriptor tableDescriptor, List<RegionInfo> newRegions, final CreateHdfsRegions hdfsRegionHandler) throws IOException { final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final Path tempdir = mfs.getTempDir(); // 1. Create Table Descriptor // using a copy of descriptor, table will be created enabling first final Path tempTableDir = FSUtils.getTableDir(tempdir, tableDescriptor.getTableName()); ((FSTableDescriptors)(env.getMasterServices().getTableDescriptors())) .createTableDescriptorForTableDirectory(tempTableDir, TableDescriptorBuilder.newBuilder(tableDescriptor).build(), false); // 2. Create Regions newRegions = hdfsRegionHandler.createHdfsRegions( env, tempdir, tableDescriptor.getTableName(), newRegions); // 3. Move Table temp directory to the hbase root location CreateTableProcedure.moveTempDirectoryToHBaseRoot(env, tableDescriptor, tempTableDir); // Move Table temp mob directory to the hbase root location Path tempMobTableDir = MobUtils.getMobTableDir(tempdir, tableDescriptor.getTableName()); if (mfs.getFileSystem().exists(tempMobTableDir)) { moveTempMobDirectoryToHBaseRoot(mfs, tableDescriptor, tempMobTableDir); } return newRegions; }
Path tempdir = fileSystemManager.getTempDir(); FileSystem fs = fileSystemManager.getFileSystem();
final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final FileSystem fs = mfs.getFileSystem(); final Path tempdir = mfs.getTempDir();
protected static List<HRegionInfo> createFsLayout(final MasterProcedureEnv env, final HTableDescriptor hTableDescriptor, List<HRegionInfo> newRegions, final CreateHdfsRegions hdfsRegionHandler) throws IOException { final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final Path tempdir = mfs.getTempDir(); // 1. Create Table Descriptor // using a copy of descriptor, table will be created enabling first final Path tempTableDir = FSUtils.getTableDir(tempdir, hTableDescriptor.getTableName()); new FSTableDescriptors(env.getMasterConfiguration()).createTableDescriptorForTableDirectory( tempTableDir, hTableDescriptor, false); // 2. Create Regions newRegions = hdfsRegionHandler.createHdfsRegions(env, tempdir, hTableDescriptor.getTableName(), newRegions); // 3. Move Table temp directory to the hbase root location final Path tableDir = FSUtils.getTableDir(mfs.getRootDir(), hTableDescriptor.getTableName()); FileSystem fs = mfs.getFileSystem(); if (!fs.delete(tableDir, true) && fs.exists(tableDir)) { throw new IOException("Couldn't delete " + tableDir); } if (!fs.rename(tempTableDir, tableDir)) { throw new IOException("Unable to move table from temp=" + tempTableDir + " to hbase root=" + tableDir); } return newRegions; }
Path tempdir = fileSystemManager.getTempDir(); FileSystem fs = fileSystemManager.getFileSystem();
@Override protected Flow executeFromState(MasterProcedureEnv env, MasterProcedureProtos.TruncateTableState state) throws InterruptedException { if (!failOnce && state == MasterProcedureProtos.TruncateTableState.TRUNCATE_TABLE_CREATE_FS_LAYOUT) { try { // To emulate an HDFS failure, create only the first region directory RegionInfo regionInfo = getFirstRegionInfo(); Configuration conf = env.getMasterConfiguration(); MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); Path tempdir = mfs.getTempDir(); Path tableDir = FSUtils.getTableDir(tempdir, regionInfo.getTable()); Path regionDir = FSUtils.getRegionDir(tableDir, regionInfo); FileSystem fs = FileSystem.get(conf); fs.mkdirs(regionDir); failOnce = true; return Flow.HAS_MORE_STATE; } catch (IOException e) { fail("failed to create a region directory: " + e); } } return super.executeFromState(env, state); } }
@Override protected Flow executeFromState(MasterProcedureEnv env, MasterProcedureProtos.CreateTableState state) throws InterruptedException { if (!failOnce && state == MasterProcedureProtos.CreateTableState.CREATE_TABLE_WRITE_FS_LAYOUT) { try { // To emulate an HDFS failure, create only the first region directory RegionInfo regionInfo = getFirstRegionInfo(); Configuration conf = env.getMasterConfiguration(); MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); Path tempdir = mfs.getTempDir(); Path tableDir = FSUtils.getTableDir(tempdir, regionInfo.getTable()); Path regionDir = FSUtils.getRegionDir(tableDir, regionInfo); FileSystem fs = FileSystem.get(conf); fs.mkdirs(regionDir); failOnce = true; return Flow.HAS_MORE_STATE; } catch (IOException e) { fail("failed to create a region directory: " + e); } } return super.executeFromState(env, state); } }