HBASE-27405 Fix the replication hfile/log cleaner report that the replication table does not exist (#4811)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
c01c8e45b4
commit
5f95a914b6
|
@ -178,4 +178,10 @@ public interface ReplicationQueueStorage {
|
||||||
* created hfile references during the call may not be included.
|
* created hfile references during the call may not be included.
|
||||||
*/
|
*/
|
||||||
Set<String> getAllHFileRefs() throws ReplicationException;
|
Set<String> getAllHFileRefs() throws ReplicationException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the replication queue table exists.
|
||||||
|
* @return Whether the replication queue table exists
|
||||||
|
*/
|
||||||
|
boolean hasData() throws ReplicationException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,4 +532,13 @@ public class TableReplicationQueueStorage implements ReplicationQueueStorage {
|
||||||
throw new ReplicationException("failed to getAllHFileRefs", e);
|
throw new ReplicationException("failed to getAllHFileRefs", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasData() throws ReplicationException {
|
||||||
|
try {
|
||||||
|
return conn.getAdmin().getDescriptor(tableName) != null;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ReplicationException("failed to get replication queue table", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,14 @@ public class ReplicationLogCleaner extends BaseLogCleanerDelegate {
|
||||||
if (this.getConf() == null) {
|
if (this.getConf() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
if (!rpm.getQueueStorage().hasData()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (ReplicationException e) {
|
||||||
|
LOG.error("Error occurred while executing queueStorage.hasData()", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
canFilter = rpm.getReplicationLogCleanerBarrier().start();
|
canFilter = rpm.getReplicationLogCleanerBarrier().start();
|
||||||
if (canFilter) {
|
if (canFilter) {
|
||||||
notFullyDeadServers = getNotFullyDeadServers.get();
|
notFullyDeadServers = getNotFullyDeadServers.get();
|
||||||
|
|
|
@ -86,6 +86,7 @@ public class TestReplicationLogCleaner {
|
||||||
when(rpm.listPeers(null)).thenReturn(new ArrayList<>());
|
when(rpm.listPeers(null)).thenReturn(new ArrayList<>());
|
||||||
ReplicationQueueStorage rqs = mock(ReplicationQueueStorage.class);
|
ReplicationQueueStorage rqs = mock(ReplicationQueueStorage.class);
|
||||||
when(rpm.getQueueStorage()).thenReturn(rqs);
|
when(rpm.getQueueStorage()).thenReturn(rqs);
|
||||||
|
when(rpm.getQueueStorage().hasData()).thenReturn(true);
|
||||||
when(rqs.listAllQueues()).thenReturn(new ArrayList<>());
|
when(rqs.listAllQueues()).thenReturn(new ArrayList<>());
|
||||||
ServerManager sm = mock(ServerManager.class);
|
ServerManager sm = mock(ServerManager.class);
|
||||||
when(services.getServerManager()).thenReturn(sm);
|
when(services.getServerManager()).thenReturn(sm);
|
||||||
|
|
Loading…
Reference in New Issue