/** * Initialize this region. * Used only by tests and SplitTransaction to reopen the region. * You should use createHRegion() or openHRegion() * @return What the next sequence (edit) id should be. * @throws IOException e * @deprecated use HRegion.createHRegion() or HRegion.openHRegion() */ @Deprecated public long initialize() throws IOException { return initialize(null); }
/** * Create a region with it's own WAL. Be sure to call * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} to clean up all resources. */ public static HRegion createRegionAndWAL(final RegionInfo info, final Path rootDir, final Configuration conf, final TableDescriptor htd, MobFileCache mobFileCache) throws IOException { HRegion region = createRegionAndWAL(info, rootDir, conf, htd, false); region.setMobFileCache(mobFileCache); region.initialize(); return region; }
/** * Create a region with it's own WAL. Be sure to call * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} to clean up all resources. */ public static HRegion createRegionAndWAL(final RegionInfo info, final Path rootDir, final Configuration conf, final TableDescriptor htd, BlockCache blockCache) throws IOException { HRegion region = createRegionAndWAL(info, rootDir, conf, htd, false); region.setBlockCache(blockCache); region.initialize(); return region; } /**
/** * Convenience method creating new HRegions. Used by createTable. * * @param info Info for region to create. * @param rootDir Root directory for HBase instance * @param wal shared WAL * @param initialize - true to initialize the region * @return new HRegion * @throws IOException */ public static HRegion createHRegion(final RegionInfo info, final Path rootDir, final Configuration conf, final TableDescriptor hTableDescriptor, final WAL wal, final boolean initialize) throws IOException { LOG.info("creating HRegion " + info.getTable().getNameAsString() + " HTD == " + hTableDescriptor + " RootDir = " + rootDir + " Table name == " + info.getTable().getNameAsString()); FileSystem fs = FileSystem.get(conf); Path tableDir = FSUtils.getTableDir(rootDir, info.getTable()); HRegionFileSystem.createRegionOnFileSystem(conf, fs, tableDir, info); HRegion region = HRegion.newHRegion(tableDir, wal, fs, conf, info, hTableDescriptor, null); if (initialize) { region.initialize(null); } return region; }
private HRegion initHRegion(TableDescriptor htd, RegionInfo info) throws IOException { Configuration conf = testUtil.getConfiguration(); ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null); Path tableDir = FSUtils.getTableDir(testDir, htd.getTableName()); Path regionDir = new Path(tableDir, info.getEncodedName()); Path storeDir = new Path(regionDir, htd.getColumnFamilies()[0].getNameAsString()); FileSystem errFS = spy(testUtil.getTestFileSystem()); // Prior to HBASE-16964, when an exception is thrown archiving any compacted file, // none of the other files are cleared from the compactedfiles list. // Simulate this condition with a dummy file doThrow(new IOException("Error for test")).when(errFS) .rename(eq(new Path(storeDir, ERROR_FILE)), any()); HRegionFileSystem fs = new HRegionFileSystem(conf, errFS, tableDir, info); final Configuration walConf = new Configuration(conf); FSUtils.setRootDir(walConf, tableDir); final WALFactory wals = new WALFactory(walConf, "log_" + info.getEncodedName()); HRegion region = new HRegion(fs, wals.getWAL(info), conf, htd, null); region.initialize(); return region; } }
/** * Open HRegion. * Calls initialize and sets sequenceId. * @return Returns <code>this</code> */ protected HRegion openHRegion(final CancelableProgressable reporter) throws IOException { // Refuse to open the region if we are missing local compression support checkCompressionCodecs(); LOG.debug("checking encryption for " + this.getRegionInfo().getEncodedName()); // Refuse to open the region if encryption configuration is incorrect or // codec support is missing checkEncryption(); // Refuse to open the region if a required class cannot be loaded LOG.debug("checking classloading for " + this.getRegionInfo().getEncodedName()); checkClassLoading(); this.openSeqNum = initialize(reporter); this.mvcc.advanceTo(openSeqNum); // The openSeqNum must be increased every time when a region is assigned, as we rely on it to // determine whether a region has been successfully reopened. So here we always write open // marker, even if the table is read only. if (wal != null && getRegionServerServices() != null && RegionReplicaUtil.isDefaultReplica(getRegionInfo())) { writeRegionOpenMarker(wal, openSeqNum); } return this; }
region = HRegion.newHRegion(path, null, fs, CONF, info, htd, null); region.initialize(); fail("Region initialization should fail due to IOException"); } catch (IOException io) {
@Override public Object run() throws Exception { runWALSplit(newConf); FileSystem newFS = FileSystem.get(newConf); // Make a new wal for new region open. WAL wal3 = createWAL(newConf, hbaseRootDir, logName); final AtomicInteger countOfRestoredEdits = new AtomicInteger(0); HRegion region3 = new HRegion(basedir, wal3, newFS, newConf, hri, htd, null) { @Override protected void restoreEdit(HStore s, Cell cell, MemStoreSizing memstoreSizing) { super.restoreEdit(s, cell, memstoreSizing); countOfRestoredEdits.incrementAndGet(); } }; long seqid3 = region3.initialize(); Result result3 = region3.get(g); // Assert that count of cells is same as before crash. assertEquals(result2.size(), result3.size()); assertEquals(htd.getFamilies().size() * countPerFamily, countOfRestoredEdits.get()); // I can't close wal1. Its been appropriated when we split. region3.close(); wal3.close(); return null; } });
long seqid = region.initialize();
public ClientSideRegionScanner(Configuration conf, FileSystem fs, Path rootDir, TableDescriptor htd, RegionInfo hri, Scan scan, ScanMetrics scanMetrics) throws IOException { // region is immutable, set isolation level scan.setIsolationLevel(IsolationLevel.READ_UNCOMMITTED); htd = TableDescriptorBuilder.newBuilder(htd).setReadOnly(true).build(); // open region from the snapshot directory region = HRegion.newHRegion(FSUtils.getTableDir(rootDir, htd.getTableName()), null, fs, conf, hri, htd, null); // we won't initialize the MobFileCache when not running in RS process. so provided an // initialized cache. Consider the case: an CF was set from an mob to non-mob. if we only // initialize cache for MOB region, NPE from HMobStore will still happen. So Initialize the // cache for every region although it may hasn't any mob CF, BTW the cache is very light-weight. region.setMobFileCache(new MobFileCache(conf)); region.initialize(); // create an internal region scanner this.scanner = region.getScanner(scan); values = new ArrayList<>(); if (scanMetrics == null) { initScanMetrics(scan); } else { this.scanMetrics = scanMetrics; } region.startRegionOperation(); }
private HRegion initHRegion(TableDescriptor htd, RegionInfo info) throws IOException { Configuration conf = testUtil.getConfiguration(); Path tableDir = FSUtils.getTableDir(testDir, htd.getTableName()); HRegionFileSystem fs = new WaitingHRegionFileSystem(conf, tableDir.getFileSystem(conf), tableDir, info); ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null); final Configuration walConf = new Configuration(conf); FSUtils.setRootDir(walConf, tableDir); final WALFactory wals = new WALFactory(walConf, "log_" + info.getEncodedName()); HRegion region = new HRegion(fs, wals.getWAL(info), conf, htd, null); region.initialize(); return region; }
region.initialize();
private HRegion initHRegion(TableDescriptor htd, byte[] startKey, byte[] stopKey, int replicaId) throws IOException { Configuration conf = TEST_UTIL.getConfiguration(); Path tableDir = FSUtils.getTableDir(testDir, htd.getTableName()); RegionInfo info = RegionInfoBuilder.newBuilder(htd.getTableName()).setStartKey(startKey) .setEndKey(stopKey).setRegionId(0L).setReplicaId(replicaId).build(); HRegionFileSystem fs = new FailingHRegionFileSystem(conf, tableDir.getFileSystem(conf), tableDir, info); final Configuration walConf = new Configuration(conf); FSUtils.setRootDir(walConf, tableDir); final WALFactory wals = new WALFactory(walConf, "log_" + replicaId); ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null); HRegion region = new HRegion(fs, wals.getWAL(info), conf, htd, null); region.initialize(); return region; }
region.initialize(); region.compact(true); metricsRegionServer.getRegionServerWrapper().forceRecompute(); region.initialize(); region.compact(true); metricsRegionServer.getRegionServerWrapper().forceRecompute();
region.initialize(new CancelableProgressable() { private long replayedEdits = 0;
/** * During compaction, the mob threshold size is changed. */ @Test public void testLargerValue() throws Exception { init(UTIL.getConfiguration(), 200); byte[] dummyData = makeDummyData(300); // larger than mob threshold Table loader = new RegionAsTable(region); for (int i = 0; i < compactionThreshold; i++) { Put p = createPut(i, dummyData); loader.put(p); region.flush(true); } assertEquals("Before compaction: store files", compactionThreshold, countStoreFiles()); assertEquals("Before compaction: mob file count", compactionThreshold, countMobFiles()); assertEquals("Before compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("Before compaction: mob rows", compactionThreshold, countMobRows()); assertEquals("Before compaction: number of mob cells", compactionThreshold, countMobCellsInMetadata()); // Change the threshold larger than the data size setMobThreshold(region, COLUMN_FAMILY, 500); region.initialize(); region.compactStores(); assertEquals("After compaction: store files", 1, countStoreFiles()); assertEquals("After compaction: mob file count", compactionThreshold, countMobFiles()); assertEquals("After compaction: referenced mob file count", 0, countReferencedMobFiles()); assertEquals("After compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("After compaction: mob rows", 0, countMobRows()); }
/** * Initialize this region. * @return What the next sequence (edit) id should be. * @throws IOException e */ public long initialize() throws IOException { return initialize(null); }
when(mockRS.getServerName()).thenReturn(mockServerName); HRegion region = spy(new HRegion(basedir, wal, this.fs, this.conf, hri, htd, mockRS)); region.initialize(); region1.initialize(); org.apache.hadoop.hbase.client.Connection hbaseConn = ConnectionFactory.createConnection(UTIL.getConfiguration());
Mockito.when(mockRS.getServerName()).thenReturn(mockServerName); HRegion region = new HRegion(basedir, wal, this.fs, this.conf, hri, htd, mockRS); long seqid = region.initialize(); region1.initialize();
@Override public void initialize() throws IOException { region.initialize(); }