Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3588,6 +3588,11 @@ public int getNumReaders() {
return readThreads;
}

@VisibleForTesting
public int getHandlerCount() {
return handlerCount;
}

/**
* When the read or write buffer size is larger than this limit, i/o will be
* done in chunks of this size. Most RPC requests and responses would be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ public NameNodeRpcServer(Configuration conf, NameNode nn)
DFS_NAMENODE_LIFELINE_HANDLER_RATIO_DEFAULT);
lifelineHandlerCount = Math.max(
(int)(handlerCount * lifelineHandlerRatio), 1);
handlerCount = handlerCount - lifelineHandlerCount;
}
lifelineRpcServer = new RPC.Builder(conf)
.setProtocol(HAServiceProtocolPB.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.MiniDFSCluster;

Expand Down Expand Up @@ -59,5 +60,30 @@ public void testNamenodeRpcBindAny() throws IOException {
conf.unset(DFS_NAMENODE_RPC_BIND_HOST_KEY);
}
}

@Test
public void testLifelineHandlerCount() throws IOException {
Configuration conf = new HdfsConfiguration();
conf.set(DFSConfigKeys.DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY, "0.0.0.0:0");
conf.setInt(DFSConfigKeys.DFS_NAMENODE_HANDLER_COUNT_KEY, 20);
conf.setInt(DFSConfigKeys.DFS_NAMENODE_LIFELINE_HANDLER_COUNT_KEY, -1);

MiniDFSCluster cluster = null;
try {
cluster = new MiniDFSCluster.Builder(conf).build();
cluster.waitActive();
int lifeHandlerCount = ((NameNodeRpcServer)cluster.getNameNodeRpc())
.getLifelineRpcServer().getHandlerCount();
assertEquals(2, lifeHandlerCount);

int clientHandlerCount = ((NameNodeRpcServer)cluster.getNameNodeRpc())
.getClientRpcServer().getHandlerCount();
assertEquals(18, clientHandlerCount);
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
}