Skip to content

Commit 76620fa

Browse files
committed
HDFS-3375. Put client name in DataXceiver thread name for readBlock and keepalive. Contributed by Todd Lipcon.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1335271 13f79535-47bb-0310-9956-ffa450edef68
1 parent 4ff5095 commit 76620fa

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ Release 2.0.0 - UNRELEASED
286286
HDFS-3365. Enable users to disable socket caching in DFS client
287287
configuration (todd)
288288

289+
HDFS-3375. Put client name in DataXceiver thread name for readBlock
290+
and keepalive (todd)
291+
289292
OPTIMIZATIONS
290293

291294
HDFS-2477. Optimize computing the diff between a block report and the

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ class DataXceiver extends Receiver implements Runnable {
8585

8686
private long opStartTime; //the start time of receiving an Op
8787
private final SocketInputWrapper socketInputWrapper;
88+
89+
/**
90+
* Client Name used in previous operation. Not available on first request
91+
* on the socket.
92+
*/
93+
private String previousOpClientName;
8894

8995
public static DataXceiver create(Socket s, DataNode dn,
9096
DataXceiverServer dataXceiverServer) throws IOException {
@@ -122,7 +128,11 @@ private DataXceiver(Socket s,
122128
*/
123129
private void updateCurrentThreadName(String status) {
124130
StringBuilder sb = new StringBuilder();
125-
sb.append("DataXceiver for client ").append(remoteAddress);
131+
sb.append("DataXceiver for client ");
132+
if (previousOpClientName != null) {
133+
sb.append(previousOpClientName).append(" at ");
134+
}
135+
sb.append(remoteAddress);
126136
if (status != null) {
127137
sb.append(" [").append(status).append("]");
128138
}
@@ -202,6 +212,8 @@ public void readBlock(final ExtendedBlock block,
202212
final String clientName,
203213
final long blockOffset,
204214
final long length) throws IOException {
215+
previousOpClientName = clientName;
216+
205217
OutputStream baseStream = NetUtils.getOutputStream(s,
206218
dnConf.socketWriteTimeout);
207219
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(
@@ -295,7 +307,8 @@ public void writeBlock(final ExtendedBlock block,
295307
final long maxBytesRcvd,
296308
final long latestGenerationStamp,
297309
DataChecksum requestedChecksum) throws IOException {
298-
updateCurrentThreadName("Receiving block " + block + " client=" + clientname);
310+
previousOpClientName = clientname;
311+
updateCurrentThreadName("Receiving block " + block);
299312
final boolean isDatanode = clientname.length() == 0;
300313
final boolean isClient = !isDatanode;
301314
final boolean isTransfer = stage == BlockConstructionStage.TRANSFER_RBW
@@ -502,7 +515,7 @@ public void transferBlock(final ExtendedBlock blk,
502515
final DatanodeInfo[] targets) throws IOException {
503516
checkAccess(null, true, blk, blockToken,
504517
Op.TRANSFER_BLOCK, BlockTokenSecretManager.AccessMode.COPY);
505-
518+
previousOpClientName = clientName;
506519
updateCurrentThreadName(Op.TRANSFER_BLOCK + " " + blk);
507520

508521
final DataOutputStream out = new DataOutputStream(

0 commit comments

Comments
 (0)