Skip to content

Commit

Permalink
HBASE-25590 Bulkload replication HFileRefs cannot be cleared in some …
Browse files Browse the repository at this point in the history
…cases where set exclude-namespace/exclude-table-cfs
  • Loading branch information
sunxin committed Feb 20, 2021
1 parent ed90a14 commit b98e731
Show file tree
Hide file tree
Showing 6 changed files with 541 additions and 266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;

import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils;

/**
* A configuration for the replication peer cluster.
*/
Expand Down Expand Up @@ -301,6 +303,10 @@ public String toString() {
* @return true if the table need replicate to the peer cluster
*/
public boolean needToReplicate(TableName table) {
return needToReplicate(table, null);
}

public boolean needToReplicate(TableName table, byte[] family) {
String namespace = table.getNamespaceAsString();
if (replicateAllUserTables) {
// replicate all user tables, but filter by exclude namespaces and table-cfs config
Expand All @@ -314,7 +320,8 @@ public boolean needToReplicate(TableName table) {
Collection<String> cfs = excludeTableCFsMap.get(table);
// if cfs is null or empty then we can make sure that we do not need to replicate this table,
// otherwise, we may still need to replicate the table but filter out some families.
return cfs != null && !cfs.isEmpty();
return cfs != null && !cfs.isEmpty()
&& (family == null || !cfs.contains(Bytes.toString(family)));
} else {
// Not replicate all user tables, so filter by namespaces and table-cfs config
if (namespaces == null && tableCFsMap == null) {
Expand All @@ -325,7 +332,9 @@ public boolean needToReplicate(TableName table) {
if (namespaces != null && namespaces.contains(namespace)) {
return true;
}
return tableCFsMap != null && tableCFsMap.containsKey(table);
return tableCFsMap != null && tableCFsMap.containsKey(table)
&& (family == null || CollectionUtils.isEmpty(tableCFsMap.get(table))
|| tableCFsMap.get(table).contains(Bytes.toString(family)));
}
}
}
Loading

0 comments on commit b98e731

Please sign in to comment.