Disclosure of Invention
One or more embodiments of the present specification describe a method and an apparatus for controlling traffic switching in a computer room, which control traffic switching from different dimensions according to different request type information (such as merchant information, interface information, and traffic switching proportion), thereby ensuring authenticity and comprehensiveness of service authentication.
According to a first aspect, there is provided a method of controlling a flow cut for controlling a message handover from a first room to a second room, the method may include:
receiving a request message, wherein the request message comprises request type information; judging whether the request type information meets a preset type condition related to the request type or not and judging whether a cut flow selection parameter generated based on the request message meets a cut flow selection condition related to a preset cut flow proportion or not; and when the request type information meets the preset type condition and the switching selection parameter meets the selection condition, determining that the switching request message is executed to the second machine room. The real flow is adopted, the flow cutting is controlled according to the granularity of information of different request types and the flow cutting proportion, and the real and comprehensive verification of the service is realized.
According to one possible design, the request type information may include merchant information and interface information, and the request type information satisfies a preset type condition related to the request type, including:
the merchant information satisfies a first preset condition related to the merchant information, and the interface information satisfies a second preset condition related to the interface information. And controlling the flow switching according to the merchant information, the interface information and the flow switching proportion, verifying the operation condition of each merchant and each interface in a second machine room (or called as a newly-built machine room), testing each merchant and each interface in the testing process, and ensuring the comprehensiveness of the test.
In one embodiment, the method may further comprise:
when the request type information does not meet a preset type condition related to the request type and/or a cut flow selection parameter generated based on the request message does not meet a cut flow selection condition related to a preset cut flow proportion, determining whether the request message comprises an identifier of a second machine room;
and when the request message comprises the identification of the second computer room, determining to switch the request message to the second computer room for execution.
In one embodiment, the method further comprises:
and when the request message does not comprise the identifier of the second machine room, transmitting the request message to a processing layer at the downstream of the gateway layer, so that the processing layer acquires corresponding service information according to the request message, and returns a switching indication message under the condition that the service information comprises the identifier of the second machine room.
In one embodiment, the method further comprises:
and when the flow switching indication message is received, determining to switch the request message to the second machine room for execution.
In one embodiment, the merchant information may include a merchant identification; the interface information may include an interface identification, an interface type, and the like.
In one embodiment, the flow cutting selection parameter is a random number generated in a range related to a preset flow cutting proportion based on the request type information, and the flow cutting selection condition is a random number of a preset value; alternatively, the first and second electrodes may be,
the flow switching selection parameter is a result of Hash operation based on the request type information; the cut stream selection condition is a hash result of a predetermined value.
According to a second aspect, there is provided a flow switching device for controlling a flow switching, the flow switching device being used for controlling message switching from a first machine room to a second machine room, the flow switching device comprising:
a receiving unit, configured to receive a request message, where the request message includes request type information;
the judging unit is used for judging whether the request type information meets a preset type condition related to the request type and whether a cut flow selection parameter generated based on the request message meets a cut flow selection condition related to a preset cut flow proportion;
and the determining unit is used for determining that the switching request message is executed to the second machine room when the request type information meets the preset type condition and the switching selection parameter meets the selection condition.
In one possible design, the request type information includes merchant information and interface information, and the determining unit is configured to determine that the request type information satisfies a preset type condition related to the request type, and includes:
the determination unit determines that the merchant information satisfies a first preset condition related to the merchant information and the interface information satisfies a second preset condition related to the interface information.
In one possible design, the determination unit is further configured to:
when the request type information does not meet a preset type condition related to the request type and/or a cut flow selection parameter generated based on the request message does not meet a cut flow selection condition related to a preset cut flow proportion, determining whether the request message comprises an identifier of a second machine room;
and when the request message comprises the identification of the second computer room, determining to switch the request message to the second computer room for execution.
In one embodiment, the flow cutting device further comprises an acquisition unit;
and the obtaining unit is used for transmitting the request message to a processing layer at the downstream of the gateway layer when the request message does not comprise the identifier of the second machine room, so that the processing layer obtains corresponding service information according to the request message, and returns a switching indication message under the condition that the service information comprises the identifier of the second machine room.
In one embodiment, the determining unit is further configured to determine to switch the request message to the second equipment room for execution when the flow switching indication message is received.
In one embodiment, the merchant information may include a merchant identification; the interface information may include an interface identification, an interface type.
In one embodiment, the flow cutting selection parameter is a random number generated in a range related to a preset flow cutting proportion based on the request type information, and the flow cutting selection condition is a random number of a preset value; alternatively, the first and second electrodes may be,
the flow switching selection parameter is a result of Hash operation based on the request type information; the cut stream selection condition is a hash result of a predetermined value.
According to a third aspect, there is provided a computer readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method of the first aspect.
According to a fourth aspect, there is provided a computing device comprising a memory and a processor, wherein the memory has stored therein executable code, and wherein the processor, when executing the executable code, implements the method of the first aspect.
By the method and the device for controlling the flow switching, which are provided by the embodiment of the specification, the flow switching is controlled by adopting the real flow according to different request type information and flow switching proportions, the smooth switching of the flow from the first machine room to the second machine room is realized, and the newly-built machine room is verified truly and comprehensively from a business perspective.
Detailed Description
The embodiment of the specification provides a method for controlling flow switching of a machine room and a flow switching device, wherein request type information in a service request is controlled through the flow switching device, gray level drainage of the machine room is controlled according to different request types (such as merchant information, interface information, commodity information and the like) and flow switching proportion, and therefore it is guaranteed that all services can be covered in a test flow service verification process, and comprehensive verification and authenticity verification are achieved.
The gray drainage refers to a distribution mode of flow in smooth transition between two machine rooms (for example, a machine room a and a machine room B), and the flow can slowly run from the machine room a to the machine room B, namely, one part of flow runs in the machine room a and the other part of flow runs in the machine room B. The machine room here refers to a server system.
The scheme provided by the specification is described below with reference to the accompanying drawings.
Fig. 1 is a schematic view of a scenario provided in an embodiment of the present disclosure, as shown in fig. 1, including a machine room a and a machine room B, where the embodiment is implemented between the machine room a and the machine room B. The machine room A and the machine room B respectively comprise a flow cutting device, an entrance gateway layer, a core application layer and a database. The whole flow switching device is arranged on an entrance gateway layer of the A/B machine room, flow interception is carried out on the entrance gateway layer, and whether flow switching or switching to the B/A machine room is carried out is judged. For example, when the flow switching device of the equipment room a receives a request message of a service, the flow switching device determines whether to forward the request message to the equipment room B for execution. The specific implementation of the flow cutting device is shown in fig. 2.
It should be noted that fig. 1 only shows a machine room a and a machine room B by way of example, and in the embodiment of this specification, at least one other machine room may also be included. When the flow switching device of the machine room a judges that the request message is switched to other machine rooms for execution, the request message can be switched to the machine room B or other machine rooms for execution according to the machine room identifier carried by the request message. The machine room A, the machine room B and other machine rooms can be different-place machine rooms or local machine rooms.
Fig. 2 is a schematic flow chart of a device for controlling flow cut provided in an embodiment of the present disclosure. The method is used for controlling message switching from a first machine room to a second machine room, for example, message switching from an A machine room to a B machine room shown in FIG. 1. In one embodiment, the first machine room includes a gateway layer, the method performed at the gateway layer of the first machine room, the method may include the steps of:
s110, receiving the request message.
The gateway layer receives a request message sent by the client, where the request message may include request message type information, and the request type information may be merchant information, interface information, and other information. The merchant information may include an identification of the merchant, and the identification of the merchant may be any identification information for identifying the merchant, such as a client identification of a client (client) sending the request message, a shop name of the merchant, and the like. The interface is an interface corresponding to a request message sent by the client, for example, an interface corresponding to a request message for purchase, payment, refund, etc. The interface information may include an Identification (ID) of the interface, a type of the interface, and the like.
Optionally, in this embodiment of the present specification, the gateway layer may simultaneously access one request message, and the one request message may be at least one request message.
And S120, judging whether the request type information meets a preset type condition related to the request type and whether a cut flow selection parameter generated based on the request message meets a cut flow selection condition related to a preset cut flow proportion.
In one embodiment of the present specification, it is assumed that the request type information is merchant information and interface information, the merchant information includes a merchant identifier, and the interface information includes an interface identifier. The preset condition corresponding to the merchant information is an identifier of some or specific merchant, for example, the specific merchant identifier is A, B or C; the preset condition corresponding to the interface information is the identification of some or specific interface, such as an interface identification X for identifying purchase, an interface identification Y for identifying payment, and an interface identification Z for identifying refund.
Judging whether the request type information meets a preset type condition related to the request type, wherein the judgment comprises the following steps: whether the merchant information meets preset conditions corresponding to the merchant information, whether the interface information meets preset conditions corresponding to the interface information, that is, whether the merchant identifier is a merchant identifier in the specific merchant identifier A, B, C, and whether the interface identifier of the interface information is an interface identifier X, Y, Z for identifying purchase, payment, and/or refund, is determined. If the merchant information and the interface information both meet the preset condition corresponding to the value, allowing the request message to be switched; and if any one of the merchant information and the interface information does not meet the corresponding preset condition, the flow cutting is not allowed. That is, if the merchant identification is a specific merchant identification and the interface identification is an interface identification identifying a purchase, payment and/or refund, the request message is allowed to be diverted; if the merchant identification is not a specific merchant identification and/or the interface identification is not an interface identification identifying a purchase, payment, and/or refund, the request message is not allowed to be diverted. .
In addition, the flow cutting judgment and control are carried out based on the preset flow cutting proportion. The preset tangential flow proportion is a self-defined proportion value for limiting tangential flow. In one embodiment, the flow switching selection parameter and the flow switching selection condition calculate the request message through a specific algorithm to generate a flow switching selection parameter, and determine whether the flow switching selection parameter meets a flow switching selection condition related to a preset flow switching proportion.
In one embodiment, the flow cutting selection parameter is a random number generated in a range related to a preset flow cutting proportion based on the request message, and the flow cutting selection condition is a random number of a preset value. Calculating each request message through a random number algorithm to obtain a random number X, determining whether the random number X is consistent with a random number of a preset value, and if so, allowing the request message corresponding to the random number X to be subjected to flow switching; and if not, not allowing the random number X to correspond to the request message to be switched.
In a more specific example, assume that the preset flow switching ratio is 1/10, i.e. 1 request message in every 10 request messages is allowed to be switched. Then for each request message it is selected to be cut with a probability of 1/10. Thus, for each request message to be processed, a random number between 1 and 10 is generated for it, and the cut-stream selection condition is set to a random number of 1 particular value between 1-10, for example a value of 7. Thus, for the current request message, if the random number generated for it happens to be 7, then it is determined that the request message is allowed to be cut; if the generated random number is not 7, the request message is not allowed to be cut, so that the probability that each request message is cut is guaranteed to be 10 percent and is consistent with the preset cut proportion.
In another embodiment, the range of the generated random numbers is not directly related to the preset cut-off ratio, for example, 1/10, but the result of calculating each message by the random number algorithm is 0 or 1. At this time, it may first compare whether the proportion of the request messages that have been cut into streams in the batch of request messages being processed reaches the preset cut stream proportion. If so, not allowing the subsequent message to be subjected to stream switching; if not, then randomly selecting a part to cut the stream in the following message. For example, a batch of request messages being processed contains 100 messages, and the batch of request messages is allowed to cut into 10 request messages at most according to the preset flow cutting proportion. For the current request message, firstly, it is determined whether 10 previous request messages have been switched, that is, it is determined whether the proportion of the switched messages reaches the preset switching proportion. If not, then the current request message may be cut. Next, it is determined whether or not to perform a stream cut based on the random number generated for the request message. For example, in the case where the random results are 1 and 0, if the generated random result is 1, the stream cutting is performed, and if 0, the stream cutting is not performed. In this way, on the basis of randomly selecting the request message, the message proportion of selecting to carry out stream switching is ensured not to be higher than the preset stream switching proportion.
In another embodiment of the present specification, the cut flow selection parameter may also be a result of a hash calculation operation based on the request type information, and the cut flow selection condition is a hash result of a predetermined value. The process is similar to the logic steps of calculating by using a random number algorithm, and is not described herein again for brevity.
It should be noted that the numerical values are merely examples of the technical solutions, and the technical solutions themselves are not limited. In the embodiments of the present specification, different values may be set as needed.
And S130, when the request type information meets the preset type condition related to the request type and the flow switching selection parameter meets the flow switching selection condition, determining that the switching request message is executed to the second machine room.
And when the request type information and the flow switching proportion both meet corresponding conditions, determining to switch the request message to a second machine room for execution.
Through setting the preset type conditions and the tangential flow proportion conditions, the grayscale drainage from a first machine room (or called an old machine room) to a second machine room (or called a newly-built new machine room) is realized by setting different request type information, such as the dimensionality (or granularity) of merchant information and interface information, and the tangential flow proportion control tangential flow, so that the comprehensive coverage of the service is ensured in the process of testing the flow service verification, and further the comprehensive verification and the authenticity verification are realized.
Alternatively, in the embodiments of the present specification, the request type information may also be other information, such as a type of goods (e.g., clothing, electronic goods, food), and the like. In the embodiment of the present specification, the request type information may be set according to the requirement.
Optionally, in an embodiment, as shown in fig. 3, the method may further include:
and S140, when the request type information does not meet the preset type condition related to the request type and/or the cut flow selection parameter generated based on the request message does not meet the cut flow selection condition related to the preset cut flow proportion, determining whether the request message comprises the identifier of the second machine room.
When at least one of the request type information does not satisfy the preset type condition related to the request type and the tangential flow selection parameter generated based on the request message does not satisfy the tangential flow selection condition related to the preset tangential flow proportion is satisfied, it is further required to determine whether the request message contains the identifier of the second machine room. If the request message contains the identifier of the second machine room, executing S130; if the request message does not contain the identity of the second room, S150 is performed.
And S150, transmitting the request message to a processing layer at the downstream of the gateway layer.
Then, the downstream processing layer may obtain the corresponding service information according to the request message, and return the flow switching indication message when the service information includes the identifier of the second equipment room.
The processing layers downstream of the gateway layer may include a core network layer and a database as in fig. 1. The service information is service basic information of a transaction performed by a user, for example, a user purchases a commodity Q, and the service information for purchasing the commodity Q may include a user account ABCDE for purchasing the commodity, a commodity name Q of the commodity Q, a purchase serial number 0101256 for purchasing the commodity Q, an ID of a client for purchasing the commodity Q, and information of a processing room B for processing an order for purchasing the commodity Q. After completing a purchase transaction, the system stores the transaction information for that transaction in a database.
In one embodiment, for example, the request message is a refund request message, and the request message includes service information such as a user account ABCDE requesting refund, a goods name Q requesting refund, and a purchase serial number 0101256 when the goods Q is purchased.
In S150, the gateway layer transmits the request message to a processing layer downstream of the gateway layer, and the processing layer acquires corresponding service information according to the request message, and determines whether the service information includes an identifier B of the processing equipment room when the product Q is purchased, that is, determines whether the service information includes an identifier of the second equipment room. When the identifier of the second machine room is included, the downstream processing layer returns a flow switching indication message to the gateway layer, and when the gateway layer receives the flow switching indication message, the request message is switched to the second machine room to be executed according to the flow switching indication message, that is, S130 is executed. In this way, forward business (such as commodity purchasing) and reverse request (such as refund request for commodity purchasing) are completed in the same machine room. That is, all transactions of the same commodity are ensured to be completed in the same machine room. For another example, a payment and a refund of the withholding are carried out by switching the refund request message to the target machine room to be executed by judging whether the refund request message includes the identifier of the different-place machine room, so that all processes of the service are ensured to be carried out in the same machine room.
When the service message does not include the identifier of the second equipment room, the equipment room to which the gateway layer belongs processes the request message, and the request type information is taken as merchant information and interface information as an example, so that the embodiment of the present specification is described.
Fig. 4 is a schematic flow chart of another apparatus for controlling a flow cut according to an embodiment of the present disclosure. As shown in fig. 4, the method is for controlling message switching from a first room to a second room, where in one embodiment the first room includes a gateway layer and the method is performed at the gateway layer of the first room. The method may comprise the steps of:
s210, receiving the request message.
The gateway layer receives a request message sent by a client of a merchant, wherein the request message comprises merchant information and interface information. The merchant information is an identifier of the client, and the interface information is interface information for identifying that the request message is a purchase request, a payment request or a refund request, such as an interface identifier.
The gateway layer receives the request message and analyzes the message information in the request message, namely the merchant information and the interface information.
S220, judging whether the merchant information meets a first preset condition related to the merchant information.
The first preset condition is the identification of the client allowing the stream cutting. The gateway layer judges whether the client identification of the merchant information is consistent with the identification of the client allowing the flow switching, if so, the request message is allowed to be subjected to the flow switching, and S230 is executed; if not, further determining whether to allow the request message to perform flow switching, i.e. executing S260.
And S230, judging whether the interface information meets a second preset condition related to the interface information.
The second preset condition is an identifier of an interface allowing for switching, for example, an identifier of an interface corresponding to a purchase request, an identifier of an interface corresponding to a payment request, an identifier of an interface corresponding to a refund request, and the like. The gateway layer judges whether the interface identifier of the interface information is consistent with the interface identifier of the allowed flow switching, if so, the flow switching of the request message is allowed, and S240 is executed; if not, further determining whether the conditions of the tangential flow ratio are satisfied, and executing step S260.
And S240, judging whether the cut flow selection parameters generated based on the request message meet cut flow selection conditions related to a preset cut flow proportion.
The preset flow switching ratio is a preset value, which is a ratio value of request messages allowed to be switched to other equipment rooms for execution in the request messages, for example, the preset flow switching ratio is 0.1, that is, 10 request messages are allowed to be switched to other equipment rooms for execution in 100 request messages.
On the basis of the steps S220 and S230, the gateway layer calculates the request message meeting the steps S220 and S230 through a specific algorithm, such as a hash algorithm or a random algorithm, generates a cut flow selection parameter, and judges whether the cut flow selection parameter meets a cut flow selection condition related to a preset cut flow proportion, and if the cut flow selection condition meets the requirement, the step S250 is executed; if not, execution S260 is performed. For a specific process, see description of whether the flow switching selection parameter generated based on the request message in S120 in fig. 3 satisfies the flow switching selection condition related to the preset flow switching ratio, which is not described herein again for brevity.
And S250, determining to switch the request message to a second machine room for execution.
And S260, judging whether the request message comprises the identifier of the second machine room.
When the merchant information does not meet a first preset condition related to the merchant information, the interface information does not meet a second preset condition related to the interface information, and any one of the tangential flow selection parameters generated based on the request message does not meet the tangential flow selection condition related to a preset tangential flow proportion, whether the request message contains an identifier of a second machine room for processing the request message in the second machine room is judged, if yes, S250 is executed, namely when the request message contains the identifier of the second machine room, S250 is executed, for example, the request is a refund request, and payment of the refund request is carried out in the machine room B, the machine room B is switched to execute the refund request. When the identifier of the second equipment room is not included in the request message, S270 is executed.
S270, the request message is transmitted to a processing layer downstream of the gateway layer.
The processing layer can obtain the corresponding service information according to the request message, and return the switching indication message under the condition that the service information includes the identifier of the second machine room. And when the gateway layer receives the switching indication message, determining to switch the request message to a second machine room for execution. The specific process is the same as the process of S150 in fig. 2, and is not repeated herein for brevity.
Optionally, in another embodiment of this description, the determination sequence of S220, S230, and S240 in fig. 4 may be arranged at will, and a technical effect of controlling the cut flow may also be achieved, which is not limited in this description. The data processing workload can be logically reduced by adopting the processing order of S220, S230, and S240 in fig. 4.
By adopting the method for controlling the flow switching provided by the embodiment of the specification, the new machine room can be verified more accurately by verifying the real flow. And controlling the tangential flow according to the merchant information, the interface information and the tangential flow proportion in a multi-dimensional mode, slowly adjusting the tangential flow proportion, and further achieving verification of the new machine room. Meanwhile, the operation condition of each merchant and each interface in the new machine room can be verified, and the problem that the merchant is not completely tested is solved.
Fig. 5 is a schematic view of a flow cutting device for controlling flow cutting provided in the present specification. As shown in fig. 5, the cut flow device is used to control message switching from a first room to a second room, and in one embodiment, the first room includes a gateway layer, and the cut flow device is at the gateway layer. The flow cutting apparatus may include a receiving unit 410, a judging unit 420, and a determining unit 430. A receiving unit 410, configured to receive a request message, where the request message includes request type information;
a determining unit 420, configured to determine whether the request type information meets a preset type condition related to the request type and whether a cut-stream selection parameter generated based on the request message meets a cut-stream selection condition related to a preset cut-stream proportion;
the determining unit 430 is configured to determine that the handover request message is executed to the second machine room when the request type information meets the preset type condition and the handover selection parameter meets the selection condition.
The flow cutting device obtains real flow, controls and controls flow cutting from request type information and flow cutting proportion, achieves flow guiding from the gray level of a first machine room to a second machine room, guarantees that all services can be covered in a test flow service verification process, and further achieves comprehensive verification and authenticity verification.
In an embodiment of the present specification, the request type information includes merchant information and interface information, and the determining unit 430 is configured to determine that the request type information satisfies a preset type condition related to the request type, including:
the determination unit 430 determines that the merchant information satisfies a first preset condition related to the merchant information and the interface information satisfies a second preset condition related to the interface information.
In an embodiment of the present specification, the determining unit 430 is further configured to determine whether the request message includes an identifier of the second equipment room when the request type information does not satisfy a preset type condition related to the request type and/or whether a cut flow selection parameter generated based on the request message satisfies a cut flow selection condition related to a preset cut flow ratio;
and when the request message comprises the identification of the second computer room, determining to switch the request message to the second computer room for execution.
In an embodiment of this specification, the flow switching apparatus further includes an obtaining unit 440, configured to, when the request message does not include an identifier of the second equipment room, transmit the request message to a processing layer downstream of the gateway layer, so that the processing layer obtains corresponding service information according to the request message, and returns a flow switching indication message when the service information includes the identifier of the second equipment room.
In the embodiment of the present specification, the determining unit 430 is further configured to determine to switch the request message to the second machine room for execution when the flow switching indication message is received.
Optionally, in this embodiment of the present specification, the merchant information includes a merchant identifier; the interface information comprises an interface identifier and an interface type.
Optionally, in an embodiment, the flow cutting selection parameter is a random number generated in a range associated with a preset flow cutting proportion based on the request type information, and the flow cutting selection condition is a random number of a predetermined value; alternatively, the first and second electrodes may be,
the flow switching selection parameter is a result of Hash operation based on the request type information; the cut stream selection condition is a hash result of a predetermined value.
The flow switching device in fig. 5 can implement the methods in fig. 2, fig. 3, and fig. 4 to achieve the technical effects corresponding to the techniques, and is not described herein again for brevity.
Embodiments of the present specification also provide a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the methods of fig. 2, 3 and 4.
The embodiment of the present specification further provides a computing device, which includes a memory and a processor, where the memory stores executable codes, and the processor executes the executable codes to implement the methods in fig. 2, fig. 3, and fig. 4.
Those skilled in the art will recognize that, in one or more of the examples described above, the functions described in this invention may be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium.
The above-mentioned embodiments, objects, technical solutions and advantages of the present invention are further described in detail, it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made on the basis of the technical solutions of the present invention should be included in the scope of the present invention.