@@ -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