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 2016/07/08 22:07:11 UTC
hbase git commit: HBASE-16017 HBase TableOutputFormat has connection
leak in getRecordWriter (Zhan Zhang)
Repository: hbase
Updated Branches:
refs/heads/branch-1.3 2e2a3fda4 -> e7513e447
HBASE-16017 HBase TableOutputFormat has connection leak in getRecordWriter (Zhan Zhang)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e7513e44
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e7513e44
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e7513e44
Branch: refs/heads/branch-1.3
Commit: e7513e447e2b8f299a39f06d35d872e0c8de3e7e
Parents: 2e2a3fd
Author: tedyu <yu...@gmail.com>
Authored: Fri Jul 8 15:06:54 2016 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Fri Jul 8 15:06:54 2016 -0700
----------------------------------------------------------------------
.../hadoop/hbase/mapred/TableOutputFormat.java | 22 ++++++++++++--------
1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/e7513e44/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java
index 6e0d9e7..08af0d3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java
@@ -53,7 +53,7 @@ public class TableOutputFormat extends FileOutputFormat<ImmutableBytesWritable,
*/
protected static class TableRecordWriter implements RecordWriter<ImmutableBytesWritable, Put> {
private BufferedMutator m_mutator;
-
+ private Connection connection;
/**
* Instantiate a TableRecordWriter with the HBase HClient for writing. Assumes control over the
* lifecycle of {@code conn}.
@@ -62,8 +62,19 @@ public class TableOutputFormat extends FileOutputFormat<ImmutableBytesWritable,
this.m_mutator = mutator;
}
+ public TableRecordWriter(JobConf job) throws IOException {
+ // expecting exactly one path
+ TableName tableName = TableName.valueOf(job.get(OUTPUT_TABLE));
+ connection = ConnectionFactory.createConnection(job);
+ m_mutator = connection.getBufferedMutator(tableName);
+ }
+
public void close(Reporter reporter) throws IOException {
this.m_mutator.close();
+ if (connection != null) {
+ connection.close();
+ connection = null;
+ }
}
public void write(ImmutableBytesWritable key, Put value) throws IOException {
@@ -75,14 +86,7 @@ public class TableOutputFormat extends FileOutputFormat<ImmutableBytesWritable,
public RecordWriter getRecordWriter(FileSystem ignored, JobConf job, String name,
Progressable progress)
throws IOException {
- // expecting exactly one path
- TableName tableName = TableName.valueOf(job.get(OUTPUT_TABLE));
- BufferedMutator mutator = null;
- // Connection is not closed. Dies with JVM. No possibility for cleanup.
- Connection connection = ConnectionFactory.createConnection(job);
- mutator = connection.getBufferedMutator(tableName);
- // Clear write buffer on fail is true by default so no need to reset it.
- return new TableRecordWriter(mutator);
+ return new TableRecordWriter(job);
}
@Override