Skip to content

Commit

Permalink
HBASE-26450 Server configuration will overwrite HStore configuration …
Browse files Browse the repository at this point in the history
…after using shell command 'update_config' (#3843)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Baiqiang Zhao <zhaobaiqiang@apache.org>
  • Loading branch information
GeorryHuang authored and Apache9 committed Nov 27, 2021
1 parent aa2b807 commit f86bff0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
Expand Up @@ -61,15 +61,13 @@
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompoundConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MemoryCompactionPolicy;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.backup.FailedArchiveException;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.conf.ConfigurationManager;
import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver;
import org.apache.hadoop.hbase.coprocessor.ReadOnlyConfiguration;
Expand Down Expand Up @@ -2627,10 +2625,11 @@ protected OffPeakHours getOffPeakHours() {

@Override
public void onConfigurationChange(Configuration conf) {
this.conf = StoreUtils.createStoreConfiguration(conf, region.getTableDescriptor(),
Configuration storeConf = StoreUtils.createStoreConfiguration(conf, region.getTableDescriptor(),
getColumnFamilyDescriptor());
this.storeEngine.compactionPolicy.setConf(conf);
this.offPeakHours = OffPeakHours.getInstance(conf);
this.conf = storeConf;
this.storeEngine.compactionPolicy.setConf(storeConf);
this.offPeakHours = OffPeakHours.getInstance(storeConf);
}

/**
Expand Down
Expand Up @@ -54,7 +54,6 @@
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.IntBinaryOperator;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
Expand Down Expand Up @@ -99,7 +98,6 @@
import org.apache.hadoop.hbase.monitoring.MonitoredTask;
import org.apache.hadoop.hbase.quotas.RegionSizeStoreImpl;
import org.apache.hadoop.hbase.regionserver.MemStoreCompactionStrategy.Action;
import org.apache.hadoop.hbase.regionserver.TestHStore.MyDefaultMemStore;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration;
import org.apache.hadoop.hbase.regionserver.compactions.DefaultCompactor;
import org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher;
Expand Down Expand Up @@ -2281,6 +2279,29 @@ private SegmentScanner getSegmentScanner(StoreScanner storeScanner) {
return segmentScanners.get(0);
}

@Test
public void testOnConfigurationChange() throws IOException {
final int COMMON_MAX_FILES_TO_COMPACT = 10;
final int NEW_COMMON_MAX_FILES_TO_COMPACT = 8;
final int STORE_MAX_FILES_TO_COMPACT = 6;

//Build a table that its maxFileToCompact different from common configuration.
Configuration conf = HBaseConfiguration.create();
conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_KEY,
COMMON_MAX_FILES_TO_COMPACT);
ColumnFamilyDescriptor hcd = ColumnFamilyDescriptorBuilder.newBuilder(family)
.setConfiguration(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_KEY,
String.valueOf(STORE_MAX_FILES_TO_COMPACT)).build();
init(this.name.getMethodName(), conf, hcd);

//After updating common configuration, the conf in HStore itself must not be changed.
conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_KEY,
NEW_COMMON_MAX_FILES_TO_COMPACT);
this.store.onConfigurationChange(conf);
assertEquals(STORE_MAX_FILES_TO_COMPACT,
store.getStoreEngine().getCompactionPolicy().getConf().getMaxFilesToCompact());
}

private HStoreFile mockStoreFileWithLength(long length) {
HStoreFile sf = mock(HStoreFile.class);
StoreFileReader sfr = mock(StoreFileReader.class);
Expand Down

0 comments on commit f86bff0

Please sign in to comment.