Disclosure of Invention
In view of the above, the present invention provides a data upgrade method and apparatus that overcomes or at least partially solves the above problems.
A data upgrading method is applied to a terminal, and comprises the following steps:
broadcasting version information of first target data of the terminal; the method comprises the steps that a plurality of terminals are included in the same local area network, and any terminal except the terminal in the local area network is used as a target terminal;
receiving the version information of the first target data of the target terminal fed back when the version information of the first target data of the target terminal is compared to be higher than the version information of the first target data of the terminal by the target terminal;
sending first confirmation upgrading information to the target terminal, establishing a first data transmission channel with the target terminal, and receiving upgrading data of first target data sent by the target terminal based on the first data transmission channel; the upgrade data of the first target data corresponds to version information of the first target data;
and executing upgrading operation based on the upgrading data.
Optionally, the method further comprises:
if the terminal is the terminal which is registered on the server connected with the terminal firstly in the local area network, setting the identification information of the terminal as target identification information;
sending program version information of second target data to the server;
receiving program upgrading data of the second target data stored in the server, which is fed back when the server compares that the program version information of the second target data stored in the server is higher than the program version information of the second target data of the terminal;
and executing upgrading operation based on the program upgrading data.
Optionally, the method further comprises:
if the version information of the third target data broadcasted by the target terminal is monitored, comparing the version information of the third target data of the target terminal with the version information of the third target data of the terminal;
if the version information of the third target data of the terminal is higher than that of the third target data of the target terminal, sending the version information of the third target data of the terminal to the target terminal;
and receiving second confirmation upgrading information sent by the target terminal, establishing a second data transmission channel with the target terminal, and transmitting upgrading data corresponding to the version information of third target data of the terminal to the target terminal based on the second data transmission channel.
Optionally, the method further comprises:
accessing a preset area of the server, and acquiring target strategy information and target parameter information stored in the preset area;
if the version information of the target strategy information is higher than the version information of the strategy information of the terminal, carrying out strategy information upgrading operation based on the target strategy information;
and if the version information of the target parameter information is higher than the version information of the parameter information of the terminal, performing parameter information upgrading operation based on the target parameter information.
Optionally, based on the upgrade data, performing an upgrade operation, including:
comparing the version information of the upgrade data with the version information of the first target data of the terminal;
and if the version information of the upgrading data is higher than the version information of the first target data of the terminal, carrying out data integrity check on the upgrading data, and if the version information of the upgrading data is higher than the version information of the first target data of the terminal, carrying out upgrading operation based on the upgrading data.
A data upgrading device is applied to a terminal, and comprises:
the information broadcasting module is used for broadcasting the version information of the first target data of the terminal; the method comprises the steps that a plurality of terminals are included in the same local area network, and any terminal except the terminal in the local area network is used as a target terminal;
the first information receiving module is used for receiving the fed back version information of the first target data of the target terminal when the target terminal compares that the version information of the first target data of the target terminal is higher than the version information of the first target data of the terminal;
the first information processing module is used for sending first confirmation upgrading information to the target terminal, establishing a first data transmission channel with the target terminal, and receiving upgrading data of first target data sent by the target terminal based on the first data transmission channel; the upgrade data of the first target data corresponds to version information of the first target data;
and the first upgrading module is used for executing upgrading operation based on the upgrading data.
Optionally, the method further comprises:
the information setting module is used for setting the identification information of the terminal as target identification information if the terminal is the terminal which is registered on a server connected with the terminal in the local area network firstly;
the first information sending module is used for sending the program version information of the second target data to the server;
the second information receiving module is used for receiving the program upgrading data of the second target data stored in the server, which is fed back when the program version information of the second target data stored in the server is compared by the server to be higher than the program version information of the second target data of the terminal;
and the second upgrading module is used for executing upgrading operation based on the program upgrading data.
Optionally, the method further comprises:
the data comparison module is used for comparing the version information of the third target data of the target terminal with the version information of the third target data of the terminal if the version information of the third target data broadcasted by the target terminal is monitored;
the second information sending module is used for sending the version information of the third target data of the terminal to the target terminal if the version information of the third target data of the terminal is higher than the version information of the third target data of the target terminal;
and the second information processing module is used for receiving second confirmation upgrading information sent by the target terminal, establishing a second data transmission channel with the target terminal, and transmitting upgrading data corresponding to the version information of third target data of the terminal to the target terminal based on the second data transmission channel.
A storage medium comprising a stored program, wherein the program performs the above-described data upgrade method.
An electronic device comprising at least one processor, and a bus and at least one memory connected to the processor; the processor and the memory complete mutual communication through the bus; the processor is used for calling the program instructions in the memory so as to execute the data upgrading method.
By means of the technical scheme, the terminal in the same local area network can broadcast the version information of the first target data of the terminal, then the target terminal higher than the version information can send the version information of the first target data of the target terminal to the terminal, and a first data transmission channel can be established between the terminal and the target terminal to transmit the upgrading data of the first target data of the target terminal, so that the terminal can finish the upgrading operation of the first target data. In the embodiment, the terminals can be upgraded mutually, and the upgrade package does not need to be downloaded from the server, so that the load of the server is reduced, and the network bandwidth occupied by the server is reduced.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
An embodiment of the present invention provides a data upgrade method, which is applied to a terminal, and referring to fig. 1, a data communication scenario of the terminal is introduced, taking a business system of a company as an example, a business system may include one or more servers, that is, a central management platform in fig. 1, for each central management platform, a plurality of terminals in a local area network (lan 1 … … lan N) may be connected, a plurality of terminals are included in the same local area network, and the terminals are equal and may perform version update synchronization of policies, parameters, and programs among each other. Specifically, referring to fig. 2, terminals in the same lan may communicate with each other through UDP (User Datagram Protocol), and any two terminals may also communicate with each other through TCP (Transmission Control Protocol).
In each local area network, a seed node is set, and the setting principle is as follows: a seed node is generated by adopting a preemptive registration mechanism, namely, which terminal is registered at the server first and which terminal can be used as the seed node.
For a seed node, the seed node may communicate with a server whether a program version is updated or not, and if the program version is updated, download a program of a latest version from the server and execute an upgrade process, specifically, if the terminal is a terminal that is registered on the server connected to the terminal first in the local area network, set the identification information of the terminal as target identification information, where setting the identification information of the terminal as the target identification information may be setting the terminal as the seed node. In addition, the seed node may interact with the server to implement data upgrade, specifically, referring to fig. 3, the method may include:
and S11, the seed node sends the program version information of the second target data to the server.
The seed node sends the program version information of the second target data in a heartbeat mode regularly, and the program version information can be 1.0, 2.0 and the like.
In this embodiment, for a piece of software, three types of data, which are a parameter, a policy, and a program, are included, and in this embodiment, program version information of the program may be sent in a heartbeat manner. In addition, for both the parameter and the policy data, the upgrade data needs to be acquired by accessing the server.
In detail, for two kinds of data, namely the parameter and the policy, the upgrading content is small, the server upgrades the two kinds of data, namely the parameter and the policy, and then places the data into a Zookeeper region, namely a preset region, of a distributed system of the server, and then the seed node accesses the Zookeeper region to acquire target policy information and target parameter information from the Zookeeper region.
And then the seed nodes respectively compare whether the version information of the target strategy information is higher than the version information of the strategy information of the terminal, and if so, the strategy information is upgraded based on the target strategy information. Specifically, whether the data of the target policy information is complete or not is checked, and if the data of the target policy information is complete, the target policy information is replaced with the policy information stored in the target policy information. By the way of processing the target parameter information similarly, if the version information of the target parameter information is larger than the version information of the parameter information of the terminal, the parameter information is upgraded based on the target parameter information.
S12, the server compares whether the program version information of the second target data stored in the server is higher than the program version information of the second target data of the terminal; if so, go to step S13.
Comparing the level of the two program version information can be through the content of the program version information, generally, the version value of the program version information of the high version is larger, and if the version 2.0 is higher than the version 1.0, the high version and the low version can be compared through the version value.
If the version value of the program version information of the second target data sent from the server is high, step S13 is executed.
And S13, the server sends the program upgrading data of the second target data stored by the server to the seed node.
And S14, the seed node executes the upgrading operation based on the program upgrading data.
After receiving the program upgrading data, the seed node confirms whether the version in the program upgrading data is higher than the program version information of the seed node, if so, the seed node verifies whether the program upgrading data is complete, and if so, the seed node upgrades the program.
In this embodiment, only the seed node needs to download the upgrade package from the server, and the network bandwidth occupation is small.
After the seed node obtains the latest upgrade data according to steps S11-S14 and performs the upgrade, the data of the seed node is the latest in the local area network where the seed node is located, and further, the data in the seed node can be used to perform the data upgrade on other terminals in the local area network.
Specifically, referring to fig. 4, the method may include:
s11, the terminal i broadcasts the version information of the first target data of the terminal i.
S12, terminal j listens to the version information of the first target data of terminal i.
In this embodiment, since the seed node is the latest upgrade data acquired from the server at first, the terminal i is the seed node at first, the upgrade data is sent to any other terminal at the seed node, for example, the terminal a, and after the terminal a is upgraded, the next terminal i may be the seed node or the terminal a, and so on until all the terminals are upgraded.
In this embodiment, the first target data may be data of a policy, a parameter, and a program of one piece of software, that is, the terminal i broadcasts its own version information, which includes the version information of the policy, the parameter, and the program.
After the terminal i broadcasts the version information of the first target data of the terminal i, any terminal in the local area network can monitor the version information.
S13, the terminal j judges whether the version information of the first target data stored in the terminal j is higher than that of the first target data of the terminal i; if yes, go to step S14.
S14, the terminal j sends the version information of the first target data of the terminal j to the terminal i.
And the terminal j monitors the broadcast information, compares the version information in the received broadcast packet with the version information of the terminal j, and sends specific upgrading information (one of upgrading strategy, parameter and program) to the terminal i if the version of the terminal j is high (any one of strategy, parameter and program is high).
It should be noted that, in the local area network, the terminals other than the terminal j may also receive the version information of the first target data of the terminal i, and then perform the comparison of the versions, and if the version information of the first target data stored in the terminal is higher than the version information of the first target data of the terminal i, the version information of the first target data of the terminal itself may also be sent to the terminal i, but the terminal i may only receive the information that is sent to the terminal first, and ignore the information that is sent to the terminal later.
And S15, the terminal i sends the first upgrade confirmation information to the terminal j.
And the terminal i receives the upgrading information of the terminal j, if the terminal i is ready for upgrading, the terminal i replies the ready upgrading information, namely the first confirmation upgrading information, and switches to the TCP state.
S16, the terminal i and the terminal j establish a first data transmission channel.
And the terminal j receives the information for preparing upgrade of the terminal i, and switches to the TCP state if the terminal i is considered to be prepared for upgrade.
And S17, the terminal j sends the upgrade data of the first target data of the terminal j to the terminal i.
In the TCP state, terminal j sends the upgrade content (one of policy, parameter, program) to terminal i.
And S18, the terminal i executes the upgrading operation based on the upgrading data.
And the terminal i receives the upgrade content of the terminal j, and performs upgrade content verification (including comparing the version information of the upgrade data with the version information of the first target data of the terminal, and performing data integrity verification on the upgrade data if the version information of the upgrade data is higher than the version information of the first target data of the terminal), wherein if the verification is successful, the synchronization is successful. The specific upgrade process may refer to the above corresponding contents, which are not described herein again.
In the above, the terminal i is introduced as a receiver of the upgrade data, and in addition, the terminal i may also be used as a sender of the upgrade data, specifically:
1) if the version information of the third target data broadcasted by the target terminal is monitored, comparing the version information of the third target data of the target terminal with the version information of the third target data of the terminal;
2) if the version information of the third target data of the terminal is higher than that of the third target data of the target terminal, sending the version information of the third target data of the terminal to the target terminal;
3) and receiving second confirmation upgrading information sent by the target terminal, establishing a second data transmission channel with the target terminal, and transmitting upgrading data corresponding to the version information of third target data of the terminal to the target terminal based on the second data transmission channel.
It should be noted that the specific operation process of the terminal in this embodiment is similar to the operation process of the terminal j, please refer to the corresponding content above.
In addition, the first target data, the second target data, and the third target data in the above embodiments are only used for distinguishing different upgrade scenarios and are named differently, and the first target data, the second target data, and the third target data may be the same software data or different software data. Such as the first target data being data of software a, the second target data being data of software B, and so on.
In the above embodiment, the seed node has two functions, one is to communicate with the server whether the version of the program is updated, and if the version is updated, the program of the latest version is downloaded from the server and the upgrading process is executed; secondly, the seed node receives the version information of other nodes in the local area network, and if the program version of the node is found to be lower than the version of the seed node, the seed node sends the latest version program downloaded by the seed node to the seed node. The policy is similar to the principle of synchronization of parameters.
In the embodiment, a secondary synchronous updating mode of 'server-seed node-terminal' is designed based on UDP and TCP protocols, and a seed node in a local area network is selected to download a program with the latest version from a server and execute an upgrading process; then the seed node is responsible for synchronizing the version information of other nodes in the local area network, and the terminals can be upgraded mutually in the local area network, so that the synchronous upgrading speed is high. By the two-stage synchronous updating mode, the load of the server is greatly reduced, and the occupation of network bandwidth is reduced.
Optionally, on the basis of the embodiment of the data upgrading method, another embodiment of the present invention provides a data upgrading apparatus, which is applied to a terminal, and with reference to fig. 5, the data upgrading apparatus includes:
aninformation broadcasting module 101, configured to broadcast version information of first target data of the terminal; the method comprises the steps that a plurality of terminals are included in the same local area network, and any terminal except the terminal in the local area network is used as a target terminal;
a firstinformation receiving module 102, configured to receive the fed back version information of the first target data of the target terminal when the target terminal compares that the version information of the first target data of the target terminal is higher than the version information of the first target data of the terminal;
the firstinformation processing module 103 is configured to send first confirmation upgrade information to the target terminal, establish a first data transmission channel with the target terminal, and receive upgrade data of first target data sent by the target terminal based on the first data transmission channel; the upgrade data of the first target data corresponds to version information of the first target data;
afirst upgrade module 104, configured to perform an upgrade operation based on the upgrade data.
Further, still include:
the data comparison module is used for comparing the version information of the third target data of the target terminal with the version information of the third target data of the terminal if the version information of the third target data broadcasted by the target terminal is monitored;
the second information sending module is used for sending the version information of the third target data of the terminal to the target terminal if the version information of the third target data of the terminal is higher than the version information of the third target data of the target terminal;
and the second information processing module is used for receiving second confirmation upgrading information sent by the target terminal, establishing a second data transmission channel with the target terminal, and transmitting upgrading data corresponding to the version information of third target data of the terminal to the target terminal based on the second data transmission channel.
Further, thefirst upgrade module 104 is configured to, when executing an upgrade operation based on the upgrade data, specifically:
comparing the version information of the upgrade data with the version information of the first target data of the terminal; and if the version information of the upgrading data is higher than the version information of the first target data of the terminal, carrying out data integrity check on the upgrading data, and if the version information of the upgrading data is higher than the version information of the first target data of the terminal, carrying out upgrading operation based on the upgrading data.
In the embodiment, a secondary synchronous updating mode of 'server-seed node-terminal' is designed based on UDP and TCP protocols, and a seed node in a local area network is selected to download a program with the latest version from a server and execute an upgrading process; then the seed node is responsible for synchronizing the version information of other nodes in the local area network, and the terminals can be upgraded mutually in the local area network, so that the synchronous upgrading speed is high. By the two-stage synchronous updating mode, the load of the server is greatly reduced, and the occupation of network bandwidth is reduced.
It should be noted that, for the working process of each module in this embodiment, please refer to the corresponding description in the above embodiments, which is not described herein again.
On the basis of the embodiment of the data upgrading device, the method further comprises the following steps:
the information setting module is used for setting the identification information of the terminal as target identification information if the terminal is the terminal which is registered on a server connected with the terminal in the local area network firstly;
the first information sending module is used for sending the program version information of the second target data to the server;
the second information receiving module is used for receiving the program upgrading data of the second target data stored in the server, which is fed back when the program version information of the second target data stored in the server is compared by the server to be higher than the program version information of the second target data of the terminal;
and the second upgrading module is used for executing upgrading operation based on the program upgrading data.
Further, still include:
the data access module is used for accessing a preset area of the server and acquiring target strategy information and target parameter information stored in the preset area;
the upgrading module is used for upgrading the strategy information based on the target strategy information if the version information of the target strategy information is higher than the version information of the strategy information of the terminal; and if the version information of the target parameter information is higher than the version information of the parameter information of the terminal, performing parameter information upgrading operation based on the target parameter information.
In this embodiment, only the seed node needs to download the upgrade package from the server, and the network bandwidth occupation is small.
It should be noted that, for the working process of each module in this embodiment, please refer to the corresponding description in the above embodiments, which is not described herein again.
The data upgrading device comprises a processor and a memory, the information broadcasting module, the first information receiving module, the first information processing module, the first upgrading module and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. One or more than one kernel can be set, and a secondary synchronous updating mode is realized by adjusting kernel parameters, so that the load of the server is greatly reduced, and the occupation of network bandwidth is reduced.
An embodiment of the present invention provides a storage medium on which a program is stored, the program implementing the data upgrade method when executed by a processor.
The embodiment of the invention provides a processor, which is used for running a program, wherein the data upgrading method is executed when the program runs.
An embodiment of the present invention provides a device 70, and referring to fig. 6, the device 70 includes at least oneprocessor 701, and abus 703 and at least onememory 702 connected to the processor; theprocessor 701 and thememory 702 complete mutual communication through abus 703;processor 701 is configured to call program instructions inmemory 702 to perform the data upgrade method described above. The device 70 herein may be a server, a PC, a PAD, a cell phone, etc.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device:
a data upgrading method is applied to a terminal, and comprises the following steps:
broadcasting version information of first target data of the terminal; the method comprises the steps that a plurality of terminals are included in the same local area network, and any terminal except the terminal in the local area network is used as a target terminal;
receiving the version information of the first target data of the target terminal fed back when the version information of the first target data of the target terminal is compared to be higher than the version information of the first target data of the terminal by the target terminal;
sending first confirmation upgrading information to the target terminal, establishing a first data transmission channel with the target terminal, and receiving upgrading data of first target data sent by the target terminal based on the first data transmission channel; the upgrade data of the first target data corresponds to version information of the first target data;
and executing upgrading operation based on the upgrading data.
Further, still include:
if the terminal is the terminal which is registered on the server connected with the terminal firstly in the local area network, setting the identification information of the terminal as target identification information;
sending program version information of second target data to the server;
receiving program upgrading data of the second target data stored in the server, which is fed back when the server compares that the program version information of the second target data stored in the server is higher than the program version information of the second target data of the terminal;
and executing upgrading operation based on the program upgrading data.
Further, still include:
if the version information of the third target data broadcasted by the target terminal is monitored, comparing the version information of the third target data of the target terminal with the version information of the third target data of the terminal;
if the version information of the third target data of the terminal is higher than that of the third target data of the target terminal, sending the version information of the third target data of the terminal to the target terminal;
and receiving second confirmation upgrading information sent by the target terminal, establishing a second data transmission channel with the target terminal, and transmitting upgrading data corresponding to the version information of third target data of the terminal to the target terminal based on the second data transmission channel.
Further, still include:
accessing a preset area of the server, and acquiring target strategy information and target parameter information stored in the preset area;
if the version information of the target strategy information is higher than the version information of the strategy information of the terminal, carrying out strategy information upgrading operation based on the target strategy information;
and if the version information of the target parameter information is higher than the version information of the parameter information of the terminal, performing parameter information upgrading operation based on the target parameter information.
Further, based on the upgrade data, performing an upgrade operation, comprising:
comparing the version information of the upgrade data with the version information of the first target data of the terminal;
and if the version information of the upgrading data is higher than the version information of the first target data of the terminal, carrying out data integrity check on the upgrading data, and if the version information of the upgrading data is higher than the version information of the first target data of the terminal, carrying out upgrading operation based on the upgrading data.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a device includes one or more processors (CPUs), memory, and a bus. The device may also include input/output interfaces, network interfaces, and the like.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.