Apache9 commented on code in PR #6910:
URL: https://github.com/apache/hbase/pull/6910#discussion_r2048777439
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegion.java:
##########
@@ -143,13 +148,23 @@ private void shutdownWAL() {
}
}
+ @RestrictedApi(explanation = "Should only be called in tests", link = "",
+ allowedOnPath = ".*/src/test/.*")
+ public void setTestFailure() {
+ this.updateFailForTest = true;
+ }
+
public void update(UpdateMasterRegion action) throws IOException {
try {
+ if (updateFailForTest) {
+ // test for HBASE-29251
+ throw new IOException("Update failed");
+ }
Review Comment:
And in side MasterRegion we just uses HRegion, for HRegion, we have a way to
inject specify implementation class. Please see HRegion.newHRegion
```
public static HRegion newHRegion(Path tableDir, WAL wal, FileSystem fs,
Configuration conf,
RegionInfo regionInfo, final TableDescriptor htd, RegionServerServices
rsServices) {
try {
@SuppressWarnings("unchecked")
Class<? extends HRegion> regionClass =
(Class<? extends HRegion>) conf.getClass(HConstants.REGION_IMPL,
HRegion.class);
Constructor<? extends HRegion> c =
regionClass.getConstructor(Path.class, WAL.class, FileSystem.class,
Configuration.class,
RegionInfo.class, TableDescriptor.class,
RegionServerServices.class);
return c.newInstance(tableDir, wal, fs, conf, regionInfo, htd,
rsServices);
} catch (Throwable e) {
// todo: what should I throw here?
throw new IllegalStateException("Could not instantiate a region
instance.", e);
}
}
```
--
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]