Summary of the invention
The object of the invention is to, a kind of control method of smart jack is provided, solve above technical problem.
The present invention also aims to, a kind of control device of smart jack is provided, solve above technical problem.
Technical problem solved by the invention can realize by the following technical solutions:
The invention provides a kind of control method of smart jack, wherein, comprise the following steps:
Step 1, smart jack has judged whether that client sends an external command to described smart jack;
Step 2, described smart jack judges whether described external command can accept, and if not, described smart jack produces a state information, and described client resends described external command after postponing setting-up time according to described state information, repeats step 1;
Step 3, inserts a command buffer alignment by described external command;
Step 4, the order according to described command buffer alignment performs the order in described command buffer alignment successively.
The control method of smart jack of the present invention, the concrete steps of described step 2 are as follows:
Step 21: described smart jack judges that whether described command buffer alignment is full, if full, performs step 26;
Step 22, obtains the timeout value that order that in described command buffer alignment, each is waited in line is corresponding;
Step 23, calculates the stand-by period of the complete needs of all command execution in described command buffer alignment;
Step 24, calculates the difference of the timeout value corresponding with the described external command that active client sends of described stand-by period;
Step 25, judges whether described difference is greater than zero, if not, performs step 3;
Step 26, described smart jack returns one with reference to delay time value to described client, and described client resends described external command according to described with reference to after delay time value delay setting-up time, repeats step 1.
The present invention also provides a kind of control device of smart jack, for implementing the control method of above-mentioned smart jack, comprises,
Interface module, with described client's side link, for receiving described external command;
Memory module, stores described command buffer alignment, and described command buffer alignment comprises the order waited in line successively;
According to imposing a condition, judge module, judges whether described external command can accept;
Module is added in order, in order to add described external command to described command buffer alignment;
Executive Module, order performs the order in described command buffer alignment.
Smart jack control device of the present invention, described memory module also stores each and orders corresponding timeout value.
Smart jack control device of the present invention, described judge module comprises a spilling judge module, in order to judge that whether described command buffer alignment is full.
Smart jack control device of the present invention, described judge module comprises the first computing module, in order to calculate in the current command buffer queue the stand-by period of the complete needs of all command execution waited in line.
Smart jack control device of the present invention, described judge module also comprises the second computing module, in order to the described timeout value of described stand-by period and described external command is got difference.
Smart jack control device of the present invention, described interface module connects a local area network or cloud server, the described external command that the described client that reception is connected with described local area network or described cloud server sends.
Beneficial effect: owing to adopting above technical scheme, the present invention, by performing remote command with client negotiate, prevents socket from causing buffer overflow owing to ordering too much on the one hand; Alleviate the pressure performing too much order in the socket short time on the other hand; Due to the state information that client can return according to socket, after reasonably postponing setting-up time, resend order, thus improve Consumer's Experience; For smart jack is performing when the remote command of client, provide solution more efficiently to see, and realize relatively simple.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, the every other embodiment that those of ordinary skill in the art obtain under the prerequisite of not making creative work, all belongs to the scope of protection of the invention.
It should be noted that, when not conflicting, the embodiment in the present invention and the feature in embodiment can combine mutually.
Below in conjunction with the drawings and specific embodiments, the invention will be further described, but not as limiting to the invention.
With reference to Fig. 1, the control method of smart jack, wherein, comprises the following steps:
Step 1, smart jack has judged whether that client sends an external command to smart jack;
Step 2, smart jack judges whether external command can accept, and if not, smart jack produces a state information, and client resends external command after postponing setting-up time according to state information;
Step 3, inserts a command buffer alignment by external command;
Step 4, according to the order of order successively in fill order buffer queue of command buffer alignment.
In order to ensure the read-write consistency of data, smart jack normally serial performs these orders one by one, and the command execution before the client sending order so rearward just needs to wait until is complete, could obtain result, stand-by period is likely longer, thus affects the Consumer's Experience of client.The hardware processing capability of smart jack itself is limited after all, if improve hardware performance for this reason, will increase manufacturing cost.The control method of smart jack of the present invention is after receiving long-range external command, and the current processing capabilities of first evaluating system, if resource allows, just accepts external command and insert command buffer alignment to wait in line to perform; If discovery system is busy or resource soon reaches critical point, just return the state information of socket to inform client, state information can be some reference values, such as advises when client resends order.
The control method of smart jack of the present invention, with reference to Fig. 2, a kind of concrete steps of step 2 are as follows:
Step 21: smart jack judges that whether command buffer alignment is full, if full, performs step 26;
Step 22, obtains the timeout value that in command buffer alignment, each order waited in line is corresponding;
Step 23, the stand-by period of the complete needs of all command execution in calculation command buffer queue;
Step 24, the difference of the timeout value that the calculating stand-by period is corresponding with the external command that active client sends;
Step 25, judges whether difference is greater than zero, if not, performs step 3;
Step 26, smart jack returns one with reference to delay time value to client, and client resends external command after postponing setting-up time with reference to delay time value, repeats step 1.
Smart jack needs the timeout value (command_timeout) of the every bar order of predefined, and sets up a module specially to carry out system resource assessment.When smart jack receives the external command of client, first this external command is assessed, if external command can accept, inserted queue and wait execution; Otherwise return a time of delay, and by this loopback time of delay to client, as postponing the reference value resending this external command.
Whether can be in time processed key point of the present invention if being how accurate evaluation goes out order.On the one hand, it is more accurate to assess, and socket is higher with the coordinating efficiency of client; But then, assessment itself also can consume jack system resource, and technical difficulty also can correspondingly increase.So assessment will average out between the two in accuracy and performance.The implementation procedure of step 2 can select other modes flexibly, object is to make smart jack before order can not process in time, the state information of smart jack can be returned client, and issue the reference value of a time of delay, such as advise that client resends external command after postponing 2 seconds.
Step 2 can be realized by following computer program, provides pseudo-code below:
The present invention also provides a kind of control device of smart jack, with reference to Fig. 3, for implementing the control method of above-mentioned smart jack, comprises,
Interface module 1, with client's side link, for receiving external command;
Memory module 2, memory command buffer queue, command buffer alignment comprises the order waited in line successively;
Judge module 3, judges whether external command can accept;
Module 4 is added in order, in order to add external command to command buffer alignment;
Executive Module 5, the order in order fill order buffer queue.
Smart jack control device of the present invention, memory module 2 also stores each and orders corresponding timeout value.
Smart jack control device of the present invention, judge module 3 can comprise a spilling judge module, in order to judge that whether described command buffer alignment is full.
Smart jack control device of the present invention, judge module 3 can also comprise the first computing module, in order to calculate in the current command buffer queue the stand-by period of the complete needs of all command execution waited in line;
Smart jack control device of the present invention, all right second computing module of judge module 3, in order to get difference by stand-by period and external command timeout value.
Smart jack control device of the present invention, interface module 1 connects a local area network or cloud server, the external command that the client that reception is connected with local area network or cloud server sends.
The present invention realizes relatively simple, by performing remote command with client negotiate, prevents socket from causing buffer overflow owing to ordering too much on the one hand; Alleviate the pressure performing too much order in the socket short time on the other hand; Due to the state information that client can return according to socket, reasonably postpone or retransmit order, thus improving Consumer's Experience; For smart jack is performing when the remote command of client, provide solution more efficiently.
The foregoing is only preferred embodiment of the present invention; not thereby embodiments of the present invention and protection range is limited; to those skilled in the art; should recognize and all should be included in the scheme that equivalent replacement done by all utilizations specification of the present invention and diagramatic content and apparent change obtain in protection scope of the present invention.