phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From karanmeht...@apache.org
Subject phoenix git commit: PHOENIX-4489 HBase Connection leak in Phoenix MR Jobs
Date Wed, 24 Jan 2018 07:42:24 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 47e8262d4 -> 42a21a950


PHOENIX-4489 HBase Connection leak in Phoenix MR Jobs


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/42a21a95
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/42a21a95
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/42a21a95

Branch: refs/heads/4.x-HBase-0.98
Commit: 42a21a95040b54eb63affaf75d12c0436679267b
Parents: 47e8262
Author: Karan Mehta <karanmehta93@gmail.com>
Authored: Tue Jan 23 23:35:38 2018 -0800
Committer: Karan Mehta <karanmehta93@gmail.com>
Committed: Tue Jan 23 23:35:38 2018 -0800

----------------------------------------------------------------------
 .../apache/phoenix/mapreduce/PhoenixInputFormat.java    | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/42a21a95/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java
index 4e3b816..ad77f7f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java
@@ -31,7 +31,6 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.HConnection;
-import org.apache.hadoop.hbase.client.HConnectionManager;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -49,6 +48,7 @@ import org.apache.phoenix.iterate.MapReduceParallelScanGrouper;
 import org.apache.phoenix.jdbc.PhoenixStatement;
 import org.apache.phoenix.mapreduce.util.ConnectionUtil;
 import org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil;
+import org.apache.phoenix.query.HBaseFactoryProvider;
 import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.util.PhoenixRuntime;
 
@@ -96,14 +96,16 @@ public class PhoenixInputFormat<T extends DBWritable> extends InputFormat<NullWr
         Preconditions.checkNotNull(splits);
 
         // Get the RegionSizeCalculator
-        HConnection connection = HConnectionManager.createConnection(config);
+        List<InputSplit> psplits;
+        try (HConnection connection =
+                     HBaseFactoryProvider.getHConnectionFactory().createConnection(config))
{
         String tableName = qplan
                 .getTableRef().getTable().getPhysicalName().toString();
         HTable table = new HTable(config, tableName);
         RegionSizeCalculator sizeCalculator = new RegionSizeCalculator(table);
 
 
-        final List<InputSplit> psplits = Lists.newArrayListWithExpectedSize(splits.size());
+            psplits = Lists.newArrayListWithExpectedSize(splits.size());
         for (List<Scan> scans : qplan.getScans()) {
             // Get the region location
             HRegionLocation location = connection.getRegionLocation(
@@ -133,8 +135,7 @@ public class PhoenixInputFormat<T extends DBWritable> extends InputFormat<NullWr
 
                     psplits.add(new PhoenixInputSplit(Collections.singletonList(aScan), regionSize,
regionLocation));
                 }
-            }
-            else {
+                } else {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Scan count[" + scans.size() + "] : " + Bytes.toStringBinary(scans
                             .get(0).getStartRow()) + " ~ " + Bytes.toStringBinary(scans.get(scans
@@ -155,6 +156,7 @@ public class PhoenixInputFormat<T extends DBWritable> extends InputFormat<NullWr
                 psplits.add(new PhoenixInputSplit(scans, regionSize, regionLocation));
             }
         }
+        }
         return psplits;
     }
     


Mime
View raw message