HBASE-27755 Fix update_all_config Table-level StoreHotnessProtector configuration was overwritten
This commit is contained in:
parent
735fb43388
commit
f709319457
|
@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.CompoundConfiguration;
|
||||
import org.apache.hadoop.hbase.RegionTooBusyException;
|
||||
import org.apache.hadoop.hbase.regionserver.Region;
|
||||
import org.apache.hadoop.hbase.regionserver.Store;
|
||||
|
@ -118,7 +119,12 @@ public class StoreHotnessProtector {
|
|||
}
|
||||
|
||||
public void update(Configuration conf) {
|
||||
init(conf);
|
||||
// Add table descriptor configuration
|
||||
CompoundConfiguration newconf = new CompoundConfiguration().add(conf);
|
||||
if (this.region != null) {
|
||||
newconf.addBytesMap(this.region.getTableDescriptor().getValues());
|
||||
}
|
||||
init(newconf);
|
||||
preparePutToStoreMap.clear();
|
||||
LOG.debug("update config: {}", this);
|
||||
}
|
||||
|
@ -201,7 +207,9 @@ public class StoreHotnessProtector {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "StoreHotnessProtector, parallelPutToStoreThreadLimit="
|
||||
return "Table: "
|
||||
+ ((this.region != null) ? this.region.getTableDescriptor().getTableName() : "UNKUNOWN")
|
||||
+ "; StoreHotnessProtector, parallelPutToStoreThreadLimit="
|
||||
+ this.parallelPutToStoreThreadLimit + " ; minColumnNum="
|
||||
+ this.parallelPutToStoreThreadLimitCheckMinColumnCount + " ; preparePutThreadLimit="
|
||||
+ this.parallelPreparePutToStoreThreadLimit + " ; hotProtect now "
|
||||
|
@ -217,6 +225,18 @@ public class StoreHotnessProtector {
|
|||
return preparePutToStoreMap;
|
||||
}
|
||||
|
||||
int getParallelPutToStoreThreadLimit() {
|
||||
return parallelPutToStoreThreadLimit;
|
||||
}
|
||||
|
||||
int getParallelPreparePutToStoreThreadLimit() {
|
||||
return parallelPreparePutToStoreThreadLimit;
|
||||
}
|
||||
|
||||
int getParallelPutToStoreThreadLimitCheckMinColumnCount() {
|
||||
return parallelPutToStoreThreadLimitCheckMinColumnCount;
|
||||
}
|
||||
|
||||
public static final long FIXED_SIZE =
|
||||
ClassSize.align(ClassSize.OBJECT + 2 * ClassSize.REFERENCE + 3 * Bytes.SIZEOF_INT);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,9 @@ import org.apache.hadoop.conf.Configuration;
|
|||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.RegionTooBusyException;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.client.RegionInfo;
|
||||
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
|
||||
import org.apache.hadoop.hbase.regionserver.Region;
|
||||
import org.apache.hadoop.hbase.regionserver.Store;
|
||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||
|
@ -129,4 +131,36 @@ public class TestStoreHotnessProtector {
|
|||
threadCount);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateConfig() {
|
||||
Configuration conf = new Configuration();
|
||||
conf.setInt(PARALLEL_PUT_STORE_THREADS_LIMIT_MIN_COLUMN_COUNT, 0);
|
||||
conf.setInt(PARALLEL_PUT_STORE_THREADS_LIMIT, 10);
|
||||
conf.setInt(PARALLEL_PREPARE_PUT_STORE_MULTIPLIER, 3);
|
||||
Region mockRegion = mock(Region.class);
|
||||
StoreHotnessProtector storeHotnessProtector = new StoreHotnessProtector(mockRegion, conf);
|
||||
|
||||
Store mockStore1 = mock(Store.class);
|
||||
RegionInfo mockRegionInfo = mock(RegionInfo.class);
|
||||
byte[] family = "testF1".getBytes();
|
||||
|
||||
TableDescriptorBuilder builder =
|
||||
TableDescriptorBuilder.newBuilder(TableName.valueOf("TestTable"));
|
||||
builder.setValue(PARALLEL_PUT_STORE_THREADS_LIMIT_MIN_COLUMN_COUNT, "1");
|
||||
builder.setValue(PARALLEL_PUT_STORE_THREADS_LIMIT, "20");
|
||||
builder.setValue(PARALLEL_PREPARE_PUT_STORE_MULTIPLIER, "30");
|
||||
|
||||
when(mockRegion.getStore(family)).thenReturn(mockStore1);
|
||||
when(mockRegion.getRegionInfo()).thenReturn(mockRegionInfo);
|
||||
when(mockRegion.getTableDescriptor()).thenReturn(builder.build());
|
||||
|
||||
// update config
|
||||
storeHotnessProtector.update(conf);
|
||||
|
||||
// table config available
|
||||
Assert.assertEquals(storeHotnessProtector.getParallelPreparePutToStoreThreadLimit(), 600);
|
||||
Assert.assertEquals(storeHotnessProtector.getParallelPutToStoreThreadLimit(), 20);
|
||||
Assert.assertEquals(storeHotnessProtector.getParallelPutToStoreThreadLimitCheckMinColumnCount(),
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue