Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 23C881057D for ; Fri, 7 Feb 2014 13:56:03 +0000 (UTC) Received: (qmail 4058 invoked by uid 500); 7 Feb 2014 13:56:02 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 3804 invoked by uid 500); 7 Feb 2014 13:55:56 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 3796 invoked by uid 99); 7 Feb 2014 13:55:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Feb 2014 13:55:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Feb 2014 13:55:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 26E9D2388A02; Fri, 7 Feb 2014 13:55:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1565658 - in /hbase/branches/hbase-10070: hbase-client/src/main/java/org/apache/hadoop/hbase/ hbase-server/src/test/java/org/apache/hadoop/hbase/ hbase-shell/src/main/ruby/ hbase-shell/src/main/ruby/hbase/ hbase-shell/src/main/ruby/shell/c... Date: Fri, 07 Feb 2014 13:55:28 -0000 To: commits@hbase.apache.org From: ddas@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140207135529.26E9D2388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ddas Date: Fri Feb 7 13:55:28 2014 New Revision: 1565658 URL: http://svn.apache.org/r1565658 Log: HTableDescriptor changes for region replicas Modified: hbase/branches/hbase-10070/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java hbase/branches/hbase-10070/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHTableDescriptor.java hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase.rb hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase/admin.rb hbase/branches/hbase-10070/hbase-shell/src/main/ruby/shell/commands/create.rb Modified: hbase/branches/hbase-10070/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java URL: http://svn.apache.org/viewvc/hbase/branches/hbase-10070/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java?rev=1565658&r1=1565657&r2=1565658&view=diff ============================================================================== --- hbase/branches/hbase-10070/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java (original) +++ hbase/branches/hbase-10070/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java Fri Feb 7 13:55:28 2014 @@ -182,6 +182,13 @@ public class HTableDescriptor implements private static final ImmutableBytesWritable DURABILITY_KEY = new ImmutableBytesWritable(Bytes.toBytes("DURABILITY")); + /** + * INTERNAL number of region replicas for the table. + */ + public static final String REGION_REPLICATION = "REGION_REPLICATION"; + private static final ImmutableBytesWritable REGION_REPLICATION_KEY = + new ImmutableBytesWritable(Bytes.toBytes(REGION_REPLICATION)); + /** Default durability for HTD is USE_DEFAULT, which defaults to HBase-global default value */ private static final Durability DEFAULT_DURABLITY = Durability.USE_DEFAULT; @@ -214,6 +221,8 @@ public class HTableDescriptor implements */ public static final long DEFAULT_MEMSTORE_FLUSH_SIZE = 1024*1024*128L; + public static final int DEFAULT_REGION_REPLICATION = 1; + private final static Map DEFAULT_VALUES = new HashMap(); private final static Set RESERVED_KEYWORDS @@ -227,6 +236,7 @@ public class HTableDescriptor implements DEFAULT_VALUES.put(DEFERRED_LOG_FLUSH, String.valueOf(DEFAULT_DEFERRED_LOG_FLUSH)); DEFAULT_VALUES.put(DURABILITY, DEFAULT_DURABLITY.name()); //use the enum name + DEFAULT_VALUES.put(REGION_REPLICATION, String.valueOf(DEFAULT_REGION_REPLICATION)); for (String s : DEFAULT_VALUES.keySet()) { RESERVED_KEYWORDS.add(new ImmutableBytesWritable(Bytes.toBytes(s))); } @@ -1058,6 +1068,26 @@ public class HTableDescriptor implements } /** + * Returns the configured replicas per region + */ + public int getRegionReplication() { + byte[] val = getValue(REGION_REPLICATION_KEY); + if (val == null || val.length == 0) { + return DEFAULT_REGION_REPLICATION; + } + return Integer.parseInt(Bytes.toString(val)); + } + + /** + * Sets the number of replicas per region. + * @param regionReplication the replication factor per region + */ + public void setRegionReplication(int regionReplication) { + setValue(REGION_REPLICATION_KEY, + new ImmutableBytesWritable(Bytes.toBytes(Integer.toString(regionReplication)))); + } + + /** * Returns all the column family names of the current table. The map of * HTableDescriptor contains mapping of family name to HColumnDescriptors. * This returns all the keys of the family map which represents the column Modified: hbase/branches/hbase-10070/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHTableDescriptor.java URL: http://svn.apache.org/viewvc/hbase/branches/hbase-10070/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHTableDescriptor.java?rev=1565658&r1=1565657&r2=1565658&view=diff ============================================================================== --- hbase/branches/hbase-10070/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHTableDescriptor.java (original) +++ hbase/branches/hbase-10070/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHTableDescriptor.java Fri Feb 7 13:55:28 2014 @@ -49,12 +49,14 @@ public class TestHTableDescriptor { htd.setMaxFileSize(v); htd.setDurability(Durability.ASYNC_WAL); htd.setReadOnly(true); + htd.setRegionReplication(2); byte [] bytes = htd.toByteArray(); HTableDescriptor deserializedHtd = HTableDescriptor.parseFrom(bytes); assertEquals(htd, deserializedHtd); assertEquals(v, deserializedHtd.getMaxFileSize()); assertTrue(deserializedHtd.isReadOnly()); assertEquals(Durability.ASYNC_WAL, deserializedHtd.getDurability()); + assertEquals(deserializedHtd.getRegionReplication(), 2); } /** Modified: hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase.rb URL: http://svn.apache.org/viewvc/hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase.rb?rev=1565658&r1=1565657&r2=1565658&view=diff ============================================================================== --- hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase.rb (original) +++ hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase.rb Fri Feb 7 13:55:28 2014 @@ -57,6 +57,7 @@ module HBaseConstants SPLITS_FILE = 'SPLITS_FILE' SPLITALGO = 'SPLITALGO' NUMREGIONS = 'NUMREGIONS' + REGION_REPLICATION = 'REGION_REPLICATION' CONFIGURATION = org.apache.hadoop.hbase.HConstants::CONFIGURATION ATTRIBUTES="ATTRIBUTES" VISIBILITY="VISIBILITY" Modified: hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase/admin.rb URL: http://svn.apache.org/viewvc/hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase/admin.rb?rev=1565658&r1=1565657&r2=1565658&view=diff ============================================================================== --- hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase/admin.rb (original) +++ hbase/branches/hbase-10070/hbase-shell/src/main/ruby/hbase/admin.rb Fri Feb 7 13:55:28 2014 @@ -219,6 +219,10 @@ module Hbase has_columns = true next end + if arg.has_key?(REGION_REPLICATION) + region_replication = JInteger.valueOf(arg.delete(REGION_REPLICATION)) + htd.setRegionReplication(region_replication) + end # Get rid of the "METHOD", which is deprecated for create. # We'll do whatever it used to do below if it's table_att. Modified: hbase/branches/hbase-10070/hbase-shell/src/main/ruby/shell/commands/create.rb URL: http://svn.apache.org/viewvc/hbase/branches/hbase-10070/hbase-shell/src/main/ruby/shell/commands/create.rb?rev=1565658&r1=1565657&r2=1565658&view=diff ============================================================================== --- hbase/branches/hbase-10070/hbase-shell/src/main/ruby/shell/commands/create.rb (original) +++ hbase/branches/hbase-10070/hbase-shell/src/main/ruby/shell/commands/create.rb Fri Feb 7 13:55:28 2014 @@ -45,7 +45,7 @@ Examples: hbase> # Optionally pre-split the table into NUMREGIONS, using hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname) hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'} - hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit', CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}} + hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit', REGION_REPLICATION => 2, CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}} You can also keep around a reference to the created table: