From e251d41a25235cdf9e47bb112c463e96450278ec Mon Sep 17 00:00:00 2001 From: Janos Gub Date: Fri, 3 Mar 2017 13:44:13 +0100 Subject: [PATCH 1/3] HBASE-17460 enable_table_replication can not perform cyclic replication of a table - addendum v2 no check for replication enablement --- .../org/apache/hadoop/hbase/client/HBaseAdmin.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index c68d3bb..7729562 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -4188,21 +4188,11 @@ public class HBaseAdmin implements Admin { throw new IllegalArgumentException("Failed to get table descriptor for table " + tableName.getNameAsString() + " from peer cluster " + peerDesc.getPeerId()); } else { - // To support cyclic replication (HBASE-17460), we need to match the - // REPLICATION_SCOPE of table on both the clusters. We should do this - // only when the replication is not already enabled on local HTD (local - // table on this cluster). - // - if (localHtd.isReplicationEnabled()) { + if (!compareForReplication(peerHtd, localHtd)) { throw new IllegalArgumentException("Table " + tableName.getNameAsString() - + " has replication already enabled for at least one Column Family."); - } else { - if (!compareForReplication(peerHtd, localHtd)) { - throw new IllegalArgumentException("Table " + tableName.getNameAsString() - + " exists in peer cluster " + peerDesc.getPeerId() - + ", but the table descriptors are not same when compared with source cluster." - + " Thus can not enable the table's replication switch."); - } + + " exists in peer cluster " + peerDesc.getPeerId() + + ", but the table descriptors are not same when compared with source cluster." + + " Thus can not enable the table's replication switch."); } } } -- 2.10.1 (Apple Git-78) From 9457b2657caca55494cdc3250ff60bca88fe3a24 Mon Sep 17 00:00:00 2001 From: Janos Gub Date: Fri, 3 Mar 2017 15:02:50 +0100 Subject: [PATCH 2/3] fixup --- .../org/apache/hadoop/hbase/HTableDescriptor.java | 25 ---------------------- .../org/apache/hadoop/hbase/client/HBaseAdmin.java | 13 ++++++----- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java index 05891df..ac72684 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java @@ -1042,31 +1042,6 @@ public class HTableDescriptor implements Comparable { } /** - * Detects whether replication has been already enabled on any of the column families of this - * table descriptor. - * @return true if any of the column families has replication enabled. - */ - public boolean isReplicationEnabled() { - // Go through each Column-Family descriptor and check if the - // Replication has been enabled already. - // Return 'true' if replication has been enabled on any CF, - // otherwise return 'false'. - // - boolean result = false; - Iterator it = this.families.values().iterator(); - - while (it.hasNext()) { - HColumnDescriptor tempHcd = it.next(); - if (tempHcd.getScope() != HConstants.REPLICATION_SCOPE_LOCAL) { - result = true; - break; - } - } - - return result; - } - - /** * @see java.lang.Object#hashCode() */ @Override diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index 7729562..1924fdc 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -4187,13 +4187,12 @@ public class HBaseAdmin implements Admin { if (peerHtd == null) { throw new IllegalArgumentException("Failed to get table descriptor for table " + tableName.getNameAsString() + " from peer cluster " + peerDesc.getPeerId()); - } else { - if (!compareForReplication(peerHtd, localHtd)) { - throw new IllegalArgumentException("Table " + tableName.getNameAsString() - + " exists in peer cluster " + peerDesc.getPeerId() - + ", but the table descriptors are not same when compared with source cluster." - + " Thus can not enable the table's replication switch."); - } + } + if (!compareForReplication(peerHtd, localHtd)) { + throw new IllegalArgumentException("Table " + tableName.getNameAsString() + + " exists in peer cluster " + peerDesc.getPeerId() + + ", but the table descriptors are not same when compared with source cluster." + + " Thus can not enable the table's replication switch."); } } } -- 2.10.1 (Apple Git-78) From baf677b36fb89d8e462be15ae19d936b03bf78cc Mon Sep 17 00:00:00 2001 From: Janos Gub Date: Fri, 3 Mar 2017 15:40:58 +0100 Subject: [PATCH 3/3] trivial hbase-server change --- .../src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java hbase-server/src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java index ee32887..ea881a7 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java @@ -51,7 +51,7 @@ import com.google.common.collect.Lists; /** * Utility class to handle the removal of HFiles (or the respective {@link StoreFile StoreFiles}) * for a HRegion from the {@link FileSystem}. The hfiles will be archived or deleted, depending on - * the state of the system. + * the state of the system. */ @InterfaceAudience.Private public class HFileArchiver { -- 2.10.1 (Apple Git-78)