HDFS-2454. Move maxXceiverCount check to before starting the thread in dataXceiver. Contributed by Harsh J

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1204124 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2011-11-20 04:27:59 +00:00
parent 513718f92d
commit 8e8bb50afd
3 changed files with 12 additions and 8 deletions

View File

@ -127,6 +127,9 @@ Release 0.23.1 - UNRELEASED
HDFS-2568. Use a set to manage child sockets in XceiverServer.
(harsh via eli)
HDFS-2454. Move maxXceiverCount check to before starting the
thread in dataXceiver. (harsh via eli)
HDFS-2536. Remove unused imports. (harsh via eli)
OPTIMIZATIONS

View File

@ -163,14 +163,6 @@ class DataXceiver extends Receiver implements Runnable {
s.setSoTimeout(stdTimeout);
}
// Make sure the xceiver count is not exceeded
int curXceiverCount = datanode.getXceiverCount();
if (curXceiverCount > dataXceiverServer.maxXceiverCount) {
throw new IOException("xceiverCount " + curXceiverCount
+ " exceeds the limit of concurrent xcievers "
+ dataXceiverServer.maxXceiverCount);
}
opStartTime = now();
processOp(op);
++opsProcessed;

View File

@ -135,6 +135,15 @@ class DataXceiverServer implements Runnable {
try {
s = ss.accept();
s.setTcpNoDelay(true);
// Make sure the xceiver count is not exceeded
int curXceiverCount = datanode.getXceiverCount();
if (curXceiverCount > maxXceiverCount) {
throw new IOException("Xceiver count " + curXceiverCount
+ " exceeds the limit of concurrent xcievers: "
+ maxXceiverCount);
}
new Daemon(datanode.threadGroup, new DataXceiver(s, datanode, this))
.start();
} catch (SocketTimeoutException ignored) {