HDFS-3880. Use Builder to build RPC server in HDFS. Contributed by Brandon Li and Junping Du

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1507579 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2013-07-27 06:23:56 +00:00
parent f888ffbf17
commit e20cd46dea
5 changed files with 36 additions and 20 deletions

View File

@ -263,6 +263,9 @@ Release 2.1.0-beta - 2013-07-02
HDFS-5024. Make DatanodeProtocol#commitBlockSynchronization idempotent. HDFS-5024. Make DatanodeProtocol#commitBlockSynchronization idempotent.
(Arpit Agarwal via jing9) (Arpit Agarwal via jing9)
HDFS-3880. Use Builder to build RPC server in HDFS.
(Brandon Li and Junping Du via szetszwo)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-4465. Optimize datanode ReplicasMap and ReplicaInfo. (atm) HDFS-4465. Optimize datanode ReplicasMap and ReplicaInfo. (atm)

View File

@ -450,10 +450,15 @@ public class DataNode extends Configured
new ClientDatanodeProtocolServerSideTranslatorPB(this); new ClientDatanodeProtocolServerSideTranslatorPB(this);
BlockingService service = ClientDatanodeProtocolService BlockingService service = ClientDatanodeProtocolService
.newReflectiveBlockingService(clientDatanodeProtocolXlator); .newReflectiveBlockingService(clientDatanodeProtocolXlator);
ipcServer = RPC.getServer(ClientDatanodeProtocolPB.class, service, ipcAddr ipcServer = new RPC.Builder(conf)
.getHostName(), ipcAddr.getPort(), conf.getInt( .setProtocol(ClientDatanodeProtocolPB.class)
DFS_DATANODE_HANDLER_COUNT_KEY, DFS_DATANODE_HANDLER_COUNT_DEFAULT), .setInstance(service)
false, conf, blockPoolTokenSecretManager); .setBindAddress(ipcAddr.getHostName())
.setPort(ipcAddr.getPort())
.setNumHandlers(
conf.getInt(DFS_DATANODE_HANDLER_COUNT_KEY,
DFS_DATANODE_HANDLER_COUNT_DEFAULT)).setVerbose(false)
.setSecretManager(blockPoolTokenSecretManager).build();
InterDatanodeProtocolServerSideTranslatorPB interDatanodeProtocolXlator = InterDatanodeProtocolServerSideTranslatorPB interDatanodeProtocolXlator =
new InterDatanodeProtocolServerSideTranslatorPB(this); new InterDatanodeProtocolServerSideTranslatorPB(this);

View File

@ -220,12 +220,15 @@ class NameNodeRpcServer implements NamenodeProtocols {
int serviceHandlerCount = int serviceHandlerCount =
conf.getInt(DFS_NAMENODE_SERVICE_HANDLER_COUNT_KEY, conf.getInt(DFS_NAMENODE_SERVICE_HANDLER_COUNT_KEY,
DFS_NAMENODE_SERVICE_HANDLER_COUNT_DEFAULT); DFS_NAMENODE_SERVICE_HANDLER_COUNT_DEFAULT);
this.serviceRpcServer = this.serviceRpcServer = new RPC.Builder(conf)
RPC.getServer(org.apache.hadoop.hdfs.protocolPB. .setProtocol(
ClientNamenodeProtocolPB.class, clientNNPbService, org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB.class)
serviceRpcAddr.getHostName(), serviceRpcAddr.getPort(), .setInstance(clientNNPbService)
serviceHandlerCount, .setBindAddress(serviceRpcAddr.getHostName())
false, conf, namesystem.getDelegationTokenSecretManager()); .setPort(serviceRpcAddr.getPort()).setNumHandlers(serviceHandlerCount)
.setVerbose(false)
.setSecretManager(namesystem.getDelegationTokenSecretManager())
.build();
// Add all the RPC protocols that the namenode implements // Add all the RPC protocols that the namenode implements
DFSUtil.addPBProtocol(conf, HAServiceProtocolPB.class, haPbService, DFSUtil.addPBProtocol(conf, HAServiceProtocolPB.class, haPbService,
@ -248,11 +251,13 @@ class NameNodeRpcServer implements NamenodeProtocols {
serviceRPCAddress = null; serviceRPCAddress = null;
} }
InetSocketAddress rpcAddr = nn.getRpcServerAddress(conf); InetSocketAddress rpcAddr = nn.getRpcServerAddress(conf);
this.clientRpcServer = RPC.getServer( this.clientRpcServer = new RPC.Builder(conf)
org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB.class, .setProtocol(
clientNNPbService, rpcAddr.getHostName(), org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB.class)
rpcAddr.getPort(), handlerCount, false, conf, .setInstance(clientNNPbService).setBindAddress(rpcAddr.getHostName())
namesystem.getDelegationTokenSecretManager()); .setPort(rpcAddr.getPort()).setNumHandlers(handlerCount)
.setVerbose(false)
.setSecretManager(namesystem.getDelegationTokenSecretManager()).build();
// Add all the RPC protocols that the namenode implements // Add all the RPC protocols that the namenode implements
DFSUtil.addPBProtocol(conf, HAServiceProtocolPB.class, haPbService, DFSUtil.addPBProtocol(conf, HAServiceProtocolPB.class, haPbService,

View File

@ -80,9 +80,11 @@ public class TestClientProtocolWithDelegationToken {
DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT, DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT,
3600000, mockNameSys); 3600000, mockNameSys);
sm.startThreads(); sm.startThreads();
final Server server = RPC.getServer(ClientProtocol.class, mockNN, ADDRESS, final Server server = new RPC.Builder(conf)
0, 5, true, conf, sm); .setProtocol(ClientProtocol.class).setInstance(mockNN)
.setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
.setSecretManager(sm).build();
server.start(); server.start();
final UserGroupInformation current = UserGroupInformation.getCurrentUser(); final UserGroupInformation current = UserGroupInformation.getCurrentUser();

View File

@ -232,8 +232,9 @@ public class TestBlockToken {
ProtobufRpcEngine.class); ProtobufRpcEngine.class);
BlockingService service = ClientDatanodeProtocolService BlockingService service = ClientDatanodeProtocolService
.newReflectiveBlockingService(mockDN); .newReflectiveBlockingService(mockDN);
return RPC.getServer(ClientDatanodeProtocolPB.class, service, ADDRESS, 0, 5, return new RPC.Builder(conf).setProtocol(ClientDatanodeProtocolPB.class)
true, conf, sm); .setInstance(service).setBindAddress(ADDRESS).setPort(0)
.setNumHandlers(5).setVerbose(true).setSecretManager(sm).build();
} }
@Test @Test