org.apache.hadoop.hbase.client.RegionInfoBuilder Java Examples
The following examples show how to use
org.apache.hadoop.hbase.client.RegionInfoBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestHbckChore.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testForSplitParent() throws Exception { TableName tableName = TableName.valueOf("testForSplitParent"); RegionInfo hri = RegionInfoBuilder.newBuilder(tableName).setStartKey(Bytes.toBytes(0)) .setEndKey(Bytes.toBytes(1)).setSplit(true).setOffline(true).setRegionId(0).build(); String regionName = hri.getEncodedName(); rsDispatcher.setMockRsExecutor(new GoodRsExecutor()); Future<byte[]> future = submitProcedure(createAssignProcedure(hri)); waitOnFuture(future); List<ServerName> serverNames = master.getServerManager().getOnlineServersList(); assertEquals(NSERVERS, serverNames.size()); hbckChore.choreForTesting(); Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions = hbckChore.getInconsistentRegions(); assertFalse(inconsistentRegions.containsKey(regionName)); }
Example #2
Source File: TestMetaTableAccessor.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testMetaLocationForRegionReplicasIsAddedAtTableCreation() throws IOException { long regionId = System.currentTimeMillis(); RegionInfo primary = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())) .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false) .setRegionId(regionId).setReplicaId(0).build(); Table meta = MetaTableAccessor.getMetaHTable(connection); try { List<RegionInfo> regionInfos = Lists.newArrayList(primary); MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 3); assertEmptyMetaLocation(meta, primary.getRegionName(), 1); assertEmptyMetaLocation(meta, primary.getRegionName(), 2); } finally { meta.close(); } }
Example #3
Source File: MasterRegion.java From hbase with Apache License 2.0 | 6 votes |
private static HRegion bootstrap(Configuration conf, TableDescriptor td, FileSystem fs, Path rootDir, FileSystem walFs, Path walRootDir, WALFactory walFactory, MasterRegionWALRoller walRoller, String serverName) throws IOException { TableName tn = td.getTableName(); RegionInfo regionInfo = RegionInfoBuilder.newBuilder(tn).setRegionId(REGION_ID).build(); Path tmpTableDir = CommonFSUtils.getTableDir(rootDir, TableName.valueOf(tn.getNamespaceAsString(), tn.getQualifierAsString() + "-tmp")); if (fs.exists(tmpTableDir) && !fs.delete(tmpTableDir, true)) { throw new IOException("Can not delete partial created proc region " + tmpTableDir); } HRegion.createHRegion(conf, regionInfo, fs, tmpTableDir, td).close(); Path tableDir = CommonFSUtils.getTableDir(rootDir, tn); if (!fs.rename(tmpTableDir, tableDir)) { throw new IOException("Can not rename " + tmpTableDir + " to " + tableDir); } WAL wal = createWAL(walFactory, walRoller, serverName, walFs, walRootDir, regionInfo); return HRegion.openHRegionFromTableDir(conf, fs, tableDir, regionInfo, td, wal, null, null); }
Example #4
Source File: TestDefaultStoreEngine.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testCustomParts() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.set(DefaultStoreEngine.DEFAULT_COMPACTOR_CLASS_KEY, DummyCompactor.class.getName()); conf.set(DefaultStoreEngine.DEFAULT_COMPACTION_POLICY_CLASS_KEY, DummyCompactionPolicy.class.getName()); conf.set(DefaultStoreEngine.DEFAULT_STORE_FLUSHER_CLASS_KEY, DummyStoreFlusher.class.getName()); HStore mockStore = Mockito.mock(HStore.class); Mockito.when(mockStore.getRegionInfo()).thenReturn(RegionInfoBuilder.FIRST_META_REGIONINFO); StoreEngine<?, ?, ?, ?> se = StoreEngine.create(mockStore, conf, CellComparatorImpl.COMPARATOR); Assert.assertTrue(se instanceof DefaultStoreEngine); Assert.assertTrue(se.getCompactionPolicy() instanceof DummyCompactionPolicy); Assert.assertTrue(se.getStoreFlusher() instanceof DummyStoreFlusher); Assert.assertTrue(se.getCompactor() instanceof DummyCompactor); }
Example #5
Source File: TestMasterProcedureScheduler.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testListLocksRegion() throws Exception { LockProcedure procedure = createExclusiveLockProcedure(3); RegionInfo regionInfo = RegionInfoBuilder.newBuilder(TableName.valueOf("ns3", "table3")).build(); queue.waitRegion(procedure, regionInfo); List<LockedResource> resources = queue.getLocks(); assertEquals(3, resources.size()); LockedResource namespaceResource = resources.get(0); assertLockResource(namespaceResource, LockedResourceType.NAMESPACE, "ns3"); assertSharedLock(namespaceResource, 1); assertTrue(namespaceResource.getWaitingProcedures().isEmpty()); LockedResource tableResource = resources.get(1); assertLockResource(tableResource, LockedResourceType.TABLE, "ns3:table3"); assertSharedLock(tableResource, 1); assertTrue(tableResource.getWaitingProcedures().isEmpty()); LockedResource regionResource = resources.get(2); assertLockResource(regionResource, LockedResourceType.REGION, regionInfo.getEncodedName()); assertExclusiveLock(regionResource, procedure); assertTrue(regionResource.getWaitingProcedures().isEmpty()); }
Example #6
Source File: TestFilterFromRegionSide.java From hbase with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() throws Exception { TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(TABLE_NAME); for (byte[] family : FAMILIES) { ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family); tableDescriptor.setColumnFamily(familyDescriptor); } RegionInfo info = RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build(); REGION = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), tableDescriptor); for(Put put:createPuts(ROWS, FAMILIES, QUALIFIERS, VALUE)){ REGION.put(put); } }
Example #7
Source File: TestBlocksRead.java From hbase with Apache License 2.0 | 6 votes |
/** * Callers must afterward call {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} */ private HRegion initHRegion(byte[] tableName, String callingMethod, Configuration conf, String family, BlockCache blockCache) throws IOException { TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(TableName.valueOf(tableName)); for (int i = 0; i < BLOOM_TYPE.length; i++) { BloomType bloomType = BLOOM_TYPE[i]; builder.setColumnFamily( ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(family + "_" + bloomType)) .setBlocksize(1).setBloomFilterType(bloomType).build()); } RegionInfo info = RegionInfoBuilder.newBuilder(TableName.valueOf(tableName)).build(); Path path = new Path(DIR + callingMethod); if (blockCache != null) { return HBaseTestingUtility.createRegionAndWAL(info, path, conf, builder.build(), blockCache); } else { return HBaseTestingUtility.createRegionAndWAL(info, path, conf, builder.build()); } }
Example #8
Source File: TestServerRemoteProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testRegionOpenProcedureIsNotHandledByDispatcher() throws Exception { TableName tableName = TableName.valueOf("testRegionOpenProcedureIsNotHandledByDisPatcher"); RegionInfo hri = RegionInfoBuilder.newBuilder(tableName).setStartKey(Bytes.toBytes(1)) .setEndKey(Bytes.toBytes(2)).setSplit(false).setRegionId(0).build(); MasterProcedureEnv env = master.getMasterProcedureExecutor().getEnvironment(); env.getAssignmentManager().getRegionStates().getOrCreateRegionStateNode(hri); TransitRegionStateProcedure proc = TransitRegionStateProcedure.assign(env, hri, null); ServerName worker = master.getServerManager().getOnlineServersList().get(0); OpenRegionProcedure openRegionProcedure = new OpenRegionProcedure(proc, hri, worker); Future<byte[]> future = submitProcedure(openRegionProcedure); Thread.sleep(2000); rsDispatcher.removeNode(worker); try { future.get(2000, TimeUnit.MILLISECONDS); fail(); } catch (TimeoutException e) { LOG.info("timeout is expected"); } Assert.assertFalse(openRegionProcedure.isFinished()); }
Example #9
Source File: InitMetaProcedure.java From hbase with Apache License 2.0 | 6 votes |
private static void writeFsLayout(Path rootDir, Configuration conf) throws IOException { LOG.info("BOOTSTRAP: creating hbase:meta region"); FileSystem fs = rootDir.getFileSystem(conf); Path tableDir = CommonFSUtils.getTableDir(rootDir, TableName.META_TABLE_NAME); if (fs.exists(tableDir) && !fs.delete(tableDir, true)) { LOG.warn("Can not delete partial created meta table, continue..."); } // Bootstrapping, make sure blockcache is off. Else, one will be // created here in bootstrap and it'll need to be cleaned up. Better to // not make it in first place. Turn off block caching for bootstrap. // Enable after. FSTableDescriptors.tryUpdateMetaTableDescriptor(conf, fs, rootDir, builder -> builder.setRegionReplication( conf.getInt(HConstants.META_REPLICAS_NUM, HConstants.DEFAULT_META_REPLICA_NUM))); TableDescriptor metaDescriptor = new FSTableDescriptors(conf).get(TableName.META_TABLE_NAME); HRegion .createHRegion(RegionInfoBuilder.FIRST_META_REGIONINFO, rootDir, conf, metaDescriptor, null) .close(); }
Example #10
Source File: TestAssignmentManager.java From hbase with Apache License 2.0 | 6 votes |
/** * It is possible that when AM send assign meta request to a RS successfully, but RS can not send * back any response, which cause master startup hangs forever */ @Test public void testAssignMetaAndCrashBeforeResponse() throws Exception { tearDown(); // See setUp(), start HBase until set up meta util = new HBaseTestingUtility(); this.executor = Executors.newSingleThreadScheduledExecutor(); setupConfiguration(util.getConfiguration()); master = new MockMasterServices(util.getConfiguration(), this.regionsToRegionServers); rsDispatcher = new MockRSProcedureDispatcher(master); master.start(NSERVERS, rsDispatcher); am = master.getAssignmentManager(); // Assign meta rsDispatcher.setMockRsExecutor(new HangThenRSRestartExecutor()); am.assign(RegionInfoBuilder.FIRST_META_REGIONINFO); assertEquals(true, am.isMetaAssigned()); // set it back as default, see setUpMeta() am.wakeMetaLoadedEvent(); }
Example #11
Source File: OfflineMetaRebuildTestCore.java From hbase with Apache License 2.0 | 6 votes |
protected RegionInfo createRegion(Configuration conf, final Table htbl, byte[] startKey, byte[] endKey) throws IOException { Table meta = TEST_UTIL.getConnection().getTable(TableName.META_TABLE_NAME); RegionInfo hri = RegionInfoBuilder.newBuilder(htbl.getName()) .setStartKey(startKey) .setEndKey(endKey) .build(); LOG.info("manually adding regioninfo and hdfs data: " + hri.toString()); Path rootDir = CommonFSUtils.getRootDir(conf); FileSystem fs = rootDir.getFileSystem(conf); Path p = new Path(CommonFSUtils.getTableDir(rootDir, htbl.getName()), hri.getEncodedName()); fs.mkdirs(p); Path riPath = new Path(p, HRegionFileSystem.REGION_INFO_FILE); FSDataOutputStream out = fs.create(riPath); out.write(RegionInfo.toDelimitedByteArray(hri)); out.close(); // add to meta. MetaTableAccessor.addRegionToMeta(TEST_UTIL.getConnection(), hri); meta.close(); return hri; }
Example #12
Source File: HbckTableInfo.java From hbase with Apache License 2.0 | 6 votes |
/** * There is a hole in the hdfs regions that violates the table integrity * rules. Create a new empty region that patches the hole. */ @Override public void handleHoleInRegionChain(byte[] holeStartKey, byte[] holeStopKey) throws IOException { errors.reportError(HbckErrorReporter.ERROR_CODE.HOLE_IN_REGION_CHAIN, "There is a hole in the region chain between " + Bytes.toStringBinary(holeStartKey) + " and " + Bytes.toStringBinary(holeStopKey) + ". Creating a new regioninfo and region " + "dir in hdfs to plug the hole."); TableDescriptor htd = getTableInfo().getTableDescriptor(); RegionInfo newRegion = RegionInfoBuilder.newBuilder(htd.getTableName()).setStartKey(holeStartKey) .setEndKey(holeStopKey).build(); HRegion region = HBaseFsckRepair.createHDFSRegionDir(conf, newRegion, htd); LOG.info("Plugged hole by creating new empty region: " + newRegion + " " + region); hbck.fixes++; }
Example #13
Source File: HBaseFsck.java From hbase with Apache License 2.0 | 6 votes |
/** * Reset the split parent region info in meta table */ private void resetSplitParent(HbckRegionInfo hi) throws IOException { RowMutations mutations = new RowMutations(hi.getMetaEntry().getRegionInfo().getRegionName()); Delete d = new Delete(hi.getMetaEntry().getRegionInfo().getRegionName()); d.addColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER); d.addColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER); mutations.add(d); RegionInfo hri = RegionInfoBuilder.newBuilder(hi.getMetaEntry().getRegionInfo()) .setOffline(false).setSplit(false).build(); Put p = MetaTableAccessor.makePutFromRegionInfo(hri, EnvironmentEdgeManager.currentTime()); mutations.add(p); meta.mutateRow(mutations); LOG.info("Reset split parent " + hi.getMetaEntry().getRegionInfo().getRegionNameAsString() + " in META"); }
Example #14
Source File: TestCanaryStatusServlet.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testReadFailuresOnly() throws IOException { CanaryTool.RegionStdOutSink regionStdOutSink = new CanaryTool.RegionStdOutSink(); ServerName serverName1 = ServerName.valueOf("staging-st04.server:22600", 1584180761635L); TableName fakeTableName1 = TableName.valueOf("fakeTableName1"); RegionInfo regionInfo1 = RegionInfoBuilder.newBuilder(fakeTableName1).build(); regionStdOutSink.publishReadFailure(serverName1, regionInfo1, new IOException()); CanaryStatusTmpl tmpl = new CanaryStatusTmpl(); StringWriter renderResultWriter = new StringWriter(); tmpl.render(renderResultWriter, regionStdOutSink); String renderResult = renderResultWriter.toString(); Assert.assertTrue(renderResult.contains("staging-st04.server,22600")); Assert.assertTrue(renderResult.contains("fakeTableName1")); }
Example #15
Source File: TestMasterRegionFlush.java From hbase with Apache License 2.0 | 6 votes |
@Before public void setUp() throws IOException { conf = HBaseConfiguration.create(); region = mock(HRegion.class); HStore store = mock(HStore.class); when(store.getStorefilesCount()).thenReturn(1); when(region.getStores()).thenReturn(Collections.singletonList(store)); when(region.getRegionInfo()) .thenReturn(RegionInfoBuilder.newBuilder(TableName.valueOf("hbase:local")).build()); flushCalled = new AtomicInteger(0); memstoreHeapSize = new AtomicLong(0); memstoreOffHeapSize = new AtomicLong(0); when(region.getMemStoreHeapSize()).thenAnswer(invocation -> memstoreHeapSize.get()); when(region.getMemStoreOffHeapSize()).thenAnswer(invocation -> memstoreOffHeapSize.get()); when(region.flush(anyBoolean())).thenAnswer(invocation -> { assertTrue(invocation.getArgument(0)); memstoreHeapSize.set(0); memstoreOffHeapSize.set(0); flushCalled.incrementAndGet(); return null; }); }
Example #16
Source File: TestReadAndWriteRegionInfoFile.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testReadAndWriteRegionInfoFile() throws IOException, InterruptedException { RegionInfo ri = RegionInfoBuilder.FIRST_META_REGIONINFO; // Create a region. That'll write the .regioninfo file. FSTableDescriptors fsTableDescriptors = new FSTableDescriptors(FS, ROOT_DIR); FSTableDescriptors.tryUpdateMetaTableDescriptor(CONF, FS, ROOT_DIR, null); HRegion r = HBaseTestingUtility.createRegionAndWAL(ri, ROOT_DIR, CONF, fsTableDescriptors.get(TableName.META_TABLE_NAME)); // Get modtime on the file. long modtime = getModTime(r); HBaseTestingUtility.closeRegionAndWAL(r); Thread.sleep(1001); r = HRegion.openHRegion(ROOT_DIR, ri, fsTableDescriptors.get(TableName.META_TABLE_NAME), null, CONF); // Ensure the file is not written for a second time. long modtime2 = getModTime(r); assertEquals(modtime, modtime2); // Now load the file. HRegionFileSystem.loadRegionInfoFileContent(r.getRegionFileSystem().getFileSystem(), r.getRegionFileSystem().getRegionDir()); HBaseTestingUtility.closeRegionAndWAL(r); }
Example #17
Source File: TestReplicationWALEntryFilters.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testSystemTableWALEntryFilter() { SystemTableWALEntryFilter filter = new SystemTableWALEntryFilter(); // meta WALKeyImpl key1 = new WALKeyImpl(RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedNameAsBytes(), TableName.META_TABLE_NAME, System.currentTimeMillis()); Entry metaEntry = new Entry(key1, null); assertNull(filter.filter(metaEntry)); // user table WALKeyImpl key3 = new WALKeyImpl(new byte[0], TableName.valueOf("foo"), System.currentTimeMillis()); Entry userEntry = new Entry(key3, null); assertEquals(userEntry, filter.filter(userEntry)); }
Example #18
Source File: TestWALMonotonicallyIncreasingSeqId.java From hbase with Apache License 2.0 | 6 votes |
private HRegion initHRegion(TableDescriptor htd, byte[] startKey, byte[] stopKey, int replicaId) throws IOException { Configuration conf = TEST_UTIL.getConfiguration(); conf.set("hbase.wal.provider", walProvider); conf.setBoolean("hbase.hregion.mvcc.preassign", false); Path tableDir = CommonFSUtils.getTableDir(testDir, htd.getTableName()); RegionInfo info = RegionInfoBuilder.newBuilder(htd.getTableName()).setStartKey(startKey) .setEndKey(stopKey).setReplicaId(replicaId).setRegionId(0).build(); fileSystem = tableDir.getFileSystem(conf); final Configuration walConf = new Configuration(conf); CommonFSUtils.setRootDir(walConf, tableDir); this.walConf = walConf; wals = new WALFactory(walConf, "log_" + replicaId); ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null); HRegion region = HRegion.createHRegion(info, TEST_UTIL.getDefaultRootDirPath(), conf, htd, wals.getWAL(info)); return region; }
Example #19
Source File: TestHRegionLocation.java From hbase with Apache License 2.0 | 6 votes |
/** * HRegionLocations are equal if they have the same 'location' -- i.e. host and port -- even if * they are carrying different regions. Verify that is indeed the case. */ @Test public void testHashAndEqualsCode() { ServerName hsa1 = ServerName.valueOf("localhost", 1234, -1L); HRegionLocation hrl1 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa1); HRegionLocation hrl2 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa1); assertEquals(hrl1.hashCode(), hrl2.hashCode()); assertTrue(hrl1.equals(hrl2)); HRegionLocation hrl3 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa1); assertNotSame(hrl1, hrl3); // They are equal because they have same location even though they are // carrying different regions or timestamp. assertTrue(hrl1.equals(hrl3)); ServerName hsa2 = ServerName.valueOf("localhost", 12345, -1L); HRegionLocation hrl4 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa2); // These have same HRI but different locations so should be different. assertFalse(hrl3.equals(hrl4)); HRegionLocation hrl5 = new HRegionLocation(hrl4.getRegion(), hrl4.getServerName(), hrl4.getSeqNum() + 1); assertTrue(hrl4.equals(hrl5)); }
Example #20
Source File: TestRegionObserverScannerOpenHook.java From hbase with Apache License 2.0 | 6 votes |
HRegion initHRegion(byte[] tableName, String callingMethod, Configuration conf, byte[]... families) throws IOException { TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(TableName.valueOf(tableName)); for (byte[] family : families) { tableDescriptor.setColumnFamily( new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family)); } ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null); RegionInfo info = RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build(); Path path = new Path(DIR + callingMethod); WAL wal = HBaseTestingUtility.createWal(conf, path, info); HRegion r = HRegion.createHRegion(info, path, conf, tableDescriptor, wal); // this following piece is a hack. currently a coprocessorHost // is secretly loaded at OpenRegionHandler. we don't really // start a region server here, so just manually create cphost // and set it to region. RegionCoprocessorHost host = new RegionCoprocessorHost(r, null, conf); r.setCoprocessorHost(host); return r; }
Example #21
Source File: TestQualifierFilterWithEmptyQualifier.java From hbase with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { TableDescriptor htd = TableDescriptorBuilder .newBuilder(TableName.valueOf("TestQualifierFilter")) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).build()).build(); RegionInfo info = RegionInfoBuilder.newBuilder(htd.getTableName()).build(); this.region = HBaseTestingUtility .createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), htd); // Insert data for (byte[] ROW : ROWS) { Put p = new Put(ROW); p.setDurability(Durability.SKIP_WAL); for (byte[] QUALIFIER : QUALIFIERS) { p.addColumn(FAMILY, QUALIFIER, VALUE); } this.region.put(p); } // Flush this.region.flush(true); }
Example #22
Source File: TestHStoreFile.java From hbase with Apache License 2.0 | 6 votes |
/** * Write a file and then assert that we can read from top and bottom halves using two * HalfMapFiles. */ @Test public void testBasicHalfMapFile() throws Exception { final RegionInfo hri = RegionInfoBuilder.newBuilder(TableName.valueOf("testBasicHalfMapFileTb")).build(); HRegionFileSystem regionFs = HRegionFileSystem.createRegionOnFileSystem(conf, fs, new Path(testDir, hri.getTable().getNameAsString()), hri); HFileContext meta = new HFileContextBuilder().withBlockSize(2 * 1024).build(); StoreFileWriter writer = new StoreFileWriter.Builder(conf, cacheConf, this.fs) .withFilePath(regionFs.createTempName()).withFileContext(meta).build(); writeStoreFile(writer); Path sfPath = regionFs.commitStoreFile(TEST_FAMILY, writer.getPath()); HStoreFile sf = new HStoreFile(this.fs, sfPath, conf, cacheConf, BloomType.NONE, true); checkHalfHFile(regionFs, sf); }
Example #23
Source File: TestStoreFileRefresherChore.java From hbase with Apache License 2.0 | 6 votes |
private HRegion initHRegion(TableDescriptor htd, byte[] startKey, byte[] stopKey, int replicaId) throws IOException { Configuration conf = TEST_UTIL.getConfiguration(); Path tableDir = CommonFSUtils.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); CommonFSUtils.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; }
Example #24
Source File: TestCacheOnWriteInSchema.java From hbase with Apache License 2.0 | 5 votes |
@Before public void setUp() throws IOException { // parameterized tests add [#] suffix get rid of [ and ]. table = Bytes.toBytes(name.getMethodName().replaceAll("[\\[\\]]", "_")); conf = TEST_UTIL.getConfiguration(); conf.setInt(HFile.FORMAT_VERSION_KEY, HFile.MAX_FORMAT_VERSION); conf.setBoolean(CacheConfig.CACHE_BLOCKS_ON_WRITE_KEY, false); conf.setBoolean(CacheConfig.CACHE_INDEX_BLOCKS_ON_WRITE_KEY, false); conf.setBoolean(CacheConfig.CACHE_BLOOM_BLOCKS_ON_WRITE_KEY, false); fs = HFileSystem.get(conf); // Create the schema ColumnFamilyDescriptor hcd = cowType .modifyFamilySchema( ColumnFamilyDescriptorBuilder.newBuilder(family).setBloomFilterType(BloomType.ROWCOL)) .build(); TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(table)).setColumnFamily(hcd).build(); // Create a store based on the schema String id = TestCacheOnWriteInSchema.class.getName(); Path logdir = new Path(CommonFSUtils.getRootDir(conf), AbstractFSWALProvider.getWALDirectoryName(id)); fs.delete(logdir, true); RegionInfo info = RegionInfoBuilder.newBuilder(htd.getTableName()).build(); walFactory = new WALFactory(conf, id); region = TEST_UTIL.createLocalHRegion(info, htd, walFactory.getWAL(info)); region.setBlockCache(BlockCacheFactory.createBlockCache(conf)); store = new HStore(region, hcd, conf, false); }
Example #25
Source File: HBaseTestingUtility.java From hbase with Apache License 2.0 | 5 votes |
public HRegion createTestRegion(String tableName, ColumnFamilyDescriptor cd, BlockCache blockCache) throws IOException { TableDescriptor td = TableDescriptorBuilder.newBuilder(TableName.valueOf(tableName)).setColumnFamily(cd).build(); RegionInfo info = RegionInfoBuilder.newBuilder(TableName.valueOf(tableName)).build(); return createRegionAndWAL(info, getDataTestDir(), getConfiguration(), td, blockCache); }
Example #26
Source File: TestSimpleRegionNormalizer.java From hbase with Apache License 2.0 | 5 votes |
private static RegionInfo createRegionInfo(final TableName tableName, final byte[] startKey, final byte[] endKey) { return RegionInfoBuilder.newBuilder(tableName) .setStartKey(startKey) .setEndKey(endKey) .setRegionId(generateRegionId()) .build(); }
Example #27
Source File: TestHRegionLocation.java From hbase with Apache License 2.0 | 5 votes |
@SuppressWarnings("SelfComparison") @Test public void testCompareTo() { ServerName hsa1 = ServerName.valueOf("localhost", 1234, -1L); HRegionLocation hsl1 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa1); ServerName hsa2 = ServerName.valueOf("localhost", 1235, -1L); HRegionLocation hsl2 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa2); assertEquals(0, hsl1.compareTo(hsl1)); assertEquals(0, hsl2.compareTo(hsl2)); int compare1 = hsl1.compareTo(hsl2); int compare2 = hsl2.compareTo(hsl1); assertTrue((compare1 > 0) ? compare2 < 0 : compare2 > 0); }
Example #28
Source File: TestWALSplit.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testHasRecoveredEdits() throws IOException { Path p = createRecoveredEditsPathForRegion(); assertFalse(WALSplitUtil.hasRecoveredEdits(conf, RegionInfoBuilder.FIRST_META_REGIONINFO)); String renamedEdit = p.getName().split("-")[0]; fs.createNewFile(new Path(p.getParent(), renamedEdit)); assertTrue(WALSplitUtil.hasRecoveredEdits(conf, RegionInfoBuilder.FIRST_META_REGIONINFO)); }
Example #29
Source File: TestHRegionFileSystem.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testOnDiskRegionCreation() throws IOException { Path rootDir = TEST_UTIL.getDataTestDirOnTestFS(name.getMethodName()); FileSystem fs = TEST_UTIL.getTestFileSystem(); Configuration conf = TEST_UTIL.getConfiguration(); // Create a Region RegionInfo hri = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())).build(); HRegionFileSystem regionFs = HRegionFileSystem.createRegionOnFileSystem(conf, fs, CommonFSUtils.getTableDir(rootDir, hri.getTable()), hri); // Verify if the region is on disk Path regionDir = regionFs.getRegionDir(); assertTrue("The region folder should be created", fs.exists(regionDir)); // Verify the .regioninfo RegionInfo hriVerify = HRegionFileSystem.loadRegionInfoFileContent(fs, regionDir); assertEquals(hri, hriVerify); // Open the region regionFs = HRegionFileSystem.openRegionFromFileSystem(conf, fs, CommonFSUtils.getTableDir(rootDir, hri.getTable()), hri, false); assertEquals(regionDir, regionFs.getRegionDir()); // Delete the region HRegionFileSystem.deleteRegionFromFileSystem(conf, fs, CommonFSUtils.getTableDir(rootDir, hri.getTable()), hri); assertFalse("The region folder should be removed", fs.exists(regionDir)); fs.delete(rootDir, true); }
Example #30
Source File: TestMobFileCache.java From hbase with Apache License 2.0 | 5 votes |
/** * Create the mob store file */ private Path createMobStoreFile(ColumnFamilyDescriptor columnFamilyDescriptor) throws IOException { // Setting up a Store TableName tn = TableName.valueOf(TABLE); TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(tn); tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor); HMobStore mobStore = (HMobStore) region.getStore(columnFamilyDescriptor.getName()); KeyValue key1 = new KeyValue(ROW, columnFamilyDescriptor.getName(), QF1, 1, VALUE); KeyValue key2 = new KeyValue(ROW, columnFamilyDescriptor.getName(), QF2, 1, VALUE); KeyValue key3 = new KeyValue(ROW2, columnFamilyDescriptor.getName(), QF3, 1, VALUE2); KeyValue[] keys = new KeyValue[] { key1, key2, key3 }; int maxKeyCount = keys.length; RegionInfo regionInfo = RegionInfoBuilder.newBuilder(tn).build(); StoreFileWriter mobWriter = mobStore.createWriterInTmp(currentDate, maxKeyCount, columnFamilyDescriptor.getCompactionCompressionType(), regionInfo.getStartKey(), false); Path mobFilePath = mobWriter.getPath(); String fileName = mobFilePath.getName(); mobWriter.append(key1); mobWriter.append(key2); mobWriter.append(key3); mobWriter.close(); String targetPathName = MobUtils.formatDate(currentDate); Path targetPath = new Path(mobStore.getPath(), targetPathName); mobStore.commitFile(mobFilePath, targetPath); return new Path(targetPath, fileName); }