Windows环境下大数据处理的构想(一)(2)
?@Override } public class WCServer { ?public static void main(String[] args) throws RemoteException,MalformedURLException { } public class WCClient { ?public static void main(String[] args) throws MalformedURLException,RemoteException,NotBoundException {??// 在注册的服务中根据url寻找服务??WCService? wcService = (WCService) Naming.lookup(Constants.WCCount_RMI);??Map<String,Integer> wordCount = wcService.wordCount("X:/xxx/words.txt"," ");??for(String? k : wordCount.keySet()) {???System.out.println(k + "\t" + wordCount.get(k));??}?}}当然这里为了简单起见,我们把代码写死了,在实际的大数据处理框架中处理逻辑是由用户完成的。我们只需要提供接口,而且第一步先进行数据映射,即map阶段,第二步才是聚合统计reduce/aggregate,中间还有shuffle,最开始还有split。这里只是为了说明RMI在Windows中可以轻易、方便地使用。有了RMI,我们一开始的数据存储和处理逻辑就可以分布在分布式环境中了;有了RMI,我们的数据和处理逻辑就可以“自由”地在节点间“旅行”了。这构成了大数据处理框架的基础。千里之行,始于足下。借鉴hadoop和spark,我们应该先搭建RPC环境。RMI使用起来太麻烦,而且功能有限,现实中的大数据框架从未真正使用过RMI,而是使用对它的封装和改良,比如说Netty。下一节我们介绍Netty,并逐渐用Netty搭建起RPC环境。学识有限,描述错误、不周的地方,还望各位技术大佬批评指正。这一节主要论述了在windows环境下处理大数据的可能性。 (编辑:ASP站长网) |