CN114416047A - Method, system and storage medium for implementing micro-service based on probe mode - Google Patents

Method, system and storage medium for implementing micro-service based on probe mode Download PDF

Info

Publication number
CN114416047A
CN114416047A CN202111500547.4A CN202111500547A CN114416047A CN 114416047 A CN114416047 A CN 114416047A CN 202111500547 A CN202111500547 A CN 202111500547A CN 114416047 A CN114416047 A CN 114416047A
Authority
CN
China
Prior art keywords
micro
service
probe
class file
proxy server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111500547.4A
Other languages
Chinese (zh)
Inventor
许刚
龙榜
饶学贵
李魁
姚振楠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Farben Information Technology Co ltd
Original Assignee
Shenzhen Farben Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Farben Information Technology Co ltd filed Critical Shenzhen Farben Information Technology Co ltd
Priority to CN202111500547.4A priority Critical patent/CN114416047A/en
Publication of CN114416047A publication Critical patent/CN114416047A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method, a system and a storage medium for realizing micro-service based on a probe mode, wherein the method for realizing the micro-service comprises the following steps: intercepting a corresponding interface in the micro-service according to an interface to be intercepted, which is configured in a JAVA probe by a user in advance; dynamically modifying the class files according to each option preset in the JAVA probe by a user, or adding new class files; and sending the modified class file and the new class file to a proxy server for processing so that the proxy server realizes the corresponding function of the micro-service by executing the received class file. The technical scheme of the invention has the advantages of low code intrusion, low resource occupation and low access cost.

Description

Method, system and storage medium for implementing micro-service based on probe mode
Technical Field
The invention relates to the technical field of computer information processing, in particular to a micro-service implementation method and system based on a probe mode and a storage medium.
Background
The micro-service is a new software technology architecture, the original single application is divided into a plurality of micro-services, and each micro-service is responsible for a subdivided business field, and is independently issued, independently started and independently deployed. Correspondingly, a corresponding registration center, a configuration center, log records, link tracking and the like need to be established.
At present, the implementation mode based on the micro service mainly comprises a spring cloud system and a proxy mechanism mode based on K8S. The former needs to modify a large amount of codes and needs to build additional services such as a single registration center, a configuration center and the like, and the additional services also need to consider building a cluster, so that the workload is large and complex; although the micro-service based on the K8S proxy mechanism overcomes the corresponding disadvantages of the former and introduces the advantages of convenient unified deployment and monitoring, the K8S needs to establish a set of management platform and a corresponding virtual network, the access threshold is higher, the hardware requirement is high, and if the micro-service is a code modified based on spring cloud, the micro-service is not convenient to directly access the K8S. In addition, both of the two implementation modes have a plurality of technical architecture branches, and once a certain branch is selected, a certain reconstruction cost is required for switching.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a method, a system and a storage medium for implementing micro-services based on a probe method, aiming at the above-mentioned defects existing in the prior art.
The invention constructs a micro-service implementation method based on a probe mode, and after a class file obtained by compiling a JAVA source code of a micro-service by using a JAVA compiler is obtained, the following steps are carried out:
s10, intercepting a corresponding interface in the micro service according to an interface to be intercepted, which is configured in a JAVA probe by a user in advance;
s20, dynamically modifying the class files or adding new class files according to various options preset in the JAVA probe by a user;
and S30, sending the modified class files and the new class files to a proxy server for processing so that the proxy server can realize corresponding functions of the micro-service by executing the received class files.
Preferably, between the step S20 and the step S30, the method further includes:
and judging whether the modified class file and the new class file meet the preset configuration rule, if so, executing the step S30.
Preferably, in step S30, the proxy server performs a process including:
the proxy server performs access processing; carrying out ginseng treatment; load balancing; and (5) configuration management.
Preferably, in the step S10, intercepting a corresponding interface in the micro service includes: intercepting a registration interface in the microservice;
the step S20 includes:
modifying the target domain name by dynamically modifying the class file according to each option preset in the JAVA probe by the user;
the step S30 includes:
and sending the modified class file to a proxy server for processing so that the proxy server realizes service flow control of the registry by executing the received class file.
Preferably, in step S10, intercepting a corresponding interface in the micro service includes: intercepting a configuration interface in the microservice;
the step S20 includes:
according to each option pre-configured in the JAVA probe by a user, storing or reading the corresponding configuration by dynamically modifying the class file;
the step S30 includes:
and sending the modified class file to a proxy server for processing so that the proxy server realizes the configuration center function of the micro service by executing the received class file.
Preferably, in step S10, intercepting a corresponding interface in the micro service includes: intercepting a log interface in the microservice;
the step S20 includes:
according to various options pre-configured in the JAVA probe by a user, a log called by the micro service is recorded by adding a new class file;
the step S30 includes:
and sending the modified class file and the new class file to a proxy server for processing so that the proxy server realizes the log function of the microservice by executing the received class file.
Preferably, in step S10, intercepting a corresponding interface in the micro service includes: intercepting a link interface in the microservice;
the step S20 includes:
tracking a full link called by the micro service by dynamically modifying the class file according to each option preset in the JAVA probe by a user;
the step S30 includes:
and sending the modified class file to a proxy server for processing so that the proxy server realizes the link tracking function of the micro-service by executing the received class file.
Preferably, in step S10, intercepting a corresponding interface in the micro service includes: intercepting a gateway interface in the microservice;
the step S20 includes:
according to each option preset in the JAVA probe by a user, carrying out flow control and mirror image service by dynamically modifying the class file;
the step S30 includes:
and sending the modified class file to a proxy server for processing so that the proxy server realizes the gateway control function of the micro-service by executing the received class file.
The present invention also constructs a storage medium storing a computer program which, when executed by a processor, implements the probe-based micro-service implementation method described above.
The invention also constructs a probe-mode-based micro-service implementation system, which comprises a processor and a memory, wherein the memory stores a computer program, and the processor implements the probe-mode-based micro-service implementation method when executing the computer program.
By implementing the technical scheme of the invention, because some additional functions of the micro-service are realized by using a JAVA probe mode, the original code of the micro-service is low-intrusive, and the resource occupation is low. In addition, the function expansion of the micro service is realized in an interface configuration mode, so that the access cost is low.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a logical block diagram of a microservice implementation system of the present invention;
fig. 2 is a flowchart of a first embodiment of a probe-based micro-service implementation method according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
First, it is explained that a Java probe is introduced in JDK1.5, which is a technology capable of dynamically modifying Java byte codes (class files). The bytecode information is obtained by the JVM before the bytecode is executed by the JVM, and the bytecode is modified to perform some additional functions.
The invention provides a micro-service implementation mode based on a JAVA probe mode, as shown in figure 1, a JAVA probe can intercept and modify or add new class files according to requests before loading JAVA class files, intercepts and sends all requests to a proxy server for processing, can execute and define various rules in the proxy server, including functions of a conventional registration center, a configuration center, link tracking and the like of micro-service, can also regularly execute various functions of modifying parameters, service mirroring and the like, and starts or closes corresponding rules or micro-service through a switch.
Fig. 2 is a flowchart of a first embodiment of the probe-based micro-service implementation method according to the present invention, in which after a class file compiled by using a JAVA compiler to a JAVA source code of a micro-service is acquired, the following steps are performed:
s10, intercepting a corresponding interface in the micro service according to an interface to be intercepted, which is configured in a JAVA probe by a user in advance;
s20, dynamically modifying the class files or adding new class files according to various options preset in the JAVA probe by a user;
and S30, sending the modified class file and the new class file to a proxy server for processing, so that the proxy server can realize corresponding functions of the micro-service by executing the received class file, for example, functions of a registration center, a configuration center, log recording, link tracking, gateway control and the like of the micro-service are realized.
In this embodiment, it should be noted that each original micro service can use the JAVA probe technology to introduce a proxy package, and the name of the micro service (default JAVA source file name) and the port number can be set by using the start parameter. In addition, one agent package can be shared by a plurality of micro services under one virtual machine, and agent packages can be respectively arranged for the plurality of micro services under one virtual machine, and the plurality of agent packages are configured into the same storage layer to realize the cluster function.
By the technical scheme of the embodiment, because some additional functions of the micro-service are realized by using a JAVA probe mode, the original code of the micro-service is low-intrusive, and the resource occupation is low. In addition, because the function expansion of the micro service is realized in the interface configuration mode, when the micro service needs to be deployed to the K8S, only the expansion code needs to be shielded or transformed, and therefore, the access cost is low. Table 1 is a comparison table of characteristics of the micro-service implementation method of this embodiment compared with two corresponding modes:
characteristics of SpringCloud K8S Probe needle
Implementation mode Introducing a technical framework Virtual network Probe needle
Code intrusion Height of Is low in Is low in
Resource occupation Medium and high grade Height of Is low in
Cost of access Height of Height of Is low in
TABLE 1
Further, in an optional embodiment, between step S20 and step S30, the method further includes:
judging whether the modified class files and the new class files conform to preset configuration rules, if so, executing step S30; if not, calling the original interface and finishing.
Further, in an optional embodiment, in step S30, the processing performed by the proxy server includes: processing the ginseng; carrying out ginseng treatment; load balancing; and (5) configuration management. In this embodiment, various rules may be defined in the proxy server, including functions of a conventional registry, a configuration center, link tracking, etc. for the microservice, and other functions such as modifying entry parameters, modifying exit parameters, service mirroring, etc. may be performed periodically, and the corresponding rule or microservice may be turned on or off by a switch.
Further, in an optional embodiment, the user can use the service interface predefined by the system (i.e. the default Http service interface implemented by the Java original micro service), or can flexibly implement various rule definitions by defining the interface mode by itself without using the service interface predefined by the system, so as to achieve zero intrusion on the code of the original micro service.
In a specific embodiment, in step S10, intercepting a corresponding interface in the microservice includes: and intercepting a registration interface in the microservice. Step S20 includes: and modifying the target domain name by dynamically modifying the class file according to each option preset in the JAVA probe by the user. Step S30 includes: and sending the modified class file to a proxy server for processing so that the proxy server realizes service flow control of the registry by executing the received class file. In the embodiment, a set of default Http service interface standards is defined first, and is realized by JAVA original microservice, and when a probe intercepts a corresponding interface, a target domain name is modified according to predefined configuration rules, so as to realize service flow control of a registry. The predefined rules may include polling, weighting, system loading, participation checking, service mirroring, etc., among others. If the corresponding interface is not intercepted or the user disables the registration function in the configuration, the interface of the micro service call is not controlled, and the corresponding function can be realized by the POD of the K8S to ensure the compatibility with the technology of the K8S and other realized corresponding registration centers.
In a specific embodiment, in step S10, intercepting a corresponding interface in the microservice includes: intercepting a configuration interface in the microservice. Step S20 includes: and according to each option preset in the JAVA probe by the user, storing or reading the corresponding configuration by dynamically modifying the class file. Step S30 includes: and sending the modified class file to a proxy server for processing so that the proxy server realizes the configuration center function of the micro service by executing the received class file. In this embodiment, a set of configured read-write interface standards is defined first, and is implemented by JAVA raw microservice, and when the probe intercepts a corresponding interface, the corresponding configuration is stored or read to local, a database, a cache, a ConfigMap of K8S, and the like according to the configured options, thereby implementing the configuration center function of the raw microservice.
In a specific embodiment, in step S10, intercepting a corresponding interface in the microservice includes: and intercepting a log interface in the microservice. Step S20 includes: and according to various options which are configured in the JAVA probe by a user in advance, adding a new class file to record the log called by the micro service. Step S30 includes: and sending the modified class file and the new class file to a proxy server for processing so that the proxy server realizes the log function of the microservice by executing the received class file. It should be noted that after the modified class file and the new class file are sent to the proxy server, the two class files are executed in different threads. In this embodiment, when the user configures the logging function in the probe configuration, the corresponding log of the micro service call is recorded and stored, and the storage medium includes but is not limited to a local file, an ES, a database, a cache system, and the like.
In a specific embodiment, in step S10, intercepting a corresponding interface in the microservice includes: intercepting a link interface in the microservice. Step S20 includes: and tracking the full link called by the micro service by dynamically modifying the class file according to each option preset in the JAVA probe by the user. Step S30 includes: and sending the modified class file to a proxy server for processing so that the proxy server realizes the link tracking function of the micro-service by executing the received class file. In this embodiment, when the user configures the link function in the probe configuration, the SpanID and TradeID parameters are added to all Http services to track the full link called by the micro service, so as to implement the link tracking function of the micro service, and further record indexes such as response time of the corresponding micro service.
Further, the user can also set the link tracking in the probe configuration to be forwarded to other link tracking systems set by the user, such as Zipkin, Jaeger, and the like.
In a specific embodiment, in step S10, intercepting a corresponding interface in the microservice includes: and intercepting a gateway interface in the microservice. Step S20 includes: and carrying out flow control and mirror image service by dynamically modifying the class file according to each option preset in the JAVA probe by the user. Step S30 includes: and sending the modified class file to a proxy server for processing so that the proxy server realizes the gateway control function of the micro-service by executing the received class file. In this embodiment, when a user configures an interface gateway function in probe configuration, the method performs microservice gateway control on configured microservice calls, and specifically includes: flow control, mirror image service, and also including blue-green deployment.
In conclusion, the functions of registration center, configuration center, log recording, link tracking, gateway control and the like of the micro-service are realized through the probe technology. In addition, the corresponding functions can be flexibly turned on or off through the switch. In addition, through a self-defined interface mode, the non-intrusive design of the original code is realized.
The present invention also constructs a storage medium storing a computer program that realizes the above-described probe-based micro-service implementation method when executed by a processor.
The invention also constructs a probe-mode-based micro-service implementation system, which comprises a processor and a memory, wherein the memory stores a computer program, and the processor implements the probe-mode-based micro-service implementation method when executing the computer program.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.

Claims (10)

1. A micro-service implementation method based on a probe mode is characterized in that after a class file obtained by compiling a JAVA source code of a micro-service by using a JAVA compiler is obtained, the following steps are carried out:
s10, intercepting a corresponding interface in the micro service according to an interface to be intercepted, which is configured in a JAVA probe by a user in advance;
s20, dynamically modifying the class files or adding new class files according to various options preset in the JAVA probe by a user;
and S30, sending the modified class files and the new class files to a proxy server for processing so that the proxy server can realize corresponding functions of the micro-service by executing the received class files.
2. The probe-based micro-service implementation method of claim 1, further comprising, between the step S20 and the step S30:
and judging whether the modified class file and the new class file meet the preset configuration rule, if so, executing the step S30.
3. The probe-based micro-service implementation method of claim 1, wherein in step S30, the proxy server performs a process including:
the proxy server performs access processing; carrying out ginseng treatment; load balancing; and (5) configuration management.
4. The probe-based micro-service implementation method of claim 1, wherein in the step S10, intercepting a corresponding interface in the micro-service comprises: intercepting a registration interface in the microservice;
the step S20 includes:
modifying the target domain name by dynamically modifying the class file according to each option preset in the JAVA probe by the user;
the step S30 includes:
and sending the modified class file to a proxy server for processing so that the proxy server realizes service flow control of the registry by executing the received class file.
5. The method for implementing micro-services based on the probe method according to claim 1, wherein the step S10 of intercepting the corresponding interface in the micro-service includes: intercepting a configuration interface in the microservice;
the step S20 includes:
according to each option pre-configured in the JAVA probe by a user, storing or reading the corresponding configuration by dynamically modifying the class file;
the step S30 includes:
and sending the modified class file to a proxy server for processing so that the proxy server realizes the configuration center function of the micro service by executing the received class file.
6. The method for implementing micro-services based on the probe method according to claim 1, wherein the step S10 of intercepting the corresponding interface in the micro-service includes: intercepting a log interface in the microservice;
the step S20 includes:
according to various options pre-configured in the JAVA probe by a user, a log called by the micro service is recorded by adding a new class file;
the step S30 includes:
and sending the modified class file and the new class file to a proxy server for processing so that the proxy server realizes the log function of the microservice by executing the received class file.
7. The method for implementing micro-services based on the probe method according to claim 1, wherein the step S10 of intercepting the corresponding interface in the micro-service includes: intercepting a link interface in the microservice;
the step S20 includes:
tracking a full link called by the micro service by dynamically modifying the class file according to each option preset in the JAVA probe by a user;
the step S30 includes:
and sending the modified class file to a proxy server for processing so that the proxy server realizes the link tracking function of the micro-service by executing the received class file.
8. The method for implementing micro-services based on the probe method according to claim 1, wherein the step S10 of intercepting the corresponding interface in the micro-service includes: intercepting a gateway interface in the microservice;
the step S20 includes:
according to each option preset in the JAVA probe by a user, carrying out flow control and mirror image service by dynamically modifying the class file;
the step S30 includes:
and sending the modified class file to a proxy server for processing so that the proxy server realizes the gateway control function of the micro-service by executing the received class file.
9. A storage medium storing a computer program which, when executed by a processor, implements the probe-based micro-service implementation method of any one of claims 1 to 8.
10. A probe-based micro-service implementation system comprising a processor and a memory storing a computer program, wherein the processor implements the probe-based micro-service implementation method according to any one of claims 1 to 8 when executing the computer program.
CN202111500547.4A 2021-12-09 2021-12-09 Method, system and storage medium for implementing micro-service based on probe mode Pending CN114416047A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111500547.4A CN114416047A (en) 2021-12-09 2021-12-09 Method, system and storage medium for implementing micro-service based on probe mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111500547.4A CN114416047A (en) 2021-12-09 2021-12-09 Method, system and storage medium for implementing micro-service based on probe mode

Publications (1)

Publication Number Publication Date
CN114416047A true CN114416047A (en) 2022-04-29

Family

ID=81264899

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111500547.4A Pending CN114416047A (en) 2021-12-09 2021-12-09 Method, system and storage medium for implementing micro-service based on probe mode

Country Status (1)

Country Link
CN (1) CN114416047A (en)

Similar Documents

Publication Publication Date Title
US10884722B2 (en) Cross-environment application of tracing information for improved code execution
US7062516B2 (en) Methods, systems, and articles of manufacture for implementing a runtime logging service storage infrastructure
US5987497A (en) System and method for managing the configuration of distributed objects
US20050177635A1 (en) System and method for allocating server resources
US20080263554A1 (en) Method and System for Scheduling User-Level I/O Threads
US10122815B1 (en) Dynamic class mapping in messaging middleware
US11704133B2 (en) Isolating applications at the edge
CN109241731A (en) A kind of method for protecting privacy based on virtual application, device and storage medium
CN110196722A (en) Cloud host batch management method, system, equipment and storage medium
CN115086166A (en) Computing system, container network configuration method, and storage medium
US11457016B2 (en) Managing shared applications at the edge of a content delivery network
CN114706690A (en) Method and system for sharing GPU (graphics processing Unit) by Kubernetes container
CN116805946A (en) Message request processing method and device, electronic equipment and storage medium
US20220206836A1 (en) Method and Apparatus for Processing Virtual Machine Migration, Method and Apparatus for Generating Virtual Machine Migration Strategy, Device and Storage Medium
CN114416047A (en) Method, system and storage medium for implementing micro-service based on probe mode
US20050108721A1 (en) Method of calling an export function stored in a shared library
Osterhage Computer Performance Optimization
CN113938527B (en) Extension processing method of API gateway, computing device and storage medium
EP4358484A1 (en) Intrusion detection method, apparatus and system, and electronic device and computer-readable medium
CN111831402A (en) Method, apparatus and computer program product for managing software functions
CN116954810A (en) Method, system, storage medium and program product for creating container application instance
CN112214177B (en) Data storage method, device and medium
CN113741912A (en) Model management system, method, device and equipment
CN111259375A (en) Processing method and device for access request applied to operating system of Internet of things
CN113467960B (en) Multi-path storage method, system, terminal and storage medium based on shared lock

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination