Skip to content

Commit 1bbab65

Browse files
committed
HBASE-27405 Fix the replication hfile/log cleaner report that the replication table does not exist
1 parent d93fffe commit 1bbab65

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestLogsCleaner.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import org.apache.hadoop.hbase.testclassification.MediumTests;
5959
import org.apache.hadoop.hbase.util.Bytes;
6060
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
61+
import org.apache.hadoop.hbase.util.FSTableDescriptors;
6162
import org.apache.hadoop.hbase.util.MockServer;
6263
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
6364
import org.junit.AfterClass;
@@ -124,6 +125,8 @@ public void beforeTest() throws Exception {
124125
fs.mkdirs(OLD_WALS_DIR);
125126

126127
TableName tableName = tableNameRule.getTableName();
128+
conf.set(ReplicationStorageFactory.REPLICATION_QUEUE_TABLE_NAME, tableName.getNameAsString());
129+
127130
TableDescriptor td = ReplicationStorageFactory.createReplicationQueueTableDescriptor(tableName);
128131
TEST_UTIL.getAdmin().createTable(td);
129132
TEST_UTIL.waitTableAvailable(tableName);
@@ -134,6 +137,7 @@ public void beforeTest() throws Exception {
134137
when(masterServices.getConnection()).thenReturn(TEST_UTIL.getConnection());
135138
ReplicationPeerManager rpm = mock(ReplicationPeerManager.class);
136139
when(masterServices.getReplicationPeerManager()).thenReturn(rpm);
140+
when(masterServices.getTableDescriptors()).thenReturn(new FSTableDescriptorsTest(conf));
137141
when(rpm.getQueueStorage()).thenReturn(queueStorage);
138142
when(rpm.getReplicationLogCleanerBarrier()).thenReturn(new ReplicationLogCleanerBarrier());
139143
when(rpm.listPeers(null)).thenReturn(new ArrayList<>());
@@ -314,4 +318,24 @@ public ZKWatcher getZooKeeper() {
314318
return null;
315319
}
316320
}
321+
322+
private static class FSTableDescriptorsTest extends FSTableDescriptors {
323+
private TableName replicationQueueTableName;
324+
325+
public FSTableDescriptorsTest(final Configuration conf) throws IOException {
326+
super(conf);
327+
replicationQueueTableName =
328+
TableName.valueOf(conf.get(ReplicationStorageFactory.REPLICATION_QUEUE_TABLE_NAME,
329+
ReplicationStorageFactory.REPLICATION_QUEUE_TABLE_NAME_DEFAULT.getNameAsString()));
330+
}
331+
332+
@Override
333+
public boolean exists(TableName tablename) throws IOException {
334+
if (tablename.equals(replicationQueueTableName)) {
335+
return true;
336+
} else {
337+
return super.exists(tablename);
338+
}
339+
}
340+
}
317341
}

0 commit comments

Comments
 (0)