CN117555685A - Resource state synchronization method, console, platform and system - Google Patents

Resource state synchronization method, console, platform and system Download PDF

Info

Publication number
CN117555685A
CN117555685A CN202311555950.6A CN202311555950A CN117555685A CN 117555685 A CN117555685 A CN 117555685A CN 202311555950 A CN202311555950 A CN 202311555950A CN 117555685 A CN117555685 A CN 117555685A
Authority
CN
China
Prior art keywords
state information
resource
current
resource state
platform
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311555950.6A
Other languages
Chinese (zh)
Inventor
雷文伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Yunxiang Zhisheng Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Yunxiang Zhisheng Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd, Beijing Yunxiang Zhisheng Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202311555950.6A priority Critical patent/CN117555685A/en
Publication of CN117555685A publication Critical patent/CN117555685A/en
Pending legal-status Critical Current

Links

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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • 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/542Event management; Broadcasting; Multicasting; Notifications
    • 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/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application provides a resource state synchronization method, a console, a platform and a system, wherein the method comprises the following steps: establishing long connection with the platform; under the condition that a change event occurs to the target resource determined by the platform and current resource state information of the target resource is generated, the current resource state information of the target resource is obtained through the long connection, wherein the current resource state information is used for indicating the state of the target resource after the change event occurs; and updating the local cache according to the current resource state information to complete the synchronization of the current resource state information. By the method and the device, the technical problems that uncertainty is added to call links among services and complexity is improved after message middleware is introduced in the related technology are solved.

Description

Resource state synchronization method, console, platform and system
Technical Field
The present disclosure relates to the field of data processing technologies, and in particular, to a resource status synchronization method, console, platform, and system.
Background
The host console and the host platform are two isolated service lines, and as the scheduling and the creation of the platform to the resources are asynchronous processes, if the console queries the resources by synchronous waiting or traditional polling mode, then desynchronizing can not be realized, the real-time performance and the reliability can be seriously influenced, the quality of the service per se can not be realized, and the stability and the high efficiency can not be realized.
At present, in order to realize the real-time performance and reliability, the synchronization of resources between a console and platform resources is performed by means of message queues, after the platform side performs verification, scheduling and creation on the requests of the resources, the messages are sent to the MQ of the unified service platform, the host console performs message collection on the MQ of the unified service platform through the self RabbitMQ, and then the console service consumes the resource messages in the RabbitMQ to perform service driving, such as notifying orders according to the messages, or binding among a plurality of resources. However, since a new middleware is introduced, the message middleware itself has a certain complexity, learning curve, performance overhead and maintenance are inevitably generated; even in some cases, message middleware may fail online, in which case it is difficult to handle.
Therefore, after the message middleware is introduced in the related technology, the technical problems that uncertainty is added to call links among services, technical complexity is increased and the like exist.
Disclosure of Invention
The application provides a resource state synchronization method, a console, a platform and a system, which at least solve the technical problems that uncertainty is added to a call link between services and complexity is improved after message middleware is introduced in the related technology.
According to an aspect of the embodiments of the present application, there is provided a resource status synchronization method, applied to a console, including:
establishing long connection with the platform;
under the condition that a change event occurs to the target resource determined by the platform and current resource state information of the target resource is generated, the current resource state information of the target resource is obtained through the long connection, wherein the current resource state information is used for indicating the state of the target resource after the change event occurs;
and updating the local cache according to the current resource state information to complete the synchronization of the current resource state information.
Optionally, as in the previous method, before said establishing a long connection with the platform, the method further comprises:
acquiring initial resource state information of the target resource on the platform and an initial sequence identifier corresponding to the initial resource state information through a target interface on the platform, wherein the sequence identifier is used for indicating the time sequence of the resource state information corresponding to the sequence identifier in all the resource state information of the target resource;
and caching the initial resource state information and the initial sequence identification locally.
Optionally, in the foregoing method, the obtaining, through the long connection, current resource status information of the target resource includes:
acquiring the current resource state information of the target resource and a current sequence identifier corresponding to the current resource state information from the platform through the long connection;
updating the local cache according to the current resource state information to complete the synchronization of the current resource state information, including:
and updating the local cache according to the corresponding current resource state information and the current sequence identifier to complete the synchronization of the current resource state information.
Optionally, in the foregoing method, before updating the local cache according to the current resource status information and the current sequence identifier that correspond to each other, the method further includes:
determining a historical sequence identifier of the target resource which is cached locally last time;
judging whether the difference value between the current sequence identifier and the historical sequence identifier is a preset value or not;
executing a jump operation for jumping to the state information of the current resource corresponding to each other and the current sequence identifier under the condition that the difference value is the preset value, updating a local cache, and completing synchronization of the state information of the current resource;
And under the condition that the difference value is not the preset value, acquiring all resource data of the target resource on the platform, wherein the resource data comprises resource state information and a sequence identifier which are mutually corresponding.
According to another aspect of the embodiments of the present application, there is further provided a resource status synchronization method, applied to a platform, including:
establishing long connection with a console;
generating current resource state information of the target resource under the condition that the change event of the target resource is determined, wherein the current resource state information is used for indicating the state of the target resource after the change event;
and sending the current resource state information to the control console through the long connection, so that the control console updates a local cache of the control console according to the current resource state information, and the synchronization of the current resource state information is completed.
Optionally, the method, sending the current resource status information to the console through the long connection, includes:
dividing the current resource state information of the target resource and a current sequence identifier corresponding to the current resource state information into a plurality of data blocks, wherein the sequence identifier is used for indicating the time sequence of the resource state information corresponding to the sequence identifier in all the resource state information of the target resource;
The plurality of data blocks is sent block by block to the console.
Optionally, before the dividing the current resource status information of the target resource and the current sequence identifier corresponding to the current resource status information into the plurality of data blocks, the method further includes:
determining a historical sequence identity corresponding to the latest of the target resource before the change event occurs;
and performing incremental operation on the historical sequence identifier according to a preset value to obtain the current sequence identifier.
According to another aspect of the embodiments of the present application, there is also provided a console for synchronizing a resource status, including:
the first establishing module is used for establishing long connection with the platform;
the acquisition module is used for acquiring the current resource state information of the target resource through the long connection under the condition that the target resource determined by the platform is subjected to a change event and the current resource state information of the target resource is generated, wherein the current resource state information is used for indicating the state of the target resource after the change event;
and the updating module is used for updating the local cache according to the current resource state information to complete the synchronization of the current resource state information.
According to another aspect of the embodiments of the present application, there is also provided a platform for synchronizing a resource status, including:
the second establishing module is used for establishing long connection with the control console;
the generation module is used for generating current resource state information of the target resource under the condition that the change event of the target resource is determined, wherein the current resource state information is used for indicating the state of the target resource after the change event;
and the sending module is used for sending the current resource state information to the control console through the long connection so that the control console updates the local cache of the control console according to the current resource state information to complete the synchronization of the current resource state information.
According to another aspect of the embodiments of the present application, there is also provided a system for resource status synchronization, including a console as described above and a platform as described above.
According to yet another aspect of the embodiments of the present application, there is also provided an electronic device including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus; wherein the memory is used for storing a computer program; a processor for performing the method steps of any of the embodiments described above by running the computer program stored on the memory.
According to a further aspect of the embodiments of the present application, there is also provided a computer-readable storage medium having stored therein a computer program, wherein the computer program is arranged to perform the method steps of any of the embodiments described above when run.
In the embodiment of the application, under the condition that a change event occurs to the target resource determined by the platform and the current resource state information of the target resource is generated, the current resource state information of the target resource is acquired through long connection; therefore, the transmission of the resource state information between the platform and the console can be realized without adopting a message middleware; the control console can update the local cache according to the current resource state information to complete the synchronization of the current resource state information; therefore, when the operation of the later control console on the resource state information is convenient, the acquired resource state information can be more fully utilized, and the efficiency is effectively improved; furthermore, the method of the embodiment can effectively solve the technical problems that after the message middleware is introduced in the related technology, uncertainty is added to a call link between services and complexity is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a schematic diagram of a hardware environment of an alternative resource state synchronization method according to an embodiment of the present application;
FIG. 2 is a flow diagram of an alternative resource status synchronization method applied to a console according to an embodiment of the present application;
FIG. 3 is a schematic diagram of an alternative resource status synchronization method applied to a console according to another embodiment of the present application;
FIG. 4 is a flow chart of an alternative resource status synchronization method applied to a platform according to an embodiment of the present application;
FIG. 5 is a schematic diagram of an alternative resource status synchronization method applied to a platform according to another embodiment of the present application;
FIG. 6 is a flow chart of an alternative resource status synchronization method according to an embodiment of the application;
FIG. 7 is a block diagram of an alternative resource status synchronization console according to an embodiment of the present application;
FIG. 8 is a block diagram of an alternative resource status synchronization platform according to an embodiment of the present application;
fig. 9 is a block diagram of an alternative electronic device according to an embodiment of the present application.
Detailed Description
In order to make the present application solution better understood by those skilled in the art, the following description will be made in detail and with reference to the accompanying drawings in the embodiments of the present application, it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that embodiments of the present application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, partial terms or terminology appearing in describing embodiments of the present application are applicable to the following explanation:
1. host platform (hereinafter simply referred to as platform): the resources are scheduled and created, and the main service components are nova, neutron, cinder and the like.
2. Host console (hereinafter simply console): and the business layer synchronizes the resources (states) of the platform and performs business operations such as binding of multiple resources, notification of resource orders and the like.
According to one aspect of the embodiments of the present application, a resource state synchronization method is provided. Alternatively, in the present embodiment, the above-described resource status synchronization method may be applied to a hardware environment constituted by the terminal 1402 and the server 1404 as shown in fig. 1. As shown in fig. 1, the server 1404 is connected to the terminal 1402 via a network, and may be used to provide services (such as game services, application services, etc.) to the terminal or clients installed on the terminal, and a database may be provided on the server or independent of the server, for providing data storage services to the server 1404.
The network may include, but is not limited to, at least one of: wired network, wireless network. The wired network may include, but is not limited to, at least one of: a wide area network, a metropolitan area network, a local area network, and the wireless network may include, but is not limited to, at least one of: WIFI (Wireless Fidelity ), bluetooth. The terminal may not be limited to a PC, a mobile phone, a tablet computer, or the like.
The resource state synchronization method in the embodiment of the application may be executed by a server, may be executed by a terminal, or may be executed by both the server and the terminal. The method for synchronizing the resource states by the terminal according to the embodiment of the present application may be performed by a client installed thereon.
Taking the method of resource status synchronization in this embodiment performed by a server as an example, fig. 2 is a flowchart of a method of resource status synchronization provided in this embodiment, applied to a console, and includes the following steps:
step S101, establishing a long connection with the platform.
The resource status synchronization method in this embodiment may be applied to a scenario of information synchronization at the time of asynchronous call, for example: the virtual machine is requested to be created at the front end, and the platform feeds back the virtual machine creation progress (i.e. the resource state in the scene is the virtual machine creation progress, which may be, for example, during creation, completion of creation, etc.) scene, etc. to the front end through the console, or may be other scenes for performing resource state synchronization. In the embodiment of the application, the above-mentioned resource state synchronization method is illustrated by taking the platform feeding back the creation progress of the virtual machine to the front end through the console, and the above-mentioned resource state synchronization method is also applicable to other types of resource states under the condition of no contradiction.
Specifically, the console may actively initiate a long connection establishment request to the platform, and after the platform responds to the console, the long connection between the console and the platform may be established.
Step S102, under the condition that the platform determines that the target resource has a change event and generates the current resource state information of the target resource, the current resource state information of the target resource is obtained through long connection, wherein the current resource state information is used for indicating the state of the target resource after the change event occurs.
Specifically, the platform may obtain the change of the underlying resource to determine whether a change event occurs in the target resource.
The target resource may be any resource, for example, any virtual machine that needs to be created, any hard disk that needs to be mounted, and so on.
Under the condition that the platform determines that the change event occurs to the target resource, the latest current resource state information of the target resource after the change event occurs can be generated.
Optionally, the platform may acquire the resource change of the bottom layer in real time, so as to determine whether the target resource has a change event.
After the platform generates the current resource state information of the target resource based on the change event, the current resource state information can be sent to the console through the pre-established long connection, so that the console can acquire the current resource state information.
Step S103, updating the local cache according to the current resource state information to complete synchronization of the current resource state information.
Specifically, after the console obtains the current resource status information, the console may update the local cache according to the current resource status information.
Optionally, updating the local cache may be: 1. replacing the local resource state information of the previous cache corresponding to the target resource with the current resource state information; 2. and adding the corresponding relation between the current resource state information and the target resource locally.
After the local cache is updated according to the current resource state information, synchronization of the current resource state information between the console and the platform is completed.
Further, after the synchronization of the current resource status information is completed, the console can directly use the current resource status information in the local cache in the subsequent process of real-time tracking and event notification to the front end.
According to the method, under the condition that a change event occurs to the target resource determined by the platform and current resource state information of the target resource is generated, the current resource state information of the target resource is obtained through long connection; therefore, the transmission of the resource state information between the platform and the console can be realized without adopting a message middleware; the control console can update the local cache according to the current resource state information to complete the synchronization of the current resource state information; therefore, when the operation of the later control console on the resource state information is convenient, the acquired resource state information can be more fully utilized, and the efficiency is effectively improved; furthermore, the method of the embodiment can effectively solve the technical problems that after the message middleware is introduced in the related technology, uncertainty is added to a call link between services and complexity is improved.
As shown in fig. 3, as an alternative embodiment, the method further includes, before the step S101 of establishing the long connection with the platform, the following steps:
step S201, obtaining initial resource state information of a target resource on a platform and an initial sequence identifier corresponding to the initial resource state information through a target interface on the platform, wherein the sequence identifier is used for indicating the time sequence of the resource state information corresponding to the sequence identifier in all the resource state information of the target resource.
Specifically, the console may obtain initial resource state information of all resources (including the target resource) in the aspects through using the RESTful API on the platform as the target interface. The RESTful API is an API interface that locates resources with URLs and describes operations with HTTP verbs (GET, POST, PUT, DELETE).
Meanwhile, the platform returns an initial sequence identifier which corresponds to each resource and is identified as sequence, and the sequence identifier corresponding to each resource monotonically increases in a global scope. For example, when the initial sequence identifier of the target resource is 1 and the sequence identifier is incremented in steps of 1, the sequence identifier becomes 2 after the change event occurs to the target resource.
For example, when the resource state is a virtual machine establishment state, the initial resource state may be a state for indicating that the virtual machine starts creation.
Step S202, the initial resource state information and the initial sequence identification are cached locally.
After the console obtains the initial resource status information and the initial sequence identifier, the console will cache the initial resource status information and the initial sequence identifier locally.
As an alternative embodiment, the method, for obtaining the current resource status information of the target resource through the long connection, includes the following steps:
step 3011, obtaining current resource state information of the target resource and a current sequence identifier corresponding to the current resource state information from the platform through long connection.
Specifically, after the long connection between the console and the platform is created, the console can track the change of the resource state of the target resource in real time, and the long connection is not disconnected, so that the platform can continuously notify the console of the event state.
Alternatively, the implementation of long connections may use Chunked Transfer Encoding of HTTP. This allows the platform to transmit event data to the console in real time by blocking when a new event occurs, without having to close the connection. The bound Encoding allows the data to be divided into a plurality of data blocks, each data block having its own unique corresponding length prefix, so that it can be transmitted block by block; and the control console can recover the current resource state information and the current sequence identifier based on the length prefix corresponding to each data block. This ensures real-time and uninterrupted communication of data transmissions.
By using the Chunked Transfer Encoding of HTTP, the platform can transmit corresponding events to the console in real time when the resource changes, and the console can continuously receive event notifications, so as to ensure timely update and synchronization of the resource state information.
Updating the local cache according to the current resource state information to complete the synchronization of the current resource state information, comprising:
step 3012, updating the local cache according to the corresponding current resource state information and the corresponding current sequence identifier, so as to complete synchronization of the current resource state information.
Specifically, after the console obtains the current resource status information and the current sequence identifier, the local cache of the console may be updated based on the current resource status information and the current sequence identifier, for example, the current resource status information and the current sequence identifier are added to the local cache, so as to complete synchronization of the current resource status information.
As an alternative embodiment, as in the foregoing method, before updating the local cache according to the current resource status information and the current sequence identifier corresponding to each other, the method further includes the following steps:
Step 401, determining a historical sequence identifier of the target resource that is cached locally last time.
Specifically, the local of the console at least caches the last received resource state information and the sequence identifier corresponding to each other, so that before the current resource state information is cached, the historical sequence identifier corresponding to the target resource and cached in the local last time can be determined.
Step 402, determining whether the difference between the current sequence identifier and the historical sequence identifier is a preset value.
Specifically, after determining the historical sequence identity, a difference between the current sequence identity and the historical sequence identity may be determined.
After determining the difference, the difference may be compared to a preset value.
The preset value may be the smallest step for sequence identification, e.g. 1.
Therefore, when the difference value is a preset value, the current resource state information is the resource state information which is sequentially generated after the historical resource state information corresponding to the historical sequence identifier; when the difference is not a preset value (e.g., 2 times the preset value, 3 times the preset value, etc.), it is indicated that at least one resource status information generated before the current resource status information and after the historical resource status information is not synchronized to the control end.
Step 403, executing a jump operation for jumping to update the local cache according to the corresponding current resource state information and the corresponding current sequence identifier to complete synchronization of the current resource state information when the difference value is a preset value.
Specifically, if the difference is the preset value, the step is skipped to "update the local cache according to the corresponding current resource status information and the current sequence identifier" through the skip operation, so as to complete synchronization of the current resource status information.
And step 404, acquiring all resource data of the target resource on the platform under the condition that the difference value is not a preset value, wherein the resource data comprises the corresponding resource state information and the sequence identifier.
Specifically, under the condition that the difference value is not a preset value, all resource data of the target resource on the platform are acquired again to acquire at least one resource state information which is not generated locally at the control end before the current resource state information and after the historical resource state information.
Further, all resource data of each resource on the platform can be obtained so as to supplement lost resource data of all resources.
As shown in fig. 4, according to another aspect of the embodiments of the present application, there is further provided an optional resource status synchronization method, applied to a platform, including the following steps:
step P101, establishing long connection with a control console;
specifically, the console may actively initiate a long connection establishment request to the platform, and after the platform responds to the console, the long connection between the console and the platform may be established.
Step P102, under the condition that the change event of the target resource is determined, generating current resource state information of the target resource, wherein the current resource state information is used for indicating the state of the target resource after the change event.
Specifically, the platform may obtain the change of the underlying resource to determine whether a change event occurs in the target resource.
The target resource may be any resource, for example, any virtual machine that needs to be created, any hard disk that needs to be mounted, and so on.
Under the condition that the platform determines that the change event occurs to the target resource, the latest current resource state information of the target resource after the change event occurs can be generated.
Optionally, the platform may acquire the resource change of the bottom layer in real time, so as to determine whether the target resource has a change event.
And step P103, transmitting the current resource state information to the control console through long connection, so that the control console updates the local cache of the control console according to the current resource state information, and the synchronization of the current resource state information is completed.
Specifically, after the platform generates the current resource state information of the target resource based on the change event, the platform can send the current resource state information to the console through the pre-established long connection, so that the console can acquire the current resource state information.
After the console obtains the current resource status information, the local cache may be updated according to the current resource status information.
Optionally, updating the local cache may be: 1. replacing the local resource state information of the previous cache corresponding to the target resource with the current resource state information; 2. and adding the corresponding relation between the current resource state information and the target resource locally.
After the local cache is updated according to the current resource state information, synchronization of the current resource state information between the console and the platform is completed.
Further, after the synchronization of the current resource status information is completed, the console can directly use the current resource status information in the local cache in the subsequent process of real-time tracking and event notification to the front end.
As an alternative embodiment, as shown in fig. 5, the method as described above, for sending the current resource status information to the console through the long connection, includes the following steps:
step P201, dividing the current resource state information of the target resource and the current sequence identifier corresponding to the current resource state information into a plurality of data blocks, wherein the sequence identifier is used for indicating the time sequence of the resource state information corresponding to the sequence identifier in all the resource state information of the target resource;
step P202, a plurality of data blocks are sent to the console block by block.
Specifically, after the long connection between the console and the platform is created, the console can track the change of the resource state of the target resource in real time, and the long connection is not disconnected, so that the platform can continuously notify the console of the event state.
Alternatively, the implementation of long connections may use Chunked Transfer Encoding of HTTP. This allows the platform to transmit event data to the console in real time by blocking when a new event occurs, without having to close the connection. The bound Encoding allows dividing the current resource status information and the current sequence identifier corresponding to the current resource status information into a plurality of data blocks, wherein each data block is provided with a unique corresponding length prefix, so that the data blocks can be transmitted block by block; and the console can judge whether the received multiple data blocks are complete (namely, whether the received multiple data blocks can be used for recovering to obtain the resource state information and the corresponding sequence identification) based on the length prefix corresponding to each data block, and after the multiple data blocks are determined to be complete, the sequence relation among the data blocks can be determined based on the multiple length prefixes, so that the current resource state information and the current sequence identification can be recovered conveniently.
The platform can send the plurality of data blocks to the console block by block after generating the plurality of data blocks, which ensures real-time and uninterrupted communication of the data transmission after sending to the console.
By using the Chunked Transfer Encoding of HTTP, the platform can transmit corresponding events to the console in real time when the resource changes, and the console can continuously receive event notifications, so as to ensure timely update and synchronization of the resource state information.
Specifically, after the console obtains the current resource status information and the current sequence identifier, the local cache of the console may be updated based on the current resource status information and the current sequence identifier, for example, the current resource status information and the current sequence identifier are added to the local cache, so as to complete synchronization of the current resource status information.
As an alternative embodiment, as the foregoing method, before dividing the current resource status information of the target resource and the current sequence identifier corresponding to the current resource status information into the plurality of data blocks, the method further includes the steps of:
determining a latest historical sequence identifier corresponding to the target resource before a change event occurs; and performing incremental operation on the historical sequence identifier according to a preset value to obtain the current sequence identifier.
Specifically, the platform may determine, before the change event occurs, a latest historical sequence identifier corresponding to the target resource; that is, before the change event occurs, the sequence identifier corresponding to the latest resource status information corresponding to the target resource.
After the historical sequence identifier is determined, the historical sequence identifier can be subjected to incremental operation according to a preset value so as to obtain the current sequence identifier.
For example, in the case where the preset value is 1 and the history sequence is identified as 3, the current sequence is identified as 4.
Further, the sequence identifier may also be used to indicate the corresponding target resource, e.g., the identifier of the target resource is M1, then the sequence identifier corresponding to the target resource may be M1-1 (i.e., the initial sequence identifier of the target resource), M1-2, and so on.
By the method of the embodiment, the current sequence identifier corresponding to each change event, namely, the sequence identifier corresponding to each resource state information can be determined, and the uniqueness of the identifiers can be ensured.
As shown in fig. 6, an application example is provided in which any of the foregoing embodiments is applied:
1. resource scan (Resource Scanning): the console first obtains resource state information for all resources (including target resources) on the current platform locally (Scan operation) through the RESTful API of the platform (i.e., one of the optional target interfaces). At the same time, the platform returns a flag called "sequence" (i.e., sequence identity), which monotonically increases in the global scope, and the console caches the flag locally. For each resource, it is bound to one "sequence" each other.
Thus, after the resource scan is completed, the console will have a local cache of resource status information for all resources on the platform and the "sequence" tag associated therewith.
This allows the console to directly use the resource data (i.e., including the one-to-one resource status information and sequence identification) in the local cache during subsequent real-time tracking of the resource status and event notification to the front-end without having to re-acquire from the platform. The implementation method can more fully utilize the acquired resource data, improves the efficiency and ensures the integrity of the resource state.
2. Real-time Tracking: the console tracks changes in resource status in real time (Track operations) by establishing long connections with the platform. This long connection is not broken to ensure continued event notification.
The implementation of long connections may use Chunked Transfer Encoding of HTTP. This allows the platform to transmit event data to the console in real time by blocking when a new event occurs, without having to close the connection. The bound Encoding allows the data to be divided into a plurality of data blocks, each data block having its own unique corresponding length prefix, so that it can be transmitted block by block; and the control console can recover the current resource state information and the current sequence identifier based on the length prefix corresponding to each data block. This ensures real-time and uninterrupted communication of data transmissions.
By using the Chunked Transfer Encoding of HTTP, the platform can transmit corresponding events to the console in real time when the resource changes, and the console can continuously receive event notifications, so as to ensure timely update and synchronization of the resource state information.
3. Event notification (Event Notification): whenever a target resource (i.e., any one of all resources) of the platform changes (e.g., adds, deletes, updates, etc.), the platform sends the corresponding resource status and operation (i.e., resource status information) of the target resource to the console over the long connection. Meanwhile, the platform increases the sequence corresponding to the target resource to obtain the current sequence identifier, and sends the current resource state information and the current sequence identifier to the console.
4. Local cache update (Local Cache Update): and the console updates the local resource cache according to the received resources and the operation, and executes corresponding processing according to the operation type. This ensures that the resource states between the console and the platform remain synchronized.
Message reliability assurance:
when a network outage occurs or an out-of-order request occurs, the console will detect whether data is lost by comparing the difference between each received "sequence" and the last round of buffered "sequence". If the difference is greater than 1, the console will perform a "Scan" operation to re-acquire the full amount of data resources of the platform to ensure the reliability of the message. This is similar to an optimistic lock mechanism to ensure reliability of the message.
It should be noted that, for simplicity of description, the foregoing method embodiments are all expressed as a series of action combinations, but it should be understood by those skilled in the art that the present application is not limited by the order of actions described, as some steps may be performed in other order or simultaneously in accordance with the present application. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily required in the present application.
From the description of the above embodiments, it will be clear to a person skilled in the art that the method according to the above embodiments may be implemented by means of software plus the necessary general hardware platform, but of course also by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (such as ROM (Read-Only Memory)/RAM (Random Access Memory ), magnetic disk, optical disc), including instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method described in the embodiments of the present application.
According to another aspect of the embodiments of the present application, there is also provided a console for implementing the above-mentioned resource state synchronization method for a console. FIG. 7 is a block diagram of an alternative resource status synchronized console, according to an embodiment of the present application, as shown in FIG. 7, the apparatus may include:
a first establishing module 11 for establishing a long connection with the platform;
the obtaining module 12 is configured to obtain, through long connection, current resource status information of the target resource when the change event occurs to the target resource determined by the platform and the current resource status information of the target resource is generated, where the current resource status information is used to indicate a status of the target resource after the change event occurs;
and the updating module 13 is used for updating the local cache according to the current resource state information to complete the synchronization of the current resource state information.
It should be noted that, the first establishing module 11 in this embodiment may be used to perform the above-mentioned step S101, the acquiring module 12 in this embodiment may be used to perform the above-mentioned step S102, and the updating module 13 in this embodiment may be used to perform the above-mentioned step S103.
The console in this embodiment may further include, in addition to the above-described modules, a module that performs any of the methods in the embodiments of the resource status synchronization method for a console as in any of the foregoing.
According to another aspect of the embodiments of the present application, there is also provided a platform for implementing the above-mentioned resource state synchronization method for a platform. FIG. 8 is a block diagram of an alternative platform for resource status synchronization according to an embodiment of the present application, as shown in FIG. 8, the apparatus may include:
a second establishing module 21, configured to establish a long connection with the console;
the generating module 22 is configured to generate current resource status information of the target resource when it is determined that the change event occurs in the target resource, where the current resource status information is used to indicate a status of the target resource after the change event occurs;
and the sending module 23 is configured to send the current resource status information to the console through long connection, so that the console updates the local cache of the console according to the current resource status information, and synchronization of the current resource status information is completed.
It should be noted that, the second establishing module 21 in this embodiment may be used to perform the step P101, the generating module 22 in this embodiment may be used to perform the step P102, and the transmitting module 23 in this embodiment may be used to perform the step P103.
The apparatus in this embodiment may further include a module for performing any of the methods in the embodiments of the resource status synchronization method for a platform as described in any of the foregoing, in addition to the foregoing modules.
According to another aspect of the embodiments of the present application, there is also provided a system for resource status synchronization, including a console as described above and a platform as described above.
It should be noted that the above modules are the same as examples and application scenarios implemented by the corresponding steps, but are not limited to what is disclosed in the above embodiments. It should be noted that the above modules may be implemented in software or in hardware as part of the apparatus shown in fig. 1, where the hardware environment includes a network environment.
According to still another aspect of the embodiments of the present application, there is further provided an electronic device for implementing the above-mentioned resource status synchronization method, where the electronic device may be a server, a terminal, or a combination thereof.
According to another embodiment of the present application, there is also provided an electronic apparatus including: as shown in fig. 9, the electronic device may include: the device comprises a processor 1501, a communication interface 1502, a memory 1503 and a communication bus 1504, wherein the processor 1501, the communication interface 1502 and the memory 1503 are in communication with each other through the communication bus 1504.
A memory 1503 for storing a computer program;
the processor 1501, when executing the program stored in the memory 1503, performs the following steps:
step S101, establishing a long connection with the platform.
Step S102, under the condition that the platform determines that the target resource has a change event and generates the current resource state information of the target resource, the current resource state information of the target resource is obtained through long connection, wherein the current resource state information is used for indicating the state of the target resource after the change event occurs.
Step S103, updating the local cache according to the current resource state information to complete synchronization of the current resource state information.
Step P101, a long connection is established with the console.
Step P102, under the condition that the change event of the target resource is determined, generating current resource state information of the target resource, wherein the current resource state information is used for indicating the state of the target resource after the change event.
And step P103, transmitting the current resource state information to the control console through long connection, so that the control console updates the local cache of the control console according to the current resource state information, and the synchronization of the current resource state information is completed.
Alternatively, in the present embodiment, the above-described communication bus may be a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus, or an EISA (Extended Industry Standard Architecture ) bus, or the like. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus. The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
As an example, the memory 1503 may include, but is not limited to, the first setup module 11, the acquisition module 12, the update module 13, the second setup module 21, the generation module 22, and the transmission module 23 in the console and the platform. In addition, the control console and other module units in the platform may be included, but are not limited to, and are not described in detail in this example.
The processor may be a general purpose processor and may include, but is not limited to: CPU (Central Processing Unit ), NP (Network Processor, network processor), etc.; but also DSP (Digital Signal Processor ), ASIC (Application Specific Integrated Circuit, application specific integrated circuit), FPGA (Field-Programmable Gate Array, field programmable gate array) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components.
The embodiment of the application also provides a computer readable storage medium, wherein the storage medium comprises a stored program, and the program executes the method steps of the method embodiment.
Alternatively, in the present embodiment, the storage medium may include, but is not limited to: various media capable of storing program codes, such as a U disk, ROM, RAM, a mobile hard disk, a magnetic disk or an optical disk.
The foregoing embodiment numbers of the present application are merely for describing, and do not represent advantages or disadvantages of the embodiments.
The integrated units in the above embodiments may be stored in the above-described computer-readable storage medium if implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the technical solution of the present application may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, including several instructions to cause one or more computer devices (which may be personal computers, servers or network devices, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application.
In the foregoing embodiments of the present application, the descriptions of the embodiments are emphasized, and for a portion of this disclosure that is not described in detail in this embodiment, reference is made to the related descriptions of other embodiments.
In several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely exemplary, and the division of the units, such as the division of the units, is merely a logical function division, and may be implemented in another manner, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interfaces, units or modules, or may be in electrical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution provided in the present embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The foregoing is merely a preferred embodiment of the present application and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present application and are intended to be comprehended within the scope of the present application.

Claims (12)

1. A method for synchronizing resource status, applied to a console, comprising:
establishing long connection with the platform;
under the condition that a change event occurs to the target resource determined by the platform and current resource state information of the target resource is generated, the current resource state information of the target resource is obtained through the long connection, wherein the current resource state information is used for indicating the state of the target resource after the change event occurs;
and updating the local cache according to the current resource state information to complete the synchronization of the current resource state information.
2. The method of claim 1, wherein prior to said establishing a long connection with a platform, the method further comprises:
acquiring initial resource state information of the target resource on the platform and an initial sequence identifier corresponding to the initial resource state information through a target interface on the platform, wherein the sequence identifier is used for indicating the time sequence of the resource state information corresponding to the sequence identifier in all the resource state information of the target resource;
and caching the initial resource state information and the initial sequence identification locally.
3. The method of claim 1, wherein the obtaining, via the long connection, current resource status information of the target resource comprises:
acquiring the current resource state information of the target resource and a current sequence identifier corresponding to the current resource state information from the platform through the long connection;
updating the local cache according to the current resource state information to complete the synchronization of the current resource state information, including:
and updating the local cache according to the corresponding current resource state information and the current sequence identifier to complete the synchronization of the current resource state information.
4. A method according to claim 3, wherein before updating the local cache according to the current resource status information and the current sequence identifier corresponding to each other, the method further comprises:
determining a historical sequence identifier of the target resource which is cached locally last time;
judging whether the difference value between the current sequence identifier and the historical sequence identifier is a preset value or not;
executing a jump operation for jumping to the state information of the current resource corresponding to each other and the current sequence identifier under the condition that the difference value is the preset value, updating a local cache, and completing synchronization of the state information of the current resource;
and under the condition that the difference value is not the preset value, acquiring all resource data of the target resource on the platform, wherein the resource data comprises resource state information and a sequence identifier which are mutually corresponding.
5. A method for synchronizing resource states, applied to a platform, comprising:
establishing long connection with a console;
generating current resource state information of the target resource under the condition that the change event of the target resource is determined, wherein the current resource state information is used for indicating the state of the target resource after the change event;
And sending the current resource state information to the control console through the long connection, so that the control console updates a local cache of the control console according to the current resource state information, and the synchronization of the current resource state information is completed.
6. The method of claim 5, wherein said sending the current resource status information to the console over the long connection comprises:
dividing the current resource state information of the target resource and a current sequence identifier corresponding to the current resource state information into a plurality of data blocks, wherein the sequence identifier is used for indicating the time sequence of the resource state information corresponding to the sequence identifier in all the resource state information of the target resource;
the plurality of data blocks is sent block by block to the console.
7. The method of claim 6, wherein prior to said dividing the current resource state information of the target resource and the current sequence identity corresponding to the current resource state information into a plurality of data blocks, the method further comprises:
determining a historical sequence identity corresponding to the latest of the target resource before the change event occurs;
And performing incremental operation on the historical sequence identifier according to a preset value to obtain the current sequence identifier.
8. A resource status synchronization console, comprising:
the first establishing module is used for establishing long connection with the platform;
the acquisition module is used for acquiring the current resource state information of the target resource through the long connection under the condition that the target resource determined by the platform is subjected to a change event and the current resource state information of the target resource is generated, wherein the current resource state information is used for indicating the state of the target resource after the change event;
and the updating module is used for updating the local cache according to the current resource state information to complete the synchronization of the current resource state information.
9. A resource status synchronization platform, comprising:
the second establishing module is used for establishing long connection with the control console;
the generation module is used for generating current resource state information of the target resource under the condition that the change event of the target resource is determined, wherein the current resource state information is used for indicating the state of the target resource after the change event;
And the sending module is used for sending the current resource state information to the control console through the long connection so that the control console updates the local cache of the control console according to the current resource state information to complete the synchronization of the current resource state information.
10. A resource status synchronization system comprising a console as claimed in claim 8 and a platform as claimed in claim 9.
11. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus, characterized in that,
the memory is used for storing a computer program;
the processor is configured to perform the method of any one of claims 1 to 7 by running the computer program stored on the memory.
12. A computer-readable storage medium, characterized in that the storage medium has stored therein a computer program, wherein the computer program is arranged to perform the method of any of claims 1 to 7 when run.
CN202311555950.6A 2023-11-21 2023-11-21 Resource state synchronization method, console, platform and system Pending CN117555685A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311555950.6A CN117555685A (en) 2023-11-21 2023-11-21 Resource state synchronization method, console, platform and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311555950.6A CN117555685A (en) 2023-11-21 2023-11-21 Resource state synchronization method, console, platform and system

Publications (1)

Publication Number Publication Date
CN117555685A true CN117555685A (en) 2024-02-13

Family

ID=89816371

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311555950.6A Pending CN117555685A (en) 2023-11-21 2023-11-21 Resource state synchronization method, console, platform and system

Country Status (1)

Country Link
CN (1) CN117555685A (en)

Similar Documents

Publication Publication Date Title
CN102932352B (en) The method that communicates and server is carried out with client
CN112118315A (en) Data processing system, method, device, electronic equipment and storage medium
CN103491055A (en) Method for synchronizing information among clients, clients and server
CN102904903B (en) Communication system and communication means
WO2014166265A1 (en) Method, terminal, cache server and system for updating webpage data
CN111698315B (en) Data processing method and device for block and computer equipment
WO2013078689A1 (en) Method and device for realizing message transfer in cloud message service
CN112422497B (en) Message transmission method and device and computer equipment
CN108540367B (en) Message processing method and system
CN105208058A (en) Information exchange system based on web session sharing
CN110545327A (en) information pushing method and system
CN107040576A (en) Information-pushing method and device, communication system
CN111159233A (en) Distributed caching method, system, computer device and storage medium
CN111464612A (en) Method for providing stable computing service in severe environment
CN112069154A (en) Automatic operation and maintenance method and related device for etcd distributed database
CN108509296B (en) Method and system for processing equipment fault
CN117555685A (en) Resource state synchronization method, console, platform and system
CN111327680A (en) Authentication data synchronization method, device, system, computer equipment and storage medium
CN111586438B (en) Method, device and system for processing service data
CN108737460B (en) Connection processing method and client
KR20160026138A (en) Rapid sync method for cloud file system and cloud file system using the same
CN114979234A (en) Session control sharing method and system in distributed cluster system
CN110971669B (en) Message notification method, device, server, electronic equipment and readable storage medium
CN108989467B (en) Centralized addressing method
CN111181791A (en) Quota management method, device, equipment and storage medium

Legal Events

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