|
@@ -349,13 +349,17 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
if (clientContext.getUseLegacyBlockReaderLocal()) {
|
|
|
reader = getLegacyBlockReaderLocal();
|
|
|
if (reader != null) {
|
|
|
- LOG.trace("{}: returning new legacy block reader local.", this);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": returning new legacy block reader local.");
|
|
|
+ }
|
|
|
return reader;
|
|
|
}
|
|
|
} else {
|
|
|
reader = getBlockReaderLocal();
|
|
|
if (reader != null) {
|
|
|
- LOG.trace("{}: returning new block reader local.", this);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": returning new block reader local.");
|
|
|
+ }
|
|
|
return reader;
|
|
|
}
|
|
|
}
|
|
@@ -363,8 +367,10 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
if (scConf.isDomainSocketDataTraffic()) {
|
|
|
reader = getRemoteBlockReaderFromDomain();
|
|
|
if (reader != null) {
|
|
|
- LOG.trace("{}: returning new remote block reader using UNIX domain "
|
|
|
- + "socket on {}", this, pathInfo.getPath());
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": returning new remote block reader using " +
|
|
|
+ "UNIX domain socket on " + pathInfo.getPath());
|
|
|
+ }
|
|
|
return reader;
|
|
|
}
|
|
|
}
|
|
@@ -399,8 +405,10 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
setVisibleLength(visibleLength).
|
|
|
build();
|
|
|
if (accessor == null) {
|
|
|
- LOG.trace("{}: No ReplicaAccessor created by {}",
|
|
|
- this, cls.getName());
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": No ReplicaAccessor created by " +
|
|
|
+ cls.getName());
|
|
|
+ }
|
|
|
} else {
|
|
|
return new ExternalBlockReader(accessor, visibleLength, startOffset);
|
|
|
}
|
|
@@ -419,10 +427,14 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
* first introduced in HDFS-2246.
|
|
|
*/
|
|
|
private BlockReader getLegacyBlockReaderLocal() throws IOException {
|
|
|
- LOG.trace("{}: trying to construct BlockReaderLocalLegacy", this);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": trying to construct BlockReaderLocalLegacy");
|
|
|
+ }
|
|
|
if (!DFSUtilClient.isLocalAddress(inetSocketAddress)) {
|
|
|
- LOG.trace("{}: can't construct BlockReaderLocalLegacy because the address"
|
|
|
- + "{} is not local", this, inetSocketAddress);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": can't construct BlockReaderLocalLegacy because " +
|
|
|
+ "the address " + inetSocketAddress + " is not local");
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
if (clientContext.getDisableLegacyBlockReaderLocal()) {
|
|
@@ -458,8 +470,10 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
}
|
|
|
|
|
|
private BlockReader getBlockReaderLocal() throws InvalidToken {
|
|
|
- LOG.trace("{}: trying to construct a BlockReaderLocal for short-circuit "
|
|
|
- + " reads.", this);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": trying to construct a BlockReaderLocal " +
|
|
|
+ "for short-circuit reads.");
|
|
|
+ }
|
|
|
if (pathInfo == null) {
|
|
|
pathInfo = clientContext.getDomainSocketFactory()
|
|
|
.getPathInfo(inetSocketAddress, conf.getShortCircuitConf());
|
|
@@ -474,8 +488,10 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
ShortCircuitReplicaInfo info = cache.fetchOrCreate(key, this);
|
|
|
InvalidToken exc = info.getInvalidTokenException();
|
|
|
if (exc != null) {
|
|
|
- LOG.trace("{}: got InvalidToken exception while trying to construct "
|
|
|
- + "BlockReaderLocal via {}", this, pathInfo.getPath());
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": got InvalidToken exception while trying to " +
|
|
|
+ "construct BlockReaderLocal via " + pathInfo.getPath());
|
|
|
+ }
|
|
|
throw exc;
|
|
|
}
|
|
|
if (info.getReplica() == null) {
|
|
@@ -511,7 +527,9 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
createShortCircuitReplicaInfoCallback.createShortCircuitReplicaInfo();
|
|
|
if (info != null) return info;
|
|
|
}
|
|
|
- LOG.trace("{}: trying to create ShortCircuitReplicaInfo.", this);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": trying to create ShortCircuitReplicaInfo.");
|
|
|
+ }
|
|
|
BlockReaderPeer curPeer;
|
|
|
while (true) {
|
|
|
curPeer = nextDomainPeer();
|
|
@@ -526,8 +544,10 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
new ExtendedBlockId(block.getBlockId(), block.getBlockPoolId()),
|
|
|
clientName);
|
|
|
if (usedPeer.booleanValue()) {
|
|
|
- LOG.trace("{}: allocShmSlot used up our previous socket {}. "
|
|
|
- + "Allocating a new one...", this, peer.getDomainSocket());
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": allocShmSlot used up our previous socket " +
|
|
|
+ peer.getDomainSocket() + ". Allocating a new one...");
|
|
|
+ }
|
|
|
curPeer = nextDomainPeer();
|
|
|
if (curPeer == null) break;
|
|
|
peer = (DomainPeer)curPeer.peer;
|
|
@@ -542,7 +562,9 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
if (curPeer.fromCache) {
|
|
|
// Handle an I/O error we got when using a cached socket.
|
|
|
// These are considered less serious, because the socket may be stale.
|
|
|
- LOG.debug("{}: closing stale domain peer {}", this, peer, e);
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
+ LOG.debug(this + ": closing stale domain peer " + peer, e);
|
|
|
+ }
|
|
|
IOUtilsClient.cleanup(LOG, peer);
|
|
|
} else {
|
|
|
// Handle an I/O error we got when using a newly created socket.
|
|
@@ -595,7 +617,7 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
ExtendedBlockId key =
|
|
|
new ExtendedBlockId(block.getBlockId(), block.getBlockPoolId());
|
|
|
if (buf[0] == USE_RECEIPT_VERIFICATION.getNumber()) {
|
|
|
- LOG.trace("Sending receipt verification byte for slot {}", slot);
|
|
|
+ LOG.trace("Sending receipt verification byte for slot " + slot);
|
|
|
sock.getOutputStream().write(0);
|
|
|
}
|
|
|
replica = new ShortCircuitReplica(key, fis[0], fis[1], cache,
|
|
@@ -628,7 +650,9 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
String msg = "access control error while " +
|
|
|
"attempting to set up short-circuit access to " +
|
|
|
fileName + resp.getMessage();
|
|
|
- LOG.debug("{}:{}", this, msg);
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
+ LOG.debug(this + ":" + msg);
|
|
|
+ }
|
|
|
return new ShortCircuitReplicaInfo(new InvalidToken(msg));
|
|
|
default:
|
|
|
LOG.warn(this + ": unknown response code " + resp.getStatus() +
|
|
@@ -660,8 +684,10 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
" is not usable.", this, pathInfo);
|
|
|
return null;
|
|
|
}
|
|
|
- LOG.trace("{}: trying to create a remote block reader from the UNIX domain "
|
|
|
- + "socket at {}", this, pathInfo.getPath());
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": trying to create a remote block reader from the " +
|
|
|
+ "UNIX domain socket at " + pathInfo.getPath());
|
|
|
+ }
|
|
|
|
|
|
while (true) {
|
|
|
BlockReaderPeer curPeer = nextDomainPeer();
|
|
@@ -675,15 +701,19 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
} catch (IOException ioe) {
|
|
|
IOUtilsClient.cleanup(LOG, peer);
|
|
|
if (isSecurityException(ioe)) {
|
|
|
- LOG.trace("{}: got security exception while constructing a remote "
|
|
|
- + " block reader from the unix domain socket at {}",
|
|
|
- this, pathInfo.getPath(), ioe);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": got security exception while constructing " +
|
|
|
+ "a remote block reader from the unix domain socket at " +
|
|
|
+ pathInfo.getPath(), ioe);
|
|
|
+ }
|
|
|
throw ioe;
|
|
|
}
|
|
|
if (curPeer.fromCache) {
|
|
|
// Handle an I/O error we got when using a cached peer. These are
|
|
|
// considered less serious, because the underlying socket may be stale.
|
|
|
- LOG.debug("Closed potentially stale domain peer {}", peer, ioe);
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
+ LOG.debug("Closed potentially stale domain peer " + peer, ioe);
|
|
|
+ }
|
|
|
} else {
|
|
|
// Handle an I/O error we got when using a newly created domain peer.
|
|
|
// We temporarily disable the domain socket path for a few minutes in
|
|
@@ -717,8 +747,10 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
* If there was another problem.
|
|
|
*/
|
|
|
private BlockReader getRemoteBlockReaderFromTcp() throws IOException {
|
|
|
- LOG.trace("{}: trying to create a remote block reader from a TCP socket",
|
|
|
- this);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": trying to create a remote block reader from a " +
|
|
|
+ "TCP socket");
|
|
|
+ }
|
|
|
BlockReader blockReader = null;
|
|
|
while (true) {
|
|
|
BlockReaderPeer curPeer = null;
|
|
@@ -731,15 +763,19 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
return blockReader;
|
|
|
} catch (IOException ioe) {
|
|
|
if (isSecurityException(ioe)) {
|
|
|
- LOG.trace("{}: got security exception while constructing a remote "
|
|
|
- + "block reader from {}", this, peer, ioe);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace(this + ": got security exception while constructing " +
|
|
|
+ "a remote block reader from " + peer, ioe);
|
|
|
+ }
|
|
|
throw ioe;
|
|
|
}
|
|
|
if ((curPeer != null) && curPeer.fromCache) {
|
|
|
// Handle an I/O error we got when using a cached peer. These are
|
|
|
// considered less serious, because the underlying socket may be
|
|
|
// stale.
|
|
|
- LOG.debug("Closed potentially stale remote peer {}", peer, ioe);
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
+ LOG.debug("Closed potentially stale remote peer " + peer, ioe);
|
|
|
+ }
|
|
|
} else {
|
|
|
// Handle an I/O error we got when using a newly created peer.
|
|
|
LOG.warn("I/O error constructing remote block reader.", ioe);
|
|
@@ -772,7 +808,9 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
if (remainingCacheTries > 0) {
|
|
|
Peer peer = clientContext.getPeerCache().get(datanode, true);
|
|
|
if (peer != null) {
|
|
|
- LOG.trace("nextDomainPeer: reusing existing peer {}", peer);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace("nextDomainPeer: reusing existing peer " + peer);
|
|
|
+ }
|
|
|
return new BlockReaderPeer(peer, true);
|
|
|
}
|
|
|
}
|
|
@@ -794,18 +832,24 @@ public class BlockReaderFactory implements ShortCircuitReplicaCreator {
|
|
|
if (remainingCacheTries > 0) {
|
|
|
Peer peer = clientContext.getPeerCache().get(datanode, false);
|
|
|
if (peer != null) {
|
|
|
- LOG.trace("nextTcpPeer: reusing existing peer {}", peer);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace("nextTcpPeer: reusing existing peer " + peer);
|
|
|
+ }
|
|
|
return new BlockReaderPeer(peer, true);
|
|
|
}
|
|
|
}
|
|
|
try {
|
|
|
Peer peer = remotePeerFactory.newConnectedPeer(inetSocketAddress, token,
|
|
|
datanode);
|
|
|
- LOG.trace("nextTcpPeer: created newConnectedPeer {}", peer);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace("nextTcpPeer: created newConnectedPeer " + peer);
|
|
|
+ }
|
|
|
return new BlockReaderPeer(peer, false);
|
|
|
} catch (IOException e) {
|
|
|
- LOG.trace("nextTcpPeer: failed to create newConnectedPeer connected to"
|
|
|
- + "{}", datanode);
|
|
|
+ if (LOG.isTraceEnabled()) {
|
|
|
+ LOG.trace("nextTcpPeer: failed to create newConnectedPeer " +
|
|
|
+ "connected to " + datanode);
|
|
|
+ }
|
|
|
throw e;
|
|
|
}
|
|
|
}
|