Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the Hadoop RPC reflection mechanism

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to understand the Hadoop RPC reflection mechanism". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand the Hadoop RPC reflection mechanism".

With Client and Server, it's natural to RPC. It's RPC.java 's turn next.

In general, distributed objects generally require stubs and frameworks to be generated based on the interface. CORBA, for example, can generate stubs and frames through IDL. But, in

Org.apache.hadoop.rpc, we don't need such a step. On the class diagram.

In order to analyze Invoker, we need to introduce some background of Java reflection implementing Dynamic Proxy.

Dynamic Proxy is implemented by two class: java.lang.reflect.Proxy and java.lang.reflect.InvocationHandler, which is a

Interface. The so-called Dynamic Proxy is a kind of class: it is a class generated at run time, and when you generate it, you must provide it with a set of interface, and then

The class claims that it implements these interface.

This Dynamic Proxy is actually a typical Proxy schema. It will not do any substantive work for you. You must provide a handler when generating its instance.

Let it take over the actual work. This handler, in Hadoop's RPC, is the Invoker object.

We can simply understand that you can generate a class through an interface, and all method calls on this class will be passed to what you passed when you generated the class.

InvocationHandler implementation is in progress.

In Hadoop's RPC, Invoker implements the invoke method of InvocationHandler (the invoke method is also the only method of InvocationHandler).

Invoker will package all the invocation method names, parameter type lists, parameter lists related to this call, and then use the Client we analyzed earlier, through socket

Passed to the server side. That is, any calls you make on the proxy class are sent to a remote server via Client.

Invoker uses Invocation. Invocation encapsulates all the relevant information about a remote call. Its main properties are: methodName, calling method name

ParameterClasses, the type list and parameters of the calling method parameters, the calling method parameters. Note that it implements the Writable interface and can be serialized.

RPC.Server implements org.apache.hadoop.ipc.Server, and you can upgrade an object to a server through RPC. Requests received by the server (via Invocation)

After de-serialization, it becomes the method name, the method parameter list, and the parameter list. With Java reflection, we can call the methods of the corresponding object. The result of the call is returned via socket

Give it back to the client, and after the client unpacks the result, it can return it to the user of Dynamic Proxy.

Thank you for your reading, the above is the content of "how to understand the Hadoop RPC reflection mechanism". After the study of this article, I believe you have a deeper understanding of how to understand the Hadoop RPC reflection mechanism, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report