Search in sources :

Example 1 with StripeCompactor

use of org.apache.hadoop.hbase.regionserver.compactions.StripeCompactor in project hbase by apache.

the class StripeStoreEngine method createComponents.

@Override
protected void createComponents(Configuration conf, Store store, CellComparator comparator) throws IOException {
    this.config = new StripeStoreConfig(conf, store);
    this.compactionPolicy = new StripeCompactionPolicy(conf, store, config);
    this.storeFileManager = new StripeStoreFileManager(comparator, conf, this.config);
    this.storeFlusher = new StripeStoreFlusher(conf, store, this.compactionPolicy, this.storeFileManager);
    this.compactor = new StripeCompactor(conf, store);
}
Also used : StripeCompactionPolicy(org.apache.hadoop.hbase.regionserver.compactions.StripeCompactionPolicy) StripeCompactor(org.apache.hadoop.hbase.regionserver.compactions.StripeCompactor)

Example 2 with StripeCompactor

use of org.apache.hadoop.hbase.regionserver.compactions.StripeCompactor in project hbase by apache.

the class TestStripeStoreEngine method testCompactionContextForceSelect.

@Test
public void testCompactionContextForceSelect() throws Exception {
    Configuration conf = HBaseConfiguration.create();
    int targetCount = 2;
    conf.setInt(StripeStoreConfig.INITIAL_STRIPE_COUNT_KEY, targetCount);
    conf.setInt(StripeStoreConfig.MIN_FILES_L0_KEY, 2);
    conf.set(StoreEngine.STORE_ENGINE_CLASS_KEY, TestStoreEngine.class.getName());
    TestStoreEngine se = createEngine(conf);
    StripeCompactor mockCompactor = mock(StripeCompactor.class);
    se.setCompactorOverride(mockCompactor);
    when(mockCompactor.compact(any(CompactionRequest.class), anyInt(), anyLong(), any(byte[].class), any(byte[].class), any(byte[].class), any(byte[].class), any(ThroughputController.class), any(User.class))).thenReturn(new ArrayList<>());
    // Produce 3 L0 files.
    StoreFile sf = createFile();
    ArrayList<StoreFile> compactUs = al(sf, createFile(), createFile());
    se.getStoreFileManager().loadFiles(compactUs);
    // Create a compaction that would want to split the stripe.
    CompactionContext compaction = se.createCompaction();
    compaction.select(al(), false, false, false);
    assertEquals(3, compaction.getRequest().getFiles().size());
    // Override the file list. Granted, overriding this compaction in this manner will
    // break things in real world, but we only want to verify the override.
    compactUs.remove(sf);
    CompactionRequest req = new CompactionRequest(compactUs);
    compaction.forceSelect(req);
    assertEquals(2, compaction.getRequest().getFiles().size());
    assertFalse(compaction.getRequest().getFiles().contains(sf));
    // Make sure the correct method it called on compactor.
    compaction.compact(NoLimitThroughputController.INSTANCE, null);
    verify(mockCompactor, times(1)).compact(compaction.getRequest(), targetCount, 0L, StripeStoreFileManager.OPEN_KEY, StripeStoreFileManager.OPEN_KEY, null, null, NoLimitThroughputController.INSTANCE, null);
}
Also used : User(org.apache.hadoop.hbase.security.User) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) CompactionContext(org.apache.hadoop.hbase.regionserver.compactions.CompactionContext) ThroughputController(org.apache.hadoop.hbase.regionserver.throttle.ThroughputController) NoLimitThroughputController(org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController) CompactionRequest(org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest) StripeCompactor(org.apache.hadoop.hbase.regionserver.compactions.StripeCompactor) Test(org.junit.Test)

Aggregations

StripeCompactor (org.apache.hadoop.hbase.regionserver.compactions.StripeCompactor)2 Configuration (org.apache.hadoop.conf.Configuration)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1 CompactionContext (org.apache.hadoop.hbase.regionserver.compactions.CompactionContext)1 CompactionRequest (org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest)1 StripeCompactionPolicy (org.apache.hadoop.hbase.regionserver.compactions.StripeCompactionPolicy)1 NoLimitThroughputController (org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController)1 ThroughputController (org.apache.hadoop.hbase.regionserver.throttle.ThroughputController)1 User (org.apache.hadoop.hbase.security.User)1 Test (org.junit.Test)1