From 8b23eef4d22e3b8a1e4633869abcb6b0b5aee6ac Mon Sep 17 00:00:00 2001 From: Peter Somogyi Date: Sat, 4 Jan 2020 12:14:19 +0100 Subject: [PATCH] HBASE-23642 Reintroduce ReplicationUtils.contains as deprecated (#983) Signed-off-by: Wellington Chevreuil Signed-off-by: Viraj Jasani Signed-off-by: stack Signed-off-by: Jan Hentschel --- .../hbase/replication/ReplicationUtils.java | 50 +++++-------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationUtils.java b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationUtils.java index e70e345aaa0a..08f53e88ac31 100644 --- a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationUtils.java +++ b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationUtils.java @@ -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 excludeNamespaces = peerConfig.getExcludeNamespaces(); - if (excludeNamespaces != null && excludeNamespaces.contains(namespace)) { - return false; - } - Map> excludedTableCFs = peerConfig.getExcludeTableCFsMap(); - // trap here, must check existence first since HashMap allows null value. - if (excludedTableCFs == null || !excludedTableCFs.containsKey(tableName)) { - return true; - } - List 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 namespaces = peerConfig.getNamespaces(); - Map> 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); @@ -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 */