org.apache.hadoop.hbase.HBaseTestingUtility.createLocalHRegion()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.apache.hadoop.hbase.HBaseTestingUtility.createLocalHRegion()方法的一些代码示例,展示了HBaseTestingUtility.createLocalHRegion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HBaseTestingUtility.createLocalHRegion()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.HBaseTestingUtility
类名称:HBaseTestingUtility
方法名:createLocalHRegion

HBaseTestingUtility.createLocalHRegion介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

/**
 * @return A region on which you must call
 *         {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done.
 */
public HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey,
  boolean isReadOnly, Durability durability, WAL wal, byte[]... families) throws IOException {
 return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey,
   isReadOnly, durability, wal, families);
}

代码示例来源:origin: apache/hbase

private static HRegion initHRegion(byte[] tableName, byte[] startKey, byte[] stopKey,
   String callingMethod, Configuration conf, boolean isReadOnly, Durability durability,
   WAL wal, byte[]... families) throws IOException {
  return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey, callingMethod, conf,
   isReadOnly, durability, wal, families);
 }
}

代码示例来源:origin: apache/hbase

/**
 * @param tableName
 * @param startKey
 * @param stopKey
 * @param callingMethod
 * @param conf
 * @param isReadOnly
 * @param families
 * @throws IOException
 * @return A region on which you must call
      {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done.
 * @deprecated use
 * {@link #createLocalHRegion(TableName, byte[], byte[], boolean, Durability, WAL, byte[]...)}
 */
@Deprecated
public HRegion createLocalHRegion(byte[] tableName, byte[] startKey, byte[] stopKey,
  String callingMethod, Configuration conf, boolean isReadOnly, Durability durability,
  WAL wal, byte[]... families) throws IOException {
 return this
   .createLocalHRegion(TableName.valueOf(tableName), startKey, stopKey, isReadOnly, durability,
     wal, families);
}

代码示例来源:origin: apache/hbase

/**
  * @return A region on which you must call {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)}
  *         when done.
  */
 public static HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey, WAL wal)
   throws IOException {
  ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null);
  return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey, false, Durability.USE_DEFAULT,
   wal, COLUMN_FAMILY_BYTES);
 }
}

代码示例来源:origin: apache/hbase

/**
  * @return A region on which you must call {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)}
  *         when done.
  */
 private static HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey, WAL wal)
   throws IOException {
  ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null);
  return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey, false, Durability.SYNC_WAL,
   wal, COLUMN_FAMILY_BYTES);
 }
}

代码示例来源:origin: apache/hbase

/**
  * @return A region on which you must call
  *         {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done.
  */
 public static HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey, WAL wal)
 throws IOException {
  ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null);
  return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey, false, Durability.SYNC_WAL,
   wal, COLUMN_FAMILY_BYTES);
 }
}

代码示例来源:origin: apache/hbase

private HRegion initHRegion(byte [] tableName, String callingMethod,
 byte[] ... families)
throws IOException {
 HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
 for(byte [] family : families) {
  htd.addFamily(new HColumnDescriptor(family));
 }
 HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
 return HBTU.createLocalHRegion(info, htd);
}

代码示例来源:origin: apache/hbase

private void initHRegion (byte [] tableName, String callingMethod, int [] maxVersions,
 byte[] ... families)
throws IOException {
 HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
 int i=0;
 for(byte [] family : families) {
  HColumnDescriptor hcd = new HColumnDescriptor(family);
  hcd.setMaxVersions(maxVersions != null ? maxVersions[i++] : 1);
  htd.addFamily(hcd);
 }
 HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
 region = TEST_UTIL.createLocalHRegion(info, htd);
}

代码示例来源:origin: apache/hbase

@Before
public void setUp() throws Exception {
 this.htd = UTIL.createTableDescriptor(name.getMethodName().replace('[','i').replace(']','i'));
 this.r = UTIL.createLocalHRegion(htd, null, null);
}

代码示例来源:origin: apache/hbase

/**
 * Create an HRegion that writes to the local tmp dirs
 * @param desc a table descriptor indicating which table the region belongs to
 * @param startKey the start boundary of the region
 * @param endKey the end boundary of the region
 * @return a region that writes to local dir for testing
 * @throws IOException
 */
public HRegion createLocalHRegion(TableDescriptor desc, byte [] startKey,
  byte [] endKey)
throws IOException {
 HRegionInfo hri = new HRegionInfo(desc.getTableName(), startKey, endKey);
 return createLocalHRegion(hri, desc);
}

代码示例来源:origin: apache/hbase

private HRegion getRegion(final Configuration conf, final String tableName) throws IOException {
 FSHLog wal = new FSHLog(FileSystem.get(conf), TEST_UTIL.getDataTestDir(),
   TEST_UTIL.getDataTestDir().toString(), conf);
 wal.init();
 ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null);
 return TEST_UTIL.createLocalHRegion(TableName.valueOf(tableName), HConstants.EMPTY_BYTE_ARRAY,
  HConstants.EMPTY_BYTE_ARRAY, false, Durability.SKIP_WAL, wal, INCREMENT_BYTES);
}

代码示例来源:origin: apache/hbase

@Before
public void setUp() throws Exception {
 this.htd = UTIL.createTableDescriptor(name.getMethodName());
 if (name.getMethodName().equals("testCompactionSeqId")) {
  UTIL.getConfiguration().set("hbase.hstore.compaction.kv.max", "10");
  UTIL.getConfiguration().set(
    DefaultStoreEngine.DEFAULT_COMPACTOR_CLASS_KEY,
    DummyCompactor.class.getName());
  HColumnDescriptor hcd = new HColumnDescriptor(FAMILY);
  hcd.setMaxVersions(65536);
  this.htd.addFamily(hcd);
 }
 this.r = UTIL.createLocalHRegion(htd, null, null);
}

代码示例来源:origin: apache/hbase

@Before
public void setUp() throws Exception {
 this.htd = UTIL.createTableDescriptor(name.getMethodName());
 this.r = UTIL.createLocalHRegion(htd, null, null);
}

代码示例来源:origin: apache/hbase

@Before
public void setUp() throws IOException {
 UTIL.getConfiguration().setLong(StoreScanner.STORESCANNER_PREAD_MAX_BYTES, 2048);
 StringBuilder sb = new StringBuilder(256);
 for (int i = 0; i < 255; i++) {
  sb.append((char) ThreadLocalRandom.current().nextInt('A', 'z' + 1));
 }
 VALUE_PREFIX = sb.append("-").toString();
 REGION = UTIL.createLocalHRegion(
  TableDescriptorBuilder.newBuilder(TABLE_NAME)
   .setColumnFamily(
    ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).setBlocksize(1024).build())
   .build(),
  null, null);
 for (int i = 0; i < 900; i++) {
  REGION
   .put(new Put(Bytes.toBytes(i)).addColumn(FAMILY, QUAL, Bytes.toBytes(VALUE_PREFIX + i)));
 }
 REGION.flush(true);
 for (int i = 900; i < 1000; i++) {
  REGION
   .put(new Put(Bytes.toBytes(i)).addColumn(FAMILY, QUAL, Bytes.toBytes(VALUE_PREFIX + i)));
 }
}

代码示例来源:origin: apache/hbase

/**
 * Tests to do a concurrent flush (using a 2nd thread) while scanning.  This tests both
 * the StoreScanner update readers and the transition from memstore -> snapshot -> store file.
 *
 * @throws Exception
 */
@Test
public void testScanAndRealConcurrentFlush() throws Exception {
 this.region = TEST_UTIL.createLocalHRegion(TESTTABLEDESC, null, null);
 Table hri = new RegionAsTable(region);
 try {
   LOG.info("Added: " +
    HBaseTestCase.addContent(hri, Bytes.toString(HConstants.CATALOG_FAMILY),
     Bytes.toString(HConstants.REGIONINFO_QUALIFIER)));
  int count = count(hri, -1, false);
  assertEquals(count, count(hri, 100, true)); // do a true concurrent background thread flush
 } catch (Exception e) {
  LOG.error("Failed", e);
  throw e;
 } finally {
  HBaseTestingUtility.closeRegionAndWAL(this.region);
 }
}

代码示例来源:origin: apache/hbase

/**
 * Tests to do a sync flush during the middle of a scan. This is testing the StoreScanner
 * update readers code essentially.  This is not highly concurrent, since its all 1 thread.
 * HBase-910.
 * @throws Exception
 */
@Test
public void testScanAndSyncFlush() throws Exception {
 this.region = TEST_UTIL.createLocalHRegion(TESTTABLEDESC, null, null);
 Table hri = new RegionAsTable(region);
 try {
   LOG.info("Added: " +
    HBaseTestCase.addContent(hri, Bytes.toString(HConstants.CATALOG_FAMILY),
     Bytes.toString(HConstants.REGIONINFO_QUALIFIER)));
  int count = count(hri, -1, false);
  assertEquals(count, count(hri, 100, false)); // do a sync flush.
 } catch (Exception e) {
  LOG.error("Failed", e);
  throw e;
 } finally {
  HBaseTestingUtility.closeRegionAndWAL(this.region);
 }
}

代码示例来源:origin: apache/hbase

public HRegion createLocalHRegionWithInMemoryFlags(TableName tableName, byte[] startKey,
  byte[] stopKey,
  boolean isReadOnly, Durability durability, WAL wal, boolean[] compactedMemStore,
  byte[]... families)
  throws IOException {
 HTableDescriptor htd = new HTableDescriptor(tableName);
 htd.setReadOnly(isReadOnly);
 int i=0;
 for (byte[] family : families) {
  HColumnDescriptor hcd = new HColumnDescriptor(family);
  if(compactedMemStore != null && i < compactedMemStore.length) {
   hcd.setInMemoryCompaction(MemoryCompactionPolicy.BASIC);
  } else {
   hcd.setInMemoryCompaction(MemoryCompactionPolicy.NONE);
  }
  i++;
  // Set default to be three versions.
  hcd.setMaxVersions(Integer.MAX_VALUE);
  htd.addFamily(hcd);
 }
 htd.setDurability(durability);
 HRegionInfo info = new HRegionInfo(htd.getTableName(), startKey, stopKey, false);
 return createLocalHRegion(info, htd, wal);
}

代码示例来源:origin: apache/hbase

@Test
public void testFilters() throws IOException {
 try {
  this.region = TEST_UTIL.createLocalHRegion(TESTTABLEDESC, null, null);
  HBaseTestCase.addContent(this.region, HConstants.CATALOG_FAMILY);
  byte [] prefix = Bytes.toBytes("ab");
  Filter newFilter = new PrefixFilter(prefix);
  Scan scan = new Scan();
  scan.setFilter(newFilter);
  rowPrefixFilter(scan);
  byte[] stopRow = Bytes.toBytes("bbc");
  newFilter = new WhileMatchFilter(new InclusiveStopFilter(stopRow));
  scan = new Scan();
  scan.setFilter(newFilter);
  rowInclusiveStopFilter(scan, stopRow);
 } finally {
  HBaseTestingUtility.closeRegionAndWAL(this.region);
 }
}

代码示例来源:origin: apache/hbase

/**
 * Test that closing a scanner while a client is using it doesn't throw
 * NPEs but instead a UnknownScannerException. HBASE-2503
 * @throws Exception
 */
@Test
public void testRaceBetweenClientAndTimeout() throws Exception {
 try {
  this.region = TEST_UTIL.createLocalHRegion(TESTTABLEDESC, null, null);
  HBaseTestCase.addContent(this.region, HConstants.CATALOG_FAMILY);
  Scan scan = new Scan();
  InternalScanner s = region.getScanner(scan);
  List<Cell> results = new ArrayList<>();
  try {
   s.next(results);
   s.close();
   s.next(results);
   fail("We don't want anything more, we should be failing");
  } catch (UnknownScannerException ex) {
   // ok!
   return;
  }
 } finally {
  HBaseTestingUtility.closeRegionAndWAL(this.region);
 }
}

代码示例来源:origin: apache/hbase

/**
 * The ExplicitColumnTracker does not support "raw" scanning.
 */
@Test
public void testRawScanWithColumns() throws Exception {
 HTableDescriptor htd = hbu.createTableDescriptor(name.getMethodName(), 0, 3,
   HConstants.FOREVER, KeepDeletedCells.TRUE);
 Region region = hbu.createLocalHRegion(htd, null, null);
 Scan s = new Scan();
 s.setRaw(true);
 s.setMaxVersions();
 s.addColumn(c0, c0);
 try {
  region.getScanner(s);
  fail("raw scanner with columns should have failed");
 } catch (org.apache.hadoop.hbase.DoNotRetryIOException dnre) {
  // ok!
 }
 HBaseTestingUtility.closeRegionAndWAL(region);
}

相关文章

HBaseTestingUtility类方法