CN109117422B - Global unique number rapid generation method and system in large-scale high-concurrency system - Google Patents

Global unique number rapid generation method and system in large-scale high-concurrency system Download PDF

Info

Publication number
CN109117422B
CN109117422B CN201710485884.8A CN201710485884A CN109117422B CN 109117422 B CN109117422 B CN 109117422B CN 201710485884 A CN201710485884 A CN 201710485884A CN 109117422 B CN109117422 B CN 109117422B
Authority
CN
China
Prior art keywords
bill
document number
document
data file
rule configuration
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710485884.8A
Other languages
Chinese (zh)
Other versions
CN109117422A (en
Inventor
王井强
王彪
张久旭
赵旭光
鞠佳佳
徐寿林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China National Software & Service Co ltd
Original Assignee
China National Software & Service Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China National Software & Service Co ltd filed Critical China National Software & Service Co ltd
Priority to CN201710485884.8A priority Critical patent/CN109117422B/en
Publication of CN109117422A publication Critical patent/CN109117422A/en
Application granted granted Critical
Publication of CN109117422B publication Critical patent/CN109117422B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a system for quickly generating a global unique number in a large-scale high-concurrency system. The method comprises the following steps: 1) creating a document number local data file in a server where the document number is located; setting a document number rule configuration table in a database; 2) when data records need to be written into the database, checking whether the local data file of the document number has document number field information; if the local document number does not exist, acquiring document number segment information from the document number rule configuration table of the database and writing the document number segment information into the local document number data file; 3) the document number manager reads the document number according to the document number field information of the document number local data file for the database to use; and when the bill number in the local bill number data file is completely taken out, the bill number manager reads a new bill number segment from the bill number rule configuration table again and writes the new bill number segment into the local bill number data file. The invention greatly improves the number taking efficiency.

Description

Global unique number rapid generation method and system in large-scale high-concurrency system
Technical Field
The invention relates to a document number generation method and a document number generation system, in particular to a method and a system for quickly generating a global unique number in a large-scale high-concurrency system, and belongs to the technical field of networks.
Technical Field
At present, two traditional methods for generating document numbers are provided, namely a standard UUID and a database sequence, but both the two methods for generating document numbers have certain problems.
The standard UUID generates the document number, the generation speed is high, but the condition of document number collision exists, the global uniqueness cannot be guaranteed, and the generated document number is unordered and irregular and cannot be generated according to rules.
The document number is generated by the database sequence, the document number is increased in sequence and can be generated according to rules, but the method occupies database resources and database connection, is highly dependent on the database and has poor performance.
Disclosure of Invention
The invention aims to provide a method and a system for quickly generating a global unique number in a large-scale high-concurrency system, aiming at the problems of performance and management of document number generation in the large-scale high-concurrency system.
The technical scheme of the invention is as follows:
a global unique number rapid generation method in a large-scale high concurrency system comprises the following steps:
1) creating a document number local data file in a server where the document number is located; setting a document number rule configuration table in a database;
2) when data records need to be written into the database, checking whether the local data file of the document number has document number field information; if the local document number does not exist, acquiring document number segment information from the document number rule configuration table of the database and writing the document number segment information into the local document number data file;
3) the document number manager reads the document number according to the document number field information of the document number local data file for the database to use; and when the bill number in the local bill number data file is completely taken out, the bill number manager reads a new bill number segment from the bill number rule configuration table again and writes the new bill number segment into the local bill number data file.
Furthermore, when the bill number manager acquires the bill number section from the bill number rule configuration table every time, the time interval between the last time of acquiring the bill number section and the current time of acquiring the bill number section is checked, and if the time interval is smaller than a set value h, the step length of the bill number cache number section in the bill number rule configuration table is increased; and if the time interval is larger than the set value H, reducing the step length of the document number cache number section in the document number rule configuration table.
Further, the method for increasing the step length of the document number cache number segment comprises the following steps: setting the step length of the single data number cache number segment to be 2 times of the previously set step length when the step length is increased every time, and stopping increasing when the step length reaches the set maximum value; the method for reducing the step length of the document number cache number section comprises the following steps: and setting the step size of the document number cache number segment to 3/4 of the previously set step size, and stopping shrinking when the step size reaches the set minimum value.
Further, the set value h is 10 seconds; the set value H was 60 seconds.
Further, the fields of the document number rule configuration table comprise document identification, document number name, reset type, modification time, sequence number length, document number generation rule, continuity, storage table, step length of discontinuous documents, formatting sequence number, domain code and document pipelining algorithm.
Further, the reset types include non-return-to-zero reset of the document number, annual return-to-zero reset of the document number, monthly return-to-zero reset of the document number, and daily return-to-zero reset of the document number.
Further, the fields of the document number rule configuration table also comprise a date format, a maximum serial number, a modifier code and a minimum serial number field.
Further, in the step 2), the document number rule configuration table in the database is accessed through the storage process, and the document number segment information is acquired.
A global unique number rapid generation system in a large-scale high concurrency system is characterized by comprising a server, a document number manager and a document number rule configuration table; the server is provided with a document number local data file, and the document number rule configuration table is arranged in a database; the bill number manager is used for checking whether the bill number field information exists in the local data file of the bill number when data records need to be written into the database; if the local document number does not exist, acquiring document number segment information from the document number rule configuration table of the database and writing the document number segment information into the local document number data file; and if so, reading the document number according to the document number field information of the local data file of the document number for the database to use.
Furthermore, when the bill number manager acquires the bill number section from the bill number rule configuration table every time, the time interval between the last time of acquiring the bill number section and the current time of acquiring the bill number section is checked, and if the time interval is smaller than a set value h, the step length of the bill number cache number section in the bill number rule configuration table is increased; and if the time interval is larger than the set value H, reducing the step length of the document number cache number section in the document number rule configuration table.
The process flow of the method of the invention is shown in figure 1, and the method comprises the following steps:
when the server of the document number is started, the method can check whether the server of the document number has the document number local data file. If not, the method creates a document number local data file. In order to improve the read-write performance of the local data file, the algorithm maps the local data file into a system memory, and the data file is directly read and written by operating a specific memory address, so that the execution performance is improved. When a number fetching request occurs, the method checks whether the local data file of the document number has document number segment cache information or not, and if yes, the method directly accesses the number segment information in the corresponding address of the mapping memory of the local data file to obtain the document number; and if the document number does not exist, accessing a document number rule configuration table in the database through the storage process, acquiring document number segment information, writing the acquired new document number segment information into a document number local data file, and allocating a new mapping memory for the newly loaded document number segment information. A stored procedure (storedProcedure) is a group of SQL statement sets for completing specific functions in a large database system, the SQL statement sets are stored in the database, the SQL statement sets are called again after first compiling without recompiling, and a user executes the SQL statement sets by specifying the name of the stored procedure and giving parameters (if the stored procedure carries the parameters). Stored procedures are an important object in databases.
The document number manager is located in a server where the document number is located, and reads the document number according to the information of the document number local data file for the database system to obtain and use. And when the bill numbers in the local data file are completely taken out, the bill number manager reads new bill number segments from the database bill number rule configuration table again through the storage process and writes the new bill number segments into the local data file.
When the bill number manager acquires the bill number segment every time, the interval between the time value of the last acquired bill number segment and the time interval of the acquired bill number segment is checked, if the interval is less than 10 seconds, the step length (corresponding to the CACHE field of SWORD _ BILLRULE) of the bill number CACHE segment is automatically set to be 2 times of the previously set step length, and the maximum step length of the bill number CACHE segment every time is 5000; if the time interval is more than 60 seconds, the step size of the document number cache number segment is automatically set to 3/4 of the previously set step size, and the minimum step size of the document number cache number segment is 10. Through the mechanism, the generation efficiency of the document number is greatly improved, and the concurrency performance of the system is improved. The method can also realize the operations of no reset, annual reset, monthly reset and daily reset of the serial number of the document number through configuration, and can realize the reset operation by one-time configuration without manually resetting the document number every time.
The invention has the following advantages:
(1) performance solution for document number generation: the document number is acquired from the local data file through the method, so that the conventional mode of frequently acquiring the document number from a database is avoided, the number taking efficiency is greatly improved, the database pressure is reduced, and the system concurrency capability is improved.
(2) Management of document number generation: the method can flexibly configure the document number coding rules of different document types, and generate the document number according to the configured document number generation rule.
(3) Resetting of document number: the document number for a particular document type has a reset rule (no reset (e.g., table 1), year reset (e.g., table 2), month reset (e.g., table 3), day reset (e.g., table 4)).
(4) Efficiency of document number generation: in the process of generating the document number by the system, the invention can automatically adjust the configured step value of the document number configuration table according to the consumption condition of the document number, thereby avoiding the performance problem caused by error configuration.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
Detailed Description
The process of the present invention is described in further detail below with reference to specific examples.
1. Configuration work
The document number component is started in the record.xml by using the method, namely the following codes are required in the record.xml file:
<component name="SwordSequenceManager"
component="com.css.sword.billcode.manager.SwordSequenceManager"
provider="oracle"datasource="SwordDS"memo=""/>
description of the configuration:
name
component name
component
Component manager class, fixed value "com.
memo
Description of the Components
datasource
The name of the data source, the data source used by the document number component, and the default data source of the persistence layer used when the document number component is null.
provider
The data source provider, at present, has a fixed value of oracle.
2. Database design
The database design consists of two parts: storage process and table required by document number
Document number non-return-to-zero reset table: the non-return-to-zero form number table is SWORD _ BILLNONE (shown in table 1), records the currently used serial number of the form number, and the serial number of the form number in the form number table cannot be automatically returned to zero and reset.
Table 1 non-return-to-zero reset table for document number
Figure BDA0001330451020000041
Document number annual zero reset table: the annual zero reset table of document numbers is SWORD _ BILLYEAR (as shown in Table 2), records the currently used serial numbers of the document numbers, and the current serial numbers of the document numbers in the table can be automatically reset to zero every year.
TABLE 2 annual reset table for document number
Figure BDA0001330451020000042
Figure BDA0001330451020000051
Monthly zero reset table for document number: the monthly reset table for document numbers is SWORD _ BILLMONTH (as shown in Table 3), records the currently used serial numbers of the document numbers, and the serial numbers of the document numbers in the table are automatically reset to zero every month.
TABLE 3 reset table for monthly receipt numbers
Figure BDA0001330451020000052
Document number daily zero reset table: the daily zero reset table of document numbers is record _ valid (as table 4), records the current serial number of the document numbers, and the document numbers in the table are automatically reset to zero every year.
TABLE 4 Bill number daily reset table
Figure BDA0001330451020000053
And (3) document number rule configuration: this requires the developer to configure the document according to the actual requirement, and the document number rule configuration table is SWORD _ BILLRULE (see Table 5)
Table 5 shows the document number rule configuration table
Figure BDA0001330451020000054
Figure BDA0001330451020000061
3. Document number generation and use
If two tables, namely, SWORD _ bitmap and SWORD _ bitmap, are already registered in the system table, it is desired to generate a document number in java code according to the rule configured in the SWORD _ bitmap table, and the following method in com.cs.sword.key.u.ils.sword.sequence utilities class can be used:
Figure BDA0001330451020000062
Figure BDA0001330451020000071
Figure BDA0001330451020000081
Figure BDA0001330451020000091
Figure BDA0001330451020000101

Claims (6)

1. a global unique number rapid generation method in a large-scale high concurrency system comprises the following steps:
1) creating a document number local data file in a server where the document number is located and mapping the document number local data file into a system memory; setting a document number rule configuration table in a database; the fields of the bill number rule configuration table comprise bill identification, bill number name, reset type, modification time, sequence number length, bill number generation rule, continuity, storage table, step length of discontinuous bill, formatting sequence number, domain code and bill pipelining algorithm; the reset types comprise non-return-to-zero reset of the document number, annual return-to-zero reset of the document number, monthly return-to-zero reset of the document number and daily return-to-zero reset of the document number; the bill number rule configuration table comprises a bill number non-return-to-zero reset table, a bill number annual return-to-zero reset table, a bill number monthly return-to-zero reset table and a bill number daily return-to-zero reset table;
2) when data records need to be written into the database and a number fetching request occurs, checking whether document number segment cache information exists in the document number local data file or not; if the local data file of the document number exists, directly accessing number segment information in a corresponding address of a mapping memory of the local data file of the document number to acquire the document number; if the mapping memory does not exist, acquiring document number segment information from the document number rule configuration table of the database in the data record storage process, writing the document number segment information into the document number local data file, and distributing a new mapping memory for newly loaded document number segment information;
3) the document number manager reads the document number according to the document number field information of the document number local data file for the database to use; when the bill number in the local data file of the bill number is completely taken, the bill number manager reads a new bill number segment from the bill number rule configuration table again and writes the new bill number segment into the local data file of the bill number; when the bill number manager acquires a bill number section from the bill number rule configuration table every time, the time interval between the last time of acquiring the bill number section and the current time of acquiring the bill number section is checked, and if the time interval is smaller than a set value h, the step length of a bill number cache section in the bill number rule configuration table is increased; and if the time interval is larger than the set value H, reducing the step length of the document number cache number section in the document number rule configuration table.
2. The method of claim 1, wherein the step size of the document number cache number segment is increased by: setting the step length of the single data number cache number segment to be 2 times of the previously set step length when the step length is increased every time, and stopping increasing when the step length reaches the set maximum value; the method for reducing the step length of the document number cache number section comprises the following steps: and setting the step size of the document number cache number segment to 3/4 of the previously set step size, and stopping shrinking when the step size reaches the set minimum value.
3. The method of claim 1, wherein the set value h is 10 seconds; the set value H was 60 seconds.
4. The method of claim 1, wherein the fields of the document number rule configuration table further comprise date format, maximum sequence number, modifier code, and minimum sequence number fields.
5. The method according to any one of claims 1 to 4, characterized in that in the step 2), the document number rule configuration table in the database is accessed through a storage process to obtain the document number field information.
6. A global unique number rapid generation system in a large-scale high concurrency system is characterized by comprising a server, a document number manager and a document number rule configuration table; the system comprises a server, a database and a document number rule configuration table, wherein a document number local data file is arranged in the server and is mapped into a system memory, and the document number rule configuration table is arranged in the database; the document number manager is used for checking whether document number segment cache information exists in a document number local data file or not when data records need to be written into the database and a number fetching request occurs; if the local data file of the document number exists, directly accessing number segment information in a corresponding address of a mapping memory of the local data file of the document number to acquire the document number; if the mapping memory does not exist, acquiring document number segment information from the document number rule configuration table of the database in the data record storage process, writing the document number segment information into the document number local data file, and distributing a new mapping memory for newly loaded document number segment information; the fields of the bill number rule configuration table comprise bill identification, a bill number name, a reset type, modification time, sequence number length, a bill number generation rule, continuity, a storage table, a step length of a discontinuous bill, a formatting sequence number, a domain code and a bill pipelining algorithm class; the reset types comprise non-return-to-zero reset of the document number, annual return-to-zero reset of the document number, monthly return-to-zero reset of the document number and daily return-to-zero reset of the document number; the bill number rule configuration table comprises a bill number non-return-to-zero reset table, a bill number annual return-to-zero reset table, a bill number monthly return-to-zero reset table and a bill number daily return-to-zero reset table; when the bill number manager acquires a bill number section from the bill number rule configuration table every time, the time interval between the last time of acquiring the bill number section and the current time of acquiring the bill number section is checked, and if the time interval is smaller than a set value h, the step length of a bill number cache section in the bill number rule configuration table is increased; and if the time interval is larger than the set value H, reducing the step length of the document number cache number section in the document number rule configuration table.
CN201710485884.8A 2017-06-23 2017-06-23 Global unique number rapid generation method and system in large-scale high-concurrency system Active CN109117422B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710485884.8A CN109117422B (en) 2017-06-23 2017-06-23 Global unique number rapid generation method and system in large-scale high-concurrency system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710485884.8A CN109117422B (en) 2017-06-23 2017-06-23 Global unique number rapid generation method and system in large-scale high-concurrency system

Publications (2)

Publication Number Publication Date
CN109117422A CN109117422A (en) 2019-01-01
CN109117422B true CN109117422B (en) 2021-02-26

Family

ID=64733075

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710485884.8A Active CN109117422B (en) 2017-06-23 2017-06-23 Global unique number rapid generation method and system in large-scale high-concurrency system

Country Status (1)

Country Link
CN (1) CN109117422B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115688683B (en) * 2023-01-05 2023-03-21 东方合智数据科技(广东)有限责任公司 Document number issuing method, device, equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102833775A (en) * 2012-08-31 2012-12-19 电信科学技术研究院 Method and equipment for performing system-level off-line testing
CN103414900A (en) * 2013-08-24 2013-11-27 渭南高新区金石为开咨询有限公司 Method for configuring video encoding quality and transmitting video data in classified mode

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030188185A1 (en) * 2002-03-28 2003-10-02 International Business Machines Corporation System and method for issuing user configurable identification numbers with collision free mapping
US7254617B2 (en) * 2002-12-06 2007-08-07 Scott Ruple Distributed cache between servers of a network
US20080244181A1 (en) * 2007-03-30 2008-10-02 Michael Walz Dynamic run-time cache size management
US8422826B2 (en) * 2009-06-05 2013-04-16 Varian Medical Systems, Inc. Method and apparatus to facilitate using fused images to identify materials
CN102436479B (en) * 2011-10-12 2014-01-08 远光软件股份有限公司 Method and system for generating globally unique data identifier
CN104040539B (en) * 2012-12-31 2017-06-06 华为技术有限公司 Date storage method and device, data manipulation method, system and access server
CN105447023B (en) * 2014-08-25 2019-02-05 阿里巴巴集团控股有限公司 Service identification generation method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102833775A (en) * 2012-08-31 2012-12-19 电信科学技术研究院 Method and equipment for performing system-level off-line testing
CN103414900A (en) * 2013-08-24 2013-11-27 渭南高新区金石为开咨询有限公司 Method for configuring video encoding quality and transmitting video data in classified mode

Also Published As

Publication number Publication date
CN109117422A (en) 2019-01-01

Similar Documents

Publication Publication Date Title
US9047392B2 (en) System and method for conversion of JMS message data into database transactions for application to multiple heterogeneous databases
US9152659B2 (en) Systems and methods for migrating database data
CN105144080B (en) System for metadata management
JP2020502626A (en) Formation and operation of test data in a database system
US8666960B2 (en) Schema-based data transfer between a data-based application and a document application
US8250590B2 (en) Apparatus, system, and method for seamless multiple format metadata abstraction
US20130173546A1 (en) Systems and methods for migrating database data
US8135688B2 (en) Partition/table allocation on demand
US11294973B2 (en) Codeless information service for abstract retrieval of disparate data
JP2006235840A (en) Database access system and database access method
CN104462269A (en) Isomerous database data exchange method and system
EP3584704A1 (en) Shared cache used to provide zero copy memory mapped database
US9514170B1 (en) Priority queue using two differently-indexed single-index tables
US9384202B1 (en) Gateway module to access different types of databases
CN112507067B (en) Cache plug-in annotating device and annotation method
US9600597B2 (en) Processing structured documents stored in a database
CN112612794A (en) Auxiliary generation method and device of relational database, computer equipment and storage medium
CN111159227B (en) Data query method, device, equipment and storage medium
US9928259B2 (en) Deleted database record reuse
CN112269982A (en) Data access control method based on authority configuration
US20220245125A1 (en) Dataset multiplexer for data processing system
CN100527131C (en) Interdynamic access method and tool of IMS data base
CN109117422B (en) Global unique number rapid generation method and system in large-scale high-concurrency system
CN114116691A (en) Data import checking method, system, device and computer readable medium
CN111241065B (en) Database adaptation development and operation method supporting domestic database

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CB03 Change of inventor or designer information

Inventor after: Wang Jingqiang

Inventor after: Wang Biao

Inventor after: Zhang Jiuxu

Inventor after: Zhao Xuguang

Inventor after: Ju Jiajia

Inventor after: Xu Shoulin

Inventor before: Wang Jingqiang

Inventor before: Wang Biao

Inventor before: Zhang Jiuxu

Inventor before: Zhao Xuguang

Inventor before: Ju Jiajia

Inventor before: Xu Shoulin

CB03 Change of inventor or designer information