From 06059a210c8725f99440ac33dc87a062b72e30e6 Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Fri, 8 Oct 2010 09:40:41 +0200 Subject: [PATCH] Fix all uses of the deprecated HBaseConfiguration constructor. --- .../hadoop/hbase/mapred/HRegionPartitioner.java | 2 +- .../org/apache/hadoop/hbase/mapred/RowCounter.java | 3 +- .../hadoop/hbase/mapred/TableInputFormat.java | 2 +- .../hadoop/hbase/mapred/TableInputFormatBase.java | 2 +- .../hadoop/hbase/mapred/TableMapReduceUtil.java | 10 ++++---- .../hadoop/hbase/mapred/TableOutputFormat.java | 2 +- .../hbase/mapreduce/TableInputFormatBase.java | 2 +- .../org/apache/hadoop/hbase/HBaseTestCase.java | 9 ++++--- .../hadoop/hbase/MapFilePerformanceEvaluation.java | 6 ++-- .../hadoop/hbase/io/TestHbaseObjectWritable.java | 2 +- .../hbase/mapreduce/TestTimeRangeMapRed.java | 2 +- .../hadoop/hbase/regionserver/TestHRegion.java | 21 ++++++++++--------- 12 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/apache/hadoop/hbase/mapred/HRegionPartitioner.java b/src/main/java/org/apache/hadoop/hbase/mapred/HRegionPartitioner.java index 8f26454..b58c5c7 100644 --- a/src/main/java/org/apache/hadoop/hbase/mapred/HRegionPartitioner.java +++ b/src/main/java/org/apache/hadoop/hbase/mapred/HRegionPartitioner.java @@ -48,7 +48,7 @@ implements Partitioner { public void configure(JobConf job) { try { - this.table = new HTable(new HBaseConfiguration(job), + this.table = new HTable(HBaseConfiguration.create(job), job.get(TableOutputFormat.OUTPUT_TABLE)); } catch (IOException e) { LOG.error(e); diff --git a/src/main/java/org/apache/hadoop/hbase/mapred/RowCounter.java b/src/main/java/org/apache/hadoop/hbase/mapred/RowCounter.java index f24d283..e43684b 100644 --- a/src/main/java/org/apache/hadoop/hbase/mapred/RowCounter.java +++ b/src/main/java/org/apache/hadoop/hbase/mapred/RowCounter.java @@ -130,8 +130,7 @@ public class RowCounter extends Configured implements Tool { * @throws Exception */ public static void main(String[] args) throws Exception { - HBaseConfiguration c = new HBaseConfiguration(); - int errCode = ToolRunner.run(c, new RowCounter(), args); + int errCode = ToolRunner.run(HBaseConfiguration.create(), new RowCounter(), args); System.exit(errCode); } } \ No newline at end of file diff --git a/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormat.java b/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormat.java index 1220a09..395a626 100644 --- a/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormat.java +++ b/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormat.java @@ -55,7 +55,7 @@ public class TableInputFormat extends TableInputFormatBase implements } setInputColumns(m_cols); try { - setHTable(new HTable(new HBaseConfiguration(job), tableNames[0].getName())); + setHTable(new HTable(HBaseConfiguration.create(job), tableNames[0].getName())); } catch (Exception e) { LOG.error(StringUtils.stringifyException(e)); } diff --git a/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormatBase.java b/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormatBase.java index 56384e1..b862eea 100644 --- a/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormatBase.java +++ b/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormatBase.java @@ -45,7 +45,7 @@ import org.apache.hadoop.mapred.Reporter; * class ExampleTIF extends TableInputFormatBase implements JobConfigurable { * * public void configure(JobConf job) { - * HTable exampleTable = new HTable(new HBaseConfiguration(job), + * HTable exampleTable = new HTable(HBaseConfiguration.create(job), * Bytes.toBytes("exampleTable")); * // mandatory * setHTable(exampleTable); diff --git a/src/main/java/org/apache/hadoop/hbase/mapred/TableMapReduceUtil.java b/src/main/java/org/apache/hadoop/hbase/mapred/TableMapReduceUtil.java index 6e7526b..e8558a0 100644 --- a/src/main/java/org/apache/hadoop/hbase/mapred/TableMapReduceUtil.java +++ b/src/main/java/org/apache/hadoop/hbase/mapred/TableMapReduceUtil.java @@ -106,7 +106,7 @@ public class TableMapReduceUtil { job.setOutputValueClass(Put.class); if (partitioner == HRegionPartitioner.class) { job.setPartitionerClass(HRegionPartitioner.class); - HTable outputTable = new HTable(new HBaseConfiguration(job), table); + HTable outputTable = new HTable(HBaseConfiguration.create(job), table); int regions = outputTable.getRegionsInfo().size(); if (job.getNumReduceTasks() > regions) { job.setNumReduceTasks(outputTable.getRegionsInfo().size()); @@ -127,7 +127,7 @@ public class TableMapReduceUtil { */ public static void limitNumReduceTasks(String table, JobConf job) throws IOException { - HTable outputTable = new HTable(new HBaseConfiguration(job), table); + HTable outputTable = new HTable(HBaseConfiguration.create(job), table); int regions = outputTable.getRegionsInfo().size(); if (job.getNumReduceTasks() > regions) job.setNumReduceTasks(regions); @@ -143,7 +143,7 @@ public class TableMapReduceUtil { */ public static void limitNumMapTasks(String table, JobConf job) throws IOException { - HTable outputTable = new HTable(new HBaseConfiguration(job), table); + HTable outputTable = new HTable(HBaseConfiguration.create(job), table); int regions = outputTable.getRegionsInfo().size(); if (job.getNumMapTasks() > regions) job.setNumMapTasks(regions); @@ -159,7 +159,7 @@ public class TableMapReduceUtil { */ public static void setNumReduceTasks(String table, JobConf job) throws IOException { - HTable outputTable = new HTable(new HBaseConfiguration(job), table); + HTable outputTable = new HTable(HBaseConfiguration.create(job), table); int regions = outputTable.getRegionsInfo().size(); job.setNumReduceTasks(regions); } @@ -174,7 +174,7 @@ public class TableMapReduceUtil { */ public static void setNumMapTasks(String table, JobConf job) throws IOException { - HTable outputTable = new HTable(new HBaseConfiguration(job), table); + HTable outputTable = new HTable(HBaseConfiguration.create(job), table); int regions = outputTable.getRegionsInfo().size(); job.setNumMapTasks(regions); } diff --git a/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java b/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java index 159b78e..80284bb 100644 --- a/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java +++ b/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java @@ -85,7 +85,7 @@ FileOutputFormat { String tableName = job.get(OUTPUT_TABLE); HTable table = null; try { - table = new HTable(new HBaseConfiguration(job), tableName); + table = new HTable(HBaseConfiguration.create(job), tableName); } catch(IOException e) { LOG.error(e); throw e; diff --git a/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java b/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java index 5e10a8b..f6670e6 100644 --- a/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java +++ b/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java @@ -49,7 +49,7 @@ import org.apache.hadoop.util.StringUtils; * class ExampleTIF extends TableInputFormatBase implements JobConfigurable { * * public void configure(JobConf job) { - * HTable exampleTable = new HTable(new HBaseConfiguration(job), + * HTable exampleTable = new HTable(HBaseConfiguration.create(job), * Bytes.toBytes("exampleTable")); * // mandatory * setHTable(exampleTable); diff --git a/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java b/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java index e2a7ffc..32ccbea 100644 --- a/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java +++ b/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java @@ -31,6 +31,7 @@ import junit.framework.TestCase; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.client.Delete; @@ -77,7 +78,7 @@ public abstract class HBaseTestCase extends TestCase { initialize(); } - public volatile HBaseConfiguration conf; + public volatile Configuration conf; /** constructor */ public HBaseTestCase() { @@ -94,7 +95,7 @@ public abstract class HBaseTestCase extends TestCase { } private void init() { - conf = new HBaseConfiguration(); + conf = HBaseConfiguration.create(); try { START_KEY = new String(START_KEY_BYTES, HConstants.UTF8_ENCODING); } catch (UnsupportedEncodingException e) { @@ -194,7 +195,7 @@ public abstract class HBaseTestCase extends TestCase { HTableDescriptor htd = new HTableDescriptor(name); htd.addFamily(new HColumnDescriptor(fam1, versions, HColumnDescriptor.DEFAULT_COMPRESSION, false, false, - Integer.MAX_VALUE, HConstants.FOREVER, + Integer.MAX_VALUE, HConstants.FOREVER, HColumnDescriptor.DEFAULT_BLOOMFILTER, HConstants.REPLICATION_SCOPE_LOCAL)); htd.addFamily(new HColumnDescriptor(fam2, versions, @@ -670,7 +671,7 @@ public abstract class HBaseTestCase extends TestCase { } public static void assertByteEquals(byte[] expected, - byte[] actual) { + byte[] actual) { if (Bytes.compareTo(expected, actual) != 0) { throw new AssertionFailedError("expected:<" + Bytes.toString(expected) + "> but was:<" + diff --git a/src/test/java/org/apache/hadoop/hbase/MapFilePerformanceEvaluation.java b/src/test/java/org/apache/hadoop/hbase/MapFilePerformanceEvaluation.java index 3740677..7635949 100644 --- a/src/test/java/org/apache/hadoop/hbase/MapFilePerformanceEvaluation.java +++ b/src/test/java/org/apache/hadoop/hbase/MapFilePerformanceEvaluation.java @@ -40,7 +40,7 @@ import org.apache.hadoop.io.WritableComparable; *

*/ public class MapFilePerformanceEvaluation { - protected final HBaseConfiguration conf; + protected final Configuration conf; private static final int ROW_LENGTH = 10; private static final int ROW_COUNT = 100000; @@ -50,7 +50,7 @@ public class MapFilePerformanceEvaluation { /** * @param c */ - public MapFilePerformanceEvaluation(final HBaseConfiguration c) { + public MapFilePerformanceEvaluation(final Configuration c) { super(); this.conf = c; } @@ -343,7 +343,7 @@ public class MapFilePerformanceEvaluation { * @throws IOException */ public static void main(String[] args) throws Exception { - new MapFilePerformanceEvaluation(new HBaseConfiguration()). + new MapFilePerformanceEvaluation(HBaseConfiguration.create()). runBenchmarks(); } } diff --git a/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java b/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java index c74223c..dac7de6 100644 --- a/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java +++ b/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java @@ -51,7 +51,7 @@ public class TestHbaseObjectWritable extends TestCase { @SuppressWarnings("boxing") public void testReadObjectDataInputConfiguration() throws IOException { - HBaseConfiguration conf = new HBaseConfiguration(); + Configuration conf = HBaseConfiguration.create(); // Do primitive type final int COUNT = 101; assertTrue(doType(conf, COUNT, int.class).equals(COUNT)); diff --git a/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java b/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java index 7c1138a..a772360 100644 --- a/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java +++ b/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java @@ -129,7 +129,7 @@ public class TestTimeRangeMapRed extends HBaseClusterTestCase { public void setConf(Configuration configuration) { this.conf = configuration; try { - table = new HTable(new HBaseConfiguration(conf), TABLE_NAME); + table = new HTable(HBaseConfiguration.create(conf), TABLE_NAME); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java index 7631b5a..3ec50c5 100644 --- a/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java +++ b/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java @@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.regionserver; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseTestCase; @@ -117,7 +118,7 @@ public class TestHRegion extends HBaseTestCase { ////////////////////////////////////////////////////////////////////////////// public void testGetWhileRegionClose() throws IOException { - HBaseConfiguration hc = initSplit(); + Configuration hc = initSplit(); int numRows = 100; byte [][] families = {fam1, fam2, fam3}; @@ -1194,7 +1195,7 @@ public class TestHRegion extends HBaseTestCase { byte [] tableName = Bytes.toBytes("testtable"); byte [][] families = {fam1, fam2, fam3}; - HBaseConfiguration hc = initSplit(); + Configuration hc = initSplit(); //Setting up region String method = this.getName(); initHRegion(tableName, method, hc, families); @@ -1257,7 +1258,7 @@ public class TestHRegion extends HBaseTestCase { public void testMerge() throws IOException { byte [] tableName = Bytes.toBytes("testtable"); byte [][] families = {fam1, fam2, fam3}; - HBaseConfiguration hc = initSplit(); + Configuration hc = initSplit(); //Setting up region String method = this.getName(); initHRegion(tableName, method, hc, families); @@ -2171,7 +2172,7 @@ public class TestHRegion extends HBaseTestCase { byte [] tableName = Bytes.toBytes("testtable"); byte [][] families = {fam1, fam2, fam3}; - HBaseConfiguration hc = initSplit(); + Configuration hc = initSplit(); //Setting up region String method = this.getName(); initHRegion(tableName, method, hc, families); @@ -2258,7 +2259,7 @@ public class TestHRegion extends HBaseTestCase { public void testSplitRegion() throws IOException { byte [] tableName = Bytes.toBytes("testtable"); byte [] qualifier = Bytes.toBytes("qualifier"); - HBaseConfiguration hc = initSplit(); + Configuration hc = initSplit(); int numRows = 10; byte [][] families = {fam1, fam3}; @@ -2663,7 +2664,7 @@ public class TestHRegion extends HBaseTestCase { //Setting up region String method = "testIndexesScanWithOneDeletedRow"; - initHRegion(tableName, method, new HBaseConfiguration(), family); + initHRegion(tableName, method, HBaseConfiguration.create(), family); Put put = new Put(Bytes.toBytes(1L)); put.add(family, qual1, 1L, Bytes.toBytes(1L)); @@ -2867,8 +2868,8 @@ public class TestHRegion extends HBaseTestCase { } } - private HBaseConfiguration initSplit() { - HBaseConfiguration conf = new HBaseConfiguration(); + private Configuration initSplit() { + Configuration conf = HBaseConfiguration.create(); // Always compact if there is more than one store file. conf.setInt("hbase.hstore.compactionThreshold", 2); @@ -2889,11 +2890,11 @@ public class TestHRegion extends HBaseTestCase { private void initHRegion (byte [] tableName, String callingMethod, byte[] ... families) throws IOException { - initHRegion(tableName, callingMethod, new HBaseConfiguration(), families); + initHRegion(tableName, callingMethod, HBaseConfiguration.create(), families); } private void initHRegion (byte [] tableName, String callingMethod, - HBaseConfiguration conf, byte [] ... families) + Configuration conf, byte [] ... families) throws IOException{ HTableDescriptor htd = new HTableDescriptor(tableName); for(byte [] family : families) { -- 1.7.3.1