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
      if (excludeNamespaces != null && excludeNamespaces.contains(namespace)) {
        return false;
      }
      // trap here, must check existence first since HashMap allows null value.
      if (excludeTableCFsMap == null || !excludeTableCFsMap.containsKey(table)) {
        return true;
      }
      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()
      // If exclude-table-cfs contains passed family then we make sure that we do not need to
      // replicate this family.
        && (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) {
        return false;
      }
      // First filter by namespaces config
      // If table's namespace in peer config, all the tables data are applicable for replication
      if (namespaces != null && namespaces.contains(namespace)) {
        return true;
      }
      // If table-cfs contains this table then we can make sure that we need replicate some CFs of
      // this table. Further we need all CFs if tableCFsMap.get(table) is null or empty.
      return tableCFsMap != null && tableCFsMap.containsKey(table)
        && (family == null || CollectionUtils.isEmpty(tableCFsMap.get(table))
        // If table-cfs must contain passed family then we need to replicate this family.
          || tableCFsMap.get(table).contains(Bytes.toString(family)));
    }
  }
Decide whether the passed family of the table need replicate to the peer cluster according to
this peer config.
@param table  name of the table
@param family family name
@return true if (the family of) the table need replicate to the peer cluster. If passed family
        is null, return true if any CFs of the table need replicate; If passed family is not
        null, return true if the passed family need replicate.
hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeerConfig.java