A kind of long connection fault tolerant mechanism based on ICP/IP protocol
Technical field
The present invention relates to the technical field of network service, more particularly to a kind of long connection fault tolerant based on ICP/IP protocol
Mechanism.
Background technology
Long connecting communication refers to that communication two party remains communication link in whole communication process, is a kind of towards connection
, reliable communication modes.Long connecting communication is used for frequent operation, point-to-point communication, and connection number can not too many feelings
Condition.The implementation method of long connection is varied, wherein the realization based on ICP/IP protocol is most widely used.Wherein, client
Connection request is initiated to server, server receives the connection request of client, and both sides establish connection;Client is complete with server
Into after once reading and writing, the connection between them can't be closed actively, and follow-up read-write operation may proceed to use this connection;
During holding is connected, if sent without packet, it is necessary to which both sides send out link detecting bag.
Specifically, the long connecting communication based on ICP/IP protocol, while link itself is kept in communication, inside carries
The application protocol and applied business content of higher network level.Long interface channel can logically be divided into three layers:Lattice chain
Road floor, application protocol layer and applied business floor.In practical application based on ICP/IP protocol, conventional three layers are usually TCP chains
Road floor, HTTP application protocol layers and SOAP operation layers.
In the prior art, long connection fault tolerant function is simply folded by the fault tolerant mechanism of each logical layer independence in long interface channel
Add and form, without synergy between the fault tolerant mechanism of each layer.
Therefore, existing long connection fault tolerant mechanism has the following disadvantages:
(1) fault-tolerant system and imperfect, mistake can only be in this Es-region propagations of generating source;
(2) definition to wrong cross-layer pass through mechanism is lacked;
(3) support to wrong menace level and respective behavior is lacked.
For example, to re-establish length there occurs a serious staging error needs in applied business layer connects network link layer with extensive
When servicing again, current fault tolerant mechanism can not specification, neatly realize above-mentioned requirements.Particularly when long Connection Service is as public
When middleware provides service altogether, it can not accomplish frequently to change server end, to meet the fault-tolerant demand of various applications simultaneously.
The content of the invention
In view of the above the shortcomings that prior art, it is an object of the invention to provide a kind of length based on ICP/IP protocol
Connection fault tolerant mechanism, various fault-tolerant demands of the long Connection Service as middleware can be met without changing server end.
In order to achieve the above objects and other related objects, the present invention provides a kind of long connection fault tolerant based on ICP/IP protocol
Mechanism, including:1) defining the error format of long connection includes following field:It is mistake title/error coded, menace level, excellent
First grade, processing mode, the wrong title/error coded and additional information for mapping to basic logic layer;2) in long interface channel
Each business operation associate at least one mistake, each logical layer can be carried out at collaboration to mistake caused by business operation
Reason;3) all business operations initiated in long interface channel, all each mistake associated by it is stated in error definition
Corresponding processing mode;4) the wrong processing mode that business processing end is declared according to each business operation, to caused
Mistake is handled.
According to the above-mentioned long connection fault tolerant mechanism based on ICP/IP protocol, wherein:The processing mode includes following three
Kind:
A, mistake caused by business operation is retained in into source generation logical layer to be handled;
B, the basic logic layer that error propagation caused by business operation to source is produced below logical layer is handled;
C, mistake caused by business operation is not handled.
Further, according to the above-mentioned long connection fault tolerant mechanism based on ICP/IP protocol, wherein:
Wrong title/the error coded is defined by long Connection Service according to own service;
The menace level represents the menace level of mistake;
The priority level represents the priority level of mistake;
It is to be transferred to basic logic that described wrong title/error coded for mapping to basic logic layer, which is represented in processing mode,
During layer processing, the mapping relations of mistake error code in across logical layer transmission processing procedure;
The additional message is used to provide additional message.
Further, according to the above-mentioned long connection fault tolerant mechanism based on ICP/IP protocol, wherein:The menace level
Include 1 grade -5 grades of 5 grades from low to high with the priority level.
Further, according to the above-mentioned long connection fault tolerant mechanism based on ICP/IP protocol, wherein:The business processing end
The error handle mode declared according to each business operation, is handled caused mistake in the following way:
If a, caused mistake is not declared, acquiescence produces the processing side of logical layer processing using the source that is retained in
Formula;
If b, caused mistake has been declared, the processing mode according to mistake statement definition is handled;
If c, producing multiple mistakes, according to the menace level in error definition, highest menace level it is wrong it is preferential must
To processing;
If d, producing multiple menace level identical mistakes, according to the priority level in error definition, highest priority scheduling
The mistake of level is preferentially handled;
If it is identical e, to produce multiple menace levels, priority level identical mistake, at first caused mistake preferentially obtain
Processing.
According to the above-mentioned long connection fault tolerant mechanism based on ICP/IP protocol, wherein:The business processing end is server
End.
According to the above-mentioned long connection fault tolerant mechanism based on ICP/IP protocol, wherein:In long interface channel, http protocol
The statement of wrong processing mode is included by HTTP REQUEST structures in layer;Wrong processing mode in soap protocol layer
Statement is included by SOAP HEADER structures;The statement of wrong processing mode is by extra Variable-Bindings knot in snmp protocol
Structure body includes.
According to the above-mentioned long connection fault tolerant mechanism based on ICP/IP protocol, wherein:The menace level, the priority scheduling
Level and the processing mode field are represented using 32 integer datas.
According to the above-mentioned long connection fault tolerant mechanism based on ICP/IP protocol, wherein:Wrong title/the error coded,
Wrong title/the error coded for mapping to basic logic layer and the extra information field are character string type, and length is 0
Between~255.
As described above, the long connection fault tolerant mechanism based on ICP/IP protocol of the present invention, has the advantages that:
(1) complete long connection fault tolerant mechanism is defined;
(2) need not change server end can meet various fault-tolerant demands of the long Connection Service as middleware.
Brief description of the drawings
Fig. 1 is shown as the schematic diagram of the error definition form of the long connection of the present invention;
Fig. 2 is shown as the long connection fault tolerant mechanism principle figure based on ICP/IP protocol of the present invention.
Embodiment
Illustrate embodiments of the present invention below by way of specific instantiation, those skilled in the art can be by this specification
Disclosed content understands other advantages and effect of the present invention easily.The present invention can also pass through specific realities different in addition
The mode of applying is embodied or practiced, the various details in this specification can also be based on different viewpoints with application, without departing from
Various modifications or alterations are carried out under the spirit of the present invention.
It should be noted that the diagram provided in the present embodiment only illustrates the basic conception of the present invention in a schematic way,
Then the component relevant with the present invention is only shown in schema rather than is painted according to component count, shape and the size during actual implement
System, kenel, quantity and the ratio of each component can be a kind of random change during its actual implementation, and its assembly layout kenel also may be used
Can be increasingly complex.
The long connection fault tolerant mechanism based on ICP/IP protocol of the present invention includes the mistake of each logical layer in long interface channel
Coprocessor system, the definition format of mistake, the statement mode of mistake, and several partial contents such as processing rule of mistake.
Specifically, the long connection fault tolerant mechanism of the invention based on ICP/IP protocol includes herein below:
1) error format of long connection is defined
Reference picture 1, the error format of long connection of the invention include following field:
A, mistake title/error coded
The field is defined by long Connection Service according to own service.Specifically, the field is character string type, and length exists
Between 0~255.
B, menace level
Specifically, the field represents the menace level of mistake, is divided into 1 grade -5 grades totally 5 grades, from low to high.When a variety of
Mistake produces simultaneously when, menace level highest mistake will be handled preferentially.The field is represented using 32 integer datas.
C, priority level
Specifically, the field represents that the priority value of mistake is divided into 1 grade -5 grades totally 5 grades, from low to high.When a variety of phases
When with the wrong of menace level while producing, priority level highest mistake is preferentially handled.The field uses 32 integers
Data represent.
D, processing mode
Specifically, the processing mode field of mistake is represented using 32 integer datas, wherein, 0-3 positions data are retention,
Remaining is expansible.0-3 positions data are defined as follows:
0-reserved (Reserved)
1-reservation (Stay-In) produces logical layer in source and handled
Specifically, mistake caused by business operation only is produced into logical layer in source to be handled, do not influenceed below the layer
Basic logic layer.
2-be absorbed in (Trap-In) to source produce logical layer below basic logic layer processing
Specifically, error propagation caused by business operation to source is produced at the basic logic layer below logical layer
Reason.In addition, in the definition format of mistake, the mapping mode of the error propagation behavior is defined, i.e., source produces logical layer
Mistake map to source and produce type of error in the basic logic layer below logical layer, to obtain the next step of corresponding mistake
Processing mode, and chain type iteration is carried out with this model.
3-do not handle (Ignore)
Specifically, mistake caused by business operation is not handled
E, wrong title/error coded of basic logic layer is mapped to
Specifically, the field is character string type, and length is between 0~255.When the field value of " processing mode " is " 2 ", i.e.,
When selection is absorbed in the mode of basic logic layer processing, the field is used to indicate mistake in across logical layer transmission processing procedure,
The mapping relations of error code.When the field value of " processing mode " is non-" 2 ", the field does not indicate that in all senses.
F, additional message
Specifically, the field is character string type, and length is between 0~255, for providing additional message.
It should be noted that it is the definition format of single error above.In actual use, reusable this definition lattice
Formula defines a variety of mistakes.
2) each business operation in long interface channel associates at least one mistake, and each logical layer can be to business operation
Caused mistake carries out collaboration processing.
3) all business operations initiated in long interface channel, all to each mistake associated by it in error definition
The corresponding processing mode of statement.
Reference picture 2, for the mistake associated by business operation, it is first determined the processing mode stated for the mistake,
If processing mode is Stay-In, mistake is retained in this layer of processing;If processing mode is Trap-In, mistake is absorbed in lower floor
Processing;Then can chain type iterative processing successively.
Specifically, in long interface channel, the statement of the processing mode of mistake uses different realities according to Different Logic layer
Existing mode.For example, the statement of processing mode wrong in http protocol layer can be included by HTTP REQUEST structures;SOAP is assisted
The statement of wrong processing mode can be included by SOAP HEADER structures in view layer;Wrong processing mode in snmp protocol
Statement can by extra Variable-Bindings structure include, etc..
4) the error handle mode that business processing end is declared according to each business operation, at caused mistake
Reason.
Wherein, business processing end is usually server end.
The error handle mode that business processing end is declared according to each business operation, using following rule to caused mistake
Handled by mistake:
If a, caused mistake is not declared, acquiescence is using reservation (Stay-In) at the place that this logical layer is handled
Reason mode, processing is performed in this logical layer;
If b, caused mistake has been declared, the processing mode according to mistake statement definition is handled;
If c, producing multiple mistakes, according to the menace level in error definition, highest menace level it is wrong it is preferential must
To processing;
If d, producing multiple menace level identical mistakes, according to the priority level in error definition, highest priority scheduling
The mistake of level is preferentially handled;
5. if multiple menace levels are identical, and priority level identical mistake, timestamp caused by foundation mistake is arranged produce
Sequence, at first caused mistake preferentially handled.
It should be noted that the long connection fault tolerant mechanism based on ICP/IP protocol of the present invention covered three layers is only
TCP link layers, HTTP application protocol layers and SOAP operation layers.And in reality use, long connection fault tolerant mechanism of the invention
It is expansible to be applied to other length connection realizations.
In summary, the long connection fault tolerant mechanism of the invention based on ICP/IP protocol defines complete long connection fault tolerant
Mechanism;Server end, which need not be changed, can meet various fault-tolerant demands of the long Connection Service as middleware.So the present invention has
Effect overcomes various shortcoming of the prior art and has high industrial utilization.
The above-described embodiments merely illustrate the principles and effects of the present invention, not for the limitation present invention.It is any ripe
Know the personage of this technology all can carry out modifications and changes under the spirit and scope without prejudice to the present invention to above-described embodiment.Cause
This, those of ordinary skill in the art is complete without departing from disclosed spirit and institute under technological thought such as
Into all equivalent modifications or change, should by the present invention claim be covered.