hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [hbase] branch branch-1.4 updated: HBASE-21645 Perform sanity check and disallow table creation/modification with region replication < 1
Date Fri, 01 Feb 2019 20:28:03 GMT
This is an automated email from the ASF dual-hosted git repository.

apurtell pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new 0feb099  HBASE-21645 Perform sanity check and disallow table creation/modification
with region replication < 1
0feb099 is described below

commit 0feb099ee8870d229c6b8f5be8d543921f1d5b5c
Author: Nihal Jain <nihaljain.cs@gmail.com>
AuthorDate: Tue Jan 8 23:24:08 2019 +0530

    HBASE-21645 Perform sanity check and disallow table creation/modification with region
replication < 1
    
    Signed-off-by: Guanghao Zhang <zghao@apache.org>
    
    Conflicts:
    	hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    	hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
    
    Amending-Author: Andrew Purtell <apurtell@apache.org>
---
 .../org/apache/hadoop/hbase/master/HMaster.java     |  7 +++++++
 .../hadoop/hbase/client/TestFromClientSide.java     | 21 +++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index 77e7d3b..0d10a7f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -1864,6 +1864,13 @@ public class HMaster extends HRegionServer implements MasterServices,
Server {
       warnOrThrowExceptionForFailure(logWarn, CONF_KEY, message, null);
     }
 
+    // check that we have minimum 1 region replicas
+    int regionReplicas = htd.getRegionReplication();
+    if (regionReplicas < 1) {
+      String message = "Table region replication should be at least one.";
+      warnOrThrowExceptionForFailure(logWarn, CONF_KEY, message, null);
+    }
+
     for (HColumnDescriptor hcd : htd.getColumnFamilies()) {
       if (hcd.getTimeToLive() <= 0) {
         String message = "TTL for column family " + hcd.getNameAsString() + " must be positive.";
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
index 58ff20f..b63b27b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
@@ -6547,4 +6547,25 @@ public class TestFromClientSide {
     }
   }
 
+  @Test(expected = DoNotRetryIOException.class)
+  public void testCreateTableWithZeroRegionReplicas() throws Exception {
+    TableName tableName = TableName.valueOf("testCreateTableWithZeroRegionReplicas");
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(new HColumnDescriptor("cf"));
+    desc.setRegionReplication(0);
+    TEST_UTIL.getHBaseAdmin().createTable(desc);
+  }
+
+  @Test(expected = DoNotRetryIOException.class)
+  public void testModifyTableWithZeroRegionReplicas() throws Exception {
+    TableName tableName = TableName.valueOf("testModifyTableWithZeroRegionReplicas");
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(new HColumnDescriptor("cf"));
+
+    TEST_UTIL.getHBaseAdmin().createTable(desc);
+    HTableDescriptor newDesc = new HTableDescriptor(desc);
+    newDesc.setRegionReplication(0);
+
+    TEST_UTIL.getHBaseAdmin().modifyTable(tableName, newDesc);
+  }
 }


Mime
View raw message