org.apache.hadoop.hbase.regionserver.HStore.getStorefilesCount()方法的使用及代码示例

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

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

HStore.getStorefilesCount介绍

暂无

代码示例

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

  1. @Override
  2. public boolean hasTooManyStoreFiles() {
  3. return getStorefilesCount() > this.blockingFileCount;
  4. }

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

  1. @Override
  2. public boolean evaluate() throws Exception {
  3. return store.getStorefilesCount() == 1;
  4. }

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

  1. @Override
  2. public String explainFailure() throws Exception {
  3. return "The store file count " + store.getStorefilesCount() + " is still greater than 1";
  4. }
  5. });

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

  1. public int countStoreFiles() {
  2. int count = 0;
  3. for (HStore store : stores.values()) {
  4. count += store.getStorefilesCount();
  5. }
  6. return count;
  7. }
  8. }

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

  1. private void waitForStoreFileCount(HStore store, int count, int timeout)
  2. throws InterruptedException {
  3. long start = System.currentTimeMillis();
  4. while (start + timeout > System.currentTimeMillis() && store.getStorefilesCount() != count) {
  5. Thread.sleep(100);
  6. }
  7. System.out.println("start=" + start + ", now=" + System.currentTimeMillis() + ", cur=" +
  8. store.getStorefilesCount());
  9. assertEquals(count, store.getStorefilesCount());
  10. }

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

  1. private void waitForStoreFileCount(HStore store, int count, int timeout)
  2. throws InterruptedException {
  3. long start = System.currentTimeMillis();
  4. while (start + timeout > System.currentTimeMillis() && store.getStorefilesCount() != count) {
  5. Thread.sleep(100);
  6. }
  7. System.out.println("start=" + start + ", now=" + System.currentTimeMillis() + ", cur=" +
  8. store.getStorefilesCount());
  9. assertEquals(count, store.getStorefilesCount());
  10. }

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

  1. private int countStoreFiles() throws IOException {
  2. HStore store = region.getStore(COLUMN_FAMILY);
  3. return store.getStorefilesCount();
  4. }

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

  1. private long testCompactionWithoutThroughputLimit() throws Exception {
  2. Configuration conf = TEST_UTIL.getConfiguration();
  3. conf.set(StoreEngine.STORE_ENGINE_CLASS_KEY, DefaultStoreEngine.class.getName());
  4. conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MIN_KEY, 100);
  5. conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_KEY, 200);
  6. conf.setInt(HStore.BLOCKING_STOREFILES_KEY, 10000);
  7. conf.set(CompactionThroughputControllerFactory.HBASE_THROUGHPUT_CONTROLLER_KEY,
  8. NoLimitThroughputController.class.getName());
  9. TEST_UTIL.startMiniCluster(1);
  10. try {
  11. HStore store = prepareData();
  12. assertEquals(10, store.getStorefilesCount());
  13. long startTime = System.currentTimeMillis();
  14. TEST_UTIL.getAdmin().majorCompact(tableName);
  15. while (store.getStorefilesCount() != 1) {
  16. Thread.sleep(20);
  17. }
  18. return System.currentTimeMillis() - startTime;
  19. } finally {
  20. TEST_UTIL.shutdownMiniCluster();
  21. }
  22. }

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

  1. try {
  2. HStore store = prepareData();
  3. assertEquals(10, store.getStorefilesCount());
  4. long startTime = System.currentTimeMillis();
  5. TEST_UTIL.getAdmin().majorCompact(tableName);
  6. while (store.getStorefilesCount() != 1) {
  7. Thread.sleep(20);

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

  1. private void loadFlushAndCompact(HRegion region, byte[] family) throws IOException {
  2. // create two hfiles in the region
  3. createHFileInRegion(region, family);
  4. createHFileInRegion(region, family);
  5. HStore s = region.getStore(family);
  6. int count = s.getStorefilesCount();
  7. assertTrue("Don't have the expected store files, wanted >= 2 store files, but was:" + count,
  8. count >= 2);
  9. // compact the two files into one file to get files in the archive
  10. LOG.debug("Compacting stores");
  11. region.compact(true);
  12. }

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

  1. @Test
  2. public void testRefreshStoreFilesNotChanged() throws IOException {
  3. init(name.getMethodName());
  4. assertEquals(0, this.store.getStorefilesCount());
  5. // add some data, flush
  6. this.store.add(new KeyValue(row, family, qf1, 1, (byte[])null), null);
  7. flush(1);
  8. // add one more file
  9. addStoreFile();
  10. HStore spiedStore = spy(store);
  11. // call first time after files changed
  12. spiedStore.refreshStoreFiles();
  13. assertEquals(2, this.store.getStorefilesCount());
  14. verify(spiedStore, times(1)).replaceStoreFiles(any(), any());
  15. // call second time
  16. spiedStore.refreshStoreFiles();
  17. //ensure that replaceStoreFiles is not called if files are not refreshed
  18. verify(spiedStore, times(0)).replaceStoreFiles(null, null);
  19. }

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

  1. /**
  2. * Writes Puts to the table and flushes few times.
  3. * @return {@link Pair} of (throughput, duration).
  4. */
  5. private Pair<Double, Long> generateAndFlushData(Table table) throws IOException {
  6. // Internally, throughput is controlled after every cell write, so keep value size less for
  7. // better control.
  8. final int NUM_FLUSHES = 3, NUM_PUTS = 50, VALUE_SIZE = 200 * 1024;
  9. Random rand = new Random();
  10. long duration = 0;
  11. for (int i = 0; i < NUM_FLUSHES; i++) {
  12. // Write about 10M (10 times of throughput rate) per iteration.
  13. for (int j = 0; j < NUM_PUTS; j++) {
  14. byte[] value = new byte[VALUE_SIZE];
  15. rand.nextBytes(value);
  16. table.put(new Put(Bytes.toBytes(i * 10 + j)).addColumn(family, qualifier, value));
  17. }
  18. long startTime = System.nanoTime();
  19. hbtu.getAdmin().flush(tableName);
  20. duration += System.nanoTime() - startTime;
  21. }
  22. HStore store = getStoreWithName(tableName);
  23. assertEquals(NUM_FLUSHES, store.getStorefilesCount());
  24. double throughput = (double)store.getStorefilesSize()
  25. / TimeUnit.NANOSECONDS.toSeconds(duration);
  26. return new Pair<>(throughput, duration);
  27. }

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

  1. int initialFiles = s.getStorefilesCount();
  2. assertEquals(initialFiles, s.getStorefilesCount());

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

  1. init(name.getMethodName());
  2. assertEquals(0, this.store.getStorefilesCount());
  3. assertEquals(0, this.store.getStorefilesCount());
  4. assertEquals(1, this.store.getStorefilesCount());
  5. assertEquals(1, this.store.getStorefilesCount());
  6. store.refreshStoreFiles();
  7. assertEquals(2, this.store.getStorefilesCount());
  8. addStoreFile();
  9. assertEquals(2, this.store.getStorefilesCount());
  10. store.refreshStoreFiles();
  11. assertEquals(5, this.store.getStorefilesCount());
  12. assertEquals(5, this.store.getStorefilesCount());
  13. store.refreshStoreFiles();
  14. assertEquals(4, this.store.getStorefilesCount());
  15. assertEquals(4, this.store.getStorefilesCount());
  16. store.refreshStoreFiles();
  17. assertEquals(1, this.store.getStorefilesCount());
  18. assertEquals(0, this.store.getStorefilesCount());

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

  1. @Test
  2. public void test() throws Exception {
  3. // sleep every 10 loops to give memstore compaction enough time to finish before reaching the
  4. // flush size.
  5. doIncrement(10);
  6. assertSum();
  7. HStore store = UTIL.getHBaseCluster().findRegionsForTable(NAME).get(0).getStore(FAMILY);
  8. // should have no store files created as we have done aggregating all in memory
  9. assertEquals(0, store.getStorefilesCount());
  10. }
  11. }

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

  1. private static void waitForCompaction(TableName tableName)
  2. throws IOException, InterruptedException {
  3. boolean compacted = false;
  4. for (Region region : TEST_UTIL.getRSForFirstRegionInTable(tableName)
  5. .getRegions(tableName)) {
  6. for (HStore store : ((HRegion) region).getStores()) {
  7. compacted = false;
  8. while (!compacted) {
  9. if (store.getStorefiles() != null) {
  10. while (store.getStorefilesCount() != 1) {
  11. Thread.sleep(100);
  12. }
  13. for (HStoreFile storefile : store.getStorefiles()) {
  14. if (!storefile.isCompactedAway()) {
  15. compacted = true;
  16. break;
  17. }
  18. Thread.sleep(100);
  19. }
  20. } else {
  21. break;
  22. }
  23. }
  24. }
  25. }
  26. }

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

  1. @Test
  2. public void testPurgeExpiredFiles() throws Exception {
  3. HStore store = prepareData();
  4. assertEquals(10, store.getStorefilesCount());
  5. TEST_UTIL.getAdmin().majorCompact(tableName);
  6. TEST_UTIL.waitFor(30000, new ExplainingPredicate<Exception>() {
  7. @Override
  8. public boolean evaluate() throws Exception {
  9. return store.getStorefilesCount() == 1;
  10. }
  11. @Override
  12. public String explainFailure() throws Exception {
  13. return "The store file count " + store.getStorefilesCount() + " is still greater than 1";
  14. }
  15. });
  16. }

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

  1. @Test
  2. public void test() throws IOException, KeeperException, InterruptedException {
  3. long now = System.currentTimeMillis();
  4. put(0, 100, now - 10000);
  5. assertValueEquals(0, 100);
  6. setExpireBefore(now - 5000);
  7. Thread.sleep(5000);
  8. UTIL.getAdmin().flush(NAME);
  9. assertNotExists(0, 100);
  10. put(0, 50, now - 1000);
  11. UTIL.getAdmin().flush(NAME);
  12. put(50, 100, now - 100);
  13. UTIL.getAdmin().flush(NAME);
  14. assertValueEquals(0, 100);
  15. setExpireBefore(now - 500);
  16. Thread.sleep(5000);
  17. UTIL.getAdmin().majorCompact(NAME);
  18. UTIL.waitFor(30000, () -> UTIL.getHBaseCluster().getRegions(NAME).iterator().next()
  19. .getStore(FAMILY).getStorefilesCount() == 1);
  20. assertNotExists(0, 50);
  21. assertValueEquals(50, 100);
  22. }
  23. }

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

  1. assertEquals(2, this.store.getStorefilesCount());

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

  1. @Test
  2. public void test() throws Exception {
  3. doIncrement(0);
  4. assertSum();
  5. // we do not hack scan operation so using scan we could get the original values added into the
  6. // table.
  7. try (ResultScanner scanner = TABLE.getScanner(new Scan().withStartRow(ROW)
  8. .withStopRow(ROW, true).addFamily(FAMILY).readAllVersions().setAllowPartialResults(true))) {
  9. Result r = scanner.next();
  10. assertTrue(r.rawCells().length > 2);
  11. }
  12. UTIL.flush(NAME);
  13. HRegion region = UTIL.getHBaseCluster().findRegionsForTable(NAME).get(0);
  14. HStore store = region.getStore(FAMILY);
  15. for (;;) {
  16. region.compact(true);
  17. if (store.getStorefilesCount() == 1) {
  18. break;
  19. }
  20. }
  21. assertSum();
  22. // Should only have two cells after flush and major compaction
  23. try (ResultScanner scanner = TABLE.getScanner(new Scan().withStartRow(ROW)
  24. .withStopRow(ROW, true).addFamily(FAMILY).readAllVersions().setAllowPartialResults(true))) {
  25. Result r = scanner.next();
  26. assertEquals(2, r.rawCells().length);
  27. }
  28. }
  29. }

相关文章

HStore类方法