Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,7 @@ public void updateConfigurationForQuotasObserver(Configuration conf) {

private void initMobCleaner() {
this.mobFileCleanerChore = new MobFileCleanerChore(this);
configurationManager.registerObserver(this.mobFileCleanerChore);
getChoreService().scheduleChore(mobFileCleanerChore);
this.mobFileCompactionChore = new MobFileCompactionChore(this);
getChoreService().scheduleChore(mobFileCompactionChore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.hadoop.hbase.master.cleaner.ReplicationBarrierCleaner;
import org.apache.hadoop.hbase.master.hbck.HbckChore;
import org.apache.hadoop.hbase.master.janitor.CatalogJanitor;
import org.apache.hadoop.hbase.mob.MobFileCleanerChore;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.junit.jupiter.api.AfterAll;
Expand Down Expand Up @@ -108,6 +109,12 @@ public void testDefaultScheduledChores() throws Exception {
TestChoreField<HbckChore> hbckChoreTestChoreField = new TestChoreField<>();
HbckChore hbckChore = hbckChoreTestChoreField.getChoreObj("hbckChore");
hbckChoreTestChoreField.testIfChoreScheduled(hbckChore);

TestChoreField<MobFileCleanerChore> mobFileCleanerTestChoreField = new TestChoreField<>();
MobFileCleanerChore mobFileCleanerChore =
mobFileCleanerTestChoreField.getChoreObj("mobFileCleanerChore");
mobFileCleanerTestChoreField.testIfChoreScheduled(mobFileCleanerChore);
assertTrue(hMaster.getConfigurationManager().containsObserver(mobFileCleanerChore));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hbase.mob;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
Expand All @@ -34,6 +35,28 @@
@Tag(SmallTests.TAG)
public class TestMobFileCleanerChore {

@Test
public void testOnConfigurationChangeResizesExecutor() {
Configuration conf = new Configuration();
conf.setInt(MobConstants.MOB_CLEANER_THREAD_COUNT, 2);
HMaster master = mock(HMaster.class);
when(master.getServerName()).thenReturn(ServerName.valueOf("localhost", 12345, 1));
when(master.getConfiguration()).thenReturn(conf);

MobFileCleanerChore chore = new MobFileCleanerChore(master);
assertEquals(2, chore.getExecutor().getCorePoolSize());
assertEquals(2, chore.getExecutor().getMaximumPoolSize());

Configuration newConf = new Configuration(conf);
newConf.setInt(MobConstants.MOB_CLEANER_THREAD_COUNT, 4);
chore.onConfigurationChange(newConf);

assertEquals(4, chore.getExecutor().getCorePoolSize());
assertEquals(4, chore.getExecutor().getMaximumPoolSize());

chore.shutdown();
}

@Test
public void testShutdownCleansUpExecutor() {
Configuration conf = new Configuration();
Expand Down