This is an automated email from the ASF dual-hosted git repository. andor pushed a commit to branch HBASE-29081_rebased in repository https://gitbox.apache.org/repos/asf/hbase.git
commit 5460e94e2e6267f87f3e44b3d95061bb93744972 Author: Anuj Sharma <[email protected]> AuthorDate: Fri Jan 9 22:45:25 2026 +0530 HBASE-29779: Call super coprocessor instead of returning for system table (#7555) * HBASE-29779: Call super coprocessor instead of returning for system tables * Instead of system table just allow operation for hbase meta only There are some other system tables such as acl or namespace which are shared with active cluster hence allowing operation with them in readonly cluster will make system inconsistent. * Invert the methods name and add negation to caller * Instead of static variable comparison use the API from TableName class This is done do avoid any conflicts after the changes in HBASE-29691: Change TableName.META_TABLE_NAME from being a global static --- .../hbase/security/access/ReadOnlyController.java | 95 ++++---- .../TestReadOnlyControllerRegionObserver.java | 258 ++++++++++++++++++++- 2 files changed, 311 insertions(+), 42 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ReadOnlyController.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ReadOnlyController.java index 3ec772798be..163d4267fae 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ReadOnlyController.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ReadOnlyController.java @@ -106,6 +106,10 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, } } + private boolean isOnMeta(final ObserverContext<? extends RegionCoprocessorEnvironment> c) { + return TableName.isMetaTableName(c.getEnvironment().getRegionInfo().getTable()); + } + @Override public void start(CoprocessorEnvironment env) throws IOException { if (env instanceof MasterCoprocessorEnvironment) { @@ -130,24 +134,30 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, return Optional.of(this); } - @Override - public void preFlush(final ObserverContext<? extends RegionCoprocessorEnvironment> c, - FlushLifeCycleTracker tracker) throws IOException { - internalReadOnlyGuard(); - RegionObserver.super.preFlush(c, tracker); - } - @Override public void preFlushScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, ScanOptions options, FlushLifeCycleTracker tracker) throws IOException { - internalReadOnlyGuard(); + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } RegionObserver.super.preFlushScannerOpen(c, store, options, tracker); } + @Override + public void preFlush(final ObserverContext<? extends RegionCoprocessorEnvironment> c, + FlushLifeCycleTracker tracker) throws IOException { + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } + RegionObserver.super.preFlush(c, tracker); + } + @Override public InternalScanner preFlush(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner, FlushLifeCycleTracker tracker) throws IOException { - internalReadOnlyGuard(); + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } return RegionObserver.super.preFlush(c, store, scanner, tracker); } @@ -178,7 +188,9 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, public void preCompactSelection(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, List<? extends StoreFile> candidates, CompactionLifeCycleTracker tracker) throws IOException { - internalReadOnlyGuard(); + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } RegionObserver.super.preCompactSelection(c, store, candidates, tracker); } @@ -186,7 +198,9 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, public void preCompactScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException { - internalReadOnlyGuard(); + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } RegionObserver.super.preCompactScannerOpen(c, store, scanType, options, tracker, request); } @@ -194,60 +208,54 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, public InternalScanner preCompact(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException { - internalReadOnlyGuard(); + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } return RegionObserver.super.preCompact(c, store, scanner, scanType, tracker, request); } @Override public void prePut(ObserverContext<? extends RegionCoprocessorEnvironment> c, Put put, WALEdit edit, Durability durability) throws IOException { - TableName tableName = c.getEnvironment().getRegionInfo().getTable(); - if (tableName.isSystemTable()) { - return; + if (!isOnMeta(c)) { + internalReadOnlyGuard(); } - internalReadOnlyGuard(); RegionObserver.super.prePut(c, put, edit, durability); } @Override public void prePut(ObserverContext<? extends RegionCoprocessorEnvironment> c, Put put, WALEdit edit) throws IOException { - TableName tableName = c.getEnvironment().getRegionInfo().getTable(); - if (tableName.isSystemTable()) { - return; + if (!isOnMeta(c)) { + internalReadOnlyGuard(); } - internalReadOnlyGuard(); RegionObserver.super.prePut(c, put, edit); } @Override public void preDelete(ObserverContext<? extends RegionCoprocessorEnvironment> c, Delete delete, WALEdit edit, Durability durability) throws IOException { - if (c.getEnvironment().getRegionInfo().getTable().isSystemTable()) { - return; + if (!isOnMeta(c)) { + internalReadOnlyGuard(); } - internalReadOnlyGuard(); RegionObserver.super.preDelete(c, delete, edit, durability); } @Override public void preDelete(ObserverContext<? extends RegionCoprocessorEnvironment> c, Delete delete, WALEdit edit) throws IOException { - if (c.getEnvironment().getRegionInfo().getTable().isSystemTable()) { - return; + if (!isOnMeta(c)) { + internalReadOnlyGuard(); } - internalReadOnlyGuard(); RegionObserver.super.preDelete(c, delete, edit); } @Override public void preBatchMutate(ObserverContext<? extends RegionCoprocessorEnvironment> c, MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException { - TableName tableName = c.getEnvironment().getRegionInfo().getTable(); - if (tableName.isSystemTable()) { - return; + if (!isOnMeta(c)) { + internalReadOnlyGuard(); } - internalReadOnlyGuard(); RegionObserver.super.preBatchMutate(c, miniBatchOp); } @@ -255,7 +263,9 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, public boolean preCheckAndPut(ObserverContext<? extends RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, Put put, boolean result) throws IOException { - internalReadOnlyGuard(); + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } return RegionObserver.super.preCheckAndPut(c, row, family, qualifier, op, comparator, put, result); } @@ -263,7 +273,9 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, @Override public boolean preCheckAndPut(ObserverContext<? extends RegionCoprocessorEnvironment> c, byte[] row, Filter filter, Put put, boolean result) throws IOException { - internalReadOnlyGuard(); + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } return RegionObserver.super.preCheckAndPut(c, row, filter, put, result); } @@ -272,7 +284,9 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, ObserverContext<? extends RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, Put put, boolean result) throws IOException { - internalReadOnlyGuard(); + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } return RegionObserver.super.preCheckAndPutAfterRowLock(c, row, family, qualifier, op, comparator, put, result); } @@ -281,7 +295,9 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, public boolean preCheckAndPutAfterRowLock( ObserverContext<? extends RegionCoprocessorEnvironment> c, byte[] row, Filter filter, Put put, boolean result) throws IOException { - internalReadOnlyGuard(); + if (!isOnMeta(c)) { + internalReadOnlyGuard(); + } return RegionObserver.super.preCheckAndPutAfterRowLock(c, row, filter, put, result); } @@ -289,7 +305,7 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, public boolean preCheckAndDelete(ObserverContext<? extends RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, Delete delete, boolean result) throws IOException { - if (!c.getEnvironment().getRegionInfo().getTable().isSystemTable()) { + if (!isOnMeta(c)) { internalReadOnlyGuard(); } return RegionObserver.super.preCheckAndDelete(c, row, family, qualifier, op, comparator, delete, @@ -299,7 +315,7 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, @Override public boolean preCheckAndDelete(ObserverContext<? extends RegionCoprocessorEnvironment> c, byte[] row, Filter filter, Delete delete, boolean result) throws IOException { - if (!c.getEnvironment().getRegionInfo().getTable().isSystemTable()) { + if (!isOnMeta(c)) { internalReadOnlyGuard(); } return RegionObserver.super.preCheckAndDelete(c, row, filter, delete, result); @@ -310,7 +326,7 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, ObserverContext<? extends RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, Delete delete, boolean result) throws IOException { - if (!c.getEnvironment().getRegionInfo().getTable().isSystemTable()) { + if (!isOnMeta(c)) { internalReadOnlyGuard(); } return RegionObserver.super.preCheckAndDeleteAfterRowLock(c, row, family, qualifier, op, @@ -321,7 +337,7 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, public boolean preCheckAndDeleteAfterRowLock( ObserverContext<? extends RegionCoprocessorEnvironment> c, byte[] row, Filter filter, Delete delete, boolean result) throws IOException { - if (!c.getEnvironment().getRegionInfo().getTable().isSystemTable()) { + if (!isOnMeta(c)) { internalReadOnlyGuard(); } return RegionObserver.super.preCheckAndDeleteAfterRowLock(c, row, filter, delete, result); @@ -409,7 +425,8 @@ public class ReadOnlyController implements MasterCoprocessor, RegionCoprocessor, @Override public void preWALAppend(ObserverContext<? extends RegionCoprocessorEnvironment> ctx, WALKey key, WALEdit edit) throws IOException { - if (!key.getTableName().isSystemTable()) { + // Only allow this operation for meta table + if (!TableName.isMetaTableName(key.getTableName())) { internalReadOnlyGuard(); } RegionObserver.super.preWALAppend(ctx, key, edit); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestReadOnlyControllerRegionObserver.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestReadOnlyControllerRegionObserver.java index 12fe32c0d23..cc9fa6f1a15 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestReadOnlyControllerRegionObserver.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestReadOnlyControllerRegionObserver.java @@ -177,6 +177,10 @@ public class TestReadOnlyControllerRegionObserver { } + private void mockOperationForMetaTable() { + when(regionInfo.getTable()).thenReturn(TableName.META_TABLE_NAME); + } + @Test(expected = DoNotRetryIOException.class) public void testPreFlushV1ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -188,6 +192,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preFlush(c, flushLifeCycleTracker); } + @Test + public void testPreFlushV1ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preFlush(c, flushLifeCycleTracker); + } + + @Test + public void testPreFlushV1MetaNoException() throws IOException { + readOnlyController.preFlush(c, flushLifeCycleTracker); + } + @Test(expected = DoNotRetryIOException.class) public void testPreFlushV2ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -199,6 +215,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preFlush(c, store, scanner, flushLifeCycleTracker); } + @Test + public void testPreFlushV2ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preFlush(c, store, scanner, flushLifeCycleTracker); + } + + @Test + public void testPreFlushV2MetaNoException() throws IOException { + readOnlyController.preFlush(c, store, scanner, flushLifeCycleTracker); + } + @Test(expected = DoNotRetryIOException.class) public void testPreFlushScannerOpenReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -210,6 +238,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preFlushScannerOpen(c, store, options, flushLifeCycleTracker); } + @Test + public void testPreFlushScannerOpenReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preFlushScannerOpen(c, store, options, flushLifeCycleTracker); + } + + @Test + public void testPreFlushScannerOpenMetaNoException() throws IOException { + readOnlyController.preFlushScannerOpen(c, store, options, flushLifeCycleTracker); + } + @Test(expected = DoNotRetryIOException.class) public void testPreMemStoreCompactionReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -254,6 +294,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preCompactSelection(c, store, candidates, compactionLifeCycleTracker); } + @Test + public void testPreCompactSelectionReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCompactSelection(c, store, candidates, compactionLifeCycleTracker); + } + + @Test + public void testPreCompactSelectionMetaNoException() throws IOException { + readOnlyController.preCompactSelection(c, store, candidates, compactionLifeCycleTracker); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCompactScannerOpenReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -267,6 +319,20 @@ public class TestReadOnlyControllerRegionObserver { compactionLifeCycleTracker, compactionRequest); } + @Test + public void testPreCompactScannerOpenReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCompactScannerOpen(c, store, scanType, options, + compactionLifeCycleTracker, compactionRequest); + } + + @Test + public void testPreCompactScannerOpenMetaNoException() throws IOException { + readOnlyController.preCompactScannerOpen(c, store, scanType, options, + compactionLifeCycleTracker, compactionRequest); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCompactReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -280,6 +346,20 @@ public class TestReadOnlyControllerRegionObserver { compactionRequest); } + @Test + public void testPreCompactReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCompact(c, store, scanner, scanType, compactionLifeCycleTracker, + compactionRequest); + } + + @Test + public void testPreCompactMetaNoException() throws IOException { + readOnlyController.preCompact(c, store, scanner, scanType, compactionLifeCycleTracker, + compactionRequest); + } + @Test(expected = DoNotRetryIOException.class) public void testPrePutV1ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -291,6 +371,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.prePut(c, put, edit); } + @Test + public void testPrePutV1ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.prePut(c, put, edit); + } + + @Test + public void testPrePutV1MetaNoException() throws IOException { + readOnlyController.prePut(c, put, edit); + } + @Test(expected = DoNotRetryIOException.class) public void testPrePutV2ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -302,6 +394,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.prePut(c, put, edit, durability); } + @Test + public void testPrePutV2ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.prePut(c, put, edit, durability); + } + + @Test + public void testPrePutV2MetaNoException() throws IOException { + readOnlyController.prePut(c, put, edit, durability); + } + @Test(expected = DoNotRetryIOException.class) public void testPreDeleteV1ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -313,6 +417,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preDelete(c, delete, edit); } + @Test + public void testPreDeleteV1ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preDelete(c, delete, edit); + } + + @Test + public void testPreDeleteV1MetaNoException() throws IOException { + readOnlyController.preDelete(c, delete, edit); + } + @Test(expected = DoNotRetryIOException.class) public void testPreDeleteV2ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -324,11 +440,41 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preDelete(c, delete, edit, durability); } + @Test + public void testPreDeleteV2ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preDelete(c, delete, edit, durability); + } + + @Test + public void testPreDeleteV2MetaNoException() throws IOException { + readOnlyController.preDelete(c, delete, edit, durability); + } + + @Test(expected = DoNotRetryIOException.class) + public void testPreBatchMutateReadOnlyException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + readOnlyController.preBatchMutate(c, miniBatchOp); + } + @Test public void testPreBatchMutateNoException() throws IOException { readOnlyController.preBatchMutate(c, miniBatchOp); } + @Test + public void testPreBatchMutateReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preBatchMutate(c, miniBatchOp); + } + + @Test + public void testPreBatchMutateMetaNoException() throws IOException { + readOnlyController.preBatchMutate(c, miniBatchOp); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCheckAndPutV1ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -340,6 +486,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preCheckAndPut(c, row, family, qualifier, op, comparator, put, result); } + @Test + public void testPreCheckAndPutV1ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCheckAndPut(c, row, family, qualifier, op, comparator, put, result); + } + + @Test + public void testPreCheckAndPutV1MetaNoException() throws IOException { + readOnlyController.preCheckAndPut(c, row, family, qualifier, op, comparator, put, result); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCheckAndPutV2ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -351,6 +509,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preCheckAndPut(c, row, filter, put, result); } + @Test + public void testPreCheckAndPutV2ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCheckAndPut(c, row, filter, put, result); + } + + @Test + public void testPreCheckAndPutV2MetaNoException() throws IOException { + readOnlyController.preCheckAndPut(c, row, filter, put, result); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCheckAndPutAfterRowLockV1ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -364,6 +534,20 @@ public class TestReadOnlyControllerRegionObserver { result); } + @Test + public void testPreCheckAndPutAfterRowLockV1ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCheckAndPutAfterRowLock(c, row, family, qualifier, op, comparator, put, + result); + } + + @Test + public void testPreCheckAndPutAfterRowLockV1MetaNoException() throws IOException { + readOnlyController.preCheckAndPutAfterRowLock(c, row, family, qualifier, op, comparator, put, + result); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCheckAndPutAfterRowLockV2ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -375,6 +559,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preCheckAndPutAfterRowLock(c, row, filter, put, result); } + @Test + public void testPreCheckAndPutAfterRowLockV2ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCheckAndPutAfterRowLock(c, row, filter, put, result); + } + + @Test + public void testPreCheckAndPutAfterRowLockV2MetaNoException() throws IOException { + readOnlyController.preCheckAndPutAfterRowLock(c, row, filter, put, result); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCheckAndDeleteV1ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -386,6 +582,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preCheckAndDelete(c, row, family, qualifier, op, comparator, delete, result); } + @Test + public void testPreCheckAndDeleteV1ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCheckAndDelete(c, row, family, qualifier, op, comparator, delete, result); + } + + @Test + public void testPreCheckAndDeleteV1MetaNoException() throws IOException { + readOnlyController.preCheckAndDelete(c, row, family, qualifier, op, comparator, delete, result); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCheckAndDeleteV2ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -397,6 +605,18 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preCheckAndDelete(c, row, filter, delete, result); } + @Test + public void testPreCheckAndDeleteV2ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCheckAndDelete(c, row, filter, delete, result); + } + + @Test + public void testPreCheckAndDeleteV2MetaNoException() throws IOException { + readOnlyController.preCheckAndDelete(c, row, filter, delete, result); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCheckAndDeleteAfterRowLockV1ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -410,6 +630,20 @@ public class TestReadOnlyControllerRegionObserver { delete, result); } + @Test + public void testPreCheckAndDeleteAfterRowLockV1ReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + mockOperationForMetaTable(); + readOnlyController.preCheckAndDeleteAfterRowLock(c, row, family, qualifier, op, comparator, + delete, result); + } + + @Test + public void testPreCheckAndDeleteAfterRowLockV1MetaNoException() throws IOException { + readOnlyController.preCheckAndDeleteAfterRowLock(c, row, family, qualifier, op, comparator, + delete, result); + } + @Test(expected = DoNotRetryIOException.class) public void testPreCheckAndDeleteAfterRowLockV2ReadOnlyException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); @@ -421,10 +655,16 @@ public class TestReadOnlyControllerRegionObserver { readOnlyController.preCheckAndDeleteAfterRowLock(c, row, filter, delete, result); } - @Test(expected = DoNotRetryIOException.class) - public void testPreBatchMutateReadOnlyException() throws IOException { + @Test + public void testPreCheckAndDeleteAfterRowLockV2ReadOnlyMetaNoException() throws IOException { readOnlyController.onConfigurationChange(readOnlyConf); - readOnlyController.preBatchMutate(c, miniBatchOp); + mockOperationForMetaTable(); + readOnlyController.preCheckAndDeleteAfterRowLock(c, row, filter, delete, result); + } + + @Test + public void testPreCheckAndDeleteAfterRowLockV2MetaNoException() throws IOException { + readOnlyController.preCheckAndDeleteAfterRowLock(c, row, filter, delete, result); } @Test(expected = DoNotRetryIOException.class) @@ -558,4 +798,16 @@ public class TestReadOnlyControllerRegionObserver { public void testPreWALAppendNoException() throws IOException { readOnlyController.preWALAppend(ctx, key, edit); } + + @Test + public void testPreWALAppendReadOnlyMetaNoException() throws IOException { + readOnlyController.onConfigurationChange(readOnlyConf); + when(key.getTableName()).thenReturn(TableName.META_TABLE_NAME); + readOnlyController.preWALAppend(ctx, key, edit); + } + + @Test + public void testPreWALAppendMetaNoException() throws IOException { + readOnlyController.preWALAppend(ctx, key, edit); + } }
