hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1035890 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java
Date Wed, 17 Nov 2010 00:52:50 GMT
Author: eli
Date: Wed Nov 17 00:52:49 2010
New Revision: 1035890

URL: http://svn.apache.org/viewvc?rev=1035890&view=rev
Log:
HDFS-1055. Improve thread naming for DataXceivers. Contributed by Todd Lipcon and Ramkumar
Vadali

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1035890&r1=1035889&r2=1035890&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Wed Nov 17 00:52:49 2010
@@ -202,6 +202,9 @@ Trunk (unreleased changes)
 
     HDFS-1071. savenamespace should write the fsimage to all configured 
     fs.name.dir in parallel (Dmytro Molkov via jghoman)
+ 
+    HDFS-1055. Improve thread naming for DataXceivers. 
+    (Todd Lipcon and Ramkumar Vadali via eli).
 
   OPTIMIZATIONS
 

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java?rev=1035890&r1=1035889&r2=1035890&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java Wed
Nov 17 00:52:49 2010
@@ -88,6 +88,20 @@ class DataXceiver extends DataTransferPr
     }
   }
 
+  /**
+   * Update the current thread's name to contain the current status.
+   * Use this only after this receiver has started on its thread, i.e.,
+   * outside the constructor.
+   */
+  private void updateCurrentThreadName(String status) {
+    StringBuilder sb = new StringBuilder();
+    sb.append("DataXceiver for client ").append(remoteAddress);
+    if (status != null) {
+      sb.append(" [").append(status).append("]");
+    }
+    Thread.currentThread().setName(sb.toString());
+  }
+
   /** Return the datanode object. */
   DataNode getDataNode() {return datanode;}
 
@@ -95,6 +109,8 @@ class DataXceiver extends DataTransferPr
    * Read/write data from/to the DataXceiveServer.
    */
   public void run() {
+    updateCurrentThreadName("Waiting for operation");
+
     DataInputStream in=null; 
     try {
       in = new DataInputStream(
@@ -119,6 +135,7 @@ class DataXceiver extends DataTransferPr
         LOG.debug(datanode.dnRegistration + ":Number of active connections is: "
             + datanode.getXceiverCount());
       }
+      updateCurrentThreadName("Cleaning up");
       IOUtils.closeStream(in);
       IOUtils.closeSocket(s);
       dataXceiverServer.childSockets.remove(s);
@@ -164,6 +181,8 @@ class DataXceiver extends DataTransferPr
             datanode.dnRegistration.getStorageID(), block, "%d")
         : datanode.dnRegistration + " Served block " + block + " to " +
             s.getInetAddress();
+
+    updateCurrentThreadName("Sending block " + block);
     try {
       try {
         blockSender = new BlockSender(block, startOffset, length,
@@ -221,6 +240,7 @@ class DataXceiver extends DataTransferPr
       long newGs, long minBytesRcvd, long maxBytesRcvd,
       String client, DatanodeInfo srcDataNode, DatanodeInfo[] targets,
       Token<BlockTokenIdentifier> blockToken) throws IOException {
+    updateCurrentThreadName("Receiving block " + block + " client=" + client);
 
     if (LOG.isDebugEnabled()) {
       LOG.debug("writeBlock receive buf size " + s.getReceiveBufferSize() +
@@ -429,11 +449,13 @@ class DataXceiver extends DataTransferPr
       }
     }
 
+    updateCurrentThreadName("Reading metadata for block " + block);
     final MetaDataInputStream metadataIn = 
       datanode.data.getMetaDataInputStream(block);
     final DataInputStream checksumIn = new DataInputStream(new BufferedInputStream(
         metadataIn, BUFFER_SIZE));
 
+    updateCurrentThreadName("Getting checksum for block " + block);
     try {
       //read metadata file
       final BlockMetadataHeader header = BlockMetadataHeader.readHeader(checksumIn);
@@ -472,6 +494,7 @@ class DataXceiver extends DataTransferPr
   @Override
   protected void opCopyBlock(DataInputStream in, Block block,
       Token<BlockTokenIdentifier> blockToken) throws IOException {
+    updateCurrentThreadName("Copying block " + block);
     // Read in the header
     if (datanode.isBlockTokenEnabled) {
       try {
@@ -547,6 +570,8 @@ class DataXceiver extends DataTransferPr
   protected void opReplaceBlock(DataInputStream in,
       Block block, String sourceID, DatanodeInfo proxySource,
       Token<BlockTokenIdentifier> blockToken) throws IOException {
+    updateCurrentThreadName("Replacing block " + block + " from " + sourceID);
+
     /* read header */
     block.setNumBytes(dataXceiverServer.estimateBlockSize);
     if (datanode.isBlockTokenEnabled) {



Mime
View raw message