Remote Communication Between Yan'an and Shanghai Underground Party During the Anti-Japanese War

    When ZHUXI (a sensitive word) was leading the National Anti-Japanese War in Yan'an, if Zhou Enlai in Shanghai went to Yan'an for a meeting, then ZHUXI could directly contact Zhou Enlai if he had something to do. But when Zhou Enlai returned to Shanghai, ZHUXI had something to do with Enlai, so how to call it remotely?

    When we first came into contact with java statements, when we introduced classes and objects, we always took real things as examples. For example, fruits are classes, and apples and bananas are objects. In the case of <thinking in java> multi-threaded communication in 21.5.3, it will take a chef and waiter and the production and consumption of meals as an example. So when I see a complex system today, I can still imagine the scenes in my life to compare the various functions and calling relationships of the system. I wonder if there are any that are the same as mine?

    Take the dubbo system analyzed a while ago (source code analysis ), it is a tool for Alibaba to implement SOA governance, and its core function is to implement a remote method call. The main objects involved are invorker, proxy, headExchangeClient, headExchangeServer, headExchangeChanel, headExchangeHandler, nettyClent, nettyServer, nettychannel, nettyhandle, classes of netty itself, and so on. For this complex system, I imagined a scenario: for example, headExchange is a core exchange layer, and it is assumed that one side is the liaison office in Yan'an, and the other side is the Yuelai Inn of the Shanghai Underground Party. And the transmission tool is the post office of the Republic of China, the private security bureau, etc. The main function is to call Comrade Enlai who is far away in Shanghai by ZHUXI. Then the detailed process is as follows:

   As mentioned earlier, if it is a local call, then ZHUXI can directly contact Comrade Enlai. Now we need to make remote calls. We will arrange a senior secretary for ZHUXI. If we ask Enlai to do things, we will directly ask the secretary (proxy) to do it. The secretary realizes all the functions of Enlai. For example, an order note is now issued, "Organize anti-Japanese policy propaganda (parameter: 77 Incident)". After the secretary got the order, he needed to pass it on. The secretary felt that he wouldn't let me go to Shanghai by himself. I needed to use the transmission company or the security bureau of the Republic of China to pass it on. However, it was so complicated and involved too many different types of work. There is still a need for division of labor and cooperation, so let’s just set up a central liaison office, make use of various ready-made transportation resources of the Republic of China, and let Shanghai set up a corresponding department, but the name is changed, and it has to be disguised, it is called “Yuelai” "Inn", the Liaison Office (headExchangeClient) and the Yuelai Inn (headExchangeServer) were born, and two departments were established. It is necessary to deal with the post office or the escort office that can transmit things, and then form a special group under those two departments. One group is called the post group (nettyClient), and the other group is called the escort group (minaClient), with a clear division of labor. Two groups were also set up under the inn, namely the grain and oil group (nettyServer) and the dinner group (minaClient). There is also a post within the Liaison Office, that is, the Senior Correspondent (HeaderExchangeChannel). He is different from the internal correspondent introduced later. The Senior Correspondent (HeaderExchangeChannel) is under the command of the Liaison Office Chief and arranges the work of two team leaders. Now, when the secretary (proxy) needs to send a message, the head of the liaison office (headExchangeClient) will let the senior correspondent handle it after receiving the order, and drink tea while waiting for the message. This is a synchronous call and must wait for the result. Next, the senior correspondent first packaged the information into an internal standard express (response, request), and then arranged for the postal team leader or the escort team leader to send it.

    Take the postal side as an example (netty transmission), but this postal service is different from the current postal service. First of all, he will send a postal courier (jboss.channel) on both sides of the receiving and delivery for the customer to use, and he will let the customer arrange two people (decoder). , encoder) specializes in packaging and unpacking to meet the requirements of express delivery, because any express must be split into small pieces when sent, and when received, it must be restored from small pieces to express, which is amazing. How to disassemble, how to assemble this is the protocol, and http is the protocol. Here we call the dubbo protocol. When it is divided into small pieces, some small pieces will be marked. For example, the first two pieces will be written with the magic code, and whether it will be sent or returned, etc., which is actually splitting and assembling postal services The work of sending and receiving (internal express response, request and postal mailing). In addition, the customer can also arrange a gatekeeper (nettyHandle) to monitor the sending and receiving work of express delivery, or sign for receipt, or return the parcel, etc. Don't worry about the first two people sent to the post office, just pay attention to the news of your gatekeeper.

    The postal team and the grain and oil team need to establish a reliable connection, so they have arranged special personnel, all called nettyChannels. The internal correspondents are under the command of the team leader and are generally on standby. When something happens, they are specially responsible for the postal courier dispatched by the post office. member (jboss.channel). As mentioned earlier, the senior correspondent (HeaderExchangeChannel) is looking for the team leader to send the express. If the postal team leader is found, the postal team leader will wake up the internal correspondent, and the internal correspondent will find the courier to send the item. At this point, the work of sending is done!

​ As for receiving, both the postal team and the grain and oil team have arranged a gatekeeper (nettyHandle) to stand by the door to see if there is any delivery. For example, if a courier is found, it will notify the internal correspondent who usually rests to work, let the internal correspondent remember the name of the courier, hold the express, and then go to the grain and oil team leader (nettyClient) to deal with it. The postal team leader arranges the MultiMessageHandler and HeartbeatHandler (if it is a heartbeat request or response, it will be processed directly) under the group's subordinates. After they have finished processing, if there is further processing, they will be handed over to the inn letter opener (DecodeHandler, This letter opener is different from the letter opener sent to the post office before. The information related to the call is divided and the information is packaged into Invocation) for processing, and then handed over to the confidential staff of Yuelai Inn (HeaderExchangeHandler). ), so the letter opener opened the letter and gave both the letter and the name of the internal correspondent to the confidential officer. The inn letter opener and the inn's confidential staff are arranged by the inn for the team leader, not the team leader's subordinates, because they can also be used by other team leaders.

    HeaderExchangeHandler is an important role, because he masters the core dubbo communication rules. After reading the letter, he will judge the type of the letter, if it is a command (request), if the command is a read-only event (Request. READONLY_EVENT), he just marked the senior correspondent. If it is a shipment that requires a reply, he will find a relevant handler (requestHandle) to handle it. The handler will find a secretary (invoker) according to the serviceKey in the command to tell Comrade Enlai. , Comrade Enlai will really handle it, and the result will be returned to the confidential personnel immediately. The confidential staff immediately wrote a reply (return value), since the letter opener gave the confidential staff the name of the internal correspondent, the confidential staff arranged for the correspondent to send it back. the postman sent it back.

    ​The gatekeeper (nettyHandle) of the Liaison Office in Yan'an is also monitoring the arrival of the courier. When he finds that there is a courier, he also wakes up the internal correspondent and takes the letter to the postal team leader (nettyClient). The MultiMessageHandler also has HeartbeatHandler processing. After they are processed, if they want to continue processing, then they will directly arrange the DecodeHandler and HeaderExchangeHandler assigned to him by the Liaison Office for processing. For the situation just now, HeaderExchangeHandler finds that it is the return of the previous request result, and will notify the secretary who was waiting before, telling him that he can bring the result back to the transaction.

----------------------------------BEGIN---------------- -------------------------

      Finally, briefly summarize the complete process : ​ZHUXI's call is handed over to Enlai's proxy secretary (proxy). The secretary goes to the headExchangeClient to submit a task to the head and wait for the server (DefaultFuture) to notify the result. The division chief handed over the task to the senior correspondent (HeaderExchangeChannel), who packaged it into an internal standard express, and arranged for the postal group leader to send it (nettyClient), who then handed over the task to the internal correspondent (nettyChannel), and the internal correspondent finally contacted the post office express. member (jboss.channel) to handle. The post office will disassemble the express into small squares and send it to Shanghai, where it will be reassembled into the original express. The grain and oil team of the inn in Shanghai arranges a special gatekeeper (nettyHandle) to monitor. When the courier (jboss.channel) delivers the goods, the gatekeeper (nettyHandle) sends the courier to the internal correspondent (let him remember this courier first). name) to the grain and oil team leader for processing. The team leader will let the handlers under him (MultiMessageHandler and HeartbeatHandler) and the handlers arranged by the inn (DecodeHandler and the inn's confidential staff (HeaderExchangeHandler)) process the information in turn, and the internal correspondent will tell you in turn when processing. If he finally arrives at the confidential officer (the internal communicator must first find his corresponding senior communicator, use the advanced one for upward calls, and use the internal one for downward calls), he will then find the relevant handler (requestHandle) for processing (the senior communicator also submits Give it to him) and wait for the result immediately, the latter will find a secretary (invoker) specially to notify Enlai (enlai_Impl) to deal with it. The processing results are in the hands of confidential personnel. After the confidential person gets the result and packs it into an internal express, let the internal correspondent (the lower operator, not the senior correspondent) send it out. The internal correspondent (nettyChannel) finds the courier (jboss.channel) remembered earlier to actually return the result.

        After the post office dismantles the parcel and sends it out, it forms the original parcel list in Yan'an, and then sends it out by the courier there (jboss.channel). Because the postal team over there has arranged a gatekeeper, it will wake up the internal correspondent and ask him to remember the name of the courier, and then hand over the internal correspondent and the courier to the postal team leader. The team leader arranges his handlers (MultiMessageHandler and HeartbeatHandler) and The handlers (DecodeHandler and HeaderExchangeHandler) arranged by the liaison office will process the information in turn, and the internal correspondent will be told to you in turn during processing. If you get to the confidential staff, the internal correspondent must first find the senior correspondent (use the senior correspondent for the upper level, and use the internal one for the lower level), and if it is found to be an internal standard response (response), call the waiter (DefaultFuture) to wake up and send it out. The proxy secretary (proxy) waiting after the instruction, the secretary finally returns the result to ZHUXI.

----------------------------------END--------------- ----------------------------
    ​Confidential officer (HeaderExchangeHandler) and senior correspondent (HeaderExchangeChannel) are two important roles! Links play a key role.

    Described so much, not only to discuss dubbo, but to compare the object-oriented complex system to the real scene. By comparing the calls in dubbo to the calls in Yan'an and Shanghai designed, ​sighs that the level design of the system is reasonable and the personnel calls are scientific. This analogy is also more convenient for me to grasp the essence of this design from a macro perspective. Do you often use analogy to real scenarios to understand other systems?

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326824361&siteId=291194637