HDFS-7266. HDFS Peercache enabled check should not lock on object (awang via cmccabe)
(cherry picked from commit 4799570dfd
)
This commit is contained in:
parent
f75570734b
commit
4eef6dcb58
|
@ -23,6 +23,9 @@ Release 2.7.0 - UNRELEASED
|
||||||
|
|
||||||
HDFS-6252. Phase out the old web UI in HDFS. (wheat9)
|
HDFS-6252. Phase out the old web UI in HDFS. (wheat9)
|
||||||
|
|
||||||
|
HDFS-7266. HDFS Peercache enabled check should not lock on object (awang
|
||||||
|
via cmccabe)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -140,12 +140,15 @@ class PeerCache {
|
||||||
* @return An open Peer connected to the DN, or null if none
|
* @return An open Peer connected to the DN, or null if none
|
||||||
* was found.
|
* was found.
|
||||||
*/
|
*/
|
||||||
public synchronized Peer get(DatanodeID dnId, boolean isDomain) {
|
public Peer get(DatanodeID dnId, boolean isDomain) {
|
||||||
|
|
||||||
if (capacity <= 0) { // disabled
|
if (capacity <= 0) { // disabled
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return getInternal(dnId, isDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized Peer getInternal(DatanodeID dnId, boolean isDomain) {
|
||||||
List<Value> sockStreamList = multimap.get(new Key(dnId, isDomain));
|
List<Value> sockStreamList = multimap.get(new Key(dnId, isDomain));
|
||||||
if (sockStreamList == null) {
|
if (sockStreamList == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -174,7 +177,7 @@ class PeerCache {
|
||||||
/**
|
/**
|
||||||
* Give an unused socket to the cache.
|
* Give an unused socket to the cache.
|
||||||
*/
|
*/
|
||||||
public synchronized void put(DatanodeID dnId, Peer peer) {
|
public void put(DatanodeID dnId, Peer peer) {
|
||||||
Preconditions.checkNotNull(dnId);
|
Preconditions.checkNotNull(dnId);
|
||||||
Preconditions.checkNotNull(peer);
|
Preconditions.checkNotNull(peer);
|
||||||
if (peer.isClosed()) return;
|
if (peer.isClosed()) return;
|
||||||
|
@ -183,7 +186,10 @@ class PeerCache {
|
||||||
IOUtils.cleanup(LOG, peer);
|
IOUtils.cleanup(LOG, peer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
putInternal(dnId, peer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void putInternal(DatanodeID dnId, Peer peer) {
|
||||||
startExpiryDaemon();
|
startExpiryDaemon();
|
||||||
|
|
||||||
if (capacity == multimap.size()) {
|
if (capacity == multimap.size()) {
|
||||||
|
|
Loading…
Reference in New Issue