WO2022068796A1 - 云平台及基于云平台的程序代码处理方法 - Google Patents

云平台及基于云平台的程序代码处理方法 Download PDF

Info

Publication number
WO2022068796A1
WO2022068796A1 PCT/CN2021/121245 CN2021121245W WO2022068796A1 WO 2022068796 A1 WO2022068796 A1 WO 2022068796A1 CN 2021121245 W CN2021121245 W CN 2021121245W WO 2022068796 A1 WO2022068796 A1 WO 2022068796A1
Authority
WO
WIPO (PCT)
Prior art keywords
program code
virtual
code
cloud
cloud platform
Prior art date
Application number
PCT/CN2021/121245
Other languages
English (en)
French (fr)
Inventor
陈普
Original Assignee
华为云计算技术有限公司
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
Priority claimed from CN202110394141.6A external-priority patent/CN114327742A/zh
Application filed by 华为云计算技术有限公司 filed Critical 华为云计算技术有限公司
Priority to EP21874456.3A priority Critical patent/EP4213016A4/en
Publication of WO2022068796A1 publication Critical patent/WO2022068796A1/zh
Priority to US18/192,988 priority patent/US20230244519A1/en

Links

Images

Classifications

    • 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • 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
    • 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances
    • 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45566Nested virtual machines
    • 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Definitions

  • the present application relates to the field of cloud technology, and in particular, to a cloud platform and a program code processing method based on the cloud platform.
  • Cloud computing services are basic cloud services provided by cloud service providers, and tenants can use basic cloud services through the Internet.
  • the server is configured in the cloud data center operated by itself, and the tenant can obtain the remote use permission of the virtual machine of a specific specification in the server by paying the cloud service provider, so as to realize the use of basic cloud services.
  • Cloud services are not limited to virtual machines, but also This can include object storage services, database services, security services, face recognition services, and more. Cloud computing services allow tenants to skip the tedious server configuration process and obtain basic cloud services provided by cloud service providers by paying.
  • the current method of using cloud services to complete large-scale computing is still relatively complicated in use. It requires the tenant to log in to the cloud platform, and the tenant enters the required virtual machine configuration on the interface provided by the cloud platform to create a virtual machine, and then log in to create a virtual machine.
  • the virtual machine is set to run a specific program code, and the user experience is not good.
  • the present application provides a cloud platform and a program code processing method based on the cloud platform, which can improve the programmer's experience of using cloud resources for program development.
  • the present application provides a method for processing program code based on cloud services.
  • the cloud platform can receive the program code of the tenant and process it, which specifically includes the following steps: the cloud platform obtains the program code of the tenant, and the program code includes a first Tag and subprogram code, the first tag is used to indicate the configuration information of the virtual instance running the subprogram code, the cloud platform creates or selects one or more first virtual instances according to the first tag, and the cloud platform sends the subprogram code to a or multiple first virtual instances, and the cloud platform receives the first running results obtained by respectively running the subprogram codes of the one or more first virtual instances.
  • a first tag indicating the configuration information of the virtual instance running the subprogram code can be set in the program code, the cloud platform obtains the program code, and the cloud platform creates or selects at least one virtual instance according to the first tag. instance to run the subprogram code, and receive the first running result obtained by at least one virtual instance running the subprogram code. Therefore, the tenant can mark the program code to notify the cloud platform to create the corresponding virtual instance and run the subprogram code. , under the premise of not changing the existing programming habits, the cloud resources can be effectively used to run the subprogram code, and the user experience can be improved.
  • the tenant does not need to log in to the first virtual instance, and the first virtual instance is configured by the cloud platform from the background, which can further improve user experience.
  • the mark is also used to separate different subprogram codes, so that the cloud platform can confirm different subprogram codes through the mark.
  • the configuration information includes virtual instance specifications.
  • the virtual instance specifications include the number of processor cores, the main frequency of the processor, and the memory size of the virtual instance.
  • the tenant marks the program code, and sets the specification of the virtual instance to be created in the configuration information indicated by the mark.
  • the virtual instance specification can be set to a high specification
  • the virtual instance specification can be set to a low specification, so that the technical effect of flexibly using cloud resources to run the subprogram code can be achieved. Therefore, tenants can also reasonably set virtual instance specifications according to the computing power of cloud resources they need by setting tags, thereby effectively saving the cost of purchasing cloud resources from cloud platforms.
  • the configuration information includes a virtual instance type, and the virtual instance type is used to indicate any one of a virtual machine, a container, and a bare metal server.
  • the tenant marks the program code, and sets the type of virtual instance to be created in the configuration information indicated by the mark, such as virtual machine, container, or bare metal server, so as to achieve flexible use of cloud resources to run sub-systems.
  • the technical effect of the program code because the selling prices of different virtual instance types, such as virtual machines, containers, and bare metal servers are different, therefore, tenants can also set the mark to reasonably choose according to the computing power of the cloud resources they need Virtual instance type, which effectively saves the cost of purchasing cloud resources from the cloud platform.
  • tenants can choose virtual machines or bare metal servers, and the two virtual instances are running in a stable state.
  • tenants can choose containers.
  • the configuration information includes the number N of virtual instances, where N is a positive integer.
  • the tenant marks the program code, and sets the number of virtual instances to be created in the configuration information indicated by the mark, which is used to indicate the number of virtual instances running the subprogram code.
  • N is set to a plural number
  • the subprogram code runs in multiple virtual instances.
  • parallel computing is an important data processing method.
  • Tenants can mark the number of virtual instances running a specific subprogram code in the program code, so that more Each virtual instance runs subprogram code in parallel, so the cloud platform can provide tenants with the ability to program in parallel.
  • the number of the first virtual instances is multiple, and the subprogram code is used to instruct the multiple first virtual instances to acquire different data to be processed from the shared storage space and perform data processing on the acquired data to be processed respectively.
  • the tenant writes the subprogram code so that the subprogram code is used to instruct the multiple first virtual instances to obtain different data to be processed from the shared storage space, respectively Data processing is performed on the received data to be processed. Therefore, multiple first virtual instances can run the same subprogram code for different data to be processed to implement the same program logic and implement parallel operations.
  • the program code also includes a nested program code and a second mark
  • the second mark is used to indicate the configuration information of the virtual instance running the nested program code
  • the nested program code is called by the subprogram code
  • the above method also includes the following steps: :
  • the cloud platform creates or selects one or more second virtual instances according to the second mark, and respectively sends the nested program code to one or more second virtual instances, and the cloud platform receives one or more second virtual instances to run the embedded program code respectively.
  • the second running result obtained by the set of program codes is sent, and the second running result is sent to the first virtual instance.
  • the subprogram code calls another subprogram code
  • the other subprogram code is called the nested program code
  • the second mark indicates the configuration information of the virtual instance running the nested program code
  • the cloud platform obtains the running result from the virtual instance running the nested program code and sends it to the subprogram code that calls the nested program code. so that the result of the operation of the nested program code can reach the first virtual instance, and the first virtual instance continues to run the subprogram code according to the operation result, thereby realizing the nesting of the program code.
  • the program code further includes a main program code
  • the subprogram code is called by the main program code
  • the method further includes the following steps: when the cloud platform runs the main program code to the position where the subprogram code needs to be called, send a message to one or more The first virtual instance requests the first running result, and the cloud platform continues to run the main program code according to the first running result.
  • the cloud platform directly runs the main program code, and when running the main program code to call the subprogram code, the cloud platform does not run the subprogram code, but requests the first virtual instance running the subprogram code for the first a running result, and continue to run the main program code according to the first running result obtained by the request, directly run the main program code through the cloud platform and communicate with the virtual instance running the subprogram code, which can realize the whole process of calling the subprogram code from the main program code , thus ensuring that the programming habits of the tenant remain unchanged.
  • the above method further includes the following steps: the cloud platform provides an upload interface for receiving program codes uploaded by the tenant, or the cloud platform provides a program editing interface for receiving program codes remotely input by the tenant.
  • the program code can be uploaded to the cloud platform through the upload interface, or the tenant can directly input the program code remotely in the program editing interface provided by the cloud platform, so as to upload the program code to the cloud platform directly.
  • the above two methods can be provided to tenants at the same time, and tenants can choose one method according to their own programming habits, thereby further improving user experience.
  • the method further includes the following steps: the cloud platform provides a cloud service and sets a cloud service application program interface API for the cloud service, wherein the subprogram code is provided with a cloud service API, and the cloud service API is used to call the cloud service provided by the cloud platform.
  • the cloud platform provides a cloud service and sets a cloud service application program interface API for the cloud service, wherein the subprogram code is provided with a cloud service API, and the cloud service API is used to call the cloud service provided by the cloud platform.
  • the cloud platform provides a cloud service and sets a cloud service application program interface API for the cloud service, wherein the subprogram code is provided with a cloud service API, and the cloud service API is used to call the cloud service provided by the cloud platform.
  • the cloud platform provides a cloud service and sets a cloud service application program interface API for the cloud service, wherein the subprogram code is provided with a cloud service API, and the cloud service API is used to call the cloud service provided by the cloud platform.
  • the cloud platform provides a cloud service and sets
  • the tenant can call the cloud service API provided by the cloud platform when writing the subprogram code, so as to make full use of the cloud resources provided by the cloud service.
  • the cloud service API includes one or any combination of an object storage service API, a database service API, a shared cache service API, and a message queue service API.
  • the first mark and the second mark are annotations of the subroutine code, or the first mark and the second mark are program codes with a predetermined syntax and adjacent to the subroutine code.
  • the first mark and the second mark can be set as comments of the subprogram code, for example, before the program code, or after the program code, with @, ⁇ , ⁇ , /, // or others with the cloud
  • the platform pre-agreed a symbol mark, and input configuration information such as the type, specification, quantity and other configuration information of the virtual instance in a predetermined format after the symbol.
  • the cloud platform detects the symbol, the Number of virtual instances are created, and subprogram codes are sent to run the virtual instances.
  • annotations there is no need to change the programming habits of tenants. Tenants only need to input symbols before or after the subprogram code, and input configuration information after the symbols to realize the utilization.
  • the first mark and the second mark can be set as program code with a predetermined syntax and adjacent to the subprogram code. For example, if the cloud platform agrees to use the function creatvirtualinstance(type,spec,N) of the predetermined syntax as the mark, the tenant can write During the program code process, call creatvirtualinstance(type,spec,N) at the adjacent position of the subroutine code (the position before or after the subroutine), and enter the type of virtual instance, the specification spec, and the number of N according to your own needs.
  • the subprogram code can be marked, and the subprogram code can be run in a virtual instance created or selected by the cloud platform according to one or any combination of type type, specification spec, and quantity N.
  • the present application provides a cloud service-based program code processing method, including the following method: the cloud platform receives the subprogram code and the first mark sent by the business virtual instance running the main program code, wherein the subprogram code is sent by the main program code.
  • Code call the first tag is used to indicate the configuration information of the virtual instance running the subprogram code
  • the cloud platform creates or selects one or more first virtual instances according to the first tag
  • the cloud platform sends the subprogram code to one or more first virtual instances.
  • the cloud platform receives the first running result obtained by running the subprogram codes of one or more first virtual instances respectively, and sends the first running result to the service virtual instance.
  • the main program code can be directly run on the tenant's service virtual machine, and the service virtual machine sends the subprogram code called by the main program code and the first mark to the cloud platform, and the cloud platform according to the first mark.
  • Create or select at least one virtual instance to run the subprogram code receive the first running result obtained by running the subprogram code in the at least one virtual instance, and send the first running result to the service virtual instance, so that the service virtual instance can continue according to the first
  • the running result continues to run the main program. Therefore, the tenant can notify the cloud platform to create a corresponding virtual instance and run the subprogram code by marking it.
  • the subprogram code can be effectively run using cloud resources. And can improve user experience.
  • the configuration information includes virtual instance specifications.
  • the virtual instance specifications include the number of processor cores, the main frequency of the processor, and the memory size of the virtual instance.
  • the tenant marks the program code, and sets the specification of the virtual instance to be created in the configuration information indicated by the mark.
  • the virtual instance specification can be set to a high specification
  • the virtual instance specification can be set to a low specification, so that the technical effect of flexibly using cloud resources to run the subprogram code can be achieved. Therefore, tenants can also reasonably set virtual instance specifications according to the computing power of cloud resources they need by setting tags, thereby effectively saving the cost of purchasing cloud resources from cloud platforms.
  • the configuration information includes a virtual instance type, and the virtual instance type is used to indicate any one of a virtual machine, a container, and a bare metal server.
  • the tenant marks the program code, and sets the type of virtual instance to be created in the configuration information indicated by the mark, such as virtual machine, container, or bare metal server, so as to achieve flexible use of cloud resources to run sub-systems.
  • the technical effect of the program code because the selling prices of different virtual instance types, such as virtual machines, containers, and bare metal servers are different, therefore, tenants can also set the mark to reasonably choose according to the computing power of the cloud resources they need Virtual instance type, which effectively saves the cost of purchasing cloud resources from the cloud platform.
  • tenants can choose virtual machines or bare metal servers, the two types of virtual instances run in a stable state, and for small-scale computing, tenants can choose containers.
  • the configuration information includes the number N of virtual instances, where N is a positive integer.
  • the tenant marks the program code, and sets the number of virtual instances to be created in the configuration information indicated by the mark, which is used to indicate the number of virtual instances running the subprogram code.
  • N is set to a plural number
  • the subprogram code runs in multiple virtual instances.
  • parallel computing is an important data processing method.
  • Tenants can mark the number of virtual instances running a specific subprogram code in the program code, so that more Each virtual instance runs subprogram code in parallel, so the cloud platform can provide tenants with the ability to program in parallel.
  • the subprogram code is used to instruct the one or more first virtual instances to acquire different data to be processed from the shared storage space and perform data processing on the acquired data to be processed.
  • the tenant writes the subprogram code so that the subprogram code is used to instruct one or more first virtual instances to obtain different data to be processed from the shared storage space and respectively. Data processing is performed on the acquired data to be processed. Therefore, one or more first virtual instances can run the same subprogram code for different data to be processed to implement the same program logic and implement parallel operations.
  • the above method further includes the following steps: the cloud platform receives the nested program code sent by the virtual instance running the service and a second mark, where the second mark is used to indicate the configuration information of the virtual instance running the nested program code, the nested program code
  • the code is called by the subprogram code
  • the cloud platform creates or selects one or more second virtual instances according to the second mark, and sends the nested program code to the one or more second virtual instances
  • the cloud platform selects one or more second virtual instances from the one or more second virtual instances.
  • the instance acquires second running results generated by running the second program code by one or more second virtual instances, and sends the second running results to the first virtual instance.
  • the subprogram code calls another subprogram code
  • the other subprogram code is called the nested program code
  • the second mark indicates the configuration information of the virtual instance running the nested program code
  • the cloud platform obtains the running result from the virtual instance running the nested program code and sends it to the subprogram code that calls the nested program code. so that the result of the operation of the nested program code can reach the first virtual instance, and the first virtual instance continues to run the subprogram code according to the operation result, thereby realizing the nesting of the program code.
  • the method further includes the following steps: the cloud platform provides a cloud service and sets a cloud service application program interface API for the cloud service, wherein the subprogram code is provided with a cloud service API, and the cloud service API is used to call the cloud service provided by the cloud platform.
  • the cloud platform provides a cloud service and sets a cloud service application program interface API for the cloud service, wherein the subprogram code is provided with a cloud service API, and the cloud service API is used to call the cloud service provided by the cloud platform.
  • the cloud platform provides a cloud service and sets a cloud service application program interface API for the cloud service, wherein the subprogram code is provided with a cloud service API, and the cloud service API is used to call the cloud service provided by the cloud platform.
  • the cloud platform provides a cloud service and sets a cloud service application program interface API for the cloud service, wherein the subprogram code is provided with a cloud service API, and the cloud service API is used to call the cloud service provided by the cloud platform.
  • the cloud platform provides a cloud service and sets
  • the tenant can call the cloud service API provided by the cloud platform when writing the subprogram code, so as to make full use of the cloud resources provided by the cloud service.
  • the cloud service API includes one or any combination of an object storage service API, a database service API, a shared cache service API, and a message queue service API.
  • the first mark is a comment of the subprogram code, or the first mark is a program code that adopts a predetermined syntax and is adjacent to the subprogram code.
  • the first mark and the second mark can be set as comments of the subprogram code, for example, before the program code, or after the program code, with @, ⁇ , ⁇ , /, // or others with the cloud
  • the platform pre-agreed a symbol mark, and input configuration information such as the type, specification, quantity and other configuration information of the virtual instance in a predetermined format after the symbol.
  • the cloud platform detects the symbol, the Number of virtual instances are created, and subprogram codes are sent to run the virtual instances.
  • annotations there is no need to change the programming habits of tenants. Tenants only need to input symbols before or after the subprogram code, and input configuration information after the symbols to realize the utilization.
  • the first mark and the second mark can be set as program code with a predetermined syntax and adjacent to the subprogram code. For example, if the cloud platform agrees to use the function creatvirtualinstance(type,spec,N) of the predetermined syntax as the mark, the tenant can write During the program code process, call creatvirtualinstance(type,spec,N) at the adjacent position of the subroutine code (the position before or after the subroutine), and enter the type of virtual instance, the specification spec, and the number of N according to your own needs.
  • the subprogram code can be marked, and the subprogram code can be run in a virtual instance created or selected by the cloud platform according to one or any combination of type type, specification spec, and quantity N.
  • the present application provides a cloud platform, comprising: a cloud service providing unit for acquiring program code of a tenant, the program code includes a first tag and a subprogram code, and the first tag is used to indicate a virtual instance for running the subprogram code configuration information, the cloud program execution unit is used to create or select one or more first virtual instances according to the first mark, send the subprogram codes to one or more first virtual instances respectively, and receive one or more first virtual instances The first running result obtained by running the subprogram code in a virtual instance respectively.
  • the third aspect or any implementation manner of the third aspect is implemented by a method corresponding to the first aspect or any implementation manner of the first aspect, and the descriptions in the first aspect or any implementation manner of the first aspect are applicable to the third aspect Or any implementation manner of the third aspect, which will not be repeated here.
  • the present application provides a cloud platform, comprising: a cloud service providing unit for creating a service virtual instance, the service virtual instance for running main program code, and a cloud program execution unit for receiving the subroutine sent by the service virtual instance.
  • a program code and a first flag wherein the subprogram code is called by the main program code, the first flag is used to indicate configuration information of a virtual instance running the subprogram code, and one or more first virtual instances are created or selected according to the first flag, Sending the subprogram code to one or more first virtual instances, receiving the first running result obtained by running the subprogram code respectively by the one or more first virtual instances, and sending the first running result to the service virtual instance.
  • the fourth aspect or any implementation manner of the fourth aspect is implemented by a method corresponding to the second aspect or any implementation manner of the second aspect, and the descriptions in the fourth aspect or any implementation manner of the fourth aspect are applicable to the second aspect or any implementation manner of the second aspect, and details are not described herein again.
  • the present application provides a computer device, the computer device includes: a processor and a memory, the memory is used for storing computer-executed instructions, and the processor is used for executing the computer-executed instructions stored in the memory, so that the computer device can implement the first aspect and
  • the method disclosed in any possible implementation manner of the first aspect or the computer device is made to implement the method disclosed in the second aspect and any possible implementation manner of the second aspect.
  • the present application is a computer storage medium, comprising computer-readable instructions, when the computer-readable instructions are executed, the method disclosed in the first aspect and any possible implementation manner of the first aspect is implemented or the second aspect is implemented. The method disclosed in any possible implementation manner of the aspect and the second aspect.
  • a seventh aspect of the present application is a computer program product comprising instructions that, when run on a computer, cause the computer to execute the method disclosed in the first aspect and any possible implementation of the first aspect, or cause the computer to execute the second aspect.
  • FIG. 1 is a schematic diagram of an internal structure of a data center according to an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of a system architecture of a program code processing system according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of another system architecture of a program code processing system according to an embodiment of the present invention.
  • FIG. 4 is a data interaction diagram of a program code processing method according to an embodiment of the present invention.
  • FIG. 5 is another schematic diagram of a system architecture of a program code processing system according to an embodiment of the present invention.
  • FIG. 6 is another schematic diagram of a system architecture of a program code processing system according to an embodiment of the present invention.
  • FIG. 7 is another data interaction diagram of a program code processing method according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a storage node according to an embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of a computing node according to an embodiment of the present invention.
  • FIG. 10 is another schematic structural diagram of a computing node according to an embodiment of the present invention.
  • FIG. 11 is another schematic structural diagram of a computing node according to an embodiment of the present invention.
  • FIG. 12 is a schematic diagram of an apparatus structure of a computer device according to an embodiment of the present invention.
  • Cloud platform used to provide an interface related to cloud services for tenants to remotely access cloud services. Tenants can log in to the cloud platform through the pre-registered account and password on the cloud service access page, and after successful login, select and purchase the corresponding cloud service on the cloud service access page, such as object storage service, virtual machine service, container service, etc. , in this embodiment of the present invention, the cloud platform may provide a cloud service for processing the program code of the tenant.
  • Business logic that is, the logic of the program, which describes what the program executes.
  • the software engineer writes the source code, and the business logic is executed during the execution of the source code.
  • the source code developed by software engineers is usually compiled into executable binary format object code by a compiler and then executed by the computer's processor.
  • the code is parsed to generate object code for execution by the computer's processor.
  • the business logic mentioned in the embodiment of the present invention is the logic of software operation, specifically, what the source code wants the computer to do.
  • Program code In this embodiment of the present invention, the program code may be source code or object code, depending on different application scenarios (will be described in detail below).
  • the program code involved can be compiled according to the programming language used.
  • the program code is a scripting language, for example, a scripting language such as python, java, ruby, etc., in the embodiments described below
  • the program code is source code
  • the tenant can directly upload the uncompiled source code to the cloud platform
  • the cloud program execution agent in the main program execution unit 30 of the cloud platform dynamically compiles the main program code
  • the cloud program execution agent of 1 dynamically compiles the program code 1, and the cloud program execution agents of the virtual instances 2-5 respectively dynamically compile the program code 2.
  • the main program code is dynamically compiled by the cloud program execution agent in the service virtual instance
  • the program code 1 is dynamically compiled by the cloud program execution agent of the virtual instance 1
  • the cloud program of the virtual instances 2-5 is used to dynamically compile the program code 1.
  • the execution agent performs dynamic compilation on the program code 2 respectively.
  • a script parser is set in the cloud program execution agent, and the above dynamic compilation can compile the script language into a bytecode file (ie, object code) that the script parser can run.
  • the program code is target code
  • the tenant can use a script parser to compile the program code locally, and compile the main program code, program code 1 and program code 2 into bytecode files, and then use a script parser to compile the program code. Upload the bytecode file to the cloud platform.
  • the tenant can use a script parser to compile the program code in the service virtual machine, compile the main program code, program code 1 and program code 2 into bytecode files, and compile the program code 1 and program code 2 into bytecode files.
  • the bytecode file of program code 1 is sent to the cloud platform, and the cloud platform sends the bytecode file of program code 1 to virtual machine 1 to run, and the bytecode file of program code 2 to virtual machine 2-5 to run.
  • the program code is source code
  • the tenant can directly upload the uncompiled source code to the cloud platform, and the main program execution unit 30 of the cloud platform will execute the code in the main program execution unit 30 of the cloud platform.
  • the cloud program execution agent of virtual instance 1 statically compiles the main program code
  • the cloud program execution agent of virtual instance 1 statically compiles program code 1
  • the cloud program execution agents of virtual instances 2-5 respectively statically compile program code 2.
  • the main program code is statically compiled by the cloud program execution agent in the service virtual instance
  • the program code 1 is statically compiled by the cloud program execution agent of the virtual instance 1
  • the cloud program of the virtual instance 2-5 is used for static compilation.
  • the execution agent performs static compilation on the program code 2 respectively.
  • a compiler is set in the cloud program execution agent, and the above static compilation can compile the source code into a binary executable file (ie, object code).
  • the program code is target code
  • the tenant can use a compiler to compile the program code locally, compile the main program code, program code 1 and program code 2 into binary executable files, and then The binary executable is uploaded to the cloud platform.
  • the tenant can use a compiler to compile the program code in the service virtual machine, compile the main program code, program code 1 and program code 2 into binary executable files, and compile the program code 1 and program code 2 into binary executable files.
  • the binary executable file is sent to the cloud platform, and the cloud platform sends the binary executable file of program code 1 to virtual machine 1 for execution, and sends the binary executable file of program code 2 to virtual machines 2-5 for execution.
  • Virtual instance a virtual instance is configured by a cloud platform, and is provided with a running environment, and the running environment includes an operating system and an application, and the virtual instance is, for example, a virtual machine, a container or a bare metal server.
  • Business virtual instance a virtual instance created by the tenant on the cloud platform.
  • the tenant can remotely log in to the business virtual instance through the client, and run the program code on the business virtual instance.
  • the business virtual instance can be used as the tenant's production environment or test environment.
  • main program code referred to as the main program, also known as the main function
  • main function in many imperative programming languages, the main function (main function) is the place where the program starts to run.
  • Subroutine code A part of the code in a large program consisting of one or more statement blocks. It is responsible for completing a specific task and is relatively independent from other code. In some cases, there are input parameters, and the subroutine code has a return value (that is, the running result), the subroutine code can be called by the main program code, and the subroutine code can also be called by the subroutine code. Nested program code: refers to the called subprogram code in the subprogram code called by the subprogram code.
  • Marking A method of marking program code pre-agreed by the cloud platform.
  • the cloud platform can provide the use method and format of the mark, so that the tenant can add the mark to the program code when writing the program code.
  • the tag has the function of separating the subprogram code, and the tag is set adjacent to the subprogram code to identify the subprogram code as the program code that needs to be executed by the virtual instance with the configuration information indicated by the tag.
  • One implementation of the tag is the subprogram code. For example, before the program code, or after the program code, it is marked with @, ⁇ , ⁇ , /, // or other symbols that are pre-agreed with the cloud platform, and the virtual instance is entered in a predetermined format after the symbol. Configuration information such as type, specification, quantity, etc.
  • the cloud platform detects the symbol, it creates a virtual instance according to the type, specification, and quantity of the virtual instance indicated by the symbol, and sends the subprogram code to run the virtual instance.
  • the tag can also be set as the program code that uses a predetermined syntax and is adjacent to the subprogram code.
  • the cloud platform agrees to use the function creatvirtualinstance(type,spec,N) with the predetermined syntax as the tag, and the tenant can write the program code during the process.
  • FIG. 1 is a schematic diagram of the internal structure of a data center according to an embodiment of the present invention.
  • a cloud platform is set in the data center, and the cloud platform communicates with a plurality of storage nodes 201, 202... ...and multiple compute nodes 301, 302 are connected.
  • the client accesses the cloud platform, and the tenant operates the client to access the cloud services provided by the cloud platform.
  • the client can be, for example, a terminal device that can be operated by the tenant and can be connected to the Internet, such as a personal computer, mobile phone, tablet computer, vehicle-mounted host, etc.
  • the client accesses the data center through the Internet, and accesses the Services provided by the cloud platform.
  • Storage nodes can provide shared storage space, such as Object Storage Service (OBS) buckets, shared caches, or shared databases.
  • OBS Object Storage Service
  • Server implementation the cloud platform can configure virtual instances on computing nodes, such as virtual machines, containers, and bare metal servers.
  • the cloud platform is used to provide interfaces or interfaces related to cloud services for tenants to remotely access cloud services.
  • Tenants can log in to the cloud platform through the pre-registered account and password, and after successful login, select and enter the cloud service access page provided by the cloud platform.
  • Purchase corresponding cloud services such as object storage services, virtual machine services, container services, etc.
  • the cloud platform may provide cloud services for processing program codes of tenants.
  • the tenant can upload the program code to the cloud platform, or directly write the program code on the cloud platform.
  • Some program codes in the program code are annotated with the configuration information of the virtual instance, and the cloud platform configures the virtual instance according to the configuration information, The part of the program code is executed through the virtual instance, and the running result of the part of the program code is obtained from the virtual instance, and finally the cloud platform notifies the tenant of the running result of the program code.
  • FIG. 2 is a schematic diagram of the system architecture of a program code processing system according to an embodiment of the present invention.
  • the program code processing system includes a data center and a client.
  • the data center is provided with a cloud platform and a shared storage.
  • the cloud platform includes a cloud service providing unit 10 , a cloud program execution unit 20 and a main program execution unit 30 .
  • the cloud service providing unit 10 is used for providing cloud services to tenants, and the cloud service providing unit 10 includes a virtual instance service interface 101 , a program code service interface 102 , and a shared storage service interface 103 .
  • the client can access the virtual instance service interface 101 to notify the cloud service providing unit 10 to create a virtual instance in the data center that can be accessed by tenants; and the client can access the shared storage service interface 103 to notify the cloud service providing unit 10 that A shared storage space is created in the data center that can be accessed by the tenant.
  • the tenant can upload data to the shared storage space and download data from the shared storage space; the client can also access the program code service interface 102, and the client can use the program code service interface 102.
  • the provided upload interface uploads the program code of the tenant to the cloud platform, and the cloud platform processes the program code uploaded by the tenant on the data center side, or the tenant can operate the client to access the program editing interface provided by the program code service interface 102, so as to realize the operation on the cloud platform.
  • the program code is written online in the middle, and the cloud platform processes the program code written by the tenant online on the data center side.
  • the shared storage space may be, for example, based on an OBS bucket, a shared cache, or a shared database.
  • a virtual instance can be, for example, a virtual machine, a container, or a bare metal server.
  • the program code may be, for example, java, C++, python, ruby or any other commonly used programming language.
  • the shared storage space may be provided by the storage node shown in FIG. 1 .
  • the main program execution unit 30 includes a cloud program execution agent, the main program execution unit 30 is used for running the main program code, and the cloud program execution agent is used for communicating with other cloud program execution agents and executing the marked and annotated program code.
  • the main program execution unit 30 may not be used, and the cloud platform may directly use a virtual instance provided with a cloud program execution agent to run the main program code.
  • the tenant can edit the program on the program editing interface provided by the program code service interface 102, or directly edit the program code locally, and send the edited program code to the upload interface provided by the program code service interface 102 through the client , wherein the cloud platform will provide the tenant with instructions to let the tenant notify the cloud platform with a predetermined mark in the process of editing the program code that the specified part of the program code needs to be executed by the virtual instance configured by the cloud platform, and the program code service interface 102 can convert the program code Send to the cloud program execution unit 20, the cloud program execution unit 20 sends the main program code in the program code to the main program execution unit 30 for execution, identifies the mark, configures the virtual instance according to the configuration information indicated by the mark, and marks the mark Part of the generated program code is sent to the configured virtual instance for execution, thereby realizing program code execution in the cloud, which can reduce the computing load of the client without changing the programming habits of the tenant, thereby improving the programming experience of the tenant.
  • the mark may be a comment of a certain piece of program code, or a program code adjacent to a certain piece of program code that is provided with a predetermined syntax.
  • the main program code public static void main(String[]args) calls program code 1 during the running process, and program code 1 is the function runInCloud1(inputDir , outputDir), program code 1, that is, the function runInCloud1(inputDir, outputDir), calls program code 2, that is, the function runInCloud2(inputFileList, outputDir), during the running process.
  • program code 1 is a subroutine code
  • the set tag is used to indicate that the function runInCloud1(inputDir, outputDir) annotated by the tag needs to be executed by the virtual instance, and the type of the virtual instance is virtual machine, the specification of the virtual machine is s2.
  • Marks are used to separate different subprogram codes, and the cloud platform can confirm different subprogram codes by detecting the marks.
  • the specification may be determined by a flavor pre-defined by the cloud platform, such as s2.small.1 described above, whose specification is, for example, a 2-core processor and 512M memory.
  • the cloud platform configures the virtual instance according to the configuration information by analyzing the configuration information indicated by the tag. .
  • the program code service interface 102 of the cloud platform sends the above program code to the cloud program execution unit 20, the cloud program execution unit 20 configures the virtual instance according to the configuration information indicated by the mark, and according to the above program code, the cloud program execution unit 20 first creates One virtual machine is used to run the program code 1.
  • the program code 1 runs to the position where the program code 2 needs to be called, 4 virtual machines are created to run the program code 2 in parallel.
  • FIG. 3 is another schematic diagram of the system architecture of the program code processing system according to an embodiment of the present invention.
  • the difference between FIG. 3 and FIG. The virtual instances 1-5 configured by the configuration information, and the cloud program execution unit 20 sends the main program code to the main program execution unit 30, sends the program code 1 to the virtual instance 1 for execution, and sends the program code 2 to the virtual instance 2-5 for execution , so that the program code of the tenant can be executed on the data center side based on the cloud platform.
  • each subprogram code corresponds to a cloud program running area.
  • virtual instance 1 is set in cloud program running area 1
  • virtual instance 2 is set in cloud program running area 2-5
  • virtual instance 1-5 can be specifically Runs on the compute node shown in Figure 1.
  • the tag can also be //, which is implemented as follows:
  • program code 1 is a subprogram code
  • program code 2 is another subprogram code (ie, nested program code) called by the subprogram code.
  • it can also be set as the main program code to call two subprogram codes respectively, for example as follows:
  • the main program code first calls program code 2 to transcode the data in the OBS bucket, and then calls program code 1 to perform H265 hash operation on the transcoded data in the OBS bucket.
  • FIG. 4 is a data interaction diagram of a program code processing method according to an embodiment of the present invention, which can be applied to the cloud platform shown in FIGS. 1-3 .
  • the program code processing method according to the embodiment of the present invention includes the following steps:
  • Step S101 The tenant writes program code on the client.
  • the program code writing tool installed in the client by the tenant writes program code
  • the tenant can mark part of the code in the form of comments according to the syntax provided by the cloud platform, and indicate the configuration information in the mark, and the configuration information is available to indicate one or any combination of the type, size, number of virtual instances running the portion of code.
  • the program code includes the main program code, the program code 1 and the program code 2, which can be, for example, the java codes described above.
  • the cloud platform configures the virtual instance according to the default type, specification or quantity.
  • the tenant can send the program code written in other places to the client, and only needs to ensure that the program code is annotated with a mark, and the method of generating the program code is not limited in this embodiment of the present invention.
  • Step S102 The client sends the program code to the cloud platform.
  • the client sends the program code to the program code service interface 102 in the cloud service providing unit 10 .
  • the program code service interface 102 is specifically implemented as an upload interface, and the upload interface is used to receive the program code uploaded by the tenant.
  • the program code service interface 102 can also be specifically implemented as a program code editing interface.
  • the tenant can remotely log in to the program code editing interface provided by the cloud service providing unit 10 by operating the client, and write program code online on the program code editing interface.
  • Step S103 The cloud service providing unit 10 sends the program code to the cloud program execution unit 20.
  • Step S104 The cloud program execution unit 20 sends the main program code to the main program execution unit 30.
  • the cloud program execution unit 20 sends the main program code to the program execution unit of the main program execution unit 30 .
  • the main program code is for example:
  • Step S105 The cloud program execution unit 20 configures the virtual instance 1 according to the mark of the program code 1.
  • program code 1 is, for example:
  • the cloud program execution unit 20 analyzes the tag, and obtains the following configuration information: it is necessary to create a virtual instance whose specification is s2.small.1, the type is virtual machine, and the number is 1, and the main program code runs to the calling program code. When it is at the position of 1, it needs to wait until the execution of program code 1 is completed before continuing to run.
  • the VM indicates that the type is a virtual machine.
  • the type may also include a container and a bare metal server (baremetal server).
  • Step S106 The cloud program execution unit 20 sends the program code 1 adjacent to the mark to the virtual instance 1 that has been configured.
  • Program code 1 is:
  • program code 1 is as follows: read the file list in the OBS bucket corresponding to the URL, call program code 2, program code 2 transcodes each file in the file list respectively, program code 1 is in the program code 2 After the transcoding is completed, a hash operation is performed on the transcoded file, and a corresponding hash value is obtained for each transcoded file.
  • each OBS bucket is located by a uniform resource locator (Uniform Resource Locator, URL).
  • URL Uniform Resource Locator
  • the cloud platform configures and records the URL for the OBS bucket. Tenants can access the OBS bucket through the URL.
  • OBS bucket is the shared storage space shown in Figure 1 and Figure 2.
  • the OBS bucket is a specific implementation of the shared storage space. Other implementations with shared storage capabilities.
  • the shared storage space is used to store data to be processed, and the data to be processed is, for example, a file in an OBS bucket.
  • the program code disposed adjacent to the mark may be referred to as cloud program code, for example, program code 1 and program code 2 may both be referred to as cloud program code, and the cloud program code is a virtual instance configured by the cloud program execution unit 20 implement. And the virtual instance 1 is set in the cloud program running area 1.
  • Step S107 the main program execution unit 30 executes the main program code to the position where the program code 1 needs to be called, and suspends the execution of the main program code, and waits for the execution of the program code 1 to be completed.
  • Step S108 The cloud program execution agent of the main program execution unit 30 requests the cloud program execution unit 20 for the running result of the program code 1.
  • Step S109 The cloud program execution unit 20 requests the virtual instance 1 for the running result of the program code 1.
  • Step S110 The virtual instance 1 executes the program code 1 to the position where the program code 2 needs to be called, and starts to wait.
  • Step S111 The cloud program execution agent of the virtual instance 1 requests the cloud program execution unit 20 for the execution result of the program code 2.
  • Step S112 The cloud program execution unit 20 configures the virtual instance 2-5 according to the configuration information indicated by the mark of the program code 2.
  • Step S113 The cloud program execution unit 20 sends the program code 2 to the configured virtual instances 2-5 respectively.
  • Step S114 The virtual instances 2-5 execute the program code 2 respectively.
  • the cloud program execution agents in the virtual instances 2-5 execute the program code 2 respectively.
  • the virtual instances 2-5 execute the same program code 2, thereby running the same business logic.
  • the business logic of the program code is as follows:
  • Each virtual instance 2-5 obtains its own task identifier taskId according to QtContext.getTaskIndex().
  • QtContext.getTaskIndex() When the virtual instance runs QtContext.getTaskIndex(), it will send a request to the cloud program execution unit 20, and the cloud program execution unit 20 will send a request to the cloud program execution unit 20 according to the request. Return the taskId to the virtual instance.
  • transcodingToH265 (fileList[i] ,outputDir+"/"+i+”.mp4") is used to transcode the i-th file in the file list to a file in H265 format.
  • each virtual instance After each virtual instance finishes running the program code 2, record the running result of the program code 2, where the running result is, for example, 1 or 0, 1 means the running is successful, 0 means the running fails, this embodiment assumes that each virtual instance successfully runs the program 2, so each virtual instance 2-5 records the running result of program code 2 as 1.
  • the cloud platform provides the data to be processed
  • the program code 2 is used to instruct the virtual instance 2-5 to obtain the data to be processed from the cloud platform and execute the business logic of the program code 2 according to the data to be processed.
  • QtContext.getTaskIndex() is a message queue service API provided by the cloud platform, which is defined by the cloud program execution unit 20 of the cloud platform.
  • QtContext.getTaskIndex() When the virtual instance calls QtContext.getTaskIndex(), it will send a request to the cloud program execution unit 20.
  • the program execution unit 20 returns the taskId to the virtual instance according to the request.
  • the cloud program execution unit 20 of the cloud platform can also provide other cloud services except the message queue service and set a cloud service application program interface API for the cloud service, wherein the program code is provided with the corresponding cloud service API.
  • the cloud service API when called, it can be used to instruct the virtual instance to call the cloud service provided by the cloud platform.
  • the cloud service AIP also includes an object storage service API, a database service API, and a shared cache service API, wherein the object storage service API is, for example, the above-mentioned API.
  • the URL of the OBS bucket needs to be input, so that the cloud program execution unit 20 locates the OBS bucket to be accessed according to the URL, and the virtual instance can access the OBS bucket through the cloud program execution unit 20 .
  • the virtual instance runs the database service API
  • the name of the database and the account password need to be input, so that the cloud program execution unit 20 locates the database and logs in to the database through the account and password, and the virtual instance can access the database through the cloud program execution unit 20 .
  • the name of the shared cache needs to be entered, so that the cloud program execution unit 20 can locate the shared cache according to the name, and the virtual instance can share the cache through the cloud program execution unit 20.
  • Step S115 The cloud program execution unit 20 requests the virtual instances 2-5 for the execution result of the program code 2 respectively.
  • the cloud program execution unit 20 sends a request for the execution result of the program code 2 to the cloud program execution agents of the virtual instances 2-5, respectively.
  • Step S116 The virtual instances 2-5 respectively return the running result of the program code 2 to the cloud program execution unit 20.
  • the cloud program execution agents of the virtual instances 2-5 respectively return the execution result of the program code 2 to the cloud program execution unit 20 .
  • Step S117 The cloud program execution unit 20 returns the running result of the program code 2 to the virtual instance 1.
  • the cloud program execution unit 20 returns the execution result of the program code 2 to the cloud program execution agent of the virtual instance 1 .
  • Step S118 The virtual instance 1 continues to run the program code 1.
  • the cloud program execution agent of the virtual instance 1 continues to run the program code 1 according to the running result of the program code 2, and executes the remaining statements:
  • Step S119 The virtual instance 1 sends the running result of the program code 1 to the cloud program execution unit 20.
  • the cloud program execution agent of the virtual instance 1 sends the execution result of the program code 1 to the cloud program execution unit 20 , where this step is the response of step 108 .
  • Step S120 the cloud program execution unit 20 sends the execution result of the program code 1 to the main program execution unit 30 .
  • the cloud program execution unit 20 sends the execution result of the program code 1 to the cloud program execution agent of the main program execution unit 30 .
  • Step S121 The main program execution unit 30 continues to execute the main program code.
  • the cloud program execution agent of the main program execution unit 30 continues to execute the main program code according to the running result (1) of the program code 1 .
  • Step S122 the main program code is finished running.
  • Step S123 The cloud program execution agent of the main program execution unit 30 notifies the cloud service providing unit 10 that the main program code has been executed.
  • Step S124 The cloud service providing unit 10 notifies the client that the main program code runs successfully.
  • the cloud service providing unit 10 notifies the client through the program code service interface 102 that the main program code has been executed.
  • the tenant learns from the program code service interface 102 through the client that the program code has been executed, and the data in the OBS bucket has been transcoded and hashed.
  • the number of virtual instances is not limited, as long as the computing capability of the data center allows, for example, a tenant can select 1-1000 virtual instances to perform parallel operations of the same program logic for different data to be processed. .
  • Embodiment 1 only one data center is disclosed. In other embodiments of the present invention, the number of data centers may be more than one. For scenarios of cross-data center cooperation, tenants may choose to configure a larger number of virtual instances.
  • the cloud platform may create a virtual instance on the physical server according to the configuration information indicated by the mark; or the cloud platform may pre-create multiple virtual instances, select and mark the multiple virtual instances. The virtual instance that matches the indicated configuration information.
  • the above mark is the annotation of the program code 1 or the program code 2, but in other embodiments of the present invention, the above mark can be other program codes using a predetermined syntax and adjacent to the program code 1 or the program code 2.
  • the mark can also be any mark pre-agreed with the cloud platform.
  • the embodiment of the present invention allows the tenant's program code to be executed on the data center side, and the tenant does not need to change their own programming habits, and can use their commonly used programming language to write the program code, and the tenant only needs to execute the part that needs to be executed on the virtual instance
  • the program code is marked, and the configuration information of the virtual instance running the program code is set in the mark.
  • the cloud platform creates or selects a virtual instance that matches the configuration information according to the mark, sends the program to the virtual instance to run, and obtains it from the virtual instance. As a result of the operation, these program codes can be run through virtual instances.
  • the computing power of the data center is fully utilized, and the entry threshold is low (only tenants are required). marking specific program code), so it can greatly improve the convenience for tenants to utilize cloud resources for massively parallel computing.
  • the tenant can create a service virtual instance in the data center through the cloud platform, write program code on the service virtual instance, or send the program code to the service virtual instance from other devices.
  • the program code runs in the service virtual instance, and the program Part of the program code in the code is annotated with the configuration information of the virtual instance.
  • the cloud platform is notified to configure the virtual instance according to the configuration information, execute the part of the program code through the virtual instance, and obtain from the virtual instance.
  • the running result of this part of the program code, and finally the business virtual instance notifies the tenant of the running result of the program code.
  • FIG. 5 is a schematic diagram of another system architecture of a program code processing system according to an embodiment of the present invention. Compared with FIG. 2, in the embodiment shown in FIG. 5, the cloud service providing unit 10 does not provide a program The code service interface 102 is provided, and the main program execution unit 30 is not set in the cloud platform.
  • Embodiment 2 directly runs the program code in the tenant's production environment or test environment (that is, the business virtual instance), and configures the virtual instance through the cloud platform to run the marked part of the program code during the program code execution process. , it can also improve the convenience for the tenant to use cloud resources to perform large-scale parallel computing, and because the second embodiment directly runs the program code in the production environment, in the scenario where the tenant purchases a business virtual instance, the program is directly executed on the business virtual instance. The code is more in line with the usage habits of tenants.
  • the program code exemplified in this embodiment is consistent with the java code shown in Embodiment 1.
  • the tenant's service virtual instance is created by the tenant using the client to access the virtual instance service interface 101 in the service providing unit of the cloud platform. After the virtual instance is created, the tenant can remotely log in to the service virtual instance through the client. After the tenant creates the service virtual instance, the cloud platform can provide the installation file of the cloud program execution agent, and the tenant can download and install the installation file to the business virtual instance.
  • the cloud program execution agent may also be pre-installed in the service virtual instance.
  • the business virtual instance directly runs the program code, and the cloud program execution agent of the business virtual instance can identify the mark, configure the virtual instance according to the mark, and send part of the program code set with the mark to the configured virtual instance for execution, so as to realize the implementation in the cloud.
  • the program code execution can reduce the computing load of the client without changing the programming habits of the tenant, thereby improving the programming experience of the tenant.
  • FIG. 6 is another schematic diagram of the system architecture of the program code processing system according to an embodiment of the present invention.
  • the difference between FIG. 6 and FIG. 5 is that a cloud program execution unit 20 is added according to the mark indicated The virtual instances 1-5 configured by the configuration information, and the cloud program execution unit 20 sends the program code 1 to the virtual instance 1 for execution, and sends the program code 2 to the virtual instance 2-5 for execution, so that the program code of the tenant can be based on the cloud platform. Executed on the data center side.
  • FIG. 7 is another data interaction diagram of a program code processing method according to an embodiment of the present invention.
  • the program code processing method shown in FIG. 7 can be applied to FIGS. 1-3 and 5-6. in the architecture shown.
  • the program code processing method according to the embodiment of the present invention includes the following steps:
  • Step S201 The client sends a service virtual instance creation request to the cloud platform.
  • the tenant operates the client to access the virtual instance service interface 101 of the cloud service providing unit 10, selects the type and specification of the service virtual instance on the virtual instance service interface 101, and the cloud platform creates the service virtual instance of the corresponding type and specification.
  • Step S202 The cloud platform creates a virtual service instance.
  • the cloud service providing unit 10 of the cloud platform creates virtual service instances of corresponding types and specifications.
  • Step S203 The tenant remotely logs in to the service virtual instance through the client, and develops program codes on the service virtual instance.
  • the tenant can also operate the service virtual instance to download program code from other devices.
  • Step S204 the service virtual instance runs the main program code.
  • the cloud program execution agent of the business virtual instance runs the main program code:
  • Step S205 the service virtual instance runs the main program code to the position where the program code 1 needs to be called, and starts to wait.
  • Step S206 The service virtual instance sends program code 1 and program code 2 to the cloud program execution unit 20.
  • the program code executed by the instance and send the program code 1 to the cloud program execution unit 20 .
  • the cloud program execution unit 20 analyzes the mark, and obtains the following information: it is necessary to create a virtual instance whose specification is s2.small.1, the type is virtual machine, and the number is 1, and the main program code runs to the calling program code 1 When the position of the program code 1 is completed, it needs to wait until the program code 1 is executed before continuing to run.
  • Step S208 The cloud program execution unit 20 sends the program code 1 to the configured virtual instance 1.
  • Step S209 The cloud program execution agent of the service virtual instance requests the cloud program execution unit 20 for the running result of the program code 1.
  • Step S210 The cloud program execution unit 20 requests the virtual instance 1 for the running result of the program code 1.
  • Step S211 The cloud program execution agent of the virtual instance 1 executes the program code 1, reaches the position where the program code 2 needs to be called, and starts to wait.
  • Step S212 The virtual instance 1 requests the cloud program execution unit 20 for the running result of the program code 2.
  • Step S213 The cloud program execution unit 20 configures the virtual instance 2-5 according to the configuration information indicated by the mark of the program code 2.
  • Step S214 The cloud program execution unit 20 sends the program code 2 to the configured virtual instances 2-5 respectively.
  • Step S215 The virtual instances 2-5 execute the program code 2 respectively.
  • Step S216 The cloud program execution unit 20 requests the virtual instance 2-5 for the execution result of the program code 2.
  • Step S217 The virtual instance 2-5 sends the execution result of the program code 1 to the cloud program execution unit 20.
  • Step S218 The cloud program execution unit 20 sends the execution result of the program code 2 to the virtual instance 1.
  • Step S219 The cloud program execution agent of the virtual instance 1 receives the running result of the program code 2, and continues to run the program code 1 according to the running result to generate the running result of the program code 1.
  • Step S220 The virtual instance 1 sends the execution result of the program code 1 to the cloud program execution unit 20.
  • Step S221 The cloud program execution unit 20 sends the execution result of the program code 1 to the cloud program execution agent of the service virtual instance.
  • Step S222 The cloud program execution agent of the service virtual instance ends waiting according to the running result of the program code 1, and continues to execute the main program code.
  • Step S223 The cloud program execution agent of the service virtual instance runs the remaining main program code.
  • the tenant logs in to the service virtual instance through the client and learns from the cloud program execution agent of the service virtual instance that the program code has been executed, and that the data in the OBS bucket has been transcoded and hashed.
  • Embodiment 2 is similar to Embodiment 1 in other aspects except that the main program execution body is a business virtual machine. It is worth noting that, similar to Embodiment 1, in this embodiment, as long as the computing power of the data center (depending on the idle The number of physical servers) allows, and the number of virtual instances is not limited. For example, a tenant may select 1-1000 virtual instances to perform parallel operations of the same program logic for different data to be processed.
  • Embodiment 2 only one data center is disclosed. In other embodiments of the present invention, the number of data centers may be more than one. For scenarios of cross-data center cooperation, tenants may choose to configure a larger number of virtual instances.
  • the cloud platform can create a virtual instance on the physical server according to the configuration information indicated by the mark; or the cloud platform pre-creates multiple virtual instances, selects and marks the multiple virtual instances The virtual instance that matches the indicated configuration information.
  • the above mark is the annotation of the program code 1 or the program code 2, but in other embodiments of the present invention, the above mark can be other program codes using a predetermined syntax and adjacent to the program code 1 or the program code 2.
  • the embodiment of the present invention allows the tenant's program code to be executed on the data center side, and the tenant does not need to change their own programming habits, and can use their commonly used programming language to write the program code, and the tenant only needs to execute the part that needs to be executed on the virtual instance
  • the program code is marked, and the configuration information of the virtual instance running the program code is set in the mark.
  • the cloud platform creates or selects a virtual instance that matches the configuration information according to the mark, sends the program code to the virtual instance to run, and executes the program code from the virtual instance. Obtain the running results of the program code, so that these program codes can be run through virtual instances.
  • Embodiment 2 directly runs the program code in the tenant's production environment or test environment (that is, the business virtual instance), and configures the virtual instance through the cloud platform to run the marked part of the program code during the program code execution process. , which can improve the convenience for the tenant to use cloud resources to perform large-scale parallel computing, and because the second embodiment directly runs the program code in the production environment, it is more in line with the tenant's usage habits in the scenario where the tenant has purchased a virtual instance of the service.
  • the main program code calls program code 1, and program code 1 calls program code 2, but it is worth noting that the embodiments of the present invention are not limited to this, the main program code
  • the program code can call program code 1 and program code 2 respectively, and the tenant can also make the main program code call more program code 1 according to actual needs, and program code 1 can be nested to call more layers of program code 2.
  • the virtual instance 2-5 configured by the cloud program execution unit 20 according to the configuration information indicated by the mark can be released after the virtual instance 2-5 returns the running result of the program code 2 to the cloud program execution unit 20,
  • the virtual instance 1 can be released after the virtual instance 1 returns the execution result of the program code 1 to the cloud program execution unit 20 .
  • the release is, for example, stopping the running of the virtual instance, deregistering the virtual instance in the physical server, or clearing the data recorded in the memory of the virtual instance. Timely release of virtual instances can improve the resource utilization efficiency of virtual instances.
  • FIG. 8 is a schematic structural diagram of a storage node according to an embodiment of the present invention.
  • the storage node ie, the storage node 201 or 202 shown in FIG. 7
  • the hardware layer includes a disk controller 2075 , physical network card 2076, physical disk 1 and physical disk 2
  • the software layer includes an object storage device (Object Storage Device, OSD) control unit 2012 and an operating system 2012
  • the OSD control unit 2012 runs on the operating system 2012
  • the operating system 2012 includes The disk drive 2013 and the physical network card driver 2014
  • the cloud platform can communicate with the OSD control unit 2011 through the physical network card 2016, and the OSD control unit 2011 controls the disk controller 2015 through the disk drive 2013 to set the physical disk 1 and physical disk 2 as multiple objects
  • the cloud platform after receiving the OBS bucket creation instruction from the tenant, the cloud platform notifies the OSD control unit 2011 to create an OBS bucket.
  • the OSD control unit 2011 sets OSD1-3 as the OBS bucket, and configures a URL for the OBS bucket.
  • the tenant can upload the data to be processed involved in the above embodiment to the OBS bucket, where the URL is the address of the data to be processed provided by the cloud platform.
  • the computing node (for example, the computing node 301 or 302 shown in FIG. 7 ) includes a software layer and a hardware layer, and the hardware layer includes a The processor, memory, disk and network card of the bus, the software layer includes the operating system and multiple virtual machines running on the operating system, such as virtual machine 1 and virtual machine 2 shown in FIG. In the system, it is used to manage multiple virtual machines and set virtual hardware for each virtual machine according to the hardware layer.
  • Each virtual machine is set with a cloud program execution agent.
  • the cloud platform can communicate with the virtual machine manager through the network card.
  • the cloud platform Create or log off virtual machines on computing nodes through the virtual machine manager, and manage the full life cycle of the virtual machines.
  • FIG. 10 is another schematic structural diagram of a computing node according to an embodiment of the present invention.
  • the computing node (for example, the computing node 301 or 302 shown in FIG. 7 ) includes a software layer and a hardware layer, and the hardware layer includes The processor, memory, disk and network card connected to the bus, the software layer includes the operating system and multiple containers running on the operating system, such as container 1 and container 2 shown in Figure 9, the container manager is set in the operating system , used to manage multiple containers and set virtual hardware for each container according to the hardware layer.
  • Each container is set with a cloud program execution agent.
  • the cloud platform can communicate with the container manager through the network card.
  • the node creates or deregisters the container, and manages the whole life cycle of the container.
  • FIG. 11 is another schematic structural diagram of a computing node according to an embodiment of the present invention.
  • the computing node (for example, the computing node 301 or 302 shown in FIG. 7) includes a software layer and a hardware layer, and the hardware layer includes The processor, memory, disk, network card, and offload card connected to the bus.
  • the software layer includes the operating system and the cloud program execution agent set in the operating system.
  • the cloud platform can manage the computing node through the offload card, so that the computing node can manage the computing node in addition to the offload card.
  • the hardware resources of the tenant are completely managed by the tenant. At this time, the computing node is the bare metal server purchased by the tenant from the cloud platform.
  • the above-mentioned virtual machines, containers, and bare metal servers are all provided with the cloud program execution agent described in the embodiment of the present invention, and the cloud program execution unit 20 can communicate with the cloud program execution agent to control the virtual machine. , containers, and bare metal servers to execute cloud program code.
  • the embodiments of the present invention enable developers to retain programming habits through the compilation technology, and can directly use the cloud environment to provide computing power during the programming process, without the need to learn complex programming, nor to subsequently design and develop the entire distributed system.
  • FIG. 12 is a schematic diagram of a device structure of a computer device according to an embodiment of the present invention.
  • the computer device includes a processor 1001, a memory 1002, a communication interface 1003, and a bus 1004.
  • the processor 1001, The memory 1002 and the communication interface 1003 are respectively connected to the bus 1004, the memory 1002 is used to store computer-executed instructions, and the processor 1001 is used to execute the computer-executed instructions stored in the memory 1002, so that the computer device can implement the above-mentioned Embodiment 1 and/or Embodiments 2.
  • the method performed by the cloud platform is performed by the cloud platform.
  • an embodiment of the present invention further provides a computer storage medium, including computer-readable instructions, when the computer-readable instructions are executed, the method executed by the cloud platform in the foregoing Embodiment 1 and/or Embodiment 2 is implemented.
  • Embodiments of the present invention also provide a computer program product containing instructions, which, when run on a computer, cause the computer to execute the method executed by the cloud platform in Embodiment 1 and/or Embodiment 2 above.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general purpose computer, special purpose computer, computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be retrieved from a website, computer, training device, or data Transmission from the center to another website site, computer, training equipment, or data center via wired (eg, coax, fiber, digital tenant line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.) means.
  • wired eg, coax, fiber, digital tenant line (DSL)
  • wireless eg, infrared, wireless, microwave, etc.
  • the computer-readable storage medium may be any available medium that can be stored by a computer, or a data storage device such as a training device, a data center, or the like that includes an integration of one or more available media.
  • the usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk (SSD)), and the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

本申请提供一种云平台及基于云服务的程序代码处理方法,该方法包括以下步骤:云平台可接收租户的程序代码,对其进行处理,具体包括以下步骤:云平台获取租户的程序代码,程序代码包括第一标记和子程序代码,第一标记用于指示运行子程序代码的虚拟实例的配置信息,云平台根据第一标记创建或选择一个或多个第一虚拟实例,云平台将子程序代码分别发送给一个或多个第一虚拟实例,云平台接收一个或多个第一虚拟实例分别运行子程序代码得到的第一运行结果。以上方式可提高程序员利用云资源进行程序开发的体验。

Description

云平台及基于云平台的程序代码处理方法 技术领域
本申请涉及云技术领域,尤其涉及一种云平台及基于云平台的程序代码处理方法。
背景技术
现阶段云计算越来越流行,是未来信息技术发展的必然趋势,云计算服务是由云服务提供商提供基础云服务,租户可通过互联网使用基础云服务,举例而言,云服务提供商在自身运营的云数据中心中配置服务器,租户可通过向云服务提供商付费获得服务器中特定规格的虚拟机的远程使用权限,从而实现基础云服务的使用,云服务并不限定于虚拟机,也可包括对象存储服务、数据库服务、安全服务、人脸识别服务等等。云计算服务可以让租户跳过繁琐的服务器配置过程,通过付费即可获得云服务提供商提供的基础云服务。
由于云计算的流行,程序员在开发大规模计算程序的过程中,也可以利用云服务提供的运算能力,例如程序员可分别设置多个虚拟机,在多个虚拟机分别写入程序员提前拆分好的程序代码,并使多个虚拟机分别运行程序代码,最后程序员在多个虚拟机中收集程序代码运行结果,从而利用云服务提供的运算能力实现大规模计算程序的运行,例如MapReduce架构下的Hadoop、Spark是较好的完成大规模计算的方式。
但是,目前的利用云服务完成大规模计算的方法在使用上还是较为复杂,需要租户登录云平台,租户在云平台提供的接口输入所需虚拟机的配置,以创建虚拟机,并登录创建好的虚拟机,设置虚拟机运行特定程序代码,用户体验不佳。
发明内容
本申请提供了一种云平台及基于云平台的程序代码处理方法,可提高程序员利用云资源进行程序开发的体验。
第一方面,本申请提供一种基于云服务的程序代码处理方法,云平台可接收租户的程序代码,对其进行处理,具体包括以下步骤:云平台获取租户的程序代码,程序代码包括第一标记和子程序代码,第一标记用于指示运行子程序代码的虚拟实例的配置信息,云平台根据第一标记创建或选择一个或多个第一虚拟实例,云平台将子程序代码分别发送给一个或多个第一虚拟实例,云平台接收一个或多个第一虚拟实例分别运行子程序代码得到的第一运行结果。
租户编写程序代码时,可在程序代码中设置用于指示运行子程序代码的虚拟实例的配置信息的第一标记,云平台获取该程序代码,云平台根据该第一标记创建或选择至少一个虚拟实例来运行子程序代码,并接收至少一个虚拟实例运行子程序代码得到的第一运行结果,因此,租户可在程序代码中打上标记,即可通知云平台创建对应的虚拟实例并运行子程序代码,在不改变已有的编程习惯的前提下,可有效利用云资源运行子程序代码,并且可提高用户体验。
并且,租户无需登录第一虚拟实例,第一虚拟实例由云平台从后台进行配置,可进一步提高用户体验。
其中,标记还用于对不同的子程序代码进行分隔,以使得云平台通过标记确认不同的子程序代码。
可选地,配置信息包括虚拟实例规格。
其中,虚拟实例规格包括虚拟实例的处理器核数、处理器主频大小、内存大小。
租户在编程过程中,在程序代码打上标记,并在标记指示的配置信息设置要创建的虚拟实例的规格,当运行子程序代码所需的运算能力较高时,虚拟实例规格可设置为高规格,当运行子程序代码所需的运算能力较低时,虚拟实例规格可设置为低规格,从而可以达成灵活利用云资源运行子程序代码的技术效果,由于虚拟实例规格与虚拟实例的售卖价格成正比,因此,租户还可以通过设置标记根据自己所需的云资源算力合理地设置虚拟实例规格,从而有效节省从云平台购买云资源的费用。
可选地,配置信息包括虚拟实例类型,虚拟实例类型用于指示虚拟机、容器、裸金属服务器中的任一者。
租户在编程过程中,在程序代码打上标记,并在标记指示的配置信息设置要创建的虚拟实例的类型,类型例如为虚拟机、容器、或裸金属服务器,从而可以达成灵活利用云资源运行子程序代码的技术效果,由于不同的虚拟实例类型,例如虚拟机、容器、和裸金属服务器的售卖价格各不相同,因此,租户还可以通过设置标记根据自己所需的云资源算力合理地选择虚拟实例类型,从而有效节省从云平台购买云资源的费用。
其中,针对大规模运算,租户可选择虚拟机或裸金属服务器,该两种虚拟实例运行状态稳定,针对小规模运算,租户可选择容器。
可选地,配置信息包括虚拟实例数量N,N为正整数。
租户在编程过程中,在程序代码打上标记,并在标记指示的配置信息设置要创建的虚拟实例的数量,该数量用于指示运行该子程序代码的虚拟实例的数量,当N设置为复数,子程序代码在多个虚拟实例中运行,针对大数据场景,并行运算是一项重要的数据处理方法,租户可以在程序代码中标记出运行某个特定子程序代码的虚拟实例的数量,让多个虚拟实例并行地运行子程序代码,因此云平台可向租户提供并行编程的能力。
可选地,第一虚拟实例的数量为多个,子程序代码用于指示多个第一虚拟实例分别从共享存储空间获取不同的待处理数据并分别对获取到的待处理数据进行数据处理。
基于多个虚拟实例并行地运行子程序代码的场景,租户通过子程序代码的编写,让子程序代码用于指示多个第一虚拟实例分别从共享存储空间获取不同的待处理数据并分别对获取到的待处理数据进行数据处理,因此,多个第一虚拟实例可针对不同的待处理数据运行相同的子程序代码以实现相同的程序逻辑,实现并行运算。
可选地,程序代码还包括嵌套程序代码和第二标记,第二标记用于指示运行嵌套程序代码的虚拟实例的配置信息,嵌套程序代码被子程序代码调用,上述方法还包括以下步骤:云平台根据第二标记创建或选择一个或多个第二虚拟实例,并分别发送嵌套程序代码至一个或多个第二虚拟实例,云平台接收一个或多个第二虚拟实例分别运 行嵌套程序代码得到的第二运行结果,并发送第二运行结果至第一虚拟实例。
在本实现方式中,子程序代码调用另一子程序代码的情况下,该另一子程序代码称为嵌套程序代码,第二标记指示运行嵌套程序代码的虚拟实例的配置信息,云平台根据第二标记指示的配置信息创建或选择一个或多个第二虚拟实例,并发送嵌套程序代码至该一个或多个第二虚拟实例运行,并将运行得到的第二运行结果发送至第一虚拟实例,因此,本实现方式中,在存在子程序代码嵌套的情况下,云平台从运行嵌套程序代码的虚拟实例获取运行结果并发送至运行调用该嵌套程序代码的子程序代码的虚拟实例,从而使得嵌套程序代码的运行结果能够到达第一虚拟实例中,第一虚拟实例根据该运行结果继续运行子程序代码,从而实现程序代码嵌套。
可选地,程序代码还包括主程序代码,子程序代码被主程序代码调用,该方法还包括以下步骤:云平台在运行主程序代码至需调用子程序代码的位置时,向一个或多个第一虚拟实例请求第一运行结果,云平台根据第一运行结果继续运行主程序代码。
在本实现方式中,云平台直接运行主程序代码,并在运行主程序代码调用子程序代码的位置时,云平台不运行子程序代码,而是向运行子程序代码的第一虚拟实例请求第一运行结果,并根据请求获得的第一运行结果继续运行主程序代码,通过云平台直接运行主程序代码并与运行子程序代码的虚拟实例通信,可实现主程序代码调用子程序代码的全过程,从而确保租户的编程习惯不变。
可选地,以上方法还包括以下步骤:云平台提供上传接口,上传接口用于接收租户上传的程序代码,或云平台提供程序编辑界面,程序编辑界面用于接收租户远程输入的程序代码。
在本实现方式中,租户在本地编写好程序代码之后,可通过上传接口把程序代码上传到云平台,或者,租户可直接在云平台提供的程序编辑界面中远程输入程序代码,从而在云平台中实现在线编程。
其中,以上两种方式可同时提供给租户,租户可根据自身编程习惯选择一种方式,从而进一步提高用户体验。
可选地,该方法还包括以下步骤:云平台提供云服务并为云服务设置云服务应用程序接口API,其中子程序代码中设置有云服务API,云服务API用于调用云平台提供的云服务。
在本实现方式中,租户在编写子程序代码中,可调用云平台提供的云服务API,从而充分地利用云服务提供的云资源。
可选地,云服务API包括:对象存储服务API、数据库服务API、共享缓存服务API、消息队列服务API中的一者或任意组合。
可选地,第一标记和第二标记为子程序代码的注解,或第一标记和第二标记为采用预定语法且与子程序代码相邻的程序代码。
在本实现方式中,第一标记和第二标记可设置为子程序代码的注解,例如为程序代码前,或程序代码后,以@、\\、\、/、//或其他的与云平台预先约定好的符号标记,并在符号之后以预定格式输入虚拟实例的类型、规格、数量等配置信息,云平台在检测到该符号时,根据该符号后指示的虚拟实例的类型、规格、数量创建虚拟实例,并发送子程序代码让虚拟实例运行,通过注解,无需改变租户的编程习惯,租户只需在 子程序代码前或后输入符号,并在符号后输入配置信息,即可实现利用云侧的虚拟实例来运行子程序代码。
第一标记和第二标记可设置为采用预定语法且与子程序代码相邻的程序代码,例如,云平台约定采用预定语法的函数creatvirtualinstance(type,spec,N)作为标记,则租户可在编写程序代码过程中,在子程序代码相邻的位置(子程序前或后的位置)调用creatvirtualinstance(type,spec,N),并根据自身需要输入虚拟实例的类型type,规格spec,数量N中的一者或任意组合,即可对子程序代码进行标记,让该子程序代码在云平台根据类型type,规格spec,数量N中的一者或任意组合创建好或选择好的虚拟实例中运行。
第二方面,本申请提供一种基于云服务的程序代码处理方法,包括以下方法:云平台接收运行主程序代码的业务虚拟实例发送的子程序代码和第一标记,其中子程序代码被主程序代码调用,第一标记用于指示运行子程序代码的虚拟实例的配置信息,云平台根据第一标记创建或选择一个或多个第一虚拟实例,云平台发送子程序代码至一个或多个第一虚拟实例,云平台接收一个或多个第一虚拟实例分别运行子程序代码得到的第一运行结果并发送第一运行结果至业务虚拟实例。
与第一方面相比,主程序代码可直接在租户的业务虚拟机上直接运行,业务虚拟机发送被主程序代码调用的子程序代码和第一标记至云平台,云平台根据该第一标记创建或选择至少一个虚拟实例来运行子程序代码,接收至少一个虚拟实例运行子程序代码得到的第一运行结果,并将第一运行结果发送给业务虚拟实例,使得业务虚拟实例可继续根据第一运行结果继续运行主程序,因此,租户通过标记即可通知云平台创建对应的虚拟实例并运行子程序代码,在不改变已有的编程习惯的前提下,可有效利用云资源运行子程序代码,并且可提高用户体验。
可选地,配置信息包括虚拟实例规格。
其中,虚拟实例规格包括虚拟实例的处理器核数、处理器主频大小、内存大小。
租户在编程过程中,在程序代码打上标记,并在标记指示的配置信息设置要创建的虚拟实例的规格,当运行子程序代码所需的运算能力较高时,虚拟实例规格可设置为高规格,当运行子程序代码所需的运算能力较低时,虚拟实例规格可设置为低规格,从而可以达成灵活利用云资源运行子程序代码的技术效果,由于虚拟实例规格与虚拟实例的售卖价格成正比,因此,租户还可以通过设置标记根据自己所需的云资源算力合理地设置虚拟实例规格,从而有效节省从云平台购买云资源的费用。
可选地,配置信息包括虚拟实例类型,虚拟实例类型用于指示虚拟机、容器、裸金属服务器中的任一者。
租户在编程过程中,在程序代码打上标记,并在标记指示的配置信息设置要创建的虚拟实例的类型,类型例如为虚拟机、容器、或裸金属服务器,从而可以达成灵活利用云资源运行子程序代码的技术效果,由于不同的虚拟实例类型,例如虚拟机、容器、和裸金属服务器的售卖价格各不相同,因此,租户还可以通过设置标记根据自己所需的云资源算力合理地选择虚拟实例类型,从而有效节省从云平台购买云资源的费用。
其中,针对大规模运算,租户可选择虚拟机或裸金属服务器,该两种虚拟实例运 行状态稳定,针对小规模运算,租户可选择容器。
可选地,配置信息包括虚拟实例数量N,N为正整数。
租户在编程过程中,在程序代码打上标记,并在标记指示的配置信息设置要创建的虚拟实例的数量,该数量用于指示运行该子程序代码的虚拟实例的数量,当N设置为复数,子程序代码在多个虚拟实例中运行,针对大数据场景,并行运算是一项重要的数据处理方法,租户可以在程序代码中标记出运行某个特定子程序代码的虚拟实例的数量,让多个虚拟实例并行地运行子程序代码,因此云平台可向租户提供并行编程的能力。
可选地,子程序代码用于指示一个或多个第一虚拟实例分别从共享存储空间获取不同的待处理数据并分别对获取到的待处理数据进行数据处理。
基于多个虚拟实例并行地运行子程序代码的场景,租户通过子程序代码的编写,让子程序代码用于指示一个或多个第一虚拟实例分别从共享存储空间获取不同的待处理数据并分别对获取到的待处理数据进行数据处理,因此,一个或多个第一虚拟实例可针对不同的待处理数据运行相同的子程序代码以实现相同的程序逻辑,实现并行运算。
可选地,上述方法还包括以下步骤:云平台接收运行业务虚拟实例发送的嵌套程序代码和第二标记,第二标记用于指示运行嵌套程序代码的虚拟实例的配置信息,嵌套程序代码被子程序代码调用,云平台根据第二标记创建或选择一个或多个第二虚拟实例,并发送嵌套程序代码至一个或多个第二虚拟实例,云平台从一个或多个第二虚拟实例获取一个或多个第二虚拟实例运行第二程序代码产生的第二运行结果,并发送第二运行结果至第一虚拟实例。
在本实现方式中,子程序代码调用另一子程序代码的情况下,该另一子程序代码称为嵌套程序代码,第二标记指示运行嵌套程序代码的虚拟实例的配置信息,云平台根据第二标记指示的配置信息创建或选择一个或多个第二虚拟实例,并发送嵌套程序代码至该一个或多个第二虚拟实例运行,并将运行得到的第二运行结果发送至第一虚拟实例,因此,本实现方式中,在存在子程序代码嵌套的情况下,云平台从运行嵌套程序代码的虚拟实例获取运行结果并发送至运行调用该嵌套程序代码的子程序代码的虚拟实例,从而使得嵌套程序代码的运行结果能够到达第一虚拟实例中,第一虚拟实例根据该运行结果继续运行子程序代码,从而实现程序代码嵌套。
可选地,该方法还包括以下步骤:云平台提供云服务并为云服务设置云服务应用程序接口API,其中子程序代码中设置有云服务API,云服务API用于调用云平台提供的云服务。
在本实现方式中,租户在编写子程序代码中,可调用云平台提供的云服务API,从而充分地利用云服务提供的云资源。
可选地,云服务API包括:对象存储服务API、数据库服务API、共享缓存服务API、消息队列服务API中的一者或任意组合。
可选地,第一标记为子程序代码的注解,或第一标记为采用预定语法且与子程序代码相邻的程序代码。
在本实现方式中,第一标记和第二标记可设置为子程序代码的注解,例如为程序 代码前,或程序代码后,以@、\\、\、/、//或其他的与云平台预先约定好的符号标记,并在符号之后以预定格式输入虚拟实例的类型、规格、数量等配置信息,云平台在检测到该符号时,根据该符号后指示的虚拟实例的类型、规格、数量创建虚拟实例,并发送子程序代码让虚拟实例运行,通过注解,无需改变租户的编程习惯,租户只需在子程序代码前或后输入符号,并在符号后输入配置信息,即可实现利用云侧的虚拟实例来运行子程序代码。
第一标记和第二标记可设置为采用预定语法且与子程序代码相邻的程序代码,例如,云平台约定采用预定语法的函数creatvirtualinstance(type,spec,N)作为标记,则租户可在编写程序代码过程中,在子程序代码相邻的位置(子程序前或后的位置)调用creatvirtualinstance(type,spec,N),并根据自身需要输入虚拟实例的类型type,规格spec,数量N中的一者或任意组合,即可对子程序代码进行标记,让该子程序代码在云平台根据类型type,规格spec,数量N中的一者或任意组合创建好或选择好的虚拟实例中运行。
第三方面,本申请提供一种云平台,包括:云服务提供单元,用于获取租户的程序代码,程序代码包括第一标记和子程序代码,第一标记用于指示运行子程序代码的虚拟实例的配置信息,云程序执行单元,用于根据第一标记创建或选择一个或多个第一虚拟实例,将子程序代码分别发送给一个或多个第一虚拟实例,并接收一个或多个第一虚拟实例分别运行子程序代码得到的第一运行结果。
第三方面或第三方面任意一种实现方式是第一方面或第一方面任意一种实现方式对应的方法实现,第一方面或第一方面任意一种实现方式中的描述适用于第三方面或第三方面任意一种实现方式任意一种实现方式,在此不再赘述。
第四方面,本申请提供一种云平台,包括:云服务提供单元,用于创建业务虚拟实例,业务虚拟实例用于运行主程序代码,云程序执行单元,用于接收业务虚拟实例发送的子程序代码和第一标记,其中子程序代码被主程序代码调用,第一标记用于指示运行子程序代码的虚拟实例的配置信息,根据第一标记创建或选择一个或多个第一虚拟实例,发送子程序代码至一个或多个第一虚拟实例,接收一个或多个第一虚拟实例分别运行子程序代码得到的第一运行结果并发送第一运行结果至业务虚拟实例。
第四方面或第四方面任意一种实现方式是第二方面或第二方面任意一种实现方式对应的方法实现,第四方面或第四方面任意一种实现方式中的描述适用于第二方面或第二方面任意一种实现方式任意一种实现方式,在此不再赘述。
第五方面,本申请提供一种计算机设备,计算机设备包括:处理器和存储器,存储器用于存储计算机执行指令,处理器用于执行存储器所存储的计算机执行指令,以使计算机设备实现第一方面及第一方面任一种可能的实现方式所揭示的方法或使计算机设备实现第二方面及第二方面任一种可能的实现方式所揭示的方法。
第六方面,本申请一种计算机存储介质,包括计算机可读指令,当计算机可读指令被执行时,实现第一方面及第一方面任一种可能的实现方式所揭示的方法或实现第二方面及第二方面任一种可能的实现方式所揭示的方法。
第七方面,本申请一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行第一方面及第一方面任一种可能的实现方式所揭示的方法或使得计算机 执行第二方面及第二方面任一种可能的实现方式所揭示的方法。
附图说明
图1是根据本发明实施例的数据中心的内部结构示意图;
图2是根据本发明实施例的程序代码处理系统的系统架构示意图;
图3是根据本发明实施例的程序代码处理系统的另一系统架构示意图;
图4是根据本发明实施例的程序代码处理方法的数据交互图;
图5是根据本发明实施例的程序代码处理系统的另一系统架构示意图;
图6是根据本发明实施例的程序代码处理系统的另一系统架构示意图;
图7是根据本发明实施例的程序代码处理方法的另一数据交互图;
图8是根据本发明实施例的存储节点的结构示意图;
图9是根据本发明实施例的计算节点的结构示意图;
图10是根据本发明实施例的计算节点的另一结构示意图;
图11是根据本发明实施例的计算节点的另一结构示意图;
图12是根据本发明实施例的计算机设备的装置结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
为了便于理解本申请实施例,首先,对本申请涉及的部分术语进行解释说明。
云平台:用于提供与云服务相关的界面以供租户远程访问云服务。租户可通过预先注册的账号密码在云服务访问页面登录云平台,并在登录成功之后,在云服务访问页面选择并购买对应的云服务,云服务例如对象存储服务、虚拟机服务、容器服务等,在本发明实施例中,云平台可提供针对租户的程序代码进行处理的云服务。
业务逻辑:即程序的逻辑,描叙了程序执行什么,软件工程师编写了源代码,源代码被执行过程中,执行业务逻辑。对应静态编译的编程语言,软件工程师开发的源代码通常会通过编译器编译成可执行的二进制格式的目标代码再由计算机的处理器执行,对于解析型编程语言,通常会由脚本解析器对源代码进行解析以生成目标代码由计算机的处理器执行。本发明实施例中提到的业务逻辑是软件运行的逻辑,具体就是源代码要计算机干什么。
程序代码:本发明实施例中,程序代码可以是源代码也可以是目标代码,具体取决于不同的应用场景(下文会详细说明)。
编译:本发明实施例中,所涉及的程序代码可根据其所采用的编程语言进行编译,当程序代码为脚本语言时,例如为python、java、ruby等脚本语言,在下文所述的实施例1中,程序代码为源代码,租户可直接将未经编译的源代码上传至云平台,由云平台的主程序执行单元30中的云程序执行代理对主程序代码进行动态编译,由虚拟实例1的云程序执行代理对程序代码1进行动态编译,由虚拟实例2-5的云程序执行代 理分别对程序代码2进行动态编译。在实施例2中,由业务虚拟实例中的云程序执行代理对主程序代码进行动态编译,由虚拟实例1的云程序执行代理对程序代码1进行动态编译,由虚拟实例2-5的云程序执行代理分别对程序代码2进行动态编译。云程序执行代理中设置有脚本解析器,上述动态编译可将脚本语言编译成脚本解析器可运行的字节码文件(即目标代码)。
可选地,在实施例1中,程序代码为目标代码,租户可在本地利用脚本解析器对程序代码进行编译,将主程序代码、程序代码1和程序代码2编译为字节码文件,再将字节码文件上传到云平台。在实施例2中,租户可在业务虚拟机利用脚本解析器对程序代码进行编译,将主程序代码、程序代码1和程序代码2编译为字节码文件,并将程序代码1和程序代码2的字节码文件发送至云平台,云平台再将程序代码1的字节码文件发送至虚拟机1运行,将程序代码2的字节码文件发送至虚拟机2-5运行。
当程序代码为非脚本语言时,例如为C++,在实施例1中,程序代码为源代码,租户可直接将未经编译的源代码上传至云平台,由云平台的主程序执行单元30中的云程序执行代理对主程序代码进行静态编译,由虚拟实例1的云程序执行代理对程序代码1进行静态编译,由虚拟实例2-5的云程序执行代理分别对程序代码2进行静态编译。在实施例2中,由业务虚拟实例中的云程序执行代理对主程序代码进行静态编译,由虚拟实例1的云程序执行代理对程序代码1进行静态编译,由虚拟实例2-5的云程序执行代理分别对程序代码2进行静态编译。云程序执行代理中设置有编译器,上述静态编译可将源代码编译成二进制可执行文件(即目标代码)。
可选地,在实施例1中,程序代码为目标代码,租户可在本地利用编译器对程序代码进行编译,将主程序代码、程序代码1和程序代码2编译为二进制可执行文件,再将二进制可执行文件上传到云平台。在实施例2中,租户可在业务虚拟机利用编译器对程序代码进行编译,将主程序代码、程序代码1和程序代码2编译为二进制可执行文件,并将程序代码1和程序代码2的二进制可执行文件发送至云平台,云平台再将程序代码1的二进制可执行文件发送至虚拟机1运行,将程序代码2的二进制可执行文件发送至虚拟机2-5运行。
值得注意的是,以上设计的虚拟机1-5、主程序执行单元30以及云程序执行代理将会在下文详细介绍。
虚拟实例:虚拟实例由云平台配置,其设置有运行环境,运行环境包括操作系统和应用,虚拟实例例如为虚拟机、容器或裸金属服务器。
业务虚拟实例:租户自己在云平台创建的虚拟实例,租户可通过客户端远程登录业务虚拟实例,在业务虚拟实例上运行程序代码,业务虚拟实例可作为租户的生产环境或测试环境。
主程序代码,简称主程序,也称主函数,在许多命令式程序设计语言里,主函数(main function)是程序开始运行的地方。
子程序代码:是一个大型程序中的某部份代码,由一个或多个语句块组成。它负责完成某项特定任务,而且相较于其他代码,具备相对的独立性。有些情况下有输入参数,并且,子程序代码有返回值(即运行结果),子程序代码可被主程序代码调用,子程序代码也可以被子程序代码调用。嵌套程序代码:是指子程序代码调用子程序代 码中,被调用的子程序代码。
标记:云平台预先约定的一种对程序代码的标记方式,云平台可提供标记的使用方法和格式,让租户可以在编写程序代码的时候添加标记到程序代码中。
标记具有分离子程序代码的作用,标记与子程序代码邻近设置,用于标识子程序代码为需由具有标记指示的配置信息的虚拟实例执行的程序代码,标记的一种实现方式为子程序代码的注解,例如为程序代码前,或程序代码后,以@、\\、\、/、//或其他的与云平台预先约定好的符号标记,并在符号之后以预定格式输入虚拟实例的类型、规格、数量等配置信息,云平台在检测到该符号时,根据该符号后指示的虚拟实例的类型、规格、数量创建虚拟实例,并发送子程序代码让虚拟实例运行,通过注解,无需改变租户的编程习惯,租户只需在子程序代码前或后输入符号,并在符号后输入配置信息,即可实现利用云侧的虚拟实例来运行子程序代码。标记也可设置为采用预定语法且与子程序代码相邻的程序代码,举例而言,云平台约定采用预定语法的函数creatvirtualinstance(type,spec,N)作为标记,则租户可在编写程序代码过程中,在子程序代码相邻的位置(子程序前或后的位置)调用creatvirtualinstance(type,spec,N),并根据自身需要输入虚拟实例的类型type,规格spec,数量N中的一者或任意组合,即可对子程序代码进行标记,让该子程序代码在云平台根据类型type,规格spec,数量N中的一者或任意组合创建好或选择好的虚拟实例中运行。
请参见图1,图1是根据本发明实施例的数据中心的内部结构示意图,如图1所示,云平台设置在数据中心,云平台通过交换设备203分别与多个存储节点201、202……以及多个计算节点301、302连接。
客户端接入云平台,租户操作客户端从而访问云平台提供的云服务。
其中,客户端可例如为可供租户操作且可接入互联网的终端设备,例如为个人电脑、手机、平板电脑、车载主机等,客户端通过互联网接入数据中心,并访问设置在数据中心的云平台提供的服务。
存储节点和计算节点均可以通过物理服务器实现,存储节点可提供共享存储空间,例如对象存储服务(Object Storage Service,OBS)桶、共享缓存、或共享数据库,存储节点通过设置有多个物理磁盘的服务器实现,云平台可在计算节点上配置虚拟实例,虚拟实例例如虚拟机、容器以及裸金属服务器。
云平台用于提供与云服务相关的界面或接口以供租户远程访问云服务,租户可通过预先注册的账号密码登录云平台,并在登录成功之后,在云平台提供的云服务访问页面选择并购买对应的云服务,云服务例如对象存储服务、虚拟机服务、容器服务等,在本发明实施例中,云平台可提供针对租户的程序代码进行处理的云服务。
下文将基于图1分别对不同的实施例进行具体说明。
实施例1:
在本实施例中,租户可上传程序代码至云平台,或直接在云平台上编写程序代码,程序代码中的部分程序代码中注解有虚拟实例的配置信息,云平台根据配置信息配置虚拟实例,通过虚拟实例执行该部分程序代码,并从虚拟实例获取该部分程序代码的运行结果,最后云平台并将程序代码的运行结果通知租户。
首先请参见图2,图2是根据本发明实施例的程序代码处理系统的系统架构示意图,如图2所示,程序代码处理系统包括数据中心和客户端,数据中心中设置有云平台和共享存储空间。
云平台包括云服务提供单元10、云程序执行单元20以及主程序执行单元30。其中,云服务提供单元10用于向租户提供云服务,云服务提供单元10包括虚拟实例服务接口101、程序代码服务接口102、共享存储服务接口103。其中,客户端可访问虚拟实例服务接口101以通知云服务提供单元10在数据中心中创建可供租户访问的虚拟实例;并且,客户端可访问共享存储服务接口103以通知云服务提供单元10在数据中心中创建可供租户访问的共享存储空间,租户可上传数据到共享存储空间,并从共享存储空间下载数据;客户端还可访问程序代码服务接口102,客户端可通过程序代码服务接口102提供的上传接口上传租户的程序代码至云平台,云平台在数据中心侧处理租户上传的程序代码,或者,租户可操作客户端访问程序代码服务接口102提供的程序编辑界面,以实现在云平台中在线编写程序代码,云平台在数据中心侧处理租户在线编写的程序代码。
举例而言,共享存储空间可例如为基于OBS桶、共享缓存或共享数据库。虚拟实例可例如为虚拟机、容器或裸金属服务器。程序代码可例如为java、C++、python、ruby或其他任何常用的程序语言。
其中,共享存储空间可由图1所示的存储节点提供。
主程序执行单元30包括云程序执行代理,主程序执行单元30用于运行主程序代码,云程序执行代理用于与其他云程序执行代理通信并执行标记注释的程序代码。
其中,也可以不使用主程序执行单元30,云平台可直接使用一个设置有云程序执行代理的虚拟实例来运行主程序代码。
在本实施例中,租户可在程序代码服务接口102提供的程序编辑界面上编辑程序,或者直接在本地编辑程序代码,通过客户端发送编辑好的程序代码至程序代码服务接口102提供的上传接口,其中,云平台会向租户提供说明,让租户在编辑程序代码过程中,以预定标记通知云平台指定的部分程序代码需由云平台配置的虚拟实例执行,程序代码服务接口102可将程序代码发送至云程序执行单元20,云程序执行单元20将程序代码中的主程序代码发送至主程序执行单元30执行,识别出标记,根据标记指示的配置信息配置虚拟实例,并将该标记所标示出的部分程序代码发送至配置好的虚拟实例执行,从而在云端实现程序代码执行,可减轻客户端的运算负荷,并无需改变租户的编程习惯,从而提高租户的编程体验。
其中,标记可以是某段程序代码的注解,或与某段程序代码相邻的设置有预定语法的程序代码。
下文以java语言举例,假设租户编写好的程序代码如下:
Figure PCTCN2021121245-appb-000001
Figure PCTCN2021121245-appb-000002
本发明实施例主要要以上程序代码进行说明,如以上程序代码所示,主程序代码:public static void main(String[]args)运行过程中调用了程序代码1,程序代码1即函数runInCloud1(inputDir,outputDir),程序代码1,即函数runInCloud1(inputDir,outputDir)在运行过程中调用了程序代码2,即函数runInCloud2(inputFileList,outputDir)。
因此程序代码1为子程序代码,程序代码2为嵌套程序代码,标记@QtFun(taskNum=1,flavor="s2.small.1",type=VM,waitingForFinished=true)和标记@QtFun(taskNum=4,cpu=1,memory=256,type=VM,waitingForFinished=true)可用于指示云平台程序代码1和程序代码2是分隔的
并且,函数runInCloud1(inputDir,outputDir)邻近设置有标记:@QtFun(taskNum=1,flavor="s2.small.1",type=VM,waitingForFinished=true),其中,@QtFun为本发明 实施例预设的标记,用于指示该标记所注解的函数runInCloud1(inputDir,outputDir)需由虚拟实例执行,且虚拟实例的类型type为虚拟机,虚拟机的规格flavor是s2.small.1,虚拟机的数量taskNum是1个,且主程序需等待该函数执行完毕才可以执行下一步(waitingForFinished=true)。
进一步,函数runInCloud2(inputFileList,outputDir)设置有标记:@QtFun(taskNum=4,cpu=1,memory=256,type=VM,waitingForFinished=true),其中,@QtFun为本发明实施例预设的标记,用于指示该标记所注解的函数runInCloud2(inputFileList,outputDir)需由虚拟实例执行,且虚拟实例的类型type为虚拟机,虚拟机的处理器规格是1核,内存规格是256M,虚拟机的数量taskNum是1个,且主程序需等待该函数执行完毕才可以执行下一步(waitingForFinished=true)。
标记用于分隔不同的子程序代码,云平台通过检测标记即可确认不同的子程序代码。
在本发明实施例中,规格可以由云平台预先定义好的flavor来确定,如上文所述的s2.small.1,其规格例如为2核处理器,512M内存。可选地,规格也可以直接指定CPU核数和内存大小,如runInCloud2(inputFileList,outputDir)中指定cpu=1,memory=256,云平台通过分析标记所指示的配置信息,根据配置信息配置虚拟实例。
具体地,云平台的程序代码服务接口102发送上述程序代码至云程序执行单元20,云程序执行单元20根据标记指示的配置信息配置虚拟实例,而根据以上程序代码,云程序执行单元20首先创建1个虚拟机来运行程序代码1,在程序代码1运行至需调用程序代码2的位置时,创建4个虚拟机来并行运行程序代码2。
并请结合图3一并参考,图3是根据本发明实施例的程序代码处理系统的另一系统架构示意图,图3与图2的区别在于其新增了云程序执行单元20根据标记所指示的配置信息配置的虚拟实例1-5,并且,云程序执行单元20发送主程序代码至主程序执行单元30,发送程序代码1至虚拟实例1执行,发送程序代码2至虚拟实例2-5执行,使得租户的程序代码可基于云平台在数据中心侧执行。
其中,每个子程序代码对应一个云程序运行区,如图2所示,虚拟实例1设置在云程序运行区1,虚拟实例2设置在云程序运行区2-5,虚拟实例1-5具体可在图1所示的计算节点上运行。
可选地,标记也可以为//,实现方式如下:
Figure PCTCN2021121245-appb-000003
Figure PCTCN2021121245-appb-000004
因此,@、//、\\、\、/、或其他的与云平台预先约定好的符号标记均可作为标记的具体实现方式。
值得注意的是,在上述实例代码中,程序代码1为子程序代码,程序代码2为子程序代码调用的另外一个子程序代码(即嵌套程序代码),可选地,在其他实现方式中,也可以设置为主程序代码分别调用两个子程序代码,举例如下:
Figure PCTCN2021121245-appb-000005
Figure PCTCN2021121245-appb-000006
在以上程序代码中,主程序代码先调用程序代码2,对OBS桶中的数据进行转码,然后再调用程序代码1对OBS桶中转码后的数据进行H265的哈希运算。
图4是根据本发明实施例的程序代码处理方法的数据交互图,可应用在图1-3所示的云平台中。如图3所示,根据本发明实施例的程序代码处理方法包括以下步骤:
步骤S101:租户在客户端编写程序代码。
其中,租户在客户端中安装的程序代码编写工具编写程序代码,并且,租户可根据云平台提供的语法以注释的方式对其中部分代码进行标记,并在标记中指示配置信息,该配置信息可用于指示运行该部分代码的虚拟实例的类型、规格、数量中的一者或任意组合。程序代码包括主程序代码、程序代码1和程序代码2,可例如为上文所述的java代码。
可选地,若租户没有在标记中指示类型、规格或数量,则云平台按照默认的类型、规格或数量配置虚拟实例。
进一步,租户可以将在其他地方编写好的程序代码发送至客户端,只需确保程序代码中注释有标记,程序代码的生成方式本发明实施例对此不作限定。
步骤S102:客户端发送程序代码至云平台。
具体地,客户端发送程序代码至云服务提供单元10中的程序代码服务接口102。
程序代码服务接口102具体实现为上传接口,该上传接口用于接收租户上传的程序代码。可选地,程序代码服务接口102也可具体实现为程序代码编辑界面,租户可通过操作客户端远程登录云服务提供单元10提供的程序代码编辑界面,在程序代码编辑界面在线编写程序代码。
步骤S103:云服务提供单元10发送程序代码至云程序执行单元20。
步骤S104:云程序执行单元20发送主程序代码至主程序执行单元30。
具体地,云程序执行单元20发送主程序代码至主程序执行单元30的程序执行单元。
主程序代码例如为:
Figure PCTCN2021121245-appb-000007
Figure PCTCN2021121245-appb-000008
步骤S105:云程序执行单元20根据程序代码1的标记配置虚拟实例1。
程序代码1的标记例如为:
@QtFun(taskNum=1,flavor="s2.small.1",type=VM,waitingForFinished=true)
云程序执行单元20对该标记进行分析,得到以下配置信息:需创建1个规格为s2.small.1,类型为虚拟机,且数量为1的虚拟实例,且主程序代码运行至调用程序代码1的位置时,需等待至程序代码1执行完毕才能继续运行。
其中VM指示类型为虚拟机,在其他实施例中,类型还可以包括容器Container以及裸金属服务器(baremetal server)。
步骤S106:云程序执行单元20发送与标记相邻的程序代码1至已经配置好的虚拟实例1。
程序代码1为:
Figure PCTCN2021121245-appb-000009
其中,程序代码1的业务逻辑如下:读取URL对应的OBS桶中的文件清单,调用程序代码2,程序代码2对文件清单中的每个文件分别进行转码处理,程序代码1在程序代码2转码完毕之后,对转码后的文件进行哈希运算,针对每个转码后的文件分别得到对应的哈希值。
其中,每个OBS桶均通过统一资源定位器(Uniform Resource Locator,URL)来定位,云平台在创建OBS桶之后,为OBS桶配置URL并记录,租户可通过URL访问到OBS桶。
值得注意的是,此处提及的OBS桶即图1和图2所示的共享存储空间,OBS桶是 共享存储空间一种具体实现方式,共享存储空间还可以通过共享缓存、共享数据库或由其他具有共享存储功能的方式实现。
在本发明实施例中,共享存储空间用于存储待处理数据,待处理数据例如为OBS桶中的文件。
在本发明实施例中,与标记邻近设置的程序代码可称为云程序代码,例如程序代码1和程序代码2均可称为云程序代码,云程序代码由云程序执行单元20配置的虚拟实例执行。且虚拟实例1设置在云程序运行区1中。
步骤S107:主程序执行单元30执行主程序代码至需调用程序代码1的位置,并暂停执行主程序代码,等待程序代码1执行完毕。
其中,主程序执行单元30的云程序执行代理执行主程序代码至String inputDir=args[2]语句之后,需调用程序代码1:runInCloud1(inputDir,outputDir),由于该程序代码1被标记为在虚拟实例中运行,因此主程序执行单元30的云程序执行代理需向云程序执行单元20请求程序代码1的运行结果。
步骤S108:主程序执行单元30的云程序执行代理向云程序执行单元20请求程序代码1的运行结果。
步骤S109:云程序执行单元20向虚拟实例1请求程序代码1的运行结果。
步骤S110:虚拟实例1执行程序代码1至需调用程序代码2的位置,开始等待。
具体地,虚拟实例1的云程序执行代理执行程序代码1,在执行完String[]inputFileList=Obs.readFileList(inputDir)之后,发现下一语句需调用程序代码2:runInCloud2(inputFileList,outputDir),由于该程序代码1被标记为需在虚拟实例中运行,因此虚拟实例1的云程序执行代理需向云程序执行单元20请求程序代码2的运行结果。
步骤S111:虚拟实例1的云程序执行代理向云程序执行单元20请求程序代码2的运行结果。
步骤S112:云程序执行单元20根据程序代码2的标记所指示的配置信息配置虚拟实例2-5。
具体地,程序代码2的标记为@QtFun(taskNum=4,cpu=1,memory=256,type=VM,waitingForFinished=true),云程序执行单元20根据配置信息创建4个类型为虚拟机的虚拟实例,其规格为1个cpu核,256M内存大小。且程序代码1运行至调用程序代码2的位置时,需等待至程序代码2执行完毕才能继续运行。
值得注意的是,当waitingForFinished=false,程序代码1运行至调用程序代码2的位置时可直接跳过程序代码2,无需等待至程序代码2执行完毕。
且虚拟实例2-5设置在云程序运行区2中。
步骤S113:云程序执行单元20分别向配置好的虚拟实例2-5发送程序代码2。
步骤S114:虚拟实例2-5分别执行程序代码2。
具体地,虚拟实例2-5中的云程序执行代理分别执行程序代码2。
Figure PCTCN2021121245-appb-000010
Figure PCTCN2021121245-appb-000011
在本步骤中,虚拟实例2-5执行相同的程序代码2,从而运行相同的业务逻辑,程序代码的业务逻辑如下:
每个虚拟实例2-5根据QtContext.getTaskIndex()获取自身的任务标识taskId,其中当虚拟实例运行QtContext.getTaskIndex()时,会向云程序执行单元20发送请求,云程序执行单元20根据该请求向虚拟实例返回taskId,虚拟实例2-5的taskId互不相同且顺序排列,例如虚拟实例2的taskId=0,虚拟实例3的taskId=1,虚拟实例4的taskId=2,虚拟实例5的taskId=3。
针对文件清单每一个文件,若其顺序号i与虚拟实例的个数4取模所得余数与虚拟实例的taskId相等,则顺序号为i的文件被该虚拟实例转码,transcodingToH265(fileList[i],outputDir+"/"+i+".mp4")用于将文件清单中的第i个文件转码为H265格式的文件。
每个虚拟实例运行程序代码2完毕之后,记录程序代码2的运行结果,其中运行结果例如为1或0,1表示运行成功,0表示运行失败,本实施例假设每个虚拟实例均成功运行程序2,因此每个虚拟实例2-5记录程序代码2的运行结果为1。
因此,本步骤中,云平台提供待处理数据,程序代码2用于指示虚拟实例2-5从云平台获取该待处理数据并根据该待处理数据执行程序代码2的业务逻辑。
进一步,QtContext.getTaskIndex()为云平台提供的消息队列服务API,其由云平台的云程序执行单元20定义,当虚拟实例调用QtContext.getTaskIndex(),会向云程序执行单元20发送请求,云程序执行单元20根据该请求向虚拟实例返回taskId。
值得注意的是,云平台的云程序执行单元20还可以提供除消息队列服务以外的其他云服务并为所述云服务设置云服务应用程序接口API,其中程序代码中设置有对应云服务API的情况下,该云服务API被调用时可用于指示虚拟实例调用云平台提供的云服务,云服务AIP还包括对象存储服务API、数据库服务API、共享缓存服务API,其中对象存储服务API例如为上述的Obs.readFileList(outputDir,URL)。
当虚拟实例运行对象存储服务API时,需输入OBS桶的URL,使得云程序执行单元20根据URL定位到要访问的OBS桶,虚拟实例可通过云程序执行单元20访问OBS桶。
当虚拟实例运行数据库服务API时,需输入数据库的名称以及账号密码,使得云程序执行单元20定位到数据库,并通过账号密码登入数据库,虚拟实例可通过云程序执行单元20访问数据库。
当虚拟实例运行共享缓存服务API,需输入共享缓存的名称,使得云程序执行单 元20可根据该名称定位到共享缓存,虚拟实例可通过云程序执行单元20共享缓存。
步骤S115:云程序执行单元20分别向虚拟实例2-5请求程序代码2的运行结果。
具体地,云程序执行单元20分别向虚拟实例2-5的云程序执行代理发送针对程序代码2的运行结果的请求。
步骤S116:虚拟实例2-5分别向云程序执行单元20返回程序代码2的运行结果。
具体地,虚拟实例2-5的云程序执行代理分别向云程序执行单元20返回程序代码2的运行结果。
步骤S117:云程序执行单元20向虚拟实例1返回程序代码2的运行结果。
具体地,云程序执行单元20向虚拟实例1的云程序执行代理返回程序代码2的运行结果。
步骤S118:虚拟实例1继续运行程序代码1。
具体地,虚拟实例1的云程序执行代理根据程序代码2的运行结果,继续运行程序代码1,执行余下的语句:
Figure PCTCN2021121245-appb-000012
并在上述语句执行完毕之后,记录程序代码1的运行结果(假设执行成功,运行结果为1)
步骤S119:虚拟实例1向云程序执行单元20发送程序代码1的运行结果。
具体地,虚拟实例1的云程序执行代理向云程序执行单元20发送程序代码1的运行结果,其中,该步骤作为步骤108的响应。
步骤S120:云程序执行单元20发送程序代码1的运行结果至主程序执行单元30。
具体地,云程序执行单元20发送程序代码1的运行结果至主程序执行单元30的云程序执行代理。
步骤S121:主程序执行单元30继续执行主程序代码。
具体地,主程序执行单元30的云程序执行代理根据程序代码1的运行结果(1)继续执行主程序代码。
步骤S122:主程序代码运行完毕。
步骤S123:主程序执行单元30的云程序执行代理通知云服务提供单元10主程序代码运行完毕。
步骤S124:云服务提供单元10通知客户端主程序代码运行成功。
具体地,云服务提供单元10通过程序代码服务接口102通知客户端主程序代码运行完毕。
至此,租户通过客户端从程序代码服务接口102获知程序代码运行完毕,且OBS桶中的数据均已经做出转码及哈希值运算处理。
值得注意的是,上述实施例中,虚拟实例的数量不作限定,只要数据中心的运算能力允许,举例而言,租户可选择1-1000个虚拟实例针对不同的待处理数据相同程序逻辑的并行运算。
并且,实施例1中,仅揭示了一个数据中心,在本发明其他实施例中,数据中心的数量可以不止1个,针对跨数据中心合作的场景,租户可选择配置数量更多的虚拟实例。
进一步,针对配置虚拟实例的步骤S105和步骤S112,云平台可根据标记指示的配置信息在物理服务器上创建虚拟实例;或云平台预先创建好多个虚拟实例,在该多个虚拟实例中选择与标记指示的配置信息匹配的虚拟实例。
并且,上述标记为所述程序代码1或程序代码2的注解,但在本发明其他实施例中,上述标记可为采用预定语法且与程序代码1或程序代码2相邻的其他程序代码。
可选地,标记也可以是任何与云平台预先约定好的标记。
综上,本发明实施例可让租户的程序代码在数据中心侧执行,且租户无需改变自身编程习惯,可运用自己常用的编程语言进行程序代码编写,租户只需对部分需在虚拟实例上执行的程序代码进行标记,并在标记中设置运行该程序代码的虚拟实例的配置信息,云平台根据标记创建或选择与配置信息匹配的虚拟实例,发送该程序到虚拟实例运行,并从虚拟实例获取运行结果,从而使得该些程序代码可通过虚拟实例运行,针对大数据处理、神经网络、大规模应用程序开发等场景,由于充分利用了数据中心的运算能力,且入门门槛较低(仅需租户对特定程序代码进行标记),因此可以极大地提高租户利用云资源进行大规模并行运算的便利性。
实施例2:
在本实施例中,租户可通过云平台在数据中心创建业务虚拟实例,在业务虚拟实例上编写程序代码,或从其他设备发送程序代码至业务虚拟实例,程序代码在业务虚拟实例中运行,程序代码中的部分程序代码中注解有虚拟实例的配置信息,业务虚拟实例运行至该部分程序代码时,通知云平台根据配置信息配置虚拟实例,通过虚拟实例执行该部分程序代码,并从虚拟实例获取该部分程序代码的运行结果,最后业务虚拟实例并将程序代码的运行结果通知租户。
具体可参见图5,图5是根据本发明实施例的程序代码处理系统的另一系统架构示意图,与图2相比,图5所示的实施例中,云服务提供单元10并没有提供程序代码服务接口102,且云平台中并没有设置主程序执行单元30。
与实施例1相比,实施例2直接在租户的生产环境或测试环境(即业务虚拟实例)中运行程序代码,并在程序代码运行过程中通过云平台配置虚拟实例运行被标记的部分程序代码,同样可以提高租户利用云资源进行大规模并行运算的便利性,且由于实施例2直接在生产环境中运行程序代码,在租户购买业务虚拟实例的场景下,直接在业务虚拟实例上直接执行程序代码,更加符合租户的使用习惯。
其中,本实施例所举例的程序代码与实施例1所示的java代码一致,租户的业务虚拟实例通过租户使用客户端访问云平台的服务提供单元中的虚拟实例服务接口101来创建,在业务虚拟实例创建好之后,租户可通过客户端端远程登录业务虚拟实例,其中,租户在创建业务虚拟实例后,云平台可提供云程序执行代理的安装文件,租户可将该安装文件下载并安装至业务虚拟实例中。
可选地,云程序执行代理也可以预装在业务虚拟实例中。
业务虚拟实例直接运行程序代码,业务虚拟实例的云程序执行代理可识别出标记,根据标记配置虚拟实例,并将设置有该标记的部分程序代码发送至配置好的虚拟实例执行,从而在云端实现程序代码执行,可减轻客户端的运算负荷,并无需改变租户的编程习惯,从而提高租户的编程体验。
并请结合图6一并参考,图6是根据本发明实施例的程序代码处理系统的另一系统架构示意图,图6与图5的区别在于其新增了云程序执行单元20根据标记所指示的配置信息配置的虚拟实例1-5,并且,云程序执行单元20发送发送程序代码1至虚拟实例1执行,发送程序代码2至虚拟实例2-5执行,使得租户的程序代码可基于云平台在数据中心侧执行。
并请结合图7一并参考,图7是根据本发明实施例的程序代码处理方法的另一数据交互图,图7所示的程序代码处理方法可应用在图1-3以及图5-6所示的架构中。如图7所示,根据本发明实施例的程序代码处理方法包括以下步骤:
步骤S201:客户端发送业务虚拟实例创建请求至云平台。
具体地,租户操作客户端访问云服务提供单元10的虚拟实例服务接口101,在虚拟实例服务接口101选择业务虚拟实例的类型和规格,云平台创建对应类型和规格的业务虚拟实例。
步骤S202:云平台创建业务虚拟实例。
具体地,云平台的云服务提供单元10创建对应类型和规格的业务虚拟实例。
步骤S203:租户通过客户端远程登录业务虚拟实例,并在业务虚拟实例上开发程序代码。
可选地,租户也可以操作业务虚拟实例从其他设备下载程序代码。
步骤S204:业务虚拟实例运行主程序代码。
具体地,业务虚拟实例的云程序执行代理运行主程序代码:
Figure PCTCN2021121245-appb-000013
步骤S205:业务虚拟实例运行主程序代码至需调用程序代码1的位置,开始等待。
具体地,业务虚拟实例的云程序执行代理运行语句String inputDir=args[2]之后,开始等待。
步骤S206:业务虚拟实例发送程序代码1和程序代码2至云程序执行单元20。
具体地,业务虚拟实例的云程序执行代理根据标记@QtFun(taskNum=1,flavor="s2.small.1",type=VM,waitingForFinished=true)识别出该标记注解的程序代码1为需虚拟实例执行的程序代码,并发送程序代码1至云程序执行单元20。
类似地,业务虚拟实例的云程序执行代理根据标记@QtFun(taskNum=4,cpu= 1,memory=256,type=VM,waitingForFinished=true)识别出该标记注解的程序代码2为需虚拟实例执行的程序代码,并发送程序代码2至云程序执行单元20。
步骤S207:云程序执行单元20根据标记@QtFun(taskNum=1,flavor="s2.small.1",type=VM,waitingForFinished=true)配置虚拟实例1。
云程序执行单元20对该标记进行分析,得到以下信息:需创建1个规格为s2.small.1,类型为虚拟机,且数量为1的虚拟实例,且主程序代码运行至调用程序代码1的位置时,需等待至程序代码1执行完毕才能继续运行。
步骤S208:云程序执行单元20发送程序代码1至配置好的虚拟实例1。
步骤S209:业务虚拟实例的云程序执行代理向云程序执行单元20请求程序代码1的运行结果。
步骤S210:云程序执行单元20向虚拟实例1请求程序代码1的运行结果。
步骤S211:虚拟实例1的云程序执行代理执行程序代码1,至需调用程序代码2的位置,开始等待。
步骤S212:虚拟实例1向云程序执行单元20请求程序代码2的运行结果。
步骤S213:云程序执行单元20根据程序代码2的标记所指示的配置信息配置虚拟实例2-5。
步骤S214:云程序执行单元20分别向配置好的虚拟实例2-5发送程序代码2。
步骤S215:虚拟实例2-5分别执行程序代码2。
步骤S216:云程序执行单元20向虚拟实例2-5请求程序代码2的运行结果。
步骤S217:虚拟实例2-5发送程序代码1的运行结果至云程序执行单元20。
步骤S218:云程序执行单元20发送程序代码2的运行结果至虚拟实例1。
步骤S219:虚拟实例1的云程序执行代理接收程序代码2的运行结果,根据该运行结果继续运行程序代码1,以产生程序代码1的运行结果。
步骤S220:虚拟实例1发送程序代码1的运行结果至云程序执行单元20。
步骤S221:云程序执行单元20发送程序代码1的运行结果至业务虚拟实例的云程序执行代理。
步骤S222:业务虚拟实例的云程序执行代理根据程序代码1的运行结果结束等待,并继续执行主程序代码。
步骤S223:业务虚拟实例的云程序执行代理运行完剩余的主程序代码。
至此,租户通过客户端登录业务虚拟实例从业务虚拟实例的云程序执行代理获知程序代码运行完毕,且OBS桶中的数据均已经做出转码及哈希值运算处理。
实施例2除主程序执行主体为业务虚拟机外,其他方面与实施例1大致相同,值得注意的是,与实施例1类似,本实施例中,只要数据中心的运算能力(取决于空闲的物理服务器的数量)允许,虚拟实例的数量不作限定,举例而言,租户可选择1-1000个虚拟实例针对不同的待处理数据相同程序逻辑的并行运算。
并且,实施例2中,仅揭示了一个数据中心,在本发明其他实施例中,数据中心的数量可以不止1个,针对跨数据中心合作的场景,租户可选择配置数量更多的虚拟实例。
进一步,针对配置虚拟实例的步骤S207和步骤S213,云平台可根据标记指示的 配置信息在物理服务器上创建虚拟实例;或云平台预先创建好多个虚拟实例,在该多个虚拟实例中选择与标记指示的配置信息匹配的虚拟实例。
并且,上述标记为所述程序代码1或程序代码2的注解,但在本发明其他实施例中,上述标记可为采用预定语法且与程序代码1或程序代码2相邻的其他程序代码。
综上,本发明实施例可让租户的程序代码在数据中心侧执行,且租户无需改变自身编程习惯,可运用自己常用的编程语言进行程序代码编写,租户只需对部分需在虚拟实例上执行的程序代码进行标记,并在标记中设置运行该程序代码的虚拟实例的配置信息,云平台根据标记创建或选择与配置信息匹配的虚拟实例,发送该程序代码到虚拟实例运行,并从虚拟实例获取该程序代码的运行结果,从而使得该些程序代码可通过虚拟实例运行,针对大数据处理、神经网络、大规模应用程序开发等场景,由于充分利用了数据中心的运算能力,且入门门槛较低(仅需租户对特定程序代码进行标记),因此可以极大地提高租户利用云资源进行大规模并行运算的便利性。
与实施例1相比,实施例2直接在租户的生产环境或测试环境(即业务虚拟实例)中运行程序代码,并在程序代码运行过程中通过云平台配置虚拟实例运行被标记的部分程序代码,可以提高租户利用云资源进行大规模并行运算的便利性,且由于实施例2直接在生产环境中运行程序代码,在租户已购买业务虚拟实例的场景下更加符合租户的使用习惯。
值得注意的是,在实施例1和实施例2中,主程序代码调用程序代码1,程序代码1再调用程序代码2,但值得注意的是,本发明实施例并不受限制于此,主程序代码可分别调用程序代码1和程序代码2,租户也可根据实际需要让主程序代码调用数量更多的程序代码1,且程序代码1可嵌套调用更多层的程序代码2。
进一步,在上述实施例中,云程序执行单元20根据标记所指示的配置信息配置的虚拟实例2-5可在虚拟实例2-5向云程序执行单元20返回程序代码2的运行结果之后释放,虚拟实例1可在虚拟实例1向云程序执行单元20返回程序代码1的运行结果之后释放。其中,释放例如为停止运行虚拟实例,并在物理服务器中注销虚拟实例,或者清空虚拟实例的内存中记录的数据。及时释放虚拟实例可提高虚拟实例的资源利用效率。
并请参见图8,图8是根据本发明实施例的存储节点的结构示意图,存储节点(即图7所示的存储节点201或202)包括软件层和硬件层,硬件层包括磁盘控制器2075、物理网卡2076,物理磁盘1和物理磁盘2,软件层包括对象存储设备(Object Storage Device,OSD)控制单元2012和操作系统2012,OSD控制单元2012运行在操作系统2012上,操作系统2012中包括磁盘驱动2013和物理网卡驱动2014,云平台可通过物理网卡2016与OSD控制单元2011进行通信,OSD控制单元2011通过磁盘驱动2013控制磁盘控制器2015将物理磁盘1和物理磁盘2设置为多个对象存储设备OSD,云平台在接收到租户的OBS桶创建指令之后,通知OSD控制单元2011创建OBS桶,此时,OSD控制单元2011将OSD1-3设置为OBS桶,并为该OBS桶配置URL,租户可将上述实施例所涉及的待处理数据上传到OBS桶中,其中URL为云平台提供的待 处理数据的地址。
并请参见图9,图9是根据本发明实施例的计算节点的结构示意图,计算节点(例如为图7所示的计算节点301或302)包括软件层和硬件层,硬件层包括分别接入总线的处理器、内存、磁盘以及网卡,软件层包括操作系统和运行在操作系统上的多个虚拟机,例如为图9所示的虚拟机1和虚拟机2,虚拟机管理器设置在操作系统中,用于管理多个虚拟机并根据硬件层为每个虚拟机设置虚拟硬件,每个虚拟机中分别设置有云程序执行代理,云平台可通过网卡与虚拟机管理器通信,云平台通过虚拟机管理器在计算节点创建或注销虚拟机,并对虚拟机进行全生命周期的管理。
并请参见图10,图10是根据本发明实施例的计算节点的另一结构示意图,计算节点(例如为图7所示的计算节点301或302)包括软件层和硬件层,硬件层包括分别接入总线的处理器、内存、磁盘以及网卡,软件层包括操作系统和运行在操作系统上的多个容器,例如为图9所示的容器1和容器2,容器管理器设置在操作系统中,用于管理多个容器并根据硬件层为每个容器设置虚拟硬件,每个容器中分别设置有云程序执行代理,云平台可通过网卡与容器管理器通信,云平台通过容器管理器在计算节点创建或注销容器,并对容器进行全生命周期的管理。
并请参见图11,图11是根据本发明实施例的计算节点的另一结构示意图,计算节点(例如为图7所示的计算节点301或302)包括软件层和硬件层,硬件层包括分别接入总线的处理器、内存、磁盘、网卡以及卸载卡,软件层包括操作系统和设置在操作系统的云程序执行代理,云平台可通过卸载卡管理计算节点,从而使得计算节点除卸载卡外的硬件资源完全由租户管理,此时计算节点为租户从云平台购买的裸金属服务器。
值得注意的是,上述的虚拟机、容器、以及裸金属服务器中,均设置有本发明实施例所述的云程序执行代理,云程序执行单元20可与云程序执行代理通信,以控制虚拟机、容器、以及裸金属服务器执行云程序代码。
因此,本发明实施例通过编译技术使开发者保留编程习惯的同时,可以直接在编程过程使用云环境提供算力,不需要学习复杂的编程,也不需要后续设计与开发整个分布式系统。
进一步,请参见图12,图12是根据本发明实施例的计算机设备的装置结构示意图,如图12所示,计算机设备包括处理器1001、存储器1002、通信接口1003以及总线1004,处理器1001、存储器1002、通信接口1003分别与总线1004连接,存储器1002用于存储计算机执行指令,处理器1001用于执行存储器1002所存储的计算机执行指令,以使计算机设备实现上述实施例1和/或实施例2中云平台所执行的方法。
并且,本发明实施例还提供一种计算机存储介质,包括计算机可读指令,当所述计算机可读指令被执行时,实现上述实施例1和/或实施例2中云平台所执行的方法。
本发明实施例还提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例1和/或实施例2中云平台所执行的方法。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可 以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本申请而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、ROM、RAM、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,训练设备,或者网络设备等)执行本申请各个实施例所述的方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地生成按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、训练设备或数据中心通过有线(例如同轴电缆、光纤、数字租户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、训练设备或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的训练设备、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。

Claims (33)

  1. 一种基于云服务的程序代码处理方法,其特征在于,包括:
    云平台获取租户的程序代码,所述程序代码包括第一标记和子程序代码,所述第一标记用于指示运行所述子程序代码的虚拟实例的配置信息;
    所述云平台根据所述第一标记创建或选择一个或多个第一虚拟实例;
    所述云平台将所述子程序代码分别发送给所述一个或多个第一虚拟实例;
    所述云平台接收所述一个或多个第一虚拟实例分别运行所述子程序代码得到的第一运行结果。
  2. 根据权利要求1所述的方法,其特征在于,所述配置信息包括虚拟实例规格。
  3. 根据权利要求1至2任一项所述的方法,其特征在于,所述配置信息包括虚拟实例类型,所述虚拟实例类型用于指示虚拟机、容器、裸金属服务器中的任一者。
  4. 根据权利要求1至3任一项所述的方法,其特征在于,所述配置信息包括虚拟实例数量N,N为正整数。
  5. 根据权利要求1至4任一项所述的方法,其特征在于,所述第一虚拟实例为多个,所述子程序代码用于指示所述多个第一虚拟实例分别从共享存储空间获取不同的待处理数据并分别对获取到的待处理数据进行数据处理。
  6. 根据权利要求1至5任一项所述的方法,其特征在于,所述程序代码还包括嵌套程序代码和第二标记,所述第二标记用于指示运行所述嵌套程序代码的虚拟实例的配置信息,所述嵌套程序代码被所述子程序代码调用,所述方法还包括:
    所述云平台根据所述第二标记创建或选择一个或多个第二虚拟实例,并分别发送所述嵌套程序代码至所述一个或多个第二虚拟实例;
    所述云平台接收所述一个或多个第二虚拟实例分别运行所述嵌套程序代码得到的第二运行结果,并发送所述第二运行结果至所述第一虚拟实例。
  7. 根据权利要求1至6任一项所述的方法,其特征在于,所述程序代码还包括主程序代码,所述子程序代码被所述主程序代码调用,所述方法还包括:
    所述云平台在运行所述主程序代码至需调用所述子程序代码的位置时,向所述一个或多个第一虚拟实例请求所述第一运行结果;
    所述云平台根据所述第一运行结果继续运行所述主程序代码。
  8. 根据权利要求1至7任一项所述的方法,其特征在于,所述方法还包括:
    所述云平台提供上传接口,所述上传接口用于接收所述租户上传的所述程序代码;或所述云平台提供程序编辑界面,所述程序编辑界面用于接收所述租户远程输入的所述程序代码。
  9. 根据权利要求1至8任一项所述的方法,其特征在于,所述方法还包括:
    所述云平台提供云服务并为所述云服务设置云服务应用程序接口API,其中所述子程序代码中设置有所述云服务API,所述云服务API用于调用所述云平台提供的云服务。
  10. 根据权利要求9所述的方法,其特征在于,所述云服务API包括:对象存储服务API、数据库服务API、共享缓存服务API、消息队列服务API中的一者或任意组合。
  11. 根据权利要求1至10任一项所述的方法,其特征在于,所述第一标记为所述子程序代码的注解;或所述第一标记为采用预定语法且与所述子程序代码相邻的程序代码。
  12. 一种基于云服务的程序代码处理方法,其特征在于,包括:
    云平台接收运行主程序代码的业务虚拟实例发送的子程序代码和第一标记,其中所述子程序代码被所述主程序代码调用,所述第一标记用于指示运行所述子程序代码的虚拟实例的配置信息;
    所述云平台根据所述第一标记创建或选择一个或多个第一虚拟实例;
    所述云平台发送所述子程序代码至所述一个或多个第一虚拟实例;
    所述云平台接收所述一个或多个第一虚拟实例分别运行所述子程序代码得到的第一运行结果并发送所述第一运行结果至所述业务虚拟实例。
  13. 根据权利要求12所述的方法,其特征在于,所述第一标记指示的配置信息包括虚拟实例规格.虚拟实例类型.虚拟实例数量N中的一者或任意组合,N为正整数,所述虚拟实例类型用于指示虚拟机、容器、裸金属服务器中的任一者。
  14. 根据权利要求12至13任一项所述的方法,其特征在于,所述方法还包括:
    所述云平台接收运行所述业务虚拟实例发送的嵌套程序代码和第二标记,所述第二标记用于指示运行所述嵌套程序代码的虚拟实例的配置信息,所述嵌套程序代码被所述子程序代码调用;
    所述云平台根据所述第二标记创建或选择一个或多个第二虚拟实例,并发送所述嵌套程序代码至所述一个或多个第二虚拟实例
    所述云平台从所述一个或多个第二虚拟实例获取所述一个或多个第二虚拟实例运行所述第二程序代码产生的第二运行结果,并发送所述第二运行结果至所述第一虚拟实例。
  15. 根据权利要求12至14任一项所述的方法,其特征在于,所述第一标记为所述子程序代码的注解;或所述第一标记为采用预定语法且与所述子程序代码相邻的程序代码。
  16. 一种云平台,其特征在于,包括:
    云服务提供单元,用于获取租户的程序代码,所述程序代码包括第一标记和子程序代码,所述第一标记用于指示运行所述子程序代码的虚拟实例的配置信息;
    云程序执行单元,用于根据所述第一标记创建或选择一个或多个第一虚拟实例,将所述子程序代码分别发送给所述一个或多个第一虚拟实例,并接收所述一个或多个第一虚拟实例分别运行所述子程序代码得到的第一运行结果。
  17. 根据权利要求16所述的云平台,其特征在于,所述第一标记指示的所述配置信息包括虚拟实例规格。
  18. 根据权利要求16至18任一项所述的云平台,其特征在于,所述第一标记指示的所述配置信息包括虚拟实例类型。
  19. 根据权利要求16至28任一项所述的云平台,其特征在于,所述第一标记指示的配置信息包括虚拟实例数量N,N为正整数,
    所述云程序执行单元,用于配置N个所述第一虚拟实例。
  20. 根据权利要求16至19任一项所述的云平台,其特征在于,所述第一虚拟实例的数量为多个,所述子程序代码用于指示所述多个第一虚拟实例分别从共享存储空间获取不同的待处理数据并分别对获取到的待处理数据进行数据处理。
  21. 根据权利要求16至30任一项所述的云平台,其特征在于,所述程序代码还包括嵌套程序代码和第二标记,所述第二标记用于指示运行所述嵌套程序代码的虚拟实例的配置信息,所述嵌套程序代码被所述子程序代码调用,
    所述云程序执行单元,还用于根据所述第二标记配置一个或多个第二虚拟实例,分别发送所述嵌套程序代码至所述一个或多个第二虚拟实例,接收所述一个或多个第二虚拟实例分别运行所述嵌套程序代码得到的第二运行结果,并发送所述第二运行结果至所述第一虚拟机实例。
  22. 根据权利要求16至21任一项所述的云平台,其特征在于,所述程序代码还包括主程序代码,所述子程序代码被所述主程序代码调用,所述云平台还包括主程序执行单元,
    在所述主程序执行单元运行所述主程序代码至需调用所述子程序代码的位置时,所述云程序执行单元向所述一个或多个第一虚拟实例请求所述第一运行结果;
    所述主程序执行单元根据所述第一运行结果继续运行所述主程序代码。
  23. 根据权利要求16至22任一项所述的云平台,其特征在于,
    所述云服务提供单元,用于提供上传接口,所述上传接口用于接收所述租户上传的所述程序代码;或所述云服务提供单元,用于提供程序编辑界面,所述程序编辑界面用于接收所述租户远程输入的所述程序代码。
  24. 根据权利要求16至23任一项所述的云平台,其特征在于,
    所述云服务提供单元,用于提供云服务并为所述云服务设置云服务应用程序接口API,其中所述第一程序代码中设置有所述云服务API,所述云服务API用于调用所述云服务提供单元提供的云服务。
  25. 根据权利要求24所述的云平台,其特征在于,所述云服务API包括:对象存储服务API.数据库服务API、共享缓存服务API、消息队列服务API中的一者或任意组合。
  26. 根据权利要求16至25任一项所述的云平台,其特征在于,所述第一标记为所述第一程序代码的注解;或所述第一标记为采用预定语法且与所述第一程序代码相邻的程序代码。
  27. 一种云平台,其特征在于,包括:
    云服务提供单元,用于创建业务虚拟实例,所述业务虚拟实例用于运行主程序代码;
    云程序执行单元,用于接收所述业务虚拟实例发送的子程序代码和第一标记,其中所述子程序代码被所述主程序代码调用,所述第一标记用于指示运行所述子程序代码的虚拟实例的配置信息;
    云程序执行单元,还用于根据所述第一标记创建或选择一个或多个第一虚拟实例,发送所述子程序代码至所述一个或多个第一虚拟实例,接收所述一个或多个第一虚拟实例分别运行所述子程序代码得到的第一运行结果并发送所述第一运行结果至所述业 务虚拟实例。
  28. 根据权利要求27所述的云平台,其特征在于,所述第一标记指示的配置信息包括虚拟实例规格.虚拟实例类型.虚拟实例数量N中的一者或任意组合,N为正整数,所述虚拟实例类型用于指示虚拟机、容器、裸金属服务器中的任一者。
  29. 根据权利要求27至28任一项所述的云平台,其特征在于,所述云程序执行单元,用于接收所述业务虚拟实例发送的嵌套程序代码和第二标记,所述第二标记用于指示运行所述嵌套程序代码的虚拟实例的配置信息,所述嵌套程序代码被所述子程序代码调用;根据所述第二标记创建或选择一个或多个第二虚拟实例,并发送所述嵌套程序代码至所述一个或多个第二虚拟实例;从所述一个或多个第二虚拟实例获取所述一个或多个第二虚拟实例运行所述第二程序代码产生的第二运行结果,并发送所述第二运行结果至所述第一虚拟实例。
  30. 根据权利要求27至28任一项所述的云平台,其特征在于,所述第一标记为所述子程序代码的注解;或所述第一标记为采用预定语法且与所述子程序代码相邻的程序代码。
  31. 一种计算机设备,其特征在于,所述计算机设备包括:处理器和存储器;
    所述存储器用于存储计算机执行指令;
    所述处理器用于执行所述存储器所存储的计算机执行指令,以使所述计算机设备实现如所述权利要求1至11任一项所述的方法或12至15任一项所述的方法。
  32. 一种计算机存储介质,其特征在于,包括计算机可读指令,当所述计算机可读指令被执行时,实现如权利要求1至11任一项所述的方法或12至15任一项所述的方法。
  33. 一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行如权利要求1至11任一项所述的方法或12至15任一项所述的方法。
PCT/CN2021/121245 2020-09-30 2021-09-28 云平台及基于云平台的程序代码处理方法 WO2022068796A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP21874456.3A EP4213016A4 (en) 2020-09-30 2021-09-28 CLOUD PLATFORM AND CLOUD PLATFORM BASED PROGRAM CODE PROCESSING METHOD
US18/192,988 US20230244519A1 (en) 2020-09-30 2023-03-30 Cloud Platform and Cloud Platform-Based Program Code Processing Method

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202011063410.2 2020-09-30
CN202011063410 2020-09-30
CN202110394141.6 2021-04-13
CN202110394141.6A CN114327742A (zh) 2020-09-30 2021-04-13 云平台及基于云平台的程序代码处理方法

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/192,988 Continuation US20230244519A1 (en) 2020-09-30 2023-03-30 Cloud Platform and Cloud Platform-Based Program Code Processing Method

Publications (1)

Publication Number Publication Date
WO2022068796A1 true WO2022068796A1 (zh) 2022-04-07

Family

ID=80949714

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/121245 WO2022068796A1 (zh) 2020-09-30 2021-09-28 云平台及基于云平台的程序代码处理方法

Country Status (3)

Country Link
US (1) US20230244519A1 (zh)
EP (1) EP4213016A4 (zh)
WO (1) WO2022068796A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105430043A (zh) * 2015-10-29 2016-03-23 贵州电网有限责任公司电力调度控制中心 一种面向虚拟化实例的启动配置实施方法
US9400675B1 (en) * 2015-07-28 2016-07-26 International Business Machines Corporation Tagging virtual machine instances based on commands
CN108292349A (zh) * 2015-10-26 2018-07-17 亚马逊科技有限公司 在分布式计算环境中提供虚拟机实例的细粒度访问远程命令执行
CN109375986A (zh) * 2012-10-31 2019-02-22 谷歌有限责任公司 基于元数据的虚拟机配置
WO2019183366A1 (en) * 2018-03-22 2019-09-26 Amazon Technologies, Inc. Adoption of existing virtual computing resources into logical containers for management operations

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10579407B2 (en) * 2016-10-28 2020-03-03 ShieldX Networks, Inc. Systems and methods for deploying microservices in a networked microservices system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109375986A (zh) * 2012-10-31 2019-02-22 谷歌有限责任公司 基于元数据的虚拟机配置
US9400675B1 (en) * 2015-07-28 2016-07-26 International Business Machines Corporation Tagging virtual machine instances based on commands
CN108292349A (zh) * 2015-10-26 2018-07-17 亚马逊科技有限公司 在分布式计算环境中提供虚拟机实例的细粒度访问远程命令执行
CN105430043A (zh) * 2015-10-29 2016-03-23 贵州电网有限责任公司电力调度控制中心 一种面向虚拟化实例的启动配置实施方法
WO2019183366A1 (en) * 2018-03-22 2019-09-26 Amazon Technologies, Inc. Adoption of existing virtual computing resources into logical containers for management operations

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4213016A4 *

Also Published As

Publication number Publication date
EP4213016A1 (en) 2023-07-19
EP4213016A4 (en) 2024-02-07
US20230244519A1 (en) 2023-08-03

Similar Documents

Publication Publication Date Title
US10990367B2 (en) Application development method, tool, and device, and storage medium
WO2018228211A1 (zh) 应用转换方法、装置及设备
CN106796522B (zh) 用于更新源代码文件的系统和方法
US9419899B2 (en) Automated service interface optimization
US20100281463A1 (en) XML based scripting framework, and methods of providing automated interactions with remote systems
US20190102201A1 (en) Component invoking method and apparatus, and component data processing method and apparatus
JP2018533125A (ja) ビジュアルコンテンツ開発
CN112035112B (zh) 应用程序开发方法、系统、介质和电子设备
WO2022222537A1 (zh) Ai应用部署方法及相关平台、集群、介质、程序产品
US11531526B1 (en) Creating portable serverless applications
CN108255708A (zh) 测试环境中访问生产文件的方法、装置、存储介质及设备
CN113986402A (zh) 函数调用方法、装置、电子设备及存储介质
US20210255837A1 (en) Opc ua server, system operating using opc ua, and method of executing opc ua system
US9116714B2 (en) Methods and systems for file processing
CN112214250A (zh) 一种应用程序组件的加载方法和装置
US11494184B1 (en) Creation of transportability container files for serverless applications
CN114327742A (zh) 云平台及基于云平台的程序代码处理方法
WO2022068796A1 (zh) 云平台及基于云平台的程序代码处理方法
CN112395096A (zh) 远程函数调用的处理方法、装置、电子设备及存储介质
CN111475148A (zh) 第三方依赖库隔离方法及装置、电子设备、存储介质
WO2022078057A1 (zh) 应用包发布方法、应用方法、装置、介质、服务器及设备
US11513833B1 (en) Event listener interface for container-based execution of serverless functions
US11003479B2 (en) Device, system and method to communicate a kernel binary via a network
CN112612474A (zh) 产品移植方法、装置、存储介质和电子设备
US20230143717A1 (en) Method for providing interactive computing service for artificial intelligence practice

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21874456

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021874456

Country of ref document: EP

Effective date: 20230412

NENP Non-entry into the national phase

Ref country code: DE