Cross-cloud forwarding method, device and equipment and computer readable storage medium
By introducing the highest priority servlet interceptor in the zuul gateway, it is directly forwarded to the private cloud gateway based on the identification information of the access request, solving the problem that the zuul gateway cannot forward directly across the cloud, and achieving efficient resource utilization and simplified cross-cloud forwarding process.
Patent Information
- Application Number
- CN202410103961.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-24
- Publication Date
- 2025-07-25
AI Technical Summary
The existing zuul gateway cannot directly forward to the private cloud based on the requested information, resulting in complex cross-cloud forwarding mode and high resource consumption.
The highest priority servlet interceptor is introduced into the zuul gateway, which is directly generated and forwarded to the gateway of the private cloud by parsing the identification information in the access request, avoiding redirection through the platform cloud's micro-server.
The cross-cloud forwarding process is simplified, resource consumption and development and maintenance difficulties are reduced, and computing power is enjoyed with a unified entrance.
Smart Images

Figure CN120378484A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and in particular, to a cross-cloud forwarding method, apparatus, device, and computer-readable storage medium. Background Art
[0002] With the continuous development of cloud services, users' requirements have become more diverse. While maintaining a unified entry, it is also necessary to ensure exclusive access to cloud computing power without being affected by other customers. For exclusive access to computing power, users generally require independent deployment or private deployment, that is, users complete requests by accessing a private cloud, and maintaining a unified entry requires the gateway service to have the ability to forward requests to their respective clouds according to different users.
[0003] In related technologies, taking the zuul gateway (zuul is a microservice gateway in spring cloud) as an example, when the gateway service forwards Hyper Text Transfer Protocol (Http) requests to a cloud that is independently deployed or privately deployed, it needs to be distinguished according to the identification of the current user. However, the forwarding of the zuul gateway can only forward requests based on the matching of the request path and cannot forward requests based on the information in the request. The above process can be understood as the zuul gateway parses the request path, determines the functional type to which the request belongs, matches the microservice corresponding to the functional type in the cloud platform according to the functional type to which the request belongs (microservices are distinguished by their processing capabilities or functions), and forwards the request to the microservice; the microservice determines whether the request needs to be forwarded to the private cloud according to the information in the request. If so, the microservice forwards the request to the gateway of the private cloud; the zuul gateway cannot directly forward the request to the gateway of the private cloud according to the information in the request. This cross-cloud forwarding mode is relatively complex and consumes more resources. Summary of the Invention
[0004] Embodiments of this application provide a cross-cloud forwarding method, apparatus, device, and computer-readable storage medium, which reduce resource consumption.
[0005] The technical solution of the embodiments of this application is implemented as follows:
[0006] In a first aspect, embodiments of this application provide a cross-cloud forwarding method, which is applied to the gateway of a platform cloud; the method includes: receiving a first access request from a user terminal; where the first access request includes identification information for accessing the cloud; determining that the access target of the first access request is a private cloud according to the identification information for accessing the cloud; in the case where the access target is a private cloud, generating a second access request according to the first access request; and directly sending the second access request to the gateway of the private cloud.
[0007] In a second aspect, an embodiment of the present application provides a cross-cloud forwarding device, which is applied to the gateway of the platform cloud; the device includes at least one interceptor and a forwarding component; the interceptor with the highest priority among the at least one interceptor is configured to receive a first access request from a user terminal; wherein, the first access request includes identification information of the accessed cloud; according to the identification information of the accessed cloud, it is determined that the access target of the first access request is a private cloud; in the case where the access target is a private cloud, a second access request is generated according to the first access request; the forwarding component is configured to directly send the second access request to the gateway of the private cloud.
[0008] In a third aspect, an embodiment of the present application provides a cross-cloud forwarding device, which includes: a memory for storing an executable computer program; a processor for implementing the cross-cloud forwarding method described in the first aspect when executing the executable computer program stored in the memory.
[0009] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which is used to implement the cross-cloud forwarding method described in the first aspect when being executed by a processor.
[0010] An embodiment of the present application provides a cross-cloud forwarding method, device, equipment and computer-readable storage medium. According to the solution provided by the embodiment of the present application, the method is applied to the gateway of the platform cloud; the method includes: receiving a first access request from a user terminal; wherein, the first access request includes identification information of the accessed cloud; according to the identification information of the accessed cloud, it is determined that the access target of the first access request is a private cloud; in the case where the access target is a private cloud, a second access request is generated according to the first access request; the second access request is directly sent to the gateway of the private cloud. The underlying servlet interceptor of the gateway of the cloud platform (for example, zuul gateway) will be executed before the interceptor of the zuul gateway itself. As the interceptor with the highest priority, it can receive the first access request preferentially. By adding this method to the zuul gateway in the present application, based on the servlet interceptor receiving the first access request, the identification information of the accessed cloud in the first access request can be obtained, so as to determine whether the user terminal wants to access a private cloud. If so, a second access request is regenerated based on the first access request, and then the second access request is directly sent to the gateway of the private cloud, without forwarding through the micro server of the platform cloud, that is, without transit, and the request is directly forwarded to the gateway of the private cloud. When the present application determines whether the user terminal wants to access a private cloud, the zuul gateway does not need to forward the request to the micro server of the cloud platform, nor does the micro server of the cloud platform need to forward the request. The cross-cloud forwarding mode is simple, reducing resource consumption. Description of the Drawings
[0011] Figure 1A schematic diagram of an interaction process provided by an embodiment of the present application;
[0012] Figure 2 An optional step flowchart of a cross-cloud forwarding method provided by an embodiment of the present application;
[0013] Figure 3 An optional step flowchart of another cross-cloud forwarding method provided by an embodiment of the present application;
[0014] Figure 4 An optional step flowchart of yet another cross-cloud forwarding method provided by an embodiment of the present application;
[0015] Figure 5 An optional step flowchart of still another cross-cloud forwarding method provided by an embodiment of the present application;
[0016] Figure 6 A schematic diagram of another interaction process provided by an embodiment of the present application;
[0017] Figure 7 An optional structural schematic diagram of a cross-cloud forwarding device provided by an embodiment of the present application;
[0018] Figure 8 A schematic diagram of the composition structure of a cross-cloud forwarding device provided by an embodiment of the present application. Detailed implementation manners
[0019] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. It should be understood that some of the embodiments described herein are only used to explain the technical solutions of the present application and do not limit the technical scope of the present application.
[0020] To better understand the cross-cloud forwarding method provided in the embodiments of the present application, before introducing the technical solutions of the embodiments of the present application, the application background and related technologies will be described first.
[0021] The current mainstream implementation mode in the cloud is the microservices mode, and the popular development framework is the Spring Cloud development framework for the cloud. The microservices development framework of Spring Cloud mainly includes gateway services, registry center services, specific services for business implementation, and the functions of the Feign component (a functional component that can process requests), etc. Among them, the gateway service can be used as the API Gateway in the microservices architecture. The API Gateway is a microservices gateway that can achieve high-performance Http forwarding, multi-tenant management, API access permission control, etc., and supports dynamic routing and filtering functions. The API Gateway provides a unified access entry (which can also be called an interface Interface) for the services in the microservices architecture. The user side first sends an Http request to the gateway service, and the gateway service forwards the request to the specific microservices for processing.
[0022] When the gateway service forwards the Http request to the independently deployed or privately deployed cloud, it needs to be distinguished according to the belonging identifier of the current user. However, the forwarding of the zuul gateway can only be based on the request path matching for request forwarding and cannot be based on the information in the request. That is to say, the zuul gateway needs to forward the request to the corresponding microservice according to the function type corresponding to the request (which can also be understood as the request path), and then the microservice determines that the user side requests to access the private cloud according to the information in the request, and the microservice forwards the request to the gateway of the private cloud. In such a situation, it becomes very difficult to achieve such a forwarding requirement.
[0023] To achieve the above forwarding effect, what those skilled in the art can think of is to process in the proxy layer (for example, the nginx component). However, the user identifier belongs to encrypted information and is usually stored in an encrypted string, and the nginx component cannot complete decryption. The nginx component is a web server and can be used for load balancing and reverse proxy. Nginx is written in the C language, and a C language running environment needs to be installed when running nginx; Zuul is implemented in the Java language and mainly provides gateway services for Java services. That is to say, the nginx component is a component before the entire zuul gateway. Before the request reaches the zuul gateway to execute complex forwarding logic, the nginx component receives the request. However, the identification information about the cloud environment is encrypted information, and the nginx component before the zuul gateway cannot decrypt it. Therefore, the solution of using the nginx component for cross-cloud forwarding does not work.
[0024] To achieve the above forwarding effect, those skilled in the art may also think of: relying on the microservices that process requests to complete request redistribution through the Feign component according to the information in the request. In this mode, the Feign component is behind the zuul gateway. The Feign component is a component in the microservices. It requires the zuul gateway in the cloud platform to forward the request to the corresponding microservice according to the function type corresponding to the request, and then the Feign component in the microservice forwards the request to the gateway of the private cloud.
[0025] Exemplarily, as Figure 1 shown, Figure 1 FIG. is a schematic diagram of an interaction process provided by an embodiment of the present application. The cross-cloud forwarding process in related technologies is described from the interaction process among the terminal, the cloud platform, and the private cloud. If the request initiated by the terminal (i.e., the user side) is for platform cloud user access, the request initiated by the user side is sent to the gateway (Gateway) of the platform cloud. The Gateway forwards the request to the corresponding microservice according to the function type corresponding to the request ( Figure 1 illustrated by taking microservice 1 in the platform cloud as an example). If the request initiated by the terminal is for private cloud user access, the request initiated by the user side is first sent to the gateway (Gateway) of the platform cloud. In the first scenario: the Gateway forwards the request to the corresponding microservice according to the function type corresponding to the request ( Figure 1 illustrated by taking microservice 1 in the platform cloud as an example), and then microservice 1 in the platform cloud determines that it needs to forward to the private cloud. Microservice 1 in the platform cloud forwards the request to the gateway (Gateway) of the private cloud, and then the Gateway forwards the request to the corresponding microservice according to the function type corresponding to the request ( Figure 1 illustrated by taking microservice 1 in the private cloud as an example); in the second scenario: the Gateway forwards the request to the corresponding microservice according to the function type corresponding to the request ( Figure 1 illustrated by taking microservice 2 in the platform cloud as an example), and then microservice 2 in the platform cloud determines that it needs to forward to the private cloud. Microservice 2 in the platform cloud forwards the request to the gateway (Gateway) of the private cloud, and then the Gateway forwards the request to the corresponding microservice according to the function type corresponding to the request ( Figure 1 illustrated by taking microservice 2 in the private cloud as an example).
[0026] The above Figure 1 forwarding mode is not only complex but also resource-consuming. Since this distribution logic is scattered in many microservices, a Feign component for forwarding requests needs to be configured in each microservice, which also makes the maintenance work extremely difficult.
[0027] The client in the embodiments of the present application, that is, the terminal, is set as a terminal device that communicates through a wireless interface, and can be referred to as a "wireless communication terminal", "wireless terminal" or "mobile terminal". Examples of mobile terminals include, but are not limited to, satellite or cellular phones; personal communication system (PCS) terminals that can combine cellular radio telephones with data processing, fax, and data communication capabilities; personal digital assistants (PDAs) that can include radio telephones, pagers, Internet / intranet access, web browsers, notebooks, calendars, and / or global positioning system (GPS) receivers; and conventional laptop and / or palm receivers or other electronic devices including radio telephone transceivers. A terminal can refer to an access terminal, user equipment (UE), user unit, user station, mobile station, mobile unit, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent, or user device. An access terminal can be a cellular phone, cordless phone, session initiation protocol (SIP) phone, wireless local loop (WLL) station, mobile phone, laptop computer, tablet computer, e-book, game console, PDA, a handheld device with wireless communication function, a computing device or other processing devices connected to a wireless modem, in-vehicle device, wearable device, a terminal in a fifth generation mobile communication technology (5G) network, or a terminal in a future evolved public land mobile network (PLMN), etc.
[0028] An embodiment of the present application provides a cross-cloud forwarding method, which is applied to the gateway of the platform cloud; as Figure 2 shown, Figure 2 is a flowchart of the steps of a cross-cloud forwarding method provided by an embodiment of the present application. The cross-cloud forwarding method includes the following steps:
[0029] S101. Receive a first access request from the client; wherein, the first access request includes identification information of the accessed cloud.
[0030] In the embodiments of the present application, whether the client is a platform cloud user or a private cloud user, the first access request initiated by the client needs to be sent to the gateway of the platform cloud first, so that the gateway of the platform cloud receives the first access request of the client. The first access request carries the permission identifier of the client, and the permission identifier is used to represent whether the cloud that the client can access is the platform cloud (the platform cloud can also be called the public cloud) or the private cloud. Exemplarily, the first access request may carry the identification information of the accessed cloud (the identification information of the accessed cloud can represent the permission identifier of the client), and the identification information of the accessed cloud can also be called the identification information of the cloud environment, and the cloud environment includes the platform cloud and the private cloud.
[0031] In the embodiments of the present application, the first access request may be an Http request.
[0032] In the embodiments of the present application, taking the gateway of the platform cloud as the zuul gateway as an example, the zuul gateway itself includes multiple interceptors. In the related art, after the zuul gateway receives the request of the client, the interceptors at all levels execute their corresponding functions, so as to allocate the request to the microservices in the platform cloud that match its function type. For example, some requests are for requesting payment orders and are allocated to the microservices with payment functions, and some requests are for searching and are allocated to the microservices with search functions. Each level of interceptor needs to be executed, consuming resources and reducing the processing efficiency. In the present application, this method is added to the zuul gateway. This method is based on the servlet interceptor, and the servlet interceptor is the underlying interceptor and the interceptor with the highest priority, and will be executed before the interceptors of zuul itself. This solution is implemented based on the underlying servlet interceptor technology of the zuul gateway of SpringCloud. Since the underlying servlet interceptor of the zuul gateway will be executed before the interceptors of the zuul gateway itself, as the interceptor with the highest priority, it can receive the first access request initiated by the client first and obtain the identification information of the accessed cloud in the first access request.
[0033] S102. Determine that the access target of the first access request is the private cloud according to the identification information of the accessed cloud.
[0034] In an embodiment of the present application, after the gateway of the platform cloud receives a first access request, it determines whether the user end is a cloud platform user or a private cloud user according to the identification information of the accessed cloud carried in the first access request. The above determination process can be implemented through the following two examples. The first example: When a forwarding target (which can be understood as the private cloud to be forwarded) is obtained according to the identification information of the accessed cloud carried in the first access request, it indicates that the access target of the first access request is a private cloud. When no forwarding target is obtained according to the identification information of the accessed cloud carried in the first access request, it indicates that the access target of the first access request is a public cloud. The access target being a private cloud can also be understood as accessing a cloud service with independent deployment or private deployment. The second example: The identification information of the accessed cloud can be the identification information of the platform cloud or the identification information of the private cloud. Directly according to the corresponding relationship set in advance between the identification information of the accessed cloud, it is determined whether the access target of the first access request is a private cloud or a public cloud.
[0035] Exemplarily, taking the identification information of the private cloud as "Private Cloud" and the gateway of the platform cloud as the zuul gateway as an example, the underlying servlet interceptor of the zuul gateway obtains "Private Cloud" according to the identification information of the accessed cloud, and determines that the user end is a private cloud user and the access target of the first access request is a private cloud. When the underlying servlet interceptor of the zuul gateway does not obtain "Private Cloud" according to the identification information of the accessed cloud, it determines that the user end is a platform cloud user and the access target of the first access request is the platform cloud.
[0036] Exemplarily, taking the identification information of the platform cloud as "Public Cloud", the identification information of the private cloud as "Private Cloud", and the gateway of the platform cloud as the zuul gateway as an example, when the identification information of the accessed cloud is "PrivateCloud", the underlying servlet interceptor of the zuul gateway determines, according to the corresponding relationship set in advance, that the user end is a private cloud user, indicating that the access target of the first access request is a private cloud. When the identification information of the accessed cloud is "Public Cloud", the underlying servlet interceptor of the zuul gateway determines, according to the corresponding relationship set in advance, that the user end is a platform cloud user, indicating that the access target of the first access request is the platform cloud.
[0037] It should be noted that the identification information of the platform cloud can be represented as "0", the identification information of the private cloud is represented as "1", and the identification information of the access cloud can be "1" or "0". The embodiments of the present application do not limit the specific form of the identification information of the access cloud, which can be pre-agreed by the terminal (i.e., the user side) and the gateway of the platform cloud, as long as the platform cloud and the private cloud can be distinguished and the servlet interceptor of the zuul gateway can identify and determine whether the user side is a platform cloud user or a private cloud user. The embodiments of the present application do not limit this.
[0038] In some embodiments, the above S102 can also be implemented in the following manner: match the identification information of the access cloud with a preset configuration rule to determine that the access target of the first access request is the private cloud.
[0039] In the embodiments of the present application, the preset configuration rule represents a request forwarding rule pre-set in the gateway of the platform cloud, and the preset configuration rule can also be referred to as a preset cloud environment configuration rule. The interceptor with the highest priority in the gateway of the platform cloud (for example, the underlying servlet interceptor of the zuul gateway) matches the forwarding target (which can also be understood as the private cloud to be forwarded) according to the identification information of the access cloud and the preset configuration rule, indicating that the access target of the first access request is the private cloud.
[0040] In the embodiments of the present application, by setting the preset configuration rule in the interceptor with the highest priority in the gateway of the platform cloud, after receiving the first access request, it can match the identification information of the access cloud carried in the first access request with the preset configuration rule, and can determine whether the access target of the first access request is the private cloud. It is not necessary for the interceptors level by level in the gateway of the platform cloud to execute their corresponding functions and allocate the request to the microservices in the platform cloud that match their function types, reducing resource consumption.
[0041] S103. In the case where the access target is the private cloud, generate a second access request according to the first access request.
[0042] S104. Direct the second access request to the gateway of the private cloud.
[0043] In the embodiments of the present application, if the user side is a platform cloud user, indicating that the access target is the platform cloud, the gateway of the platform cloud will allocate it to the microservices in the platform cloud according to the function type corresponding to the first access request. If the user side is a private cloud user, indicating that the access target is the private cloud, the gateway of the platform cloud regenerates a second access request according to the parameters in the first access request, so as to initiate a new request (i.e., the second access request) to the gateway of the private cloud again.
[0044] In the embodiment of the present application, since it is the forwarding component (HttpClient) that interacts (sends and receives information) with the gateway of the private cloud, rather than the interceptor with the highest priority for receiving the first access request and determining whether it is the private cloud, the interceptor with the highest priority still needs to generate a second access request in the forwarding format defined by the forwarding component according to the first access request, so that the forwarding component can directly send the second access request to the gateway of the private cloud without transit. The gateway of the platform cloud initiates a new request (i.e., the second access request) to the gateway of the private cloud, so that the gateway of the private cloud allocates the microservers in the private cloud based on the second access request, generates response information, and sends the response information to the gateway of the platform cloud; the gateway of the platform cloud returns a request result to the user side based on the response information returned by the gateway of the private cloud, and the request result includes the microservers in the private cloud that are allocated.
[0045] In the embodiment of the present application, when the access target is the private cloud, according to the first access request and the obtained forwarding target (which can be understood as the private cloud to be forwarded), a second access request is constructed, and the second access request is no longer sent to the next-level interceptor, nor is it sent to the microservers of the platform cloud. The second access request is directly sent to the gateway of the private cloud without forwarding through the microservers of the platform cloud, that is, without transit, and the request is directly forwarded to the gateway of the private cloud. The cross-cloud forwarding mode is simple and reduces resource consumption.
[0046] The embodiments of the present application provide a cross-cloud forwarding method, apparatus, device, and computer-readable storage medium. According to the solution provided by the embodiments of the present application, the method is applied to the gateway of the platform cloud; the method includes: receiving a first access request from a user terminal; wherein, the first access request includes identification information of the accessed cloud; determining that the access target of the first access request is a private cloud according to the identification information of the accessed cloud; in the case where the access target is a private cloud, generating a second access request according to the first access request; and directly sending the second access request to the gateway of the private cloud. The servlet interceptor at the bottom layer of the gateway (zuul gateway) of the cloud platform will be executed before the interceptor of the zuul gateway itself. As the interceptor with the highest priority, it can receive the first access request first. In this application, this method is added to the zuul gateway. Based on the servlet interceptor receiving the first access request, the identification information of the accessed cloud in the first access request can be obtained, so as to determine whether the user terminal is going to access the private cloud. If so, a second access request is regenerated based on the first access request, and then the second access request is directly sent to the gateway of the private cloud, without forwarding through the microservices of the platform cloud, that is, without transit, and the request is directly forwarded to the gateway of the private cloud. When this application determines whether the user terminal is going to access the private cloud, the zuul gateway does not need to forward the request to the microservices of the cloud platform, nor does the microservices of the cloud platform need to forward the request. The cross-cloud forwarding mode is simple and the resource consumption is reduced.
[0047] In some embodiments, the gateway of the platform cloud includes at least one interceptor; after S101 above Figure 2 the cross-cloud forwarding method further includes S105. Based on the above Figure 2 as Figure 3 shown Figure 3 is an optional step flowchart of another cross-cloud forwarding method provided by the embodiments of the present application.
[0048] S105. In the case where it is determined according to the identification information of the accessed cloud that the access target of the first access request is not a private cloud, the first access request is handed over to the next interceptor, and the microservices in the platform cloud are allocated based on the first access request by the next interceptor.
[0049] In the embodiments of the present application, the gateway of the platform cloud includes multiple interceptors. The interceptor with the highest priority in the gateway of the platform cloud matches according to the identification information of the accessed cloud and the preset configuration rules. If the forwarding target (which can be understood as the private cloud to be forwarded) is not matched, it indicates that the access target of the first access request is not the private cloud. The first access request is handed over to the next interceptor, and the interceptors in the gateway of the platform cloud execute their corresponding functions level by level, and the request is allocated to the microservices in the platform cloud that match its function type, that is, according to the function type corresponding to the first access request, the microservices in the platform cloud are allocated. In the case where the access target is not the private cloud, the corresponding steps in the related art are executed, improving the applicable scenarios of request forwarding.
[0050] In some embodiments, after the above S104, the cross-cloud forwarding method further includes the following steps: receiving the response information returned by the gateway of the private cloud; the response information includes the allocation result of the microservices in the private cloud by the gateway of the private cloud based on the second access request; based on the response information, returning the request result to the user side.
[0051] In the embodiments of the present application, after the gateway of the platform cloud directly sends the second access request to the gateway of the private cloud, the gateway of the private cloud allocates the microservices in the private cloud based on the second access request. Exemplarily, the function type of the second access request is parsed, and the microservices that match the function type are allocated. For example, some requests are for paying an order, and they are allocated to the microservices with payment functions; some requests are for searching, and they are allocated to the microservices with search functions, obtaining the allocation result, and the allocation result represents the microservices in the private cloud that are allocated. The gateway of the private cloud generates response information based on the allocation result, the parameter information included in the second access request (such as the corresponding platform cloud gateway, user side, first access request, etc.), and the processing result of the request by the allocated microservices (such as the payment interface, search result, etc.), and sends the response information to the gateway of the platform cloud. The gateway of the platform cloud receives the response information and returns the request result of the first access request to the user side based on the response information. The request result can be the allocated microservices, the processing result of the request, etc.
[0052] In the embodiments of the present application, the forwarding component in the gateway of the platform cloud receives the response information returned by the gateway of the private cloud. The forwarding component sends the response information to the interceptor with the highest priority, and the interceptor with the highest priority returns the request result to the user side based on the response information, completing the cross-cloud forwarding process. The entire cross-cloud forwarding process is executed by the gateway of the platform cloud without passing through the microservices of the platform cloud, reducing the platform computing power and improving the request processing efficiency.
[0053] In the embodiment of the present application, this method serves as an expansion of the function of the platform cloud gateway (zuul gateway), and the entire calling process is completely imperceptible to the caller (i.e., the user end). For the user end, it initiates the first access request to the platform cloud gateway to access the private cloud, and then receives the request result returned by the platform cloud gateway based on the first access request. For each access request sent by the user end with private cloud access rights, it is sent to the platform cloud gateway, and a request is initiated to the platform cloud gateway, thereby realizing the cross-cloud forwarding process, that is, ensuring the unification of the entrance and satisfying the purpose of exclusive computing power.
[0054] In some embodiments, the gateway of the platform cloud includes at least one interceptor, a read-write module, and a forwarding component; based on the above Figure 2 ,like Figure 4 As shown, Figure 4 An optional step flow chart of another cross-cloud forwarding method provided in an embodiment of the present application, the cross-cloud forwarding method includes the following steps.
[0055] S201. Receive a first access request from a user terminal through an interceptor with the highest priority among at least one interceptor.
[0056] In an embodiment of the present application, the gateway of the platform cloud includes at least one interceptor, and the cross-cloud forwarding method provided by the present application is executed based on the interceptor with the highest priority (for example, the underlying servlet interceptor of the zuul gateway), and the first access request from the user end is received preferentially by the interceptor with the highest priority.
[0057] It should be noted that Figure 4 S201 and above Figure 2 The implementation process of S101 and the technical effect achieved are consistent and will not be repeated here.
[0058] S202. Write the first access request into the request parameters of the interceptor with the highest priority through the read-write module; wherein the request parameters include path information, header information and login information, the path information represents the function type to which the request belongs, the path information corresponds to the function of the assigned microserver, the header information includes identification information for accessing the cloud, and the login information represents the cloud access rights of the user end.
[0059] In an embodiment of the present application, after receiving a first access request, the read-write module writes the first access request to the position corresponding to the request parameter according to the type of the request parameter (Http Servlet Request) set by the interceptor with the highest priority. The request parameters include, but are not limited to, path information, header information (header information), and login information (body information). Among them, the path information represents the functional type to which the request belongs, and the path information corresponds to the functions of the allocated micro server. For example, the path information represents that the functional type to which the request belongs is search, and according to this path information, a micro server with a search function can be allocated. The header information includes the identification information for accessing the cloud. In one scenario, when the user terminal is a private cloud user, the interceptor with the highest priority can obtain the forwarding target (the private cloud to be forwarded) from the header information; when the user terminal is a public cloud user, the interceptor with the highest priority cannot obtain the forwarding target from the header information. In another scenario, when the user terminal is a private cloud user, the header information includes the identification information of the private cloud, and the interceptor with the highest priority can determine from the header information that the access target of the first access request is the private cloud; when the user terminal is a public cloud user, the header information includes the identification information of the public cloud, and the interceptor with the highest priority can determine from the header information that the access target of the first access request is the public cloud. The body information is the user information of the user terminal itself, which represents the cloud access permission of the user terminal. The gateway of the platform cloud can determine whether the terminal (i.e., the user terminal) has cloud access permission according to the body information. If the login information represents that the user terminal has cloud access permission, the interceptor with the highest priority in the gateway of the platform cloud determines whether the access target is the private cloud according to the header information; if the login information represents that the user terminal does not have cloud access permission, the gateway of the platform cloud does not execute the cross-cloud forwarding step.
[0060] In an embodiment of the present application, the request parameter further includes format information (method information), and the format information is used to represent the data format of the request.
[0061] S203. Determine that the access target of the first access request is the private cloud according to the header information in the request parameter by the interceptor with the highest priority.
[0062] In an embodiment of the present application, after writing the request parameter, the read-write module reads the header information in the request parameter, and then the interceptor with the highest priority determines whether the access target of the first access request is the private cloud according to the header information in the request parameter.
[0063] Exemplarily, taking the gateway of the platform cloud as the zuul gateway, the first access request as an Http request, and the interceptor with the highest priority as the servlet interceptor as an example, for the method of request forwarding based on the information in the Http request, when the target of the request is a cloud service deployed independently or privately, the servlet interceptor judges the information in the request and can forward the request to the target cloud environment (corresponding to forwarding the first access request to the private cloud) according to the configuration (corresponding to the preset configuration rule). The implementation steps of this technology are as follows: Add this method in the zuul gateway. This method is based on the underlying servlet interceptor and will be executed before the interceptors of zuul itself. When the servlet interceptor receives an Http request (corresponding to the first access request), it will match the forwarding rule in the configuration (corresponding to the preset configuration rule) according to the information in the request, such as the parameters in the header, and obtain the forwarding target (the private cloud to be forwarded). If the forwarding target is not obtained, no logical processing will be done, and only the Http request will be handed over to the next interceptor for continued execution. When the forwarding target is obtained, the forwarding process will start.
[0064] It should be noted that Figure 4 The implementation process and the achieved technical effects of S203 in Figure 2 are the same as those of S102 above, and will not be elaborated here.
[0065] S204. Through the interceptor with the highest priority, in the case where the access target is the private cloud, generate a second access request corresponding to the forwarding component according to the request parameters.
[0066] In the embodiments of the present application, the read-write module reads the path information, header information (header information), login information (body information), and format information (method information) in the request parameters. The interceptor with the highest priority reconstructs the request parameter information in the forwarding format defined by the forwarding component according to the request parameters and the obtained forwarding target (the private cloud to be forwarded), and generates a second access request, so that the forwarding component can directly send the second access request to the gateway of the private cloud without transit.
[0067] It should be noted that Figure 4 The implementation process and the achieved technical effects of S204 in Figure 2 are the same as those of S103 above, and will not be elaborated here.
[0068] S205. Through the forwarding component, directly send the second access request to the gateway of the private cloud.
[0069] Exemplarily, taking the gateway of the platform cloud as the zuul gateway, the first access request as an Http request, the interceptor with the highest priority as the servlet interceptor, and the forwarding component as HttpClient, the forwarding process includes: obtaining request information from the request parameters (Http Servlet Request parameters) of the servlet interceptor, and using the path information, header information, method information, body information in the Http Servlet Request and the obtained forwarding target to reconstruct the Http Request request parameter information of the HttpClient. The HttpClient initiates a new Http request to the target cloud environment (corresponding to the forwarding component directly sending the second access request to the gateway of the private cloud).
[0070] It should be noted that Figure 4 the implementation process of S205 in Figure 2 is the same as that of S104 in the above, and the achieved technical effects are also the same, so it will not be elaborated here.
[0071] In the embodiment of the present application, the servlet interceptor preferentially receives the Http request from the user side, and the reading and writing module writes the Http request into the Http Servlet Request request parameters of the servlet interceptor. When the servlet interceptor determines whether the access target of the Http request is the private cloud according to the header information in the Http Servlet Request request parameters and obtains the forwarding target (the private cloud to be forwarded), it reconstructs the Http Request request parameter information of the HttpClient according to the Http Servlet Request request parameters, generates a new Http request, and then directly sends the new Http request to the gateway of the private cloud through the HttpClient without transit, reducing resource consumption. This solution realizes cross-cloud forwarding through the gateway of the platform cloud and the gateway of the private cloud, without passing through the microserver of the platform cloud, reducing the redundancy of the code. Moreover, this cross-cloud forwarding solution is configurable and can be configured on the servlet interceptor in the zuul gateway of the platform cloud. The cross-cloud forwarding process is simple, reducing the development and maintenance difficulty.
[0072] In some embodiments, based on the above Figure 4 , as Figure 5 shown Figure 5 is an optional step flowchart of another cross-cloud forwarding method provided by the embodiment of the present application. After S205 in the above Figure 4 , this cross-cloud forwarding method further includes S206 - S208.
[0073] S206. Receive the response information returned by the gateway of the private cloud through the forwarding component.
[0074] S207. Write the response information into the response parameters of the interceptor with the highest priority through the reading and writing module.
[0075] In the embodiment of the present application, the reading and writing module writes the response information received by the forwarding component into the corresponding position of the response parameter according to the type of the response parameter (Http Servlet Response) set by the interceptor with the highest priority. Response parameter.
[0076] S208. Based on the response parameters, the interceptor with the highest priority returns the request result to the user side, and no longer forwards the first access request to the next interceptor.
[0077] In the embodiment of the present application, after writing the response parameters, the response parameters are read through the reading and writing module, and then the interceptor with the highest priority generates a request result according to the response parameters and returns the request result to the user side.
[0078] Exemplarily, taking the interceptor with the highest priority as the servlet interceptor and the forwarding component as HttpClient, after HttpClient receives the return information (corresponding to the response information), the reading module obtains the information from the HttpResponse of Http Client and writes it into the response parameters (Http Servlet Response) of the servlet interceptor. The servlet interceptor returns this request, and no longer forwards the Http request to the next interceptor for execution, improving the processing efficiency and reducing the resource consumption.
[0079] Next, an exemplary application of the embodiment of the present application in an actual application scenario will be described.
[0080] Based on the above Figure 1 , as Figure 6 shown, Figure 6 is a schematic diagram of another interaction process provided by the embodiment of the present application. From the interaction process between the terminal, the cloud platform and the private cloud, the implementation method of cross-cloud forwarding based on the zuul gateway provided by the present application is described. If the request initiated by the terminal (that is, the user side) is a platform cloud user access, the request initiated by the user side is sent to the gateway (Gateway) of the platform cloud. Gateway forwards the request to the corresponding microservice according to the function type corresponding to the request ( Figure 6Take microservice 1 in the platform cloud as an example for illustration). If the request initiated by the terminal is a private cloud user access, the request initiated by the user side is first sent to the gateway (Gateway) of the platform cloud. The first scenario: The Gateway determines that it needs to forward to the private cloud according to the identification information of the accessed cloud in the request. The Gateway forwards the request to the gateway (Gateway) of the private cloud, and then the Gateway forwards the request to the corresponding microservice according to the function type corresponding to the request ( Figure 6 Take microservice 1 in the private cloud as an example for illustration); The second scenario: The Gateway determines that it needs to forward to the private cloud according to the identification information of the accessed cloud in the request. The Gateway forwards the request to the gateway (Gateway) of the private cloud, and then the Gateway forwards the request to the corresponding microservice according to the function type corresponding to the request ( Figure 6 Take microservice 2 in the private cloud as an example for illustration).
[0081] The above Figure 6 The implementation method of cross-cloud forwarding based on the zuul gateway provided above is applicable to scenarios with requirements for cloud platform computing power and hybrid applications of public and private clouds. Through the request forwarding between the gateway of the platform cloud and the gateway of the private cloud, there is no need to pass through the microservices of the platform cloud, reducing the redundancy of the code. Moreover, this cross-cloud forwarding method is a configurable cross-cloud forwarding technology, which can be configured on the interceptor with the highest priority in the gateway of the platform cloud. The cross-cloud forwarding process is simple, reducing the development and maintenance difficulty. For the user side, it interacts with the gateway of the platform cloud, sends all its access requests to the gateway of the platform cloud, and then the gateway of the platform cloud executes the cross-cloud forwarding process, and then receives the request result returned by the gateway of the platform cloud. The gateway of the platform cloud has a unified cross-cloud forwarding processing mode, and the user side adopts a unified entry to meet the exclusive computing power of the unified entry.
[0082] To implement the cross-cloud forwarding method of the embodiments of the present application, the embodiments of the present application also provide a cross-cloud forwarding device, as Figure 7 shown, Figure 7 This is an optional structural schematic diagram of a cross-cloud forwarding device provided by the embodiments of the present application. The cross-cloud forwarding device 70 is applied to the gateway of the platform cloud; The cross-cloud forwarding device 70 includes: at least one interceptor and a forwarding component 702; The interceptor 701 with the highest priority among the at least one interceptor is used to receive the first access request from the user side; Wherein, the first access request includes the identification information of the accessed cloud; According to the identification information of the accessed cloud, determine that the access target of the first access request is the private cloud; In the case where the access target is the private cloud, generate a second access request according to the first access request; The forwarding component 702 is used to directly send the second access request to the gateway of the private cloud.
[0083] In some embodiments, the interceptor 701 with the highest priority is further configured to match according to the identity information of the accessed cloud and a preset configuration rule to determine that the access target of the first access request is a private cloud.
[0084] In some embodiments, the gateway of the platform cloud includes at least one interceptor;
[0085] The interceptor 701 with the highest priority is further configured to, when it is determined according to the identity information of the accessed cloud that the access target of the first access request is not a private cloud, forward the first access request to the next interceptor, and allocate the micro-servers in the platform cloud based on the first access request through the next interceptor.
[0086] In some embodiments, the forwarding component 702 is further configured to receive the response information returned by the gateway of the private cloud; the response information includes the allocation result of the micro-servers in the private cloud by the gateway of the private cloud based on the second access request;
[0087] The interceptor 701 with the highest priority is further configured to return a request result to the user terminal based on the response information.
[0088] In some embodiments, the gateway of the platform cloud further includes a read-write module 703;
[0089] The read-write module 703 is configured to write the first access request into the request parameters of the interceptor 701 with the highest priority; wherein the request parameters include path information, header information, and login information, the path information represents the functional type to which the request belongs, the path information corresponds to the functions of the allocated micro-servers, the header information includes the identity information of the accessed cloud, and the login information represents the cloud access permission of the user terminal.
[0090] In some embodiments, the interceptor 701 with the highest priority is further configured to, when the access target is a private cloud, generate a second access request corresponding to the forwarding component 702 according to the request parameters;
[0091] The forwarding component 702 is further configured to directly send the second access request to the gateway of the private cloud.
[0092] In some embodiments, the forwarding component 702 is further configured to receive the response information returned by the gateway of the private cloud;
[0093] The read-write module 703 is further configured to write the response information into the response parameters of the interceptor 701 with the highest priority;
[0094] The interceptor 701 with the highest priority is further configured to return the request result to the client based on the response parameter, and no longer forward the first access request to the next interceptor.
[0095] It should be noted that when the cross-cloud forwarding device provided in the above embodiment performs cross-cloud forwarding, only the division of the above program modules is used for illustration. In actual applications, the above processing can be allocated to different program modules according to needs, that is, the internal structure of the device is divided into different program modules to complete all or part of the above-described processing. In addition, the cross-cloud forwarding device provided in the above embodiment and the cross-cloud forwarding method embodiment belong to the same concept. For the specific implementation process and beneficial effects, please refer to the method embodiment, which will not be elaborated here. For the technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0096] In the embodiment of the present application, Figure 8 FIG. is a schematic structural diagram of a cross-cloud forwarding device proposed in an embodiment of the present application. As Figure 8 shown, the cross-cloud forwarding device 80 proposed in the embodiment of the present application includes a processor 801 and a memory 802 for storing an executable computer program. When the processor 801 executes the executable computer program stored in the memory 802, the cross-cloud forwarding method provided in the embodiment of the present application is implemented.
[0097] In some embodiments, the cross-cloud forwarding device 80 may further include a communication interface 803 and a bus 804 for connecting the processor 801, the memory 802, and the communication interface 803.
[0098] In the embodiment of the present application, the above processor 801 may be at least one of an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, and a microprocessor. It can be understood that for different devices, the electronic devices for implementing the above processor functions may be others, and the embodiments of the present application do not make specific limitations.
[0099] In an embodiment of the present application, the bus 804 is used to connect the communication interface 803, the processor 801, and the memory 802 to enable communication between these components.
[0100] The memory 802 is used to store executable computer programs and data. The executable computer programs include computer operation instructions. The memory 802 may include high-speed RAM memory and may also include non-volatile memory, such as at least two disk memories. In practical applications, the above-mentioned memory 802 may be volatile memory, such as random access memory (RAM); or non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the above types of memory, and provide the executable computer programs and data to the processor 801.
[0101] In addition, in this embodiment, each functional module may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional module.
[0102] If the integrated unit is implemented in the form of a software functional module and is not sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of this technical solution, may be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the method of this embodiment. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs, etc., which can store program codes.
[0103] The embodiment of the present application provides a computer-readable storage medium storing a computer program, which is used to implement the cross-cloud forwarding method described in any of the above embodiments when executed by a processor.
[0104] Exemplarily, the program instructions corresponding to a cross-cloud forwarding method in this embodiment can be stored on storage media such as optical discs, hard disks, USB flash drives, etc. When the program instructions corresponding to a cross-cloud forwarding method in the storage media are read or executed by an electronic device, the cross-cloud forwarding method described in any of the above embodiments can be implemented.
[0105] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories and optical memories, etc.) containing computer-usable program codes.
[0106] The present application is described with reference to the schematic flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the schematic flowcharts and / or block diagrams can be implemented by computer program instructions, and the combination of the flows and / or blocks in the schematic flowcharts and / or block diagrams can also be implemented. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to generate a machine, so that the instructions executed by the processors of the computer or other programmable data processing devices generate means for implementing the specified functions in one or more of the following schematic flow Figure 1 one or more of the flows and / or Figure 1 one or more of the blocks.
[0107] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implements the specified functions in one or more of the following schematic flow Figure 1 one or more of the flows and / or Figure 1 one or more of the blocks.
[0108] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Therefore, the instructions executed on the computer or other programmable device provide steps for implementing the specified functions in one or more of the following schematic flow Figure 1 one or more of the flows and / or Figure 1 one or more of the blocks.
[0109] As mentioned above, only the preferred embodiments of the present application are described, and they are not used to limit the protection scope of the present application.
Claims
1. A cross-cloud forwarding method, characterized in that, The method is applied to the gateway of the platform cloud; the method includes: Receiving a first access request from a client; wherein, the first access request includes identification information of the accessed cloud; Determining that the access target of the first access request is a private cloud according to the identification information of the accessed cloud; Generating a second access request according to the first access request when the access target is a private cloud; Directly sending the second access request to the gateway of the private cloud.
2. The method according to claim 1, wherein The determining that the access target of the first access request is a private cloud according to the identification information of the accessed cloud includes: Matching the identification information of the accessed cloud with a preset configuration rule to determine that the access target of the first access request is a private cloud.
3. The method according to claim 1, characterized in that, The gateway of the platform cloud includes at least one interceptor; the method further includes: When it is determined that the access target of the first access request is not a private cloud according to the identification information of the accessed cloud, forwarding the first access request to the next interceptor, and allocating micro-servers in the platform cloud based on the first access request through the next interceptor.
4. The method according to claim 1, wherein After directly sending the second access request to the gateway of the private cloud, the method further includes: Receiving response information returned by the gateway of the private cloud; the response information includes the allocation result of the micro-servers in the private cloud based on the second access request by the gateway of the private cloud; Returning a request result to the client based on the response information.
5. The method according to any one of claims 1-4, characterized in that, The gateway of the platform cloud includes at least one interceptor and a read-write module; the receiving of the first access request from the client includes: Receiving the first access request from the client through the interceptor with the highest priority among the at least one interceptor; The method further includes: Writing the first access request into the request parameters of the interceptor with the highest priority through the read-write module; wherein, the request parameters include path information, header information, and login information, the path information represents the functional type to which the request belongs, the path information corresponds to the functions of the allocated micro-servers, the header information includes the identification information of the accessed cloud, and the login information represents the cloud access permission of the client.
6. The method according to claim 5, wherein The gateway of the platform cloud further includes a forwarding component; the generating of the second access request according to the first access request; directly sending the second access request to the gateway of the private cloud includes: Generating a second access request corresponding to the forwarding component according to the request parameters through the interceptor with the highest priority when the access target is a private cloud; Directly sending the second access request to the gateway of the private cloud through the forwarding component.
7. The method according to claim 6, wherein Receiving response information returned by the gateway of the private cloud; Returning a request result to the client based on the response information includes: Receiving the response information returned by the gateway of the private cloud through the forwarding component; Writing the response information into the response parameters of the interceptor with the highest priority through the read-write module; Based on the response parameters, the interceptor with the highest priority returns the request result to the client, and no longer forwards the first access request to the next interceptor.
8. A cross-cloud forwarding device, characterized in that, The device is applied to the gateway of the platform cloud; the device includes at least one interceptor and a forwarding component; The interceptor with the highest priority among the at least one interceptor is configured to receive a first access request from a client; wherein, the first access request includes identification information for accessing the cloud; according to the identification information for accessing the cloud, it is determined that the access target of the first access request is a private cloud; in the case where the access target is a private cloud, a second access request is generated according to the first access request; The forwarding component is configured to directly send the second access request to the gateway of the private cloud.
9. A cross-cloud forwarding device, characterized in that, The device includes: A memory for storing an executable computer program; A processor, when executing the executable computer program stored in the memory, implements the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, A computer program is stored and, when executed by a processor, implements the method according to any one of claims 1-7.