Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
The service processing method provided by the application is also applied to the storage of service data, the service data is stored according to the number identification for identifying the service, the method is different from the random strategy storage in the traditional mode, the number identification is pre-distributed, and the number identification is uniformly managed before being used.
For example, assuming a storage location of service data of a certain service, the storage location may include an HA database, an HB database, an HC database, and an HD database. And, assuming that the number identifier to be used by the service can be any number value in the interval of 0000001 to 4000000, then, in the service processing method of the application, 0000001 to 4000000 can be divided and respectively allocated to each database.
As table 1 below illustrates an allocation manner (not limited to this manner), 0000001 to 4000000 may be divided into four number segments, each number segment including a plurality of number identifiers, for example, 0000001 is one number identifier, and 0000002 is another number identifier. Each number segment is allocated to a database, that is, if a service is represented by a number identifier in a certain number segment, the service data of the service is stored in the database corresponding to the number segment. For example, if the service is identified with 0000001 as a number, the service data will be stored in the HA database. Table 1 also sets status information, which can be used to indicate that the database corresponding to a certain number of segments is working normally or has a fault. For example, a current database failure may be represented by a "0" and a current database failure may be represented by a "1".
TABLE 1 number assignment relationship
Number section
|
Database with a plurality of databases
|
Status information
|
0000001~1000000
|
HA
|
0
|
1000001~2000000
|
HB
|
1
|
2000001~3000000
|
HC
|
1
|
3000001~4000000
|
HD
|
1 |
Based on the above division of the number identifiers, the service processing method shown in fig. 1 may be performed, and the method may include:
in step 101, a target number segment is determined according to the state information corresponding to the number segments, each number segment includes a plurality of number identifiers, the storage locations corresponding to the target number segments are normal, and one number identifier is selected from the target number segment.
For example, when a service processing system receives a service processing request, a number identifier corresponding to the service may be generated, and in subsequent service processing, the number identifier may be used to represent the service; and the storage of the service data in the service processing can also be identified according to the number.
In this step, a number identifier corresponding to the service is generated. The generating method may be, for example, taking the number allocation relationship shown in table 1, assuming that the current service may be represented by one number identifier generated in four number segments in table 1, then, according to the state information, the number segment with a normal state of the database may be represented by the state information, and is used as an available number segment.
Referring to the example of fig. 1, if the status information of the HA database is "0", indicating that the HA is faulty, the HA is removed, one number segment is selected from the number segments respectively corresponding to the HB, HC, and HD, and is used as a target number segment, and the number identifier of the current service is also generated from the target number segment.
Illustratively, 2000001-3000000 can be selected as the destination number segment, and a number identifier is selected from the destination number segment, for example, 2000001 is selected as the number identifier of the service. The selection mode is not limited, and can be freely set, for example, a number identifier can be randomly selected.
In step 102, the number identifier is used as an identifier of the service to be processed, and the service data of the service to be processed is stored in the storage location corresponding to the target number segment.
In this step, since the number identifier 2000001 of the service is obtained from the number segment 2000001-3000000, the service data of the service can be stored in the database HC corresponding to the number segment 2000001-3000000 by referring to the corresponding relationship shown in table 1.
In the service processing method of the present example, when the service data is stored according to the number identifier, the random policy storage is no longer performed, and the database selected by the random policy may fail, but the number segment corresponding to the storage location that normally operates may be selected according to the state of the storage location corresponding to the number segment to generate the number identifier, thereby improving the reliability of service processing.
When the state of the storage position changes, for example, a certain database fails, the service processing method can be used for effectively processing the failure. Fig. 2 illustrates a flow of a service processing method, which describes a processing procedure for a fault:
in step 201, when a service processing request is received, a target number segment is determined according to the state information corresponding to each of the number segments, and a number identifier of the service is generated from the target number segment.
For example, still taking table 1 as an example, one number segment may be selected from the number segments corresponding to the HB repository, the HC repository, and the HD repository as a destination number segment according to the status information, and if 2000001 to 3000000 are selected as the destination number segment, a number identifier may be selected from the destination number segment, for example, 2000001 may be selected as the number identifier of the current service.
In step 202, the service data is stored in the storage location according to the storage location corresponding to the target number segment. For example, according to the number identifier 2000001 of the current service, the service data is stored in the database HC corresponding to the target number segment 2000001-3000000 where the number identifier is located.
In step 203, when the data storage fails, the state information corresponding to the storage location is modified.
For example, if the insertion of the service data into the HC library fails and the HC library is unavailable, the service processing system detects that the HC library fails, and the corresponding status information of the HC library can be modified. For example, in the example of table 1, the status information of the HC library may be modified from "1" to "0".
In step 204, the target number segments are released and one of the other number segments is reselected as the target number segment. For example, for a plurality of service processing requests of a certain service, after a target number segment is obtained once, the same number segment may be used to generate number identifiers for the plurality of services, for example, after 2000001-3000000 is obtained as the target number segment, the number segment may be used to allocate the number identifiers for the plurality of services until the number identifier of the number segment is used up. In this example, if the HC library corresponding to the target number segment is found to be faulty when the target number segment is not used up, the number segment may be released, and the target number segment may be reacquired when a service processing request is received next time. Since the state information has been modified according to the state of the HC bank, when the target number segment is reacquired, the number segments 2000001-3000000 corresponding to the HC bank will not be selected any more as the target number segment.
According to the service processing method, when the storage position fails, the state information of the storage position can be modified, so that when the target number segment is selected according to the state information, the number segment corresponding to the failed storage position is excluded, and the number segment is automatically switched to other number segments to be acquired, and the effectiveness of service processing is improved.
Fig. 3 illustrates an application scenario of the service processing method of the present application, which is an example, and the specific implementation is not limited to this scenario, and may also be other system architectures as long as the service processing method of the present application can be implemented. As shown in fig. 3, for example, the number assignment relationship shown in table 1 may be stored in the number segment generating system 31, and when a service receiving platform 32 receives a certain service request, a target number segment for generating a number identifier of the current service may be acquired from the number segment generating system 31.
For example, the number segment generating system 31 may select a number segment corresponding to a database with a normal state as a target number segment according to the state information, and provide the target number segment to the service receiving platform 32, and the service receiving platform 32 may generate a number identifier for identifying the service according to the target number segment. And, the service receiving platform 32 may insert the service data into the database corresponding to the target number segment, for example, into the HC database. Alternatively, the number segment generation system 31 may select a target number segment, determine a number identifier from the target number segment, provide the number identifier to the service receiving platform 32, and store data according to the number identifier.
With continued reference to fig. 3, if the service receiving platform 32 fails to insert data into the HC library, and the HC may have failed, the service receiving platform 32 may notify the state analysis system 33 of the state of the failure of the HC library. Moreover, the way in which the state analysis system 33 learns the HC library failure may be passive acquisition, for example, the service receiving platform 32 notifies, and the service receiving platform 32 may send a state notification indicating the HC library failure; or it may be an active acquisition, for example, the status analysis system 33 periodically detects the status of the storage locations and detects a failure in the HC bank.
When the state analysis system 33 detects that the state of one of the storage locations is a failure, for example, the HC library in the above example is a failure, the state information corresponding to the database in the number generation system 31 may be modified, and the state information of the HC library is modified from "1" to "0", so that the subsequent number generation system 31 will not select the HC library any more when selecting the target number, and automatic elimination of the failed library is achieved.
In addition, in the service processing method of the present application, the number segment division of the number identifier may be as follows: according to the generated information of the number identifications, dividing the number identifications into a plurality of number sections according to a preset rule, and then distributing the number sections to a plurality of preset storage positions, so that one number section corresponds to one storage position. Several examples of number segment partitioning and allocation are listed below, and the specific implementation is not limited thereto.
For example, if the generation information of the number identifier is "the number identifier that can be used by a certain service is 0000001 to 4000000", the number identifier interval to be divided is 0000001 to 4000000 is obtained accordingly. The preset rule for this example may be "equal division", e.g., the number identifications will be assigned to four databases, the HA, HB, HC and HD databases. The number identification interval "0000001-4000000" can be divided into four parts on average, each part is called a number segment, and each number segment comprises a plurality of number identifications, such as the four number segments illustrated in table 1. The four number segments can be respectively distributed to four databases, each database corresponds to one number segment, and if the number identification of a certain service is selected from one number segment, the service data of the service is stored in the database corresponding to the number segment.
For another example, assuming that the generation information of the number identifier is "an identifier of a plurality of letters such as A, B, C included in the number identifier that can be used by a certain service", an identifier of a plurality of letter beginnings included in the number identifier to be divided is obtained accordingly. The preset rule of this example may be "alphabetically divided", for example, the number identifications are to be allocated to four databases, the HA library, the HB library, the HC library, and the HD library. Number identifications beginning with the a letter may be grouped into one number segment and assigned to the HA pool, number identifications beginning with the B letter may be grouped into another number segment and assigned to the HB pool, with the other number identifications being similarly divided.
The present application further provides a service processing system, which may be configured to execute the service processing method according to the embodiment of the present application, and as shown in fig. 4, the system may include: an identity generation module 41 and a data storage module 42.
The identifier generating module 41 is configured to determine a target number segment according to state information corresponding to each of the number segments, where the state information is used to indicate that a storage location corresponding to the number segment is normal or faulty; each number segment comprises a plurality of number identifications, the storage positions corresponding to the target number segments are normal, and one number identification is selected from the target number segments;
and the data storage module 42 is configured to use the number identifier as an identifier of a service to be processed, and store service data of the service to be processed to a storage location corresponding to the target number segment.
Referring to fig. 5, the system may further include: a state modifying module 43, configured to modify, when it is detected that the state of one of the storage locations is a fault, the state information corresponding to the storage location, so that the number segment corresponding to the storage location is no longer used as the target number segment.
Further, the method can also comprise the following steps: a failure acquisition module 44, configured to receive a status notification for the storage location, where the status notification is used to indicate that the storage location has failed; alternatively, the state of the storage location is periodically detected and the fault is detected.
Further, the method can also comprise the following steps: the identifier distribution module 45 is configured to divide the plurality of number identifiers into the plurality of number segments according to a preset rule according to the generation information of the number identifiers; and distributing the plurality of number segments to a plurality of preset storage positions, so that one number segment corresponds to one storage position.
In another example, the identifier generating module 41 is further configured to release the target number segment and reselect one of the other number segments as the target number segment when the storage of the service data of the service to be processed to the storage location corresponding to the target number segment fails.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.