Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
Fig. 1 is a flow chart of a container example start-stop method of a container application provided in an embodiment of the present application. As shown in FIG. 1, the method includes S101-S103.
S101, if a start-stop setting instruction of the container application is received, a preset start-stop setting interface is called to receive a container instance to be started and stopped of the container application set by a user through the preset start-stop setting interface and a start-stop implementation mode of the container instance, wherein the start-stop implementation mode comprises a parallel implementation mode and a serial implementation mode.
The step is to determine a container instance to be started and stopped by the container application and a start and stop implementation mode of the container instance, and specifically can be realized by: and if a start-stop setting instruction of the container application is received, calling a preset start-stop setting interface to receive a container instance to be started and stopped of the container application set by a user through the preset start-stop setting interface and a start-stop implementation mode of the container instance. The set container application to be started and stopped can be one or a plurality of container examples, and the set starting and stopping implementation mode comprises one of a parallel implementation mode or a serial implementation mode.
The start-stop setting instruction of the container application can be triggered in various modes, such as by clicking or triggering a button or an image by a user, for example, clicking a start-stop setting button corresponding to a certain container application in a list of the container application, and triggering the start-stop setting instruction of the container application; such as by receiving a voice start-stop setting message from a user to trigger a corresponding start-stop setting instruction. The start-stop setting instruction comprises information of the container application, such as identification information of the container application. The identification information of the container application may be the name of the container application or the number of the container application, etc. information that can determine which container application is specific. Various information of the container application, such as related information of each container instance of the container application, and the like, can be acquired according to the identification information of the container application.
And calling a preset start-stop setting interface according to the start-stop setting instruction, wherein the preset start-stop setting interface is developed by a developer and can exist in the form of a setting interface. The container application to be started and stopped can be set through the preset starting and stopping setting interface, and the starting and stopping implementation mode of the container instance is set. Fig. 2 is a schematic block diagram of a setting interface provided by an embodiment of the present application. In the setup interface, all container instance information, all operation implementations, etc. of the container application are included. Each container instance and each operation implementation mode are preceded by a corresponding selection button for a user to set the container instance to be started and stopped and the start-stop operation mode of the container instance.
In other embodiments, the container instance to be started and stopped and the start and stop implementation manner of the container instance can be determined in other manners, such as directly by a command manner.
S102, if a start-stop operation instruction of a container instance is received, acquiring a start-stop operation type in the start-stop operation instruction, wherein the start-stop operation type comprises start, stop and restart.
The start-stop operation instruction of the container instance may be sent by the user to the server side of the PaaS platform, for example, the user may generate the start-stop operation instruction by clicking an operation type button/icon in a setting interface; or, the user can generate the start-stop operation instruction by sending relevant voices such as operation types to the server side of the PaaS platform, and can also generate the start-stop operation instruction of the container instance directly by a command mode.
Clicking on the "start"/"stop"/"restart" button in fig. 2 triggers a start-stop operation instruction. The start-stop operation instruction comprises a start-stop operation type (the start-stop operation type corresponds to start, stop and restart respectively), a determined container instance to be started and stopped, a start-stop implementation mode and the like.
In one embodiment, sending a start-stop operation instruction of a container instance to a server side of the PaaS platform includes: storing the container instance to be started and stopped in an array; assigning the start-stop implementation mode to a corresponding parameter, such as a parameter key, for identifying whether the parallel operation implementation mode or the serial operation implementation mode is implemented, if the parallel operation implementation mode and the serial operation implementation mode are respectively indicated by 1 and 0, if the determined start-stop implementation mode is 1, the key=1 identifies the parallel implementation mode; and sending the array, the assigned corresponding parameters and the start-stop operation type to a server side of the PaaS platform. It should be noted that, when the start-stop operation instruction is received, the start-stop operation type may be obtained, for example, a trigger event corresponding to the start-stop operation instruction is detected. If the user clicks the icon/button corresponding to the stop operation type on the setting interface, the start-stop operation type is corresponding to stop.
The start-stop operation types include stop, start, restart, etc. Stopping means stopping a container instance in an operation state, and setting an IP state of the container instance to a stopped state in which the container instance is in a disabled state; starting a container instance in a to-be-stopped state, and setting the IP state of the container instance as an operation state, wherein the container instance is in an enabled state in the operation state; the restarting stops the container instance in the running state, sets the IP state of the container instance to the stopped state, then starts the container instance in the stopped state immediately, and sets the IP state of the container instance to the running state.
And S103, connecting a host machine where the container instance to be started and stopped of the container application is located through a container arrangement tool according to the start-stop implementation mode and the start-stop operation type, and executing corresponding start-stop operation on the container instance to be started and stopped on the host machine.
If the start-stop implementation mode is serial and the start-stop operation type is start-up, serially starting the container examples to be started and stopped; if the start-stop implementation mode is parallel and the start-stop operation type is start-up, the container instance to be started and stopped is started in parallel; if the start-stop implementation mode is serial and the start-stop operation type is stop, serially stopping the container instance to be started and stopped; if the start-stop implementation mode is parallel and the start-stop operation type is stop, the container instance to be started and stopped is stopped in parallel; if the start-stop implementation mode is serial, the start-stop operation type is restarting, and then the container instance to be started and stopped is stopped in series and restarted; if the start-stop implementation mode is parallel, the start-stop operation type is restarted, and then the container instance to be started and stopped is stopped and restarted in parallel.
Specifically, step S103 includes the steps of: according to the start-stop implementation mode, the container instance of the container application to be started and stopped is packaged as an object; and according to the start-stop operation type, a preset interface of a container arrangement tool is called, a container instance to be started and stopped in the object is uploaded to the container arrangement tool through the preset interface, so that a host machine where the container instance to be started and stopped in the object is located is connected through the container arrangement tool, and a container start-stop instruction is generated according to the start-stop operation type and the container instance to be started in the object, so that the container start-stop instruction is executed on the host machine where the container instance to be started and stopped is located, and the corresponding start-stop operation of the container instance to be started and stopped is realized.
It should be noted that in the embodiment of the present application, the host machine where the container instance to be started and stopped is located is connected by the container arrangement tool, so that the corresponding start and stop operation for the corresponding container instance on the host machine is implemented, and because the container arrangement tool can be connected with the host machine where the container instance is located, the embodiment of the present application can perform the corresponding start and stop operation without logging in the container instance, thereby improving the speed and efficiency of starting and stopping the container instance of the container application.
In an embodiment, as shown in fig. 3, if the start-stop operation type is start-up, the start-stop implementation is a parallel implementation, and the step S103 includes the following steps S201 to S205.
S201, determining a container instance to be started in the container instances to be started and stopped really according to the state of the container instances to be started and stopped.
And circularly traversing each container instance to be started and stopped, and determining the actual container instance to be started in the container instances to be started and stopped according to the state of the container instance to be started and stopped. It will be appreciated that there may be instances of containers that need to be started and stopped that are naturally started, and that no further repeated starts are required. The method comprises the step of determining the actual container instance to be started in the container instances to be started and stopped to count the number of the container instances to be started.
S202, counting the number of the container instances to be started, and marking the IP state of the container instances to be started as the state to be started.
The number of container instances to be started is counted because data of the number of container instances to be started is needed in the object in the start interface.
S203, packaging the container instance to be started, the number of the container instances to be started plus the number of the container instances currently started by the container application and the application to which the container instance to be started belongs into objects.
Wherein the number of container instances to be started plus the number of container instances currently started by the container application is understood as the sum of the number of container instances to be started at this time and the number of container instances currently started. And packaging the container instance to be started, the sum of the calculated numbers and the application to which the container instance to be started belongs into an object. Such as an object that is recognizable by a preset initiation interface in the container orchestration tool. If the start-stop implementation is a parallel implementation, the encapsulated object data form is: { "id": { app id }, "instance": { instance_number }, wherein { app id }: refers to the container application to which the container instance to be started belongs; { install_number }, refers to the sum of the number of container instances to be started this time and the number of container instances currently started. The number of container instances to be started is the number of container instances to be started.
S204, uploading the packaged object to a container arranging tool according to the start-stop operation type, connecting a host machine where a container instance to be started in the object is located through the container arranging tool, and starting the container instance to be started on the host machine.
Specifically, step S204 includes: invoking a preset starting interface according to the start-stop operation type, uploading the packaged object to a container arranging tool through the preset starting interface so as to connect a host machine where a container instance to be started is located through the container arranging tool, and generating a container starting instruction according to the start-stop operation type and the container instance to be started in the object; and sending the container starting instruction to a host machine where the container instance to be started is located, and executing the container starting instruction in the host machine to realize the starting of the container instance to be started. The preset starting interface is an interface provided by the container arranging tool, and the packaged object is uploaded to the preset starting interface so as to be uploaded to the container arranging tool through the preset starting interface. Wherein the generated starting instruction comprises the following steps: a container instance to be started by dockerrun. The container arranging tool can be a Marathon tool or other container arranging tools. The encapsulated object may be sent/submitted by POST when sent to a preset initiation interface of the container orchestration tool, where the preset initiation interface is e.g. http:///{ marathon_api }/v2/apps/{ appid? force=true. Wherein marathon_api refers to the address where the Marathon tool is located, and app id refers to the container application to which the container instance to be started in parallel belongs.
S205, if the information of successful starting returned by the container arrangement tool is received, setting the IP state of the started container instance as the running state.
And receiving the successful start-up information returned by the preset start-up interface of the container arrangement tool, wherein the successful start-up information means that all container instances are started up successfully. In addition to setting the IP states of all container instances that are started to be running states, the states of all container instances need to be modified to be starting states.
In an embodiment, as shown in fig. 4, if the start-stop operation type is start-up, the start-stop implementation is a serial implementation, and the step S103 includes the following steps S301 to S308.
S301, obtaining a container instance to be started and stopped.
Because the start-stop implementation is a serial implementation, a container instance to be started and stopped is acquired first.
S302, determining whether the container instance to be started and stopped needs to be started according to the state of the container instance to be started and stopped.
It will be appreciated that there may be instances of containers to be started or stopped that are naturally started, and that no further repeated start-up is required. If the container instance to be started and stopped needs to be started, step S303 is executed; if no start is required, step S307 is performed.
S303, marking the IP state of the container instance to be started as the state to be started.
S304, packaging the container instance to be started, the quantity of the container instances +1 of the container application currently started and the application of the container instance to be started into objects.
Such as an object that is recognizable by a preset initiation interface in the container orchestration tool. If the start-stop implementation is a serial implementation, the encapsulated object data form is: { "id": { app id }, "instance": { instance_number }, wherein { app id }: refers to the container application to which the container instance to be started belongs; { install_number }, refer to the number of container instances that have been currently started +1.
S305, uploading the packaged object to a container arranging tool according to the start-stop operation type, connecting a host machine where a container instance to be started in the object is located through the container arranging tool, and starting the container instance to be started on the host machine.
Please refer to the detailed description of step S204, and the detailed description is omitted here.
And S306, if the information of successful starting returned by the container arrangement tool is received, setting the IP state of the started container instance as the running state.
S307, judging whether all container instances to be started and stopped are acquired.
If there are more container instances to be started and stopped that are not acquired, step S308 is executed; if all the container instances to be started and stopped are acquired, ending.
S308, obtaining the next container instance to be started and stopped. Taking the next container instance to be started and stopped as the container instance to be started and stopped. Then, the process returns to step S302.
In an embodiment, as shown in fig. 5, if the start-stop operation type is stop, the start-stop implementation is a parallel implementation, and the step S103 includes the following steps S401 to S403.
S401, packaging all container instances to be started and stopped into objects.
Such as an object that is recognizable by a preset stop interface in the container orchestration tool. If the start-stop implementation is a parallel implementation, the encapsulated object data may be in the form of: { "ids": task0, task1, … }. The task refers to a task value of each container instance needing to be started and stopped on the Marathon tool. If the start-stop implementation is a parallel implementation, multiple container instances requiring start-stop are packaged as one object.
And S402, uploading the packaged object to a container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be stopped in the object is located through the container arranging tool, and stopping all the container instances to be stopped on the host machine.
Specifically, step S402 includes: invoking a preset stopping interface according to the start-stop operation type, uploading the packaged object to a container arranging tool through the preset stopping interface so as to connect a host machine where a container instance to be stopped is located through the container arranging tool, and generating a container stopping instruction according to the start-stop operation type and the container instance to be stopped in the object; and sending the container stopping instruction to a host machine where the container instance to be stopped is located, and executing the container stopping instruction in the host machine so as to stop the container instance to be stopped. The preset stop interface is an interface provided by the container arrangement tool, and the packaged object is uploaded to the preset stop interface so as to be uploaded to the container arrangement tool through the preset stop interface. The generated stopping instruction is a container instance (identifier or IP) to be started and stopped, wherein the identifier or IP of the container instance to be started and stopped is acquired in advance. And if the start-stop implementation mode is a parallel implementation mode, sending the packaged object to a preset stop interface. When the packaged object is sent to a preset stopping interface, the object can be sent/submitted in a POST mode, and the preset stopping interface is http:// { marathon_api }/v2/tasks/delete force=true & scale=true. Wherein, marathon_api refers to the address of the Marathon tool, and tasks refer to the task value of each container on the Marathon tool, that is, the task includes the encapsulated object value. It will be appreciated that tasks are submitted to the container orchestration tool, which executes the corresponding tasks. Specifically, when the container arrangement tool executes the corresponding tasks, the host computer where the container instance to be stopped is located is connected, a container stopping instruction is generated according to the start-stop operation type and the container instance to be stopped in the object, the container stopping instruction is sent to the host computer where the container instance to be stopped is located, and the container stopping instruction is executed in the host computer, so that the container instance to be stopped is stopped.
S403, if the information of successful stopping returned by the container arrangement tool is received, recovering the resources corresponding to the stopped container instance, and setting the IP state of the stopped container instance as a stopping state.
Receiving success information returned by the preset stopping interface of the container orchestration tool means that all container instances to be stopped have been stopped. Recycling resources of the stopped container instance includes: the IP of the container instance is reclaimed, the generated object is purged, etc. And sets the IP state of the stopped container instance to a stopped state or to an unused state.
In an embodiment, as shown in fig. 6, if the start-stop operation type is stop, the start-stop implementation is a serial implementation, and the step S103 includes the following steps S501-S506.
S501, a container instance to be started and stopped is obtained.
S502, packaging the container instance to be started and stopped into an object.
If the start-stop implementation is a serial implementation, the encapsulated object data may be in the form of: { "ids": task }. If the start-stop implementation is a serial implementation, a plurality of container instances needing to be started and stopped are respectively packaged as objects. Each object includes a container instance to be started and stopped.
S503, uploading the packaged object to a container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started and stopped in the object is located through the container arranging tool, and stopping the container instance to be started and stopped on the host machine.
And S504, if the information of successful stopping returned by the container arrangement tool is received, recovering the resources corresponding to the stopped container instance, and setting the IP state of the stopped container instance as a stopping state.
S505, judging whether all container instances to be started and stopped are acquired.
If there are more container instances to be started and stopped that are not acquired, step S506 is executed; if all the container instances to be started and stopped are acquired, ending.
S506, obtaining the next container instance to be started and stopped, and returning to the step S502.
In an embodiment, as shown in fig. 7, the start-stop operation type includes restarting, the start-stop implementation includes a parallel implementation, and the step S103 includes: according to the start-stop implementation mode and the start-stop operation type, connecting a host machine where the container instance to be started and stopped is located through a container arrangement tool, stopping all the container instances to be started and stopped on the host machine, and starting all the stopped container instances. Specifically, the following steps S601 to S607 are included.
S601, packaging all container instances to be started and stopped into objects.
S602, uploading the packaged object to a container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started and stopped in the object is located through the container arranging tool, and stopping all the container instances to be started and stopped on the host machine.
S603, if the information of successful stopping returned by the container arrangement tool is received, recovering the resources corresponding to the stopped container instance, and setting the IP state of the stopped container instance as a stopping state.
Steps S601-S603 are to stop all container instances to be started and stopped.
S604, taking the stopped container instance as a container instance to be started, counting the number of the container instances to be started, and marking the IP state of the container instance to be started as the state to be started.
The number of container instances to be started is the same as the number of container instances to be started and stopped in step S601. The container instance to be started is the container instance stopped in the previous step.
S605, the container instance to be started, the number of the container instances to be started plus the number of the container instances currently started by the container application and the application to which the container instance to be started belongs are packaged into objects.
S606, uploading the packaged object to a container arranging tool according to the start-stop operation type, connecting a host machine where a container instance to be started in the object is located through the container arranging tool, and starting the container instance to be started on the host machine.
S607, if the successful starting information returned by the container editing tool is received, setting the IP state of the started container instance as the running state.
Steps S604-S607 are to start all container instances that are stopped.
The steps in this embodiment are the same as the corresponding steps in fig. 3 and 5, and refer to the corresponding descriptions in fig. 3 and 5 specifically, and are not repeated here.
It should be noted that the embodiment of fig. 7 does not include: the corresponding step of determining the actual container instance to be started in the container instance to be started and stopped according to the state of the container instance to be started and stopped is not needed to be executed, because the container instance in the enabled state is impossible to exist in consideration of the fact that the container instance stopped through the steps S601-S603 is necessarily stopped, and therefore the step of determining the actual container instance to be started in the container instance to be started and stopped according to the state of the container instance to be started and stopped is not needed to be executed.
In an embodiment, as shown in fig. 8, the start-stop operation type includes restarting, the start-stop implementation includes a serial implementation, and the step S103 includes: acquiring a container instance to be started and stopped; connecting a host machine where the container instance to be started and stopped is located through a container arranging tool according to the start-stop operation type, stopping the container instance to be started and stopped on the host machine, and starting the stopped container instance; judging whether all container instances to be started and stopped are acquired or not; and if the container instance to be started and stopped is not acquired, acquiring the next container instance to be started and stopped, and returning to the step of executing the host machine where the container instance to be started and stopped is connected through the container arranging tool according to the start and stop operation type, stopping the container instance to be started and stopped on the host machine, and starting the stopped container instance. Specifically, the following steps S701 to S710 are included.
S701, obtaining a container instance to be started and stopped.
S702, packaging the container instance to be started and stopped into an object.
S703, uploading the packaged object to a container arranging tool according to the start-stop operation type, so as to connect a host machine where the container instance to be started and stopped in the object is located through the container arranging tool, and stopping the container instance to be stopped on the host machine.
And S704, if the information of successful stopping returned by the container arrangement tool is received, recovering the resources corresponding to the stopped container instance, and setting the IP state of the stopped container instance as a stopping state.
Steps S701-S704 are to stop an instance of a container to be started and stopped.
S705, taking the stopped container instance as the container instance to be started, and marking the IP state of the container instance to be started as the state to be started.
The container instance to be started is the container instance that has been stopped after executing steps S701-S704.
S706, the container instance to be started, the number of container instances +1 of the container application currently started and the application of the container instance to be started are packaged into objects.
And S707, uploading the packaged object to a container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started in the object is located through the container arranging tool, and starting the container instance to be started on the host machine.
And S708, if the information of successful starting returned by the container arrangement tool is received, setting the IP state of the started container instance as the running state.
Steps S705-S708 are to launch a container instance to be launched.
S709, judging whether all container instances to be started and stopped are acquired. If all the container instances to be started and stopped are acquired, ending.
S710, if there is a container instance to be started and stopped yet not acquired, acquiring a next container instance to be started and stopped, taking the next container instance to be started and stopped as the container instance to be started and stopped, and returning to execute the step S702.
The steps in this embodiment are the same as the corresponding steps in fig. 4 and 6, and refer to the corresponding descriptions in fig. 4 and 6 specifically, and are not repeated here.
According to the embodiment of the method, the container examples applied to one or more containers are automatically started and stopped through the container arrangement tool, the container examples are automatically started and stopped, the container examples do not need to be started and stopped manually one by one on the corresponding container examples, the speed and the efficiency of the container examples of the container application are improved, meanwhile, the condition of omission caused by the fact that the container examples are started and stopped by manually inputting the corresponding commands is avoided, a user does not need to have higher expertise, and time cost and labor cost are saved.
FIG. 9 is a schematic block diagram of a container example start-stop device for a container application provided by embodiments of the present application. The device comprises a unit corresponding to a container instance start-stop method for executing the container application. As shown in fig. 9, the container example start-stop apparatus 100 of the container application includes a container mode determining unit 101, an operation type determining unit 102, and a start-stop unit 103.
The container mode determining unit 101 is configured to call a preset start-stop setting interface to receive a container instance to be started and stopped of the container application and a start-stop implementation mode of the container instance, which are set by a user through the preset start-stop setting interface, if a start-stop setting instruction of the container application is received, where the start-stop implementation modes include a parallel implementation mode and a serial implementation mode;
an operation type determining unit 102, configured to obtain a start-stop operation type in a start-stop operation instruction if a start-stop operation instruction of a container instance is received, where the start-stop operation type includes start, stop, and restart;
and the start-stop unit 103 is configured to connect, according to the start-stop implementation manner and the start-stop operation type, a host where the container instance to be started and stopped by the container application is located through a container arrangement tool, and perform a corresponding start-stop operation on the container instance to be started and stopped on the host.
In an embodiment, if the start-stop operation type is start, the start-stop implementation is a parallel implementation, and the start-stop unit 103 includes a parallel start determining unit, a number counting unit, a parallel start packaging unit, a parallel start unit, and a parallel start setting unit. The parallel start determining unit is used for determining a container instance to be started really in the container instances to be started and stopped according to the state of the container instances to be started and stopped. And the quantity counting unit is used for counting the quantity of the container instances to be started and marking the IP state of the container instances to be started as the state to be started. And the parallel starting packaging unit is used for packaging the container instance to be started, the number of the container instances to be started plus the number of the container instances currently started by the container application and the application to which the container instance to be started belongs into objects. And the parallel starting unit is used for uploading the packaged object to the container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started in the object is located through the container arranging tool, and starting the container instance to be started on the host machine. And the parallel start setting unit is used for setting the IP state of the started container instance as the running state if receiving the information of successful start returned by the container arrangement tool.
In an embodiment, if the start-stop operation type is start, the start-stop implementation is a serial implementation, and the start-stop unit 103 includes a start single instance obtaining unit, a serial start determining unit, a marking unit, a serial start packaging unit, a serial start setting unit, and a serial start judging unit. The method comprises the steps of starting a single instance obtaining unit, wherein the single instance obtaining unit is used for obtaining a container instance to be started and stopped. And the serial start determining unit is used for determining whether the container instance to be started and stopped needs to be started or not according to the state of the container instance to be started and stopped. And the marking unit is used for marking the IP state of the container instance to be started as the state to be started if the container instance to be started and stopped is required to be started. And the serial starting packaging unit is used for packaging the container instance to be started, the number of the container instances which are currently started by the container application +1 and the application of the container instance to be started into an object. And the serial starting unit is used for uploading the packaged object to the container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started in the object is located through the container arranging tool, and starting the container instance to be started on the host machine. And the serial starting setting unit is used for setting the IP state of the started container instance to be the running state if receiving the starting success information returned by the container arrangement tool. And the serial starting judging unit is used for judging whether all the container examples to be started and stopped are acquired or not if the container examples to be started and stopped do not need to be started. And the starting single-instance obtaining unit is further used for obtaining the next container instance to be started and stopped if the container instance to be started and stopped still exists and is not obtained, and then triggering the serial starting determining unit.
In an embodiment, if the start-stop operation type includes stop, the start-stop implementation includes parallel implementation, and the start-stop unit 103 includes a parallel stop encapsulation unit, a parallel stop unit, and a parallel stop recovery unit. And the parallel stopping packaging unit is used for packaging all the container instances to be started and stopped into objects. And the parallel stopping unit is used for uploading the packaged object to the container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started and stopped in the object is located through the container arranging tool, and stopping all the container instances to be started and stopped on the host machine. And the parallel stopping recovery unit is used for recovering the resources corresponding to the stopped container instance and setting the IP state of the stopped container instance as a stopping state if receiving the information of successful stopping returned by the container arrangement tool.
In an embodiment, if the start-stop operation type includes stopping, the start-stop implementation includes a serial implementation, and the start-stop unit 103 includes a stop single instance obtaining unit, a serial stop packaging unit, a serial stop recycling unit, and a serial stop judging unit. And the stop single instance obtaining unit is used for obtaining a container instance to be started and stopped. And the serial stop packaging unit is used for packaging the container instance to be started and stopped into an object. And the serial stopping unit is used for uploading the packaged object to the container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started and stopped in the object is located through the container arranging tool, and stopping the container instance to be started and stopped on the host machine. And the serial stop recovery unit is used for recovering the resources corresponding to the stopped container instance and setting the IP state of the stopped container instance as a stop state if receiving the information of successful stopping returned by the container arrangement tool. And the serial stop judging unit is used for judging whether all container instances to be started and stopped have been acquired. The stopping single-instance obtaining unit is further used for obtaining the next container instance to be started and stopped if the container instance to be started and stopped still exists and is not obtained. The serial stop encapsulation unit is then triggered.
In an embodiment, if the start-stop operation type includes restarting, the start-stop implementation includes parallel implementation, and the start-stop unit 103 includes a parallel stop encapsulation unit, a parallel stop recovery unit, a quantity statistics unit, a parallel start encapsulation unit, a parallel start unit, and a parallel start setting unit. And the parallel stopping packaging unit is used for packaging all the container instances to be started and stopped into objects. And the parallel stopping unit is used for uploading the packaged object to the container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started and stopped in the object is located through the container arranging tool, and stopping all the container instances to be started and stopped on the host machine. And the parallel stopping recovery unit is used for recovering the resources corresponding to the stopped container instance and setting the IP state of the stopped container instance as a stopping state if receiving the information of successful stopping returned by the container arrangement tool. And the quantity counting unit is used for counting the quantity of the container instances to be started and marking the IP state of the container instances to be started as the state to be started. And the parallel starting packaging unit is used for packaging the container instance to be started, the number of the container instances to be started plus the number of the container instances currently started by the container application and the application to which the container instance to be started belongs into objects. And the parallel starting unit is used for uploading the packaged object to the container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started in the object is located through the container arranging tool, and starting the container instance to be started on the host machine. And the parallel start setting unit is used for setting the IP state of the started container instance as the running state if receiving the information of successful start returned by the container arrangement tool.
In an embodiment, if the start-stop operation type includes a restart, the start-stop implementation includes a serial implementation, and the start-stop unit 103 includes a restart single instance obtaining unit, a serial stop packaging unit, a serial stop recovery unit, a marking unit, a serial start packaging unit, a serial start setting unit, and a serial restart judging unit. The restarting single instance obtaining unit is used for obtaining a container instance to be started and stopped. And the serial stop packaging unit is used for packaging the container instance to be started and stopped into an object. And the serial stopping unit is used for uploading the packaged object to the container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started and stopped in the object is located through the container arranging tool, and stopping the container instance to be started and stopped on the host machine. And the serial stop recovery unit is used for recovering the resources corresponding to the stopped container instance and setting the IP state of the stopped container instance as a stop state if receiving the information of successful stopping returned by the container arrangement tool. And the marking unit is used for marking the IP state of the container instance to be started as the state to be started. And the serial starting packaging unit is used for packaging the container instance to be started, the number of the container instances which are currently started by the container application +1 and the application of the container instance to be started into an object. And the serial starting unit is used for uploading the packaged object to the container arranging tool according to the start-stop operation type, connecting a host machine where the container instance to be started in the object is located through the container arranging tool, and starting the container instance to be started on the host machine. And the serial starting setting unit is used for setting the IP state of the started container instance to be the running state if receiving the starting success information returned by the container arrangement tool. And the serial restarting judging unit is used for judging whether all container instances to be started and stopped are acquired. The restarting single instance acquiring unit is further configured to acquire a next container instance to be started and stopped if there is still a container instance to be started and stopped that is not acquired, take the next container instance to be started and stopped as the container instance to be started and stopped, and then trigger the serial stop packaging unit.
It should be noted that, as those skilled in the art can clearly understand the specific implementation process of the foregoing apparatus and each unit, reference may be made to the corresponding description in the foregoing method embodiment, and for convenience and brevity of description, no further description is provided herein.
The above-described apparatus may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 10.
Fig. 10 is a schematic block diagram of a computer device according to an embodiment of the present application. The device is a terminal and other devices, such as a server in a PaaS platform. The device 100 comprises a processor 102, a memory and a network interface 103 connected by a system bus 101, wherein the memory may comprise a non-volatile storage medium 104 and an internal memory 105.
The non-volatile storage medium 104 may store an operating system 1041 and computer programs 1042. The computer program 1042 stored in the nonvolatile storage medium, when executed by the processor 102, can implement the container instance start-stop method of the container application described in the server. The processor 102 is used to provide computing and control capabilities to support the operation of the overall device 100. The internal memory 105 provides an environment for the execution of a computer program in a non-volatile storage medium that, when executed by the processor 102, causes the processor 102 to perform the container instance start-stop method of the container application described in the server above. The network interface 103 is used for network communication. It will be appreciated by persons skilled in the art that the structures shown in the figures are block diagrams of only some of the structures associated with the aspects of the present application and do not constitute limitations on the apparatus to which the aspects of the present application may be applied, and that a particular apparatus may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
Wherein the processor 102 is configured to execute a computer program stored in a memory to implement any one of the embodiments of the container instance start-stop method of the container application described above.
It should be appreciated that in embodiments of the present application, the processor 102 may be a central processing unit (Central Processing Unit, CPU), which may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSPs), application specific integrated circuits (application lication Specific Integrated Circuit, ASICs), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Those skilled in the art will appreciate that all or part of the flow in a method embodying the above described embodiments may be accomplished by computer programs instructing the relevant hardware. The computer program may be stored in a storage medium, which may be a computer readable storage medium. The computer program is executed by at least one processor in the computer system to implement the flow steps of the embodiments of the method described above.
Accordingly, the present application also provides a storage medium. The storage medium may be a computer-readable storage medium including a non-volatile computer-readable storage medium. The storage medium stores a computer program which, when executed by a processor, implements any of the embodiments of the container instance start-stop method of the container application described above.
The storage medium may be a U-disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk, or other various computer-readable storage media that can store program codes.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus, device, and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and the division of the units is merely a logical function division, and other divisions may be implemented in practice. It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus, device and unit described above may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein. While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.