@Override public void run() { try { while (running.get()) { // flush or compact if (random.nextBoolean()) { TestRegionServerNoMaster.flushRegion(HTU, hriPrimary); } else { HTU.compact(table.getName(), random.nextBoolean()); } } } catch (Exception ex) { LOG.warn(ex.toString(), ex); exceptions[1].compareAndSet(null, ex); } } };
@Test public void test() throws IOException, InterruptedException { try (Table t = UTIL.getConnection().getTable(NAME1)) { writeData(t); // Flush the data UTIL.flush(NAME1); // Issue a compaction UTIL.compact(NAME1, true); Thread.sleep(2000); } Set<String> jmxMetrics = readJmxMetricsWithRetry(); assertNotNull(jmxMetrics); long name1TableMetricsCount = jmxMetrics.stream().filter(metric -> metric.contains("MetaTable_table_" + NAME1)).count(); assertEquals(5L, name1TableMetricsCount); String putWithClientMetricNameRegex = "MetaTable_client_.+_put_request.*"; long putWithClientMetricsCount = jmxMetrics.stream().filter(metric -> metric.matches(putWithClientMetricNameRegex)) .count(); assertEquals(5L, putWithClientMetricsCount); }
@Test public void test() throws IOException, InterruptedException { try (Table t = UTIL.getConnection().getTable(NAME)) { writeData(t); // Flush the data UTIL.flush(NAME); // Issue a compaction UTIL.compact(NAME, true); Scan s = new Scan(); s.addColumn(FAMILY, QUALIFIER); try (ResultScanner scanner = t.getScanner(s)) { for (int i = 0; i < NUM_ROWS; i++) { Result result = scanner.next(); assertNotNull("The " + (i + 1) + "th result was unexpectedly null", result); assertEquals(1, result.getFamilyMap(FAMILY).size()); assertArrayEquals(Bytes.toBytes(i + 1), result.getRow()); assertArrayEquals(Bytes.toBytes(replacedValue), result.getValue(FAMILY, QUALIFIER)); } assertNull(scanner.next()); } } } }
TEST_UTIL.compact(true); for (int i = 20; i < 300; i++) { byte[] row = Bytes.toBytes("key" + Integer.toString(i));
admin.flush(tn); LOG.info("Synchronously compacting the table"); TEST_UTIL.compact(tn, true);
@Test public void testRegionReplicaReplicationForFlushAndCompaction() throws Exception { // Tests a table with region replication 3. Writes some data, and causes flushes and // compactions. Verifies that the data is readable from the replicas. Note that this // does not test whether the replicas actually pick up flushed files and apply compaction // to their stores int regionReplication = 3; final TableName tableName = TableName.valueOf(name.getMethodName()); HTableDescriptor htd = HTU.createTableDescriptor(tableName); htd.setRegionReplication(regionReplication); HTU.getAdmin().createTable(htd); Connection connection = ConnectionFactory.createConnection(HTU.getConfiguration()); Table table = connection.getTable(tableName); try { // load the data to the table for (int i = 0; i < 6000; i += 1000) { LOG.info("Writing data from " + i + " to " + (i+1000)); HTU.loadNumericRows(table, HBaseTestingUtility.fam1, i, i+1000); LOG.info("flushing table"); HTU.flush(tableName); LOG.info("compacting table"); HTU.compact(tableName, false); } verifyReplication(tableName, regionReplication, 0, 1000); } finally { table.close(); connection.close(); } }
util.compact(tableName, true); assertEquals(1, region.getStoreFileList(new byte[][]{familyNameBytes}).size()); assertEquals(refSFCount+1,
TEST_UTIL.compact(tableName, true); table.put(p);
admin.flush(tn); LOG.info("Synchronously compacting the table"); TEST_UTIL.compact(tn, true);
util.compact(tableName, true); assertNotNull(preadScanner.next()); assertNotNull(streamScanner.next());
TEST_UTIL.compact(tableName, true);
UTIL2.compact(TABLE_NAME, true);
HTU.compact(table.getName(), true);
TEST_UTIL.compact(tn, false); long numFilesAfterMinorCompaction = getNumHFilesForRegion(region);
TEST_UTIL.compact(tn, true);
public void flush(String name) throws Exception { TableName table = TableName.valueOf(name); utility.get().flush(table); utility.get().compact(table, true); } }
@Override public void run() { try { while (running.get()) { // flush or compact if (random.nextBoolean()) { TestRegionServerNoMaster.flushRegion(HTU, hriPrimary); } else { HTU.compact(table.getName(), random.nextBoolean()); } } } catch (Exception ex) { LOG.warn(ex.toString(), ex); exceptions[1].compareAndSet(null, ex); } } };
@Test public void test() throws IOException, InterruptedException { try (Table t = UTIL.getConnection().getTable(NAME)) { writeData(t); // Flush the data UTIL.flush(NAME); // Issue a compaction UTIL.compact(NAME, true); Scan s = new Scan(); s.addColumn(FAMILY, QUALIFIER); try (ResultScanner scanner = t.getScanner(s)) { for (int i = 0; i < NUM_ROWS; i++) { Result result = scanner.next(); assertNotNull("The " + (i + 1) + "th result was unexpectedly null", result); assertEquals(1, result.getFamilyMap(FAMILY).size()); assertArrayEquals(Bytes.toBytes(i + 1), result.getRow()); assertArrayEquals(Bytes.toBytes(replacedValue), result.getValue(FAMILY, QUALIFIER)); } assertNull(scanner.next()); } } } }
@Test public void testRegionReplicaReplicationForFlushAndCompaction() throws Exception { // Tests a table with region replication 3. Writes some data, and causes flushes and // compactions. Verifies that the data is readable from the replicas. Note that this // does not test whether the replicas actually pick up flushed files and apply compaction // to their stores int regionReplication = 3; final TableName tableName = TableName.valueOf(name.getMethodName()); HTableDescriptor htd = HTU.createTableDescriptor(tableName); htd.setRegionReplication(regionReplication); HTU.getAdmin().createTable(htd); Connection connection = ConnectionFactory.createConnection(HTU.getConfiguration()); Table table = connection.getTable(tableName); try { // load the data to the table for (int i = 0; i < 6000; i += 1000) { LOG.info("Writing data from " + i + " to " + (i+1000)); HTU.loadNumericRows(table, HBaseTestingUtility.fam1, i, i+1000); LOG.info("flushing table"); HTU.flush(tableName); LOG.info("compacting table"); HTU.compact(tableName, false); } verifyReplication(tableName, regionReplication, 0, 1000); } finally { table.close(); connection.close(); } }