Skip to content

Commit 7313535

Browse files
author
sunxin
committed
HBASE-25590 Bulkload replication HFileRefs cannot be cleared in some cases where set exclude-namespace/exclude-table-cfs
1 parent ed90a14 commit 7313535

File tree

6 files changed

+542
-266
lines changed

6 files changed

+542
-266
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeerConfig.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.apache.hadoop.hbase.util.Bytes;
3030
import org.apache.yetus.audience.InterfaceAudience;
3131

32+
import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils;
33+
3234
/**
3335
* A configuration for the replication peer cluster.
3436
*/
@@ -301,6 +303,10 @@ public String toString() {
301303
* @return true if the table need replicate to the peer cluster
302304
*/
303305
public boolean needToReplicate(TableName table) {
306+
return needToReplicate(table, null);
307+
}
308+
309+
public boolean needToReplicate(TableName table, byte[] family) {
304310
String namespace = table.getNamespaceAsString();
305311
if (replicateAllUserTables) {
306312
// replicate all user tables, but filter by exclude namespaces and table-cfs config
@@ -314,7 +320,8 @@ public boolean needToReplicate(TableName table) {
314320
Collection<String> cfs = excludeTableCFsMap.get(table);
315321
// if cfs is null or empty then we can make sure that we do not need to replicate this table,
316322
// otherwise, we may still need to replicate the table but filter out some families.
317-
return cfs != null && !cfs.isEmpty();
323+
return cfs != null && !cfs.isEmpty()
324+
&& (family == null || !cfs.contains(Bytes.toString(family)));
318325
} else {
319326
// Not replicate all user tables, so filter by namespaces and table-cfs config
320327
if (namespaces == null && tableCFsMap == null) {
@@ -325,7 +332,9 @@ public boolean needToReplicate(TableName table) {
325332
if (namespaces != null && namespaces.contains(namespace)) {
326333
return true;
327334
}
328-
return tableCFsMap != null && tableCFsMap.containsKey(table);
335+
return tableCFsMap != null && tableCFsMap.containsKey(table)
336+
&& (family == null || CollectionUtils.isEmpty(tableCFsMap.get(table))
337+
|| tableCFsMap.get(table).contains(Bytes.toString(family)));
329338
}
330339
}
331340
}

0 commit comments

Comments
 (0)