HBASE-16638 Reduce the number of Connection's created in classes of hbase-spark module - Addendum (Weiqing Yang)
This commit is contained in:
parent
9d304d3b2d
commit
ee6f0ddef6
|
@ -79,14 +79,14 @@ private[spark] object HBaseConnectionCache extends Logging {
|
||||||
connectionMap.foreach {
|
connectionMap.foreach {
|
||||||
x => {
|
x => {
|
||||||
if(x._2.refCount < 0) {
|
if(x._2.refCount < 0) {
|
||||||
logError("Bug to be fixed: negative refCount")
|
logError(s"Bug to be fixed: negative refCount of connection ${x._2}")
|
||||||
}
|
}
|
||||||
|
|
||||||
if(forceClean || ((x._2.refCount <= 0) && (tsNow - x._2.timestamp > timeout))) {
|
if(forceClean || ((x._2.refCount <= 0) && (tsNow - x._2.timestamp > timeout))) {
|
||||||
try{
|
try{
|
||||||
x._2.connection.close()
|
x._2.connection.close()
|
||||||
} catch {
|
} catch {
|
||||||
case e: IOException => logWarning("Fail to close connection", e)
|
case e: IOException => logWarning(s"Fail to close connection ${x._2}", e)
|
||||||
}
|
}
|
||||||
connectionMap.remove(x._1)
|
connectionMap.remove(x._1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ConnectionMocker extends Connection {
|
||||||
def abort(why: String, e: Throwable) = {}
|
def abort(why: String, e: Throwable) = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HBaseConnectionCacheSuit extends FunSuite with Logging {
|
class HBaseConnectionCacheSuite extends FunSuite with Logging {
|
||||||
/*
|
/*
|
||||||
* These tests must be performed sequentially as they operate with an
|
* These tests must be performed sequentially as they operate with an
|
||||||
* unique running thread and resource.
|
* unique running thread and resource.
|
Loading…
Reference in New Issue