Skip to content

Commit

Permalink
HBASE-14361 Investigate unused connection objects
Browse files Browse the repository at this point in the history
Signed-off-by: stack <[email protected]>
  • Loading branch information
chenheng authored and saintstack committed Sep 10, 2015
1 parent 21dfb61 commit eb8a8c4
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class ReplicationSink {

private static final Log LOG = LogFactory.getLog(ReplicationSink.class);
private final Configuration conf;
private final Connection sharedHtableCon;
private Connection sharedHtableCon;
private final MetricsSink metrics;
private final AtomicLong totalReplicatedEdits = new AtomicLong();

Expand All @@ -88,7 +88,6 @@ public ReplicationSink(Configuration conf, Stoppable stopper)
this.conf = HBaseConfiguration.create(conf);
decorateConf();
this.metrics = new MetricsSink();
this.sharedHtableCon = ConnectionFactory.createConnection(this.conf);
}

/**
Expand Down Expand Up @@ -213,7 +212,9 @@ private <K1, K2, V> List<V> addToHashMultiMap(Map<K1, Map<K2,List<V>>> map, K1 k
*/
public void stopReplicationSinkServices() {
try {
this.sharedHtableCon.close();
if (this.sharedHtableCon != null) {
this.sharedHtableCon.close();
}
} catch (IOException e) {
LOG.warn("IOException while closing the connection", e); // ignoring as we are closing.
}
Expand All @@ -232,6 +233,9 @@ protected void batch(TableName tableName, Collection<List<Row>> allRows) throws
}
Table table = null;
try {
if (this.sharedHtableCon == null) {
this.sharedHtableCon = ConnectionFactory.createConnection(this.conf);
}
table = this.sharedHtableCon.getTable(tableName);
for (List<Row> rows : allRows) {
table.batch(rows, null);
Expand Down

0 comments on commit eb8a8c4

Please sign in to comment.