今天学习了有关RPC的有关知识,RPC(remote procedure call)是一种
远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议。RPC是hadoop构建的基础。在学习的过程中有一个问题困扰了我快一天了,我并没有解决,因此就打算把这个问题放弃,在本文中记录一下。
在网上的一些资料中,我看到他们构建RPC Server端的时候写着这样的代码:
- public class MyServer {
- public static int PORT = 5432;
- public static String IPAddress = "127.0.0.1";
-
- public static void main(String[] args) throws Exception {
- MyProxy proxy = new MyProxy();
- final Server server = RPC.getServer(proxy, IPAddress, PORT, new Configuration());//困扰我的代码
- server.start();
- }
- }
对我产生困扰的是第7行代码,在hadoop1.x中有关RPC的代码中我确实找到了RPC.getServer这个方法。但是在我使用的hadoop2.4.0中我只找到了:
- /**
- * Construct a server for a protocol implementation instance.
- *
- * @param protocol the class of protocol to use
- * @param instance the instance of protocol whose methods will be called
- * @param conf the configuration to use
- * @param bindAddress the address to bind on to listen for connection
- * @param port the port to listen for connections on
- * @param numHandlers the number of method handler threads to run
- * @param numReaders the number of reader threads to run
- * @param queueSizePerHandler the size of the queue per hander thread
- * @param verbose whether each call should be logged
- * @param secretManager The secret manager to use to validate incoming requests.
- * @param portRangeConfig A config parameter that can be used to restrict
- * the range of ports used when port is 0 (an ephemeral port)
- * @return The Server instance
- * @throws IOException on any error
- */
- RPC.Server getServer(Class<?> protocol, Object instance, String bindAddress,
- int port, int numHandlers, int numReaders,
- int queueSizePerHandler, boolean verbose,
- Configuration conf,
- SecretManager<? extends TokenIdentifier> secretManager,
- String portRangeConfig
- ) throws IOException;
-
-
我并没有看明白这里的东西,测试代码没有写成功,希望路过的大神可以教我在hadoop2.x中构建RPC Server端。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29876573/viewspace-1813631/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29876573/viewspace-1813631/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)