anmolnar commented on code in PR #7743:
URL: https://github.com/apache/hbase/pull/7743#discussion_r2849136094
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java:
##########
@@ -4422,13 +4430,30 @@ public void onConfigurationChange(Configuration
newConf) {
}
// append the quotas observer back to the master coprocessor key
setQuotasObserver(newConf);
+
+ boolean readOnlyMode =
newConf.getBoolean(HConstants.HBASE_GLOBAL_READONLY_ENABLED_KEY,
+ HConstants.HBASE_GLOBAL_READONLY_ENABLED_DEFAULT);
+ if (readOnlyMode) {
+ addReadOnlyCoprocessors(newConf);
+ } else {
Review Comment:
I think you can still call the sync method:
```java
private void syncReadOnlyConfigurations(boolean readOnlyMode, Configuration
conf) {
conf.setBoolean(HConstants.HBASE_GLOBAL_READONLY_ENABLED_KEY,
readOnlyMode);
// If readonly is true then add the coprocessor of master
if (readOnlyMode) {
addReadOnlyCoprocessors(conf);
} else {
removeReadOnlyCoprocessors(conf);
}
}
```
You can either call it with `this.conf` and with `newConf`. In the latter
case the `setBoolean()` call will be a no-op, but that's okay.
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java:
##########
@@ -4422,13 +4430,30 @@ public void onConfigurationChange(Configuration
newConf) {
}
// append the quotas observer back to the master coprocessor key
setQuotasObserver(newConf);
+
+ boolean readOnlyMode =
newConf.getBoolean(HConstants.HBASE_GLOBAL_READONLY_ENABLED_KEY,
+ HConstants.HBASE_GLOBAL_READONLY_ENABLED_DEFAULT);
+ if (readOnlyMode) {
+ addReadOnlyCoprocessors(newConf);
+ } else {
+ // Needed as safety measure in case the coprocessors are added in
hbase-site.xml manually and
+ // the user toggles the read only mode on and off.
Review Comment:
Discussed offline that you're going to refactor the unit test instead.
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java:
##########
@@ -1292,6 +1303,87 @@ RegionEventDescriptor.EventType.REGION_CLOSE,
getRegionInfo(), mvcc.getReadPoint
}
}
+ private boolean isReadOnlyModeEnabled(Configuration conf) {
+ return conf.getBoolean(HConstants.HBASE_GLOBAL_READONLY_ENABLED_KEY,
+ HConstants.HBASE_GLOBAL_READONLY_ENABLED_DEFAULT);
+ }
+
+ private String[] append(String[] original, String value) {
+ List<String> list = original != null
+ ? new ArrayList<>(Arrays.asList(original))
+ : new ArrayList<>();
+
+ list.add(value);
+ return list.toArray(new String[0]);
+ }
+
+ private void addReadOnlyCoprocessors(Configuration conf) {
+ String[] regionCoprocs =
conf.getStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY);
Review Comment:
I meant the following with `ArrayList`
```java
List<String> regionCoprocs = new
ArrayList<>(conf.getStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY));
```
And later:
```java
if (!regionCoprocs.contains(regionCP)) {
regionCoprocs.add(regionCP);
}
```
At the end:
```java
conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
regionCoprocs.toArray());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]