From e251d41a25235cdf9e47bb112c463e96450278ec Mon Sep 17 00:00:00 2001 From: Janos Gub Date: Fri, 3 Mar 2017 13:44:13 +0100 Subject: [PATCH 1/2] 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/2] 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)