Home Database Mysql Tutorial 解析MapReduce原理–笔记(9)hadoopRPC基础

解析MapReduce原理–笔记(9)hadoopRPC基础

Jun 07, 2016 pm 04:32 PM
mapreduce principle notes parse

基本概念 模块 RPC 通常采用客户机/服务器模型。请求程序是客户机,服务提供程序则是一个服务器。包括以下几个模块 通信模块:两个相互协作的通信模块实现请求-应答协议。同步方式和异步方式。 Stub程序:客户端和服务器端均包含Stub程序,代理程序。它使得

基本概念
模块
RPC通常采用客户机/服务器模型。请求程序是客户机,服务提供程序则是一个服务器。包括以下几个模块
通信模块:两个相互协作的通信模块实现请求-应答协议。同步方式和异步方式。
Stub程序:客户端和服务器端均包含Stub程序,代理程序。它使得远程函数调用表现的跟本地调用一样,对用户程序完全透明。
在客户端,它表现的就像一个本地程序,但不直接执行本地调用,而是将请求信息通过网络模块发送给服务器端。
在服务器端,解码请求消息中的参数,调用相应的服务过程和编码应答结果的返回值。
调度程序:接收来自通信模块的请求消息,并根据其中的标识选择一个Stub程序处理。线程池处理。
客户程序/服务过程:请求的发出者和请求的处理者。
步骤
1.客户程序以本地方式调用系统产生的Stub程序。
2.该Stub程序将函数调用信息按照网络通信模块的要求封装成消息包。并交给通信模块发送到远程服务器端。
3.远程服务器端接收此消息后,将此消息发送给相应的Stub程序。
4.Stub程序拆封消息,形成被调过程要求的形式,并调用对应的函数。
5.被调用函数按照所获参数执行,并将结果返回给Stub程序。
6.Stub程序将此结果封装成消息,通过网络通信模块逐级地传送给客户程序。

HadoopRPC
接口:

public static VersionedProtocol getProxy/waitForProxy():构造一个客户端代理对象,用于向服务器发送RPC请求。public static Server getServer():为某个协议示例构造一个服务器对象,用于处理客户端发送的请求。
Copy after login

步骤:
1.定义RPC协议。RPC协议是客户端与服务器端之间的通信接口,它定义了服务器端对外提供的服务接口。interface ClientProtocol extends org.apache.hadoop.ipc.VersionedProtocol{public static final long versionID=1L;String echo(String value) throws IOException;int add(int v1,int v2) throws IOException;}2.实现RPC协议。public static class ClientProtocolImpl implements ClientProtocl{public long getProtocolVersion(String protocol,long clientVersion){return ClientProtocol.versionID ;}public String echo(String value) throws IOException{return value;}public int add(int v1,int v2) throws IOException{return v1+v2;}}3.构造并启动RPC Serverserver = RPC.getServer(new ClientProtocolImpl(),serverHost,serverPort,numHandlers,false,conf);//numHandlers表示服务器端处理请求的线程数目。server.start();4.构造RPC Client,并发送RPC请求。proxy = (ClientProtocol)RPC.getProxy(ClientProtocol.class,ClientProtocol.versionID,addr,conf);int result = proxy.add(4,5);String echoResult = proxy.echo("hello");
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
How to delete Xiaohongshu notes How to delete Xiaohongshu notes Mar 21, 2024 pm 08:12 PM

How to delete Xiaohongshu notes? Notes can be edited in the Xiaohongshu APP. Most users don’t know how to delete Xiaohongshu notes. Next, the editor brings users pictures and texts on how to delete Xiaohongshu notes. Tutorial, interested users come and take a look! Xiaohongshu usage tutorial How to delete Xiaohongshu notes 1. First open the Xiaohongshu APP and enter the main page, select [Me] in the lower right corner to enter the special area; 2. Then in the My area, click on the note page shown in the picture below , select the note you want to delete; 3. Enter the note page, click [three dots] in the upper right corner; 4. Finally, the function bar will expand at the bottom, click [Delete] to complete.

What should I do if the notes I posted on Xiaohongshu are missing? What's the reason why the notes it just sent can't be found? What should I do if the notes I posted on Xiaohongshu are missing? What's the reason why the notes it just sent can't be found? Mar 21, 2024 pm 09:30 PM

As a Xiaohongshu user, we have all encountered the situation where published notes suddenly disappeared, which is undoubtedly confusing and worrying. In this case, what should we do? This article will focus on the topic of "What to do if the notes published by Xiaohongshu are missing" and give you a detailed answer. 1. What should I do if the notes published by Xiaohongshu are missing? First, don't panic. If you find that your notes are missing, staying calm is key and don't panic. This may be caused by platform system failure or operational errors. Checking release records is easy. Just open the Xiaohongshu App and click "Me" → "Publish" → "All Publications" to view your own publishing records. Here you can easily find previously published notes. 3.Repost. If found

Detailed explanation of Oracle error 3114: How to solve it quickly Detailed explanation of Oracle error 3114: How to solve it quickly Mar 08, 2024 pm 02:42 PM

Detailed explanation of Oracle error 3114: How to solve it quickly, specific code examples are needed. During the development and management of Oracle database, we often encounter various errors, among which error 3114 is a relatively common problem. Error 3114 usually indicates a problem with the database connection, which may be caused by network failure, database service stop, or incorrect connection string settings. This article will explain in detail the cause of error 3114 and how to quickly solve this problem, and attach the specific code

Analysis of the function and principle of nohup Analysis of the function and principle of nohup Mar 25, 2024 pm 03:24 PM

Analysis of the role and principle of nohup In Unix and Unix-like operating systems, nohup is a commonly used command that is used to run commands in the background. Even if the user exits the current session or closes the terminal window, the command can still continue to be executed. In this article, we will analyze the function and principle of the nohup command in detail. 1. The role of nohup: Running commands in the background: Through the nohup command, we can let long-running commands continue to execute in the background without being affected by the user exiting the terminal session. This needs to be run

How to add product links in notes in Xiaohongshu Tutorial on adding product links in notes in Xiaohongshu How to add product links in notes in Xiaohongshu Tutorial on adding product links in notes in Xiaohongshu Mar 12, 2024 am 10:40 AM

How to add product links in notes in Xiaohongshu? In the Xiaohongshu app, users can not only browse various contents but also shop, so there is a lot of content about shopping recommendations and good product sharing in this app. If If you are an expert on this app, you can also share some shopping experiences, find merchants for cooperation, add links in notes, etc. Many people are willing to use this app for shopping, because it is not only convenient, but also has many Experts will make some recommendations. You can browse interesting content and see if there are any clothing products that suit you. Let’s take a look at how to add product links to notes! How to add product links to Xiaohongshu Notes Open the app on the desktop of your mobile phone. Click on the app homepage

Parsing Wormhole NTT: an open framework for any Token Parsing Wormhole NTT: an open framework for any Token Mar 05, 2024 pm 12:46 PM

Wormhole is a leader in blockchain interoperability, focused on creating resilient, future-proof decentralized systems that prioritize ownership, control, and permissionless innovation. The foundation of this vision is a commitment to technical expertise, ethical principles, and community alignment to redefine the interoperability landscape with simplicity, clarity, and a broad suite of multi-chain solutions. With the rise of zero-knowledge proofs, scaling solutions, and feature-rich token standards, blockchains are becoming more powerful and interoperability is becoming increasingly important. In this innovative application environment, novel governance systems and practical capabilities bring unprecedented opportunities to assets across the network. Protocol builders are now grappling with how to operate in this emerging multi-chain

Analysis of the meaning and usage of midpoint in PHP Analysis of the meaning and usage of midpoint in PHP Mar 27, 2024 pm 08:57 PM

[Analysis of the meaning and usage of midpoint in PHP] In PHP, midpoint (.) is a commonly used operator used to connect two strings or properties or methods of objects. In this article, we’ll take a deep dive into the meaning and usage of midpoints in PHP, illustrating them with concrete code examples. 1. Connect string midpoint operator. The most common usage in PHP is to connect two strings. By placing . between two strings, you can splice them together to form a new string. $string1=&qu

An in-depth analysis of the functions and working principles of the Linux chage command An in-depth analysis of the functions and working principles of the Linux chage command Feb 24, 2024 pm 03:48 PM

The chage command in the Linux system is a command used to modify the password expiration date of a user account. It can also be used to modify the longest and shortest usable date of the account. This command plays a very important role in managing user account security. It can effectively control the usage period of user passwords and enhance system security. How to use the chage command: The basic syntax of the chage command is: chage [option] user name. For example, to modify the password expiration date of user "testuser", you can use the following command

See all articles