HBASE-20421 HBasecontext creates a connection but does not close it (Yu Wang)

This commit is contained in:
tedyu 2018-04-17 19:45:53 -07:00
parent fd2cec75f3
commit f4f2b68238
1 changed files with 179 additions and 173 deletions

View File

@ -628,6 +628,7 @@ class HBaseContext(@transient val sc: SparkContext,
throw new FileAlreadyExistsException("Path " + stagingDir + " already exists")
}
val conn = HBaseConnectionCache.getConnection(config)
try {
val regionLocator = conn.getRegionLocator(tableName)
val startKeys = regionLocator.getStartKeys
if (startKeys.length == 0) {
@ -708,8 +709,10 @@ class HBaseContext(@transient val sc: SparkContext,
compactionExclude)
rollOverRequested = false
})
} finally {
if(null != conn) conn.close()
}
}
/**
* Spark Implementation of HBase Bulk load for short rows some where less then
@ -760,6 +763,7 @@ class HBaseContext(@transient val sc: SparkContext,
throw new FileAlreadyExistsException("Path " + stagingDir + " already exists")
}
val conn = HBaseConnectionCache.getConnection(config)
try {
val regionLocator = conn.getRegionLocator(tableName)
val startKeys = regionLocator.getStartKeys
if (startKeys.length == 0) {
@ -871,8 +875,10 @@ class HBaseContext(@transient val sc: SparkContext,
compactionExclude)
rollOverRequested = false
})
} finally {
if(null != conn) conn.close()
}
}
/**
* This will return a new HFile writer when requested