You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2017/10/20 19:46:41 UTC
hbase git commit: HBASE-17934 Backport HBASE-17779
"disable_table_replication returns misleading message and does not turn off
replication" - revert due to lack of credit
Repository: hbase
Updated Branches:
refs/heads/branch-1.3 6124f9dfe -> 1300faffb
HBASE-17934 Backport HBASE-17779 "disable_table_replication returns misleading message and does not turn off replication" - revert due to lack of credit
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1300faff
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1300faff
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1300faff
Branch: refs/heads/branch-1.3
Commit: 1300faffbc37eb0f3962639efa9ff990e80461ed
Parents: 6124f9d
Author: tedyu <yu...@gmail.com>
Authored: Fri Oct 20 12:46:34 2017 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Fri Oct 20 12:46:34 2017 -0700
----------------------------------------------------------------------
.../client/replication/ReplicationAdmin.java | 35 +++++---------------
.../TestReplicationAdminWithClusters.java | 17 ----------
2 files changed, 8 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/1300faff/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java
index 91e5ac6..4e522c8 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java
@@ -660,17 +660,15 @@ public class ReplicationAdmin implements Closeable {
/**
* Set the table's replication switch if the table's replication switch is already not set.
* @param tableName name of the table
- * @param enableRep is replication switch enable or disable
+ * @param isRepEnabled is replication switch enable or disable
* @throws IOException if a remote or network exception occurs
*/
- private void setTableRep(final TableName tableName, boolean enableRep) throws IOException {
+ private void setTableRep(final TableName tableName, boolean isRepEnabled) throws IOException {
Admin admin = null;
try {
admin = this.connection.getAdmin();
HTableDescriptor htd = admin.getTableDescriptor(tableName);
- ReplicationState currentReplicationState = getTableReplicationState(htd);
- if (enableRep && currentReplicationState != ReplicationState.ENABLED
- || !enableRep && currentReplicationState != ReplicationState.DISABLED) {
+ if (isTableRepEnabled(htd) ^ isRepEnabled) {
boolean isOnlineSchemaUpdateEnabled =
this.connection.getConfiguration()
.getBoolean("hbase.online.schema.update.enable", true);
@@ -678,7 +676,7 @@ public class ReplicationAdmin implements Closeable {
admin.disableTable(tableName);
}
for (HColumnDescriptor hcd : htd.getFamilies()) {
- hcd.setScope(enableRep ? HConstants.REPLICATION_SCOPE_GLOBAL
+ hcd.setScope(isRepEnabled ? HConstants.REPLICATION_SCOPE_GLOBAL
: HConstants.REPLICATION_SCOPE_LOCAL);
}
admin.modifyTable(tableName, htd);
@@ -699,32 +697,15 @@ public class ReplicationAdmin implements Closeable {
}
/**
- * This enum indicates the current state of the replication for a given table.
- */
- private enum ReplicationState {
- ENABLED, // all column families enabled
- MIXED, // some column families enabled, some disabled
- DISABLED // all column families disabled
- }
-
- /**
* @param htd table descriptor details for the table to check
- * @return ReplicationState the current state of the table.
+ * @return true if table's replication switch is enabled
*/
- private ReplicationState getTableReplicationState(HTableDescriptor htd) {
- boolean hasEnabled = false;
- boolean hasDisabled = false;
-
+ private boolean isTableRepEnabled(HTableDescriptor htd) {
for (HColumnDescriptor hcd : htd.getFamilies()) {
if (hcd.getScope() != HConstants.REPLICATION_SCOPE_GLOBAL) {
- hasDisabled = true;
- } else {
- hasEnabled = true;
+ return false;
}
}
-
- if (hasEnabled && hasDisabled) return ReplicationState.MIXED;
- if (hasEnabled) return ReplicationState.ENABLED;
- return ReplicationState.DISABLED;
+ return true;
}
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/1300faff/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java
index ab95c43..d628a7c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java
@@ -67,23 +67,6 @@ public class TestReplicationAdminWithClusters extends TestReplicationBase {
}
@Test(timeout = 300000)
- public void disableNotFullReplication() throws Exception {
- HTableDescriptor table = admin2.getTableDescriptor(tableName);
- HColumnDescriptor f = new HColumnDescriptor("notReplicatedFamily");
- table.addFamily(f);
- admin1.disableTable(tableName);
- admin1.modifyTable(tableName, table);
- admin1.enableTable(tableName);
-
-
- admin.disableTableRep(tableName);
- table = admin1.getTableDescriptor(tableName);
- for (HColumnDescriptor fam : table.getColumnFamilies()) {
- assertEquals(fam.getScope(), HConstants.REPLICATION_SCOPE_LOCAL);
- }
- }
-
- @Test(timeout = 300000)
public void testEnableReplicationWhenSlaveClusterDoesntHaveTable() throws Exception {
admin2.disableTable(tableName);
admin2.deleteTable(tableName);