HBASE-26270 Provide getConfiguration method for Region and Store interface (#3671)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Anoop Sam John <anoopsamjohn@apache.org>
This commit is contained in:
meiyi 2021-09-22 10:23:25 +08:00 committed by meiyi
parent 2599bd8eab
commit e6508f6776
5 changed files with 28 additions and 2 deletions

View File

@ -44,10 +44,10 @@ import org.apache.yetus.audience.InterfaceAudience;
* Wraps a Configuration to make it read-only.
*/
@InterfaceAudience.Private
class ReadOnlyConfiguration extends Configuration {
public class ReadOnlyConfiguration extends Configuration {
private final Configuration conf;
ReadOnlyConfiguration(final Configuration conf) {
public ReadOnlyConfiguration(final Configuration conf) {
this.conf = conf;
}

View File

@ -119,6 +119,7 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.conf.ConfigurationManager;
import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.coprocessor.ReadOnlyConfiguration;
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionSnare;
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
import org.apache.hadoop.hbase.exceptions.TimeoutIOException;
@ -1962,6 +1963,11 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
}
}
@Override
public Configuration getReadOnlyConfiguration() {
return new ReadOnlyConfiguration(this.conf);
}
private ThreadPoolExecutor getStoreOpenAndCloseThreadPool(
final String threadNamePrefix) {
int numStores = Math.max(1, this.htableDescriptor.getColumnFamilyCount());

View File

@ -69,6 +69,7 @@ import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.conf.ConfigurationManager;
import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver;
import org.apache.hadoop.hbase.coprocessor.ReadOnlyConfiguration;
import org.apache.hadoop.hbase.io.HeapSize;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.io.crypto.Encryption;
@ -2801,6 +2802,11 @@ public class HStore implements Store, HeapSize, StoreConfigInformation,
return mixedRowReadsCount.sum();
}
@Override
public Configuration getReadOnlyConfiguration() {
return new ReadOnlyConfiguration(this.conf);
}
void updateMetricsStore(boolean memstoreRead) {
if (memstoreRead) {
memstoreOnlyRowReadsCount.increment();

View File

@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CompareOperator;
@ -597,4 +598,10 @@ public interface Region extends ConfigurationObserver {
* max wait time period.
*/
boolean waitForFlushes(long timeout);
/**
* @return a read only configuration of this region; throws {@link UnsupportedOperationException}
* if you try to set a configuration.
*/
Configuration getReadOnlyConfiguration();
}

View File

@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.OptionalDouble;
import java.util.OptionalLong;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
@ -292,4 +293,10 @@ public interface Store {
* @return the number of read requests from the files under this store.
*/
long getMixedRowReadsCount();
/**
* @return a read only configuration of this store; throws {@link UnsupportedOperationException}
* if you try to set a configuration.
*/
Configuration getReadOnlyConfiguration();
}