Skip to content

Commit

Permalink
HBASE-23642 Reintroduce ReplicationUtils.contains as deprecated (apac…
Browse files Browse the repository at this point in the history
…he#983)

Signed-off-by: Wellington Chevreuil <[email protected]>
Signed-off-by: Viraj Jasani <[email protected]>
Signed-off-by: stack <[email protected]>
Signed-off-by: Jan Hentschel <[email protected]>
  • Loading branch information
petersomogyi authored and Guanghao Zhang committed Jan 9, 2020
1 parent 910f8e0 commit 8b23eef
Showing 1 changed file with 12 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,44 +154,6 @@ public static boolean isReplicationForBulkLoadDataEnabled(final Configuration c)
HConstants.REPLICATION_BULKLOAD_ENABLE_DEFAULT);
}

/**
* Returns whether we should replicate the given table.
*/
public static boolean contains(ReplicationPeerConfig peerConfig, TableName tableName) {
String namespace = tableName.getNamespaceAsString();
if (peerConfig.replicateAllUserTables()) {
// replicate all user tables, but filter by exclude namespaces and table-cfs config
Set<String> excludeNamespaces = peerConfig.getExcludeNamespaces();
if (excludeNamespaces != null && excludeNamespaces.contains(namespace)) {
return false;
}
Map<TableName, List<String>> excludedTableCFs = peerConfig.getExcludeTableCFsMap();
// trap here, must check existence first since HashMap allows null value.
if (excludedTableCFs == null || !excludedTableCFs.containsKey(tableName)) {
return true;
}
List<String> cfs = excludedTableCFs.get(tableName);
// 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();
} else {
// Not replicate all user tables, so filter by namespaces and table-cfs config
Set<String> namespaces = peerConfig.getNamespaces();
Map<TableName, List<String>> tableCFs = peerConfig.getTableCFsMap();

if (namespaces == null && tableCFs == 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;
}
return tableCFs != null && tableCFs.containsKey(tableName);
}
}

public static FileSystem getRemoteWALFileSystem(Configuration conf, String remoteWALDir)
throws IOException {
return new Path(remoteWALDir).getFileSystem(conf);
Expand Down Expand Up @@ -242,6 +204,18 @@ public static boolean shouldSyncTableSchema(Configuration conf) {
HConstants.REPLICATION_SYNC_TABLE_SCHEMA_DEFAULT);
}

/**
* @deprecated Will be removed in HBase 3.
* Use {@link ReplicationPeerConfig#needToReplicate(TableName)} instead.
* @param peerConfig configuration for the replication peer cluster
* @param tableName name of the table
* @return true if the table need replicate to the peer cluster
*/
@Deprecated
public static boolean contains(ReplicationPeerConfig peerConfig, TableName tableName) {
return peerConfig.needToReplicate(tableName);
}

/**
* Get the adaptive timeout value when performing a retry
*/
Expand Down

0 comments on commit 8b23eef

Please sign in to comment.