Embodiment
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Embodiment 1
See Fig. 1, embodiments provide a kind of method of synchronous service data, comprising:
Step 101: the first service server, when the program code monitoring operation business produces the first business datum, obtains the class sum functions for generation of the first business datum in program code;
Step 102: according to such and this function, obtain the first synchronizing information that the first business datum is corresponding, the parameter type of the parameter that class mark, the function identification of this function, this function that the first synchronizing information comprises such comprise and parameter value;
Step 103: other each service servers in the service server group that this business is corresponding except the first service server send the first synchronizing information, make other each service servers perform class sum functions according to the first synchronizing information respectively and produce the first business datum, to realize synchronous first business datum.
Preferably, according to such and this function, obtain the first synchronizing information that the first business datum is corresponding, comprising:
Obtain such class mark and the function identification of this function;
Obtain each parameter that this function comprises, obtain the parameter value of each parameter respectively, and obtain the parameter type of each parameter value;
The class of acquisition is identified, function identification, parameter type and parameter value form the first synchronizing information corresponding to the first business datum.
Preferably, other each service servers in the service server group that this business is corresponding except the first service server send the first synchronizing information, comprising:
Obtain the address of other each service servers service server group corresponding to business except the first service server from Control Server, the address according to other each service servers sends the first synchronizing information respectively to other each service servers; Or,
Send the first synchronizing information, the service identification of this business and the mark of the first service server to Control Server, make Control Server send the first synchronizing information respectively to other each service servers according to the address of other each service servers in service server group corresponding to business except the first service server.
Further, the method also comprises:
Receive the second synchronizing information that the second service server sends, the second synchronizing information comprises class mark, function identification, parameter type and parameter value;
According to the second synchronizing information, perform the function that class corresponding to such mark is corresponding with this function identification, to produce the second business datum.
Preferably, according to the second synchronizing information, perform the function that class corresponding to such mark is corresponding with this function identification, to produce the second business datum, comprising:
According to the class mark that the second synchronizing information comprises, from program code, obtain the class that such mark is corresponding;
According to the function identification that the second synchronizing information comprises, from program code, obtain the function that this function identification is corresponding;
The parameter type comprised according to the second synchronizing information and parameter value, perform the function of class and the acquisition obtained, to produce the second business datum.
In embodiments of the present invention, the first service server, when the program code monitoring operation business produces the first business datum, obtains the class sum functions for generation of the first business datum in program code; According to such sum functions, obtain the first synchronizing information that the first business datum is corresponding, the parameter type of the parameter that class mark, the function identification of this function, this function that the first synchronizing information comprises such comprise and parameter value; Other each service servers in the service server group that this business is corresponding except the first service server send the first synchronizing information, make other each service servers perform class sum functions according to the first synchronizing information respectively and produce the first business datum, to realize synchronous first business datum.Because the capacity of the first synchronizing information is very little, the bandwidth sent shared by the first synchronizing information is little, and the speed sending the first synchronizing information is very fast, other each service servers generate the first business datum fast according to the first synchronizing information after receiving the first synchronizing information, so save the network bandwidth, improve the efficiency of synchronous service data.
Embodiment 2
Embodiments provide a kind of method of synchronous service data.
At present, in order to alleviate the pressure that huge visit capacity causes service server, multiple service server is usually used to provide service, the corresponding service server group of a business like this for a business.When the service server of in service server group produces business datum, the method that this service server can be provided by the embodiment of the present invention is by other each service servers in this service server group except this service server of the synchronizing traffic data that produces.
Wherein, this business is a corresponding load-balanced server also, for the load pressure of each service server in the service server group that this business balanced is corresponding.When this load-balanced server receives a service request of this business, load-balanced server is according to the loading condition of service server each in service server group, determine the service server that load pressure is minimum, and this service request is transmitted to the service server determined.
See Fig. 2, the method specifically comprises:
Step 201: the first service server, when the program code monitoring operation business produces the first business datum, obtains the class sum functions for generation of the first business datum in this program code;
Wherein, technical staff, when the program code of the business of writing, marks the class sum functions that can produce business datum in program code, is then stored in by the program code of business in each service server that service server group corresponding to this business comprise.
Wherein, class is a kind of data type in Object-oriented Programming Design, for describing a class things with common trait.The enclosed inside of class function, operationally need class to be instantiated as object, this object has such feature described, and carrys out call function by this object.Such as, " teacher " is exactly a class, and " teacher " this class describes the common trait of all teachers." teacher " this class can encapsulate " preparing lessons " function and " check and prepare lessons this " function.Instantiation is carried out to " teacher " this class and can obtain an object " teacher Li ".Operationally, carry out call function by object " teacher Li " " to prepare lessons " or " check and prepare lessons this ".Wherein, " teacher Li " call function " is prepared lessons " and can be produced business datum, and " teacher Li " call function " is checked and prepared lessons this " and can not produce business datum.
Wherein, class is instantiated as object, in internal memory, opens up a memory space exactly, for storing the data message of this object.Such as, " teacher " this class is instantiated as object " teacher Li ", in internal memory, open up the data message that a memory space stores " teacher Li " exactly, the data message of " teacher Li " can comprise " teacher Li " and teach class name and course name etc.
This step is specially, when the first service server receives the service request of load-balanced server forwarding, run the program code of this business to process this service request, now the program code of the first service server to this business is monitored, when the class monitoring certain mark in program code calls the function of certain mark, judge that such and this function are performed and create the first business datum, from program code, now obtain such and this function.
Wherein, the first service server is the arbitrary service server in service server group corresponding to this business.
Such as, when the first service server receives the service request of load-balanced server forwarding, run the program code of this business 1 to process this service request, now the program code of the first service server to this business 1 is monitored, when the class monitoring certain mark in program code calls the function of certain mark, judge that such and this function are performed and create the first business datum.Suppose that the class of this mark is class " teacher ", the function of this mark is that function " is prepared lessons ".From program code, now obtain such " teacher " and this function " is prepared lessons ".
Step 202: according to the class sum functions obtained, obtain the first synchronizing information that the first business datum is corresponding, the parameter type of the parameter that class mark, the function identification of this function, this function that the first synchronizing information comprises such comprise and parameter value;
Wherein, such class mark can be such class name etc., and the function identification of this function can be the function name etc. of this function.Function comprises at least one parameter, and when running this function, the parameter that function comprises is endowed parameter value, and parameter value has corresponding parameter type, and parameter type can be integer or character type etc.
This step is specially, and obtains such the class mark of class name as such from such.The function identification of function name as this function of this function is obtained from this function.Obtain each parameter that this function comprises, obtain the parameter value of each parameter respectively, and obtain the parameter type of each parameter value.The class of acquisition is identified, function identification, parameter type and parameter value form the first synchronizing information corresponding to the first business datum.
Such as, from such " teacher ", obtain such the class mark of class name " teacher " as such.The function name obtaining this function from this function " is prepared lessons " " is prepared lessons " as the function identification of this function.Obtain this function " to prepare lessons " each parameter comprised, suppose that function " is prepared lessons " and comprise parameter " teacher ", " course " and " number of pages ", the parameter value " 5 pages " of the parameter value " teacher Li " of " teacher ", the parameter value " Chinese language " of parameter " course " and the parameter " number of pages " of getting parms, and the value that gets parms " teacher Li ", " Chinese language " and parameter value " 5 pages " parameter type be integer.The class obtained mark " teacher ", function identification " are prepared lessons ", parameter value " teacher Li " and parameter type integer, parameter value " Chinese language " and parameter type integer thereof and parameter value " 5 pages " and parameter type integer thereof form the first synchronizing information S1 corresponding to the first business datum.
Wherein, after getting the first synchronizing information corresponding to the first business datum by the operation of above-mentioned steps 201 and 202, can as follows 203 operation other each service servers except the first service server that the first synchronizing traffic data is comprised to the service server group that this business is corresponding in.
Step 203: other each service servers in the service server group that this business is corresponding except the first service server send the first synchronizing information, make other each service servers perform such according to the first synchronizing information respectively and produce the first business datum, to realize synchronous first business datum with this function;
Wherein, in a network can also Control Server be set, in Control Server, stores the mark of each service server and the corresponding relation of address that service server group corresponding to this business comprise.Control Server and load-balanced server can be same server, also can be different servers.
Wherein, this step can be realized by mode in following first and second liang, is specially:
The mark of service identification and the first service server that the first, first service server sends this business is to Control Server.Control Server is according to the service identification of this business, from the corresponding relation of service identification and service server group, obtain the service server group that this business is corresponding, according to the mark of the first service server, the mark of other each service servers except the first service server is obtained from this service server group, then according to the mark of other each service servers, the address of other each service servers in service server group except the first service server is obtained from the mark of service server and the corresponding relation of address, and the address of other each service servers is returned to the first service server.First service server, according to the address of other each service servers, sends the first synchronizing information respectively to other each service servers.After other each service servers receive the first synchronizing information, perform such according to the first synchronizing information respectively and produce the first business datum, to realize synchronous first business datum with this function.
Such as, suppose that service server group comprises service server 1,2 and 3, wherein, service server 1 is the first service server.The mark F1 of service identification B1 and the first service server that the first service server 1 sends this business 1 is to Control Server.Control Server is according to the service identification B1 of this business 1, from the corresponding relation of service identification as shown in table 1 and service server group, obtain the service server group (F1 of this business 1 correspondence, F2, F3), according to the mark F1 of the first service server, from this service server group (F1, F2, the mark of the service server 2 and 3 obtained except the first service server F3) is respectively F2 and F3, then according to mark F2 and the F3 of service server 2 and 3, service server group (F1 is obtained from the mark of service server as shown in table 2 and the corresponding relation of address, F2, the address of the service server 2 and 3 F3) except the first service server 1 is respectively URL2 and URL3, and the address URL 2 of service server 2 and 3 and URL3 are returned to the first service server 1.First service server 1, according to the address URL 2 of service server 2 and 3 and URL3, sends the first synchronizing information S1 respectively to service server 2 and 3.After service server 2 and 3 receives the first synchronizing information S1, perform such " teacher " and this function according to the first synchronizing information S1 respectively and " prepare lessons " and produce the first business datum, to realize synchronous first business datum.
Table 1
Service identification |
Service server group |
B1 |
(F1、F2、F3) |
…… |
…… |
Table 2
The mark of service server |
The address of service server |
F1 |
URL1 |
F2 |
URL2 |
F3 |
URL3 |
Second, first service server sends the first synchronizing information, the service identification of this business and the mark of the first service server to Control Server.Control Server is according to the service identification of this business, corresponding service server group is obtained with the corresponding relation of service server group from service identification, according to the mark of the first service server, the mark of other each service servers except the first service server is obtained from the service server group obtained, then according to the mark of other each service servers, from the mark of service server and the corresponding relation of address, the address of other each service servers is obtained.First synchronizing information is sent to other each service servers according to the address of other each service servers by Control Server respectively.After other each service servers receive the first synchronizing information, perform such according to the first synchronizing information respectively and produce the first business datum, to realize synchronous first business datum with this function.
Such as, the first service server 1 sends the first synchronizing information S1, the service identification B1 of this business 1 and the mark F1 of the first service server to Control Server.Control Server is according to the service identification B1 of this business 1, from service identification as shown in table 1 with obtain corresponding service server group (F1 the corresponding relation of service server group, F2, F3), according to the mark F1 of the first service server, from the service server group (F1 obtained, F2, the mark of the service server 2 and 3 obtained except the first service server 1 F3) is respectively F2 and F3, then according to mark F2 and the F3 of service server 2 and 3, the address obtaining service server 2 and 3 from the mark of service server as shown in table 2 and the corresponding relation of address is respectively URL2 and URL3.First synchronizing information S1 is sent to service server 2 and 3 according to the address URL 2 of service server 2 and 3 and URL3 by Control Server respectively.After service server 2 and 3 receives the first synchronizing information S1, perform such " teacher " and this function according to the first synchronizing information S1 respectively and " prepare lessons " and produce the first business datum, to realize synchronous first business datum.
Wherein, when each service servers of other except the first service server comprised for the service server group that this business is corresponding produce business datums, the business datum that synchronously can produce according to the operation of step 201-203 with the first service server.
Wherein, the first service server both can obtain the first synchronizing information when generation the first business datum, and other each service servers except the first service server sending to service server group to comprise the first synchronizing information.Also can as follows 204 and 205 operation receive the second synchronizing information that other service servers send, and generate the second business datum according to the second synchronizing information.
Step 204: the first service server receives the second synchronizing information that the second service server sends, and the second synchronizing information comprises class mark, function identification, parameter type and parameter value;
Wherein, the second service server is the arbitrary service server in service server group corresponding to this business except the first service server.
Such as, first service server 1 receives the second synchronizing information S2 that the second service server 2 sends, the second synchronizing information S2 comprises that class mark " teacher ", function identification " are prepared lessons ", the parameter type integer of parameter value " Mr. Zhang " and correspondence thereof, " mathematics " and the parameter type integer of correspondence thereof and the parameter type integer of parameter value " 10 pages " and correspondence thereof.
Step 205: according to the second synchronizing information, performs the function that class corresponding to such mark is corresponding with this function identification, to produce the second business datum.
Particularly, according to the class mark that the second synchronizing information comprises, from the program code of business, the class that such mark is corresponding is obtained.According to the function identification that the second synchronizing information comprises, from the program code of business, obtain the function that this function identification is corresponding.The parameter type comprised according to the second synchronizing information and parameter value, perform the class sum functions obtained, to produce the second business datum.
Wherein, the class sum functions of acquisition can be performed in the following way, be specially:
The parameter type comprised according to the second synchronizing information and parameter value, by the class instantiation obtained, obtain an object.The parameter type comprise the second synchronizing information and parameter value substitute in the function obtained, and call this function, to produce the second business datum by this object.
Such as, according to class mark " teacher " that the second synchronizing information S2 comprises, from the program code of business 1, the class " teacher " that such mark is corresponding is obtained." prepare lessons " according to the function identification that the second synchronizing information S2 comprises, from the program code of business 1, obtain function corresponding to this function identification " prepare lessons ".The parameter value " Mr. Zhang " comprised according to the second synchronizing information S2 and data type integer thereof, be instantiated as object " Mr. Zhang " by the class " teacher " obtained.The parameter value " mathematics " comprised by second synchronizing information S2 and parameter type integer thereof and parameter value " 10 pages " and parameter type integer thereof are updated to during function " prepares lessons ", carry out call function by object " Mr. Zhang " " to prepare lessons ", making " Mr. Zhang prepares lessons to mathematics and obtains 10 pages of records of preparing lessons ", thus produce the second business datum.
Wherein, when other each service servers except the first service server that the service server group that this business is corresponding comprises receive synchronizing information, can come to generate business datum, to complete synchronous service data according to synchronizing information according to the operation of above-mentioned steps 204 and 205 with the first service server.
In embodiments of the present invention, the first service server, when the program code monitoring operation business produces the first business datum, obtains the class sum functions for generation of the first business datum in program code; According to such sum functions, obtain the first synchronizing information that the first business datum is corresponding, the parameter type of the parameter that class mark, the function identification of this function, this function that the first synchronizing information comprises such comprise and parameter value; Other each service servers in the service server group that this business is corresponding except the first service server send the first synchronizing information, make other each service servers perform class sum functions according to the first synchronizing information respectively and produce the first business datum, to realize synchronous first business datum.Because the capacity of the first synchronizing information is very little, the bandwidth sent shared by the first synchronizing information is little, and the speed sending the first synchronizing information is very fast, other each service servers generate the first business datum fast according to the first synchronizing information after receiving the first synchronizing information, so save the network bandwidth, improve the efficiency of synchronous service data.
Embodiment 3
See Fig. 3, embodiments provide a kind of device of synchronous service data, comprising:
First acquisition module 301, for the first service server when the program code monitoring operation business produces the first business datum, obtains the class sum functions for generation of the first business datum in program code;
Second acquisition module 302, for according to such and this function, obtains the first synchronizing information that the first business datum is corresponding, the parameter type of the parameter that class mark, the function identification of this function, this function that the first synchronizing information comprises such comprise and parameter value;
Sending module 303, the first synchronizing information is sent for other each service servers in service server group corresponding to this business except the first service server, make other each service servers perform class sum functions according to the first synchronizing information respectively and produce the first business datum, to realize synchronous first business datum.
Wherein, the second acquisition module 302 comprises:
First acquiring unit, for obtaining such class mark and the function identification of this function;
Second acquisition unit, for obtaining each parameter that this function comprises, obtaining the parameter value of each parameter respectively, and obtaining the parameter type of each parameter value;
Component units, for the class of acquisition being identified, function identification, parameter type and parameter value form the first synchronizing information corresponding to the first business datum.
Wherein, sending module 303 comprises:
First transmitting element, for obtaining the address of other each service servers in service server group corresponding to this business except the first service server from Control Server, the address according to other each service servers sends the first synchronizing information respectively to other each service servers; Or,
Second transmitting element, for sending the first synchronizing information, the service identification of this business and the mark of the first service server to Control Server, Control Server is made to send the first synchronizing information respectively to other each service servers according to the address of other each service servers in service server group corresponding to this business except the first service server.
Further, this device also comprises:
Receiver module, for receiving the second synchronizing information that the second service server sends, the second synchronizing information comprises class mark, function identification, parameter type and parameter value;
Executive Module, for according to the second synchronizing information, performs the function that class sum functions mark corresponding to class mark is corresponding, to produce the second business datum.
Wherein, Executive Module comprises:
3rd acquiring unit, for the class mark comprised according to the second synchronizing information, obtains the class that class mark is corresponding from program code;
4th acquiring unit, for the function identification comprised according to the second synchronizing information, obtains the function that function identification is corresponding from this program code;
Performance element, for the parameter type that comprises according to the second synchronizing information and parameter value, performs the function of class and the acquisition obtained, to produce the second business datum.
In embodiments of the present invention, the first service server, when the program code monitoring operation business produces the first business datum, obtains the class sum functions for generation of the first business datum in program code; According to such sum functions, obtain the first synchronizing information that the first business datum is corresponding, the parameter type of the parameter that class mark, the function identification of this function, this function that the first synchronizing information comprises such comprise and parameter value; Other each service servers in the service server group that this business is corresponding except the first service server send the first synchronizing information, make other each service servers perform class sum functions according to the first synchronizing information respectively and produce the first business datum, to realize synchronous first business datum.Because the capacity of the first synchronizing information is very little, the bandwidth sent shared by the first synchronizing information is little, and the speed sending the first synchronizing information is very fast, other each service servers generate the first business datum fast according to the first synchronizing information after receiving the first synchronizing information, so save the network bandwidth, improve the efficiency of synchronous service data.
One of ordinary skill in the art will appreciate that all or part of step realizing above-described embodiment can have been come by hardware, the hardware that also can carry out instruction relevant by program completes, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium mentioned can be read-only memory, disk or CD etc.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.