Summary of the invention
In view of this, fundamental purpose of the present invention is to provide a kind of method of device upgrade, with solve device upgrade workload in the prior art big, have a big risk, problem that cost is high.
For achieving the above object, technical scheme of the present invention is achieved in that
The invention provides a kind of method of device upgrade, comprising:
Worker thread for the devices allocation to be upgraded free time;
Institute's assignment thread is carried out updating operation according to the ROMPaq of configuration to described equipment to be upgraded.
Wherein, described is the worker thread of devices allocation free time to be upgraded, specifically comprises:
User interface UI sends upgrade request message to management thread, comprises equipment identities sign ID to be upgraded and action type in the described message, and described action type is for beginning upgrading;
Management thread is according to device id to be upgraded and action type in the described upgrade request message, the current state of searching in the internal storage data corresponding described equipment to be upgraded be to be upgraded, suspend, upgrading failure and upgrade overtime wherein a kind ofly, determine that described equipment to be upgraded can carry out the operation that begins to upgrade;
All devices in the described management thread traversal internal memory is to the worker thread of current state for the devices allocation free time of preparation upgrading;
Described management thread sends upgrade to institute's assignment thread.
Wherein, described definite beginning updating operation also comprises after can carrying out:
Management thread to Data Update thread and UI more new thread send Data Update message, comprise device id to be upgraded and dbjective state in the described message, described dbjective state is for preparing upgrading;
Described Data Update thread is updated to the current state of corresponding described equipment to be upgraded in the internal storage data according to Data Update message and prepares upgrading, and described UI more new thread is updated to the state of corresponding described equipment to be upgraded in the display interface according to Data Update message and prepares upgrading;
Described Data Update thread returns to management thread and upgrades the response message that finishes.
Wherein, described Data Update thread also comprises after internal storage data is upgraded:
Described Data Update thread notification data synchronizing thread upgrades;
Internal storage data after described data sync thread will upgrade saves as text and is sent to upgrade server.
Wherein, described is the worker thread of devices allocation free time to be upgraded, further comprises:
Described management thread to UI more new thread send Data Update message, comprise device id to be upgraded and dbjective state in the described message, described dbjective state is during upgrading;
Described UI more new thread is updated to the state of corresponding described equipment to be upgraded in the display interface during upgrading according to Data Update message.
Wherein, described institute assignment thread is treated updating apparatus and is carried out updating operation, specifically comprises:
Described worker thread is resolved the upgrade that is received, and obtains the Internet protocol IP information and the required pseudoinstruction of carrying out operation steps of upgrading of described equipment to be upgraded;
Described worker thread sends the pseudoinstruction of described operation steps to described equipment to be upgraded;
Described equipment to be upgraded is carried out respective phases of operation according to the reception pseudoinstruction.
Wherein, described worker thread is treated updating apparatus and is carried out updating operation, further comprises:
Described equipment to be upgraded returns the step execution result to described worker thread after each operation steps executes, described step execution result for operate successfully, operation failure and operation overtime wherein a kind of;
Described worker thread with described step execution result send to Data Update thread and UI more new thread carry out the renewal of described equipment state to be upgraded.
Wherein, described method further comprises: carry out in the updating operation process at described equipment to be upgraded, described updating operation is suspended, specifically comprise:
UI sends to management thread and suspends request message, comprises equipment identities sign ID to be upgraded and action type in the described message, and described action type is suspended for upgrading;
Management thread travels through all worker threads according to described time-out request message, judge and have the worker thread of carrying out described device upgrade operation to be upgraded, determine that then described equipment to be upgraded can carry out the operation that upgrading suspends, and the time-out variable that will carry out the worker thread that described device upgrade to be upgraded operates is revised as the time-out variate-value.
Wherein, described judgement upgrading pausing operation also comprises after can carrying out:
Management thread to Data Update thread and UI more new thread send Data Update message, comprise device id to be upgraded and dbjective state in the described message, described dbjective state is suspended for waiting;
Described Data Update thread is updated to the current state of corresponding described equipment to be upgraded in the internal storage data according to Data Update message and waits to suspend, and described UI more new thread is updated to the state of corresponding described equipment to be upgraded in the display interface according to Data Update message and waits to suspend;
Described Data Update thread returns to management thread and upgrades the response message that finishes.
Wherein, described management thread is revised and is suspended after the variable, also comprises:
Worker thread is carried out the upgrading pausing operation;
If described upgrading pausing operation success, then described worker thread to Data Update thread and UI more new thread send Data Update message and carry out the renewal of corresponding equipment state to be upgraded, comprise device id to be upgraded and dbjective state in the described message, described dbjective state is for suspending;
If described upgrading pausing operation failure or overtime, described worker thread stops the pausing operation of upgrading, and the notice management thread.
Device updating method of the present invention, configuration updating operation program and on control end in order to realize the thread of specific function, after ROMPaq starts, co-ordination between each thread, the present invention can realize the auto-update of batch device, need not user's manual operations, improved upgrading efficient, reduced upgrading the risk and cost, and the escalation process may command, the upgrading progress can show.
Embodiment
The technical solution of the present invention is further elaborated below in conjunction with the drawings and specific embodiments.
Device updating method of the present invention will adopt software programming to the operating process that equipment is upgraded, and at control end this software program be stored, and updating operation is called software program by control end and finished automatically, has saved manual trouble.
For this reason, embodiments of the invention are expanded basic thread and are obtained in order to realize the various threads of specific function, comprise: management thread, worker thread, Data Update thread, data sync thread and user interface (UI, User Interface) be new thread etc. more.Wherein, management thread is responsible for the resources allocation and the management of worker thread; Worker thread be responsible for equipment to be upgraded between communicate by letter, realization updating operation, and return result, worker thread disposes a plurality of according to actual needs, thereby can realize the upgrading to multiple devices; The Data Update thread is used for the data of escalation process are upgraded; The data sync thread is used for that upgrade server is preserved and uploaded to data updated to be backed up; UI more new thread is used for the update software interface display, makes the user can in time understand the variation of escalation process and operating result.Behind the program start of upgrading, intercom mutually between each thread, and co-ordination, a plurality of worker threads can be realized the upgrading to multiple devices, the Data Update thread makes that the internal storage data of control end is upgraded in time, the data sync thread makes the data in the upgrade server and the internal storage data of control end reach synchronous renewal, and UI more new thread makes that the user interface video data is upgraded in time.In addition, embodiments of the invention can realize to equipment begin upgrading and upgrading suspends two kinds of operations, the operation that can upgrade and suspend the equipment in the escalation process, thereby the process may command that makes upgrading.
Embodiments of the invention have carried out comprising as giving a definition to equipment state: to be upgraded, prepare upgrading, during upgrading, treat to suspend, suspend, upgrade successfully, upgrade and fail and upgrade overtime.
The so-called state that is meant when equipment is not carried out any operation to be upgraded is the original state of equipment, is in the operation that the equipment of state to be upgraded can begin to upgrade, and equipment state is prepared upgrading by to be upgraded changing into.
So-called prepare upgrading and be meant the initiation updating operation, but the state during unallocated worker thread, carry out the distribution of worker thread by management thread after, this equipment state changes into during upgrading by preparing upgrading.
So-called during upgrading being meant is assigned to worker thread, begun updating operation.Be in the operation that equipment during upgrading can be upgraded and be suspended, state is waited to suspend by during upgrading changing into.If updating operation is finished, state is upgraded successfully by during upgrading changing into; If failure is carried out in certain step operation in the escalation process, then state-transition is the upgrading failure; If certain step operation overtime in the escalation process, then state-transition is overtime for upgrading.
What is called is waited to suspend and is meant that initiating pausing operation in the device upgrade has also received order, waits for just in execution in step return result.Behind the return result, this equipment state changes time-out into by waiting to suspend.
The so-called time-out is meant that equipment is in halted state, suspends the operation of upgrading.The equipment that is in halted state can be carried out the operation that begins to upgrade once more, and state-transition is for preparing upgrading.
The so-called upgrading is meant that successfully all updating operation all complete successfully, and upgrading finishes.The successful equipment state of upgrading can not change again.
So-called upgrading failure is meant in the device upgrade process that certain step is carried out failure; The equipment of upgrading failure can be carried out the operation that begins to upgrade once more, and state-transition is upgraded for preparing, and continues upgrade step.
The overtime not return results in the expection stipulated time of equipment step updating operation that is meant of so-called upgrading; The overtime equipment of upgrading can be carried out the operation that begins to upgrade once more, and state-transition is upgraded for preparing, and continues upgrade step.
Below in conjunction with inner each the thread work situation synoptic diagram of embodiment of the invention control end shown in Figure 2, control end of the present invention is described the process that equipment carries out updating operation, as shown in Figure 3, mainly may further comprise the steps:
Step 301, UI initiates upgrade request message to management thread.
The user initiates updating operation by UI, and sends upgrade request message by UI to management thread, comprises in this message: (ID, Identity) and action type etc., wherein, action type is upgraded for beginning in the identify label of equipment to be upgraded.
Step 302, management thread judge that whether this equipment to be upgraded can carry out the operation that begins to upgrade, if can carry out, then forwards step 303 to; Otherwise, do not carry out any operation, process ends.
After management thread receives upgrade request message,, analyze internal storage data, and then judge whether this equipment to be upgraded can carry out the operation that begins to upgrade according to device id to be upgraded and the action type in this message.Equipment current state corresponding to be upgraded in the control inspection internal storage data whether be to be upgraded, suspend, the upgrading failure and upgrade overtime wherein a kind of, if judge that then this equipment to be upgraded can carry out the operation that begins to upgrade, and forward step 303 to; Otherwise, judge that this equipment to be upgraded can not carry out the operation that begins to upgrade, and process ends.Because, by aforementioned the present invention be device definition state as can be known, have only when equipment be in to be upgraded, suspend, upgrading failure or when upgrading state overtime, the just operation that can begin to upgrade.
After step 303, management thread determined that this equipment to be upgraded can be carried out the operation that begins to upgrade, more new thread and Data Update thread sent the message of Data Update respectively to UI.Comprise device id to be upgraded and dbjective state in this message, the dbjective state of corresponding beginning updating operation is for preparing upgrading.
Step 304, UI more new thread and Data Update thread carries out Data Update respectively according to the received data updating message.
UI more new thread the equipment state corresponding to be upgraded in the display interface is updated to the preparation upgrading, thereby the show state that makes display interface treat updating apparatus upgrades in time according to device id to be upgraded and dbjective state in the received data updating message.
Similarly, the Data Update thread is according to device id to be upgraded and dbjective state in the received data updating message, the state of corresponding equipment to be upgraded in the internal storage data is updated to prepares upgrading.In addition, after the Data Update thread upgrades and finishes, continuing the notification data synchronizing thread upgrades, internal storage data after the data sync thread will upgrade saves as text, and initiation file transfer protocol (FTP) (FTP, File Transfer Protocol) operation is uploaded to upgrade server with newly-generated file, is stored by upgrade server.It is pointed out that the Data Update thread carries out all wanting the notification data synchronizing thread to upgrade, thereby making the information of control end and upgrade server reach synchronous after the renewal operation of internal storage data at every turn.
Step 305, Data Update thread are returned to management thread and are upgraded the response that finishes.
After the renewal operation of Data Update thread is finished, return response message, finish, can carry out next step operation with the renewal operation of informing this Data Update thread of management thread to management thread.
Step 306, management thread are devices allocation worker thread to be upgraded.
After management thread receives the response message that the Data Update thread returns, all devices ID that stores in the traversal internal memory, the current state of searching equipment.The state that finds is for preparing the equipment of upgrading, then show this equipment is carried out the operation that begins to upgrade, management thread writes down the ID of this equipment and is the worker thread of this free time of devices allocation, send upgrade to the assignment thread, send then and update message to more new thread of UI, by UI more new thread will be updated to during upgrading to state that should equipment in the display interface.If all worker threads all are in busy state, then wouldn't carry out the distribution of worker thread, when being arranged, idle thread does distribution again.Management thread all needed to travel through all devices ID that stores in the internal memory before the thread that at every turn shares out the work, then, all working thread can't divide timing when all being in busy state, need not these facility informations that can't share out the work thread are write down once more and manage, make the processing logic complicated problems, and travel through all devices ID that stores in the internal memory before the thread that at every turn shares out the work, make each logical organization of distributing simplify, distribute when equipment to be upgraded can guarantee maximum when being a plurality of.
Step 307 after worker thread receives upgrade, is carried out corresponding updating operation.
Whole updating operation is made up of a series of operation steps, and a worker thread is responsible for all updating operation of an equipment according to the ROMPaq that disposes.All there is a resident program on each equipment, on the agreement port of equipment, carries out socket (socket) and monitor.After worker thread receives the upgrade of management thread, resolve command information, obtain Internet protocol (IP, the Internet Protocol) information of equipment to be upgraded and the pseudoinstruction of the operation steps that upgrading will be carried out.Then, the IP information that the worker thread utilization is obtained is set up socket with equipment to be upgraded and is connected, send the resident program of pseudoinstruction after the successful connection, generate executable shell (shell) order according to the pseudoinstruction that receives, thereby carry out respective phases of operation by resident program to equipment to be upgraded.Equipment to be upgraded to the worker thread return results, thereby is finished an operation steps after each operation steps executes, disconnect socket then and connect.When carrying out next step operation, set up socket once more and connect, and repeat aforesaid operations.All complete up to all operation stepss, show that then upgrading finishes.
Equipment to be upgraded is after each operation steps executes, return the step execution result to worker thread, and worker thread is after obtaining the operating result in per step, notification data more new thread and UI more new thread carry out Data Update, thereby make that internal storage data and interface display information are upgraded in time.Aforesaid step execution result comprises: operate successfully, operation failure and operation overtime.It is pointed out that if equipment to be upgraded makes a mistake when carrying out certain operation steps, as: operation failure or operation overtime then to the result of failure of worker thread return or operation overtime, report corresponding daily record explanation failure or overtime reason simultaneously.Worker thread suspends updating operation immediately, and the notice management thread.After the user can mediate problem according to the daily record that reports, the operation that begins to upgrade by the UI initiation again, and reselect idle worker thread by management thread and continue to carry out uncompleted updating operation step.
Step 308, after upgrading is finished, the worker thread notification data more new thread and UI more new thread the state of correspondence equipment to be upgraded is updated to upgrade successfully, management thread is with the resource release of this worker thread.
Below again in conjunction with inner each the thread work situation synoptic diagram of embodiment of the invention control end shown in Figure 2, control end of the present invention is described the upgrade process of pausing operation of equipment, as shown in Figure 4, mainly may further comprise the steps:
Step 401, UI initiates to suspend request message to management thread.
The user initiates the upgrading pausing operation by UI, and sends the time-out request message by UI to management thread, comprises in this message: the ID of equipment to be upgraded and action type etc., wherein, action type is suspended for upgrading.
Step 402, management thread judge that whether this equipment to be upgraded can carry out the operation that upgrading suspends, if can carry out, then forwards step 403 to; Otherwise, do not carry out any operation, process ends.
Management thread according to receive and suspend request message, travel through all worker threads, judge whether to exist the worker thread of carrying out corresponding device upgrade operation to be upgraded, if exist, judge that then this upgrading pausing operation can carry out; Otherwise, judge that this upgrading pausing operation can not carry out.
Step 403, management thread judge that this equipment to be upgraded can carry out the operation that upgrading suspends, and more new thread and Data Update thread send the message of Data Update respectively to UI.Comprise device id to be upgraded and dbjective state in this message, the dbjective state of respective upgrades pausing operation is suspended for waiting.
Step 404, UI more new thread and Data Update thread carries out Data Update respectively according to the received data updating message.
UI more new thread the equipment state corresponding to be upgraded in the display interface is updated to waits to suspend, thereby the show state that makes display interface treat updating apparatus upgrades in time according to device id to be upgraded and dbjective state in the received data updating message.
Similarly, the Data Update thread is according to device id to be upgraded and dbjective state in the received data updating message, the state of corresponding equipment to be upgraded in the internal storage data is updated to waits to suspend.In addition, after the Data Update thread upgrades and finishes, continue the notification data synchronizing thread and upgrade, internal storage data after the data sync thread will upgrade saves as text, and initiate the FTP operation, and newly-generated file is uploaded to upgrade server, store by upgrade server.
Step 405, Data Update thread are returned to management thread and are upgraded the response that finishes.
After the renewal operation of Data Update thread is finished, return response message, finish, can carry out next step operation with the renewal operation of informing this Data Update thread of management thread to management thread.
Step 406, management thread are revised the time-out variate-value of the corresponding worker thread of equipment to be upgraded.
After management thread receives the response message that the Data Update thread returns, all devices ID that stores in the traversal internal memory, the current state of searching equipment.The state of finding is an equipment to be suspended, then show this equipment is carried out the operation that upgrading suspends, management thread travels through all worker threads, find the worker thread of carrying out this device upgrade operation, and the time-out variable of this worker thread made amendment, the initial value that suspends variable is false, expression does not suspend, to suspend variable and be revised as true, expression suspends.It is pointed out that worker thread in the process of carrying out the updating operation step, execute per step operation after, all need to judge, if judge that suspending variate-value is false, then continues next step updating operation to suspending variable; If judge that suspending variate-value is true, then carry out the upgrading pausing operation, stop follow-up updating operation step, and to Data Update thread and UI more new thread send Data Update message, comprise device id to be upgraded and dbjective state in this message, this dbjective state is for suspending.Data Update thread and UI more new thread are updated to time-out with the state of corresponding device in internal storage data and the interface information respectively.In addition, if worker thread is carried out upgrading pausing operation failure or overtime, then notify management thread, and report corresponding log information.The user can mediate problem according to the log information that reports, and initiates the operation that upgrading suspends by UI again then.
It more than is the detailed description of the device updating method of the embodiment of the invention, device updating method of the present invention can be realized the updating operation to batch device, for example: Web TV (IPTV, Internet ProtocolTelevision) Exterior Gateway Protocol (EGP in the system, External Gateway Protocol) server updating and content distributing network (CDN, Content Delivery Network) acting server upgrading etc.Before device updating method of the present invention is operated in actual applications, the check of can in test environment, upgrading earlier, thus can guarantee carrying out smoothly of formal updating operation.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention.