|
@@ -39,6 +39,7 @@ import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Random;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
@@ -162,7 +163,7 @@ public class DataNode extends Configured
|
|
|
private final Map<Block, Block> ongoingRecovery = new HashMap<Block, Block>();
|
|
|
private LinkedList<String> delHints = new LinkedList<String>();
|
|
|
public final static String EMPTY_DEL_HINT = "";
|
|
|
- int xmitsInProgress = 0;
|
|
|
+ AtomicInteger xmitsInProgress = new AtomicInteger();
|
|
|
Daemon dataXceiverServer = null;
|
|
|
ThreadGroup threadGroup = null;
|
|
|
long blockReportInterval;
|
|
@@ -702,7 +703,7 @@ public class DataNode extends Configured
|
|
|
data.getCapacity(),
|
|
|
data.getDfsUsed(),
|
|
|
data.getRemaining(),
|
|
|
- xmitsInProgress,
|
|
|
+ xmitsInProgress.get(),
|
|
|
getXceiverCount());
|
|
|
myMetrics.heartbeats.inc(now() - startTime);
|
|
|
//LOG.info("Just sent heartbeat, with name " + localName);
|
|
@@ -1109,7 +1110,7 @@ public class DataNode extends Configured
|
|
|
* Do the deed, write the bytes
|
|
|
*/
|
|
|
public void run() {
|
|
|
- xmitsInProgress++;
|
|
|
+ xmitsInProgress.getAndIncrement();
|
|
|
Socket sock = null;
|
|
|
DataOutputStream out = null;
|
|
|
BlockSender blockSender = null;
|
|
@@ -1158,10 +1159,10 @@ public class DataNode extends Configured
|
|
|
LOG.warn(dnRegistration + ":Failed to transfer " + b + " to " + targets[0].getName()
|
|
|
+ " got " + StringUtils.stringifyException(ie));
|
|
|
} finally {
|
|
|
+ xmitsInProgress.getAndDecrement();
|
|
|
IOUtils.closeStream(blockSender);
|
|
|
IOUtils.closeStream(out);
|
|
|
IOUtils.closeSocket(sock);
|
|
|
- xmitsInProgress--;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1290,7 +1291,7 @@ public class DataNode extends Configured
|
|
|
"data=" + data +
|
|
|
", localName='" + dnRegistration.getName() + "'" +
|
|
|
", storageID='" + dnRegistration.getStorageID() + "'" +
|
|
|
- ", xmitsInProgress=" + xmitsInProgress +
|
|
|
+ ", xmitsInProgress=" + xmitsInProgress.get() +
|
|
|
"}";
|
|
|
}
|
|
|
|