CN109388626B - Method and apparatus for assigning numbers to services - Google Patents

Method and apparatus for assigning numbers to services Download PDF

Info

Publication number
CN109388626B
CN109388626B CN201710665501.5A CN201710665501A CN109388626B CN 109388626 B CN109388626 B CN 109388626B CN 201710665501 A CN201710665501 A CN 201710665501A CN 109388626 B CN109388626 B CN 109388626B
Authority
CN
China
Prior art keywords
service
numbers
database
services
cache queue
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
CN201710665501.5A
Other languages
Chinese (zh)
Other versions
CN109388626A (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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710665501.5A priority Critical patent/CN109388626B/en
Publication of CN109388626A publication Critical patent/CN109388626A/en
Application granted granted Critical
Publication of CN109388626B publication Critical patent/CN109388626B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Abstract

The embodiment of the disclosure discloses a method for allocating numbers to services, which comprises the following steps: monitoring the number of the residual numbers contained in a buffer queue for distributing the numbers to the services; and requesting the number segment number from the database when the number is less than a predetermined threshold.

Description

Method and apparatus for assigning numbers to services
Technical Field
The present disclosure relates to the field of data processing, and more particularly, to a method and apparatus for assigning numbers to services.
Background
In the current mainstream distributed system deployment application, a unique number (such as a common order number, a commodity number, an attribute number, a template number, and the like) is often allocated to service data for storage, and different service scenarios may require different number starting values and number segments to facilitate service differentiation of the system.
In the prior art, various systems create a number generation table using a MYSQL database. For example, a number generation table is created for each system, each application server first queries the value of the current service type number, increases the current number by a certain number segment on the condition of the service type and the value of the current number, if the number segment is not obtained, the value of the current number and the service type are continuously queried to obtain the number segment, and if the number segment is obtained successfully, the value of the current number and the number segment are maintained in a cache queue in the server. And when the serial number is acquired aiming at the service, performing synchronous lock control, namely, ensuring that only one thread acquires the next serial number in the cache queue currently and modifying the current serial number into the acquired serial number by each server, and if the serial number in the cache queue is completely acquired, continuing to perform resource competition with other servers to acquire the appointed number segment and store the appointed number segment in the cache queue.
In the process of implementing the concept of the present invention, the inventor finds that at least the following problems exist in the prior art: the flexibility is poor, for example, each service system maintains the generation of the service type number, and the number required by the newly accessed service cannot be generated quickly; the expansibility is poor, for example, when a number required by a newly accessed service is generated, a number initial value of a current service type may need to be added to the new service in a number generation table through a data script; maintenance cost is high, for example, each service system needs to maintain its own number generation and number rule, and for a newly accessed service, secondary development and online operation are needed; and poor performance, for example, each application server needs to perform lock synchronization control when acquiring a number from a memory, and calculates the number to be acquired in real time, and finally assembles the number according to business rules, if the number in the cache queue is used up, the application server performs resource competition with other servers, the server which has taken the lock has the right to acquire the designated number segment and store the number segment in the cache queue for maintenance, and the server which has not taken the lock will circulate indefinitely until it is taken.
In order to implement centralized, efficient, and flexible management of numbers and improve the development efficiency of a service system in a scenario supporting cross-system and different services, a method and a system capable of efficiently generating numbers with a certain rule in a scenario supporting cross-system and different services are required.
Disclosure of Invention
In view of the above, the present disclosure provides a method and apparatus for assigning numbers to services.
One aspect of the present disclosure provides a method for assigning numbers to services, comprising: monitoring the number of the residual numbers contained in a buffer queue for distributing the numbers to the services; and requesting the number segment number from the database when the number is less than a predetermined threshold.
According to an embodiment of the present disclosure, the method further comprises: acquiring a line lock aiming at the cache queue from a database; when the row lock aiming at the cache queue is successfully acquired, acquiring a number segment with a preset length from a starting number to be allocated currently from the database; determining all numbers by using the number segments and prefixes for identifying the types of the services; and writing all the determined numbers into the cache queue as the number segment numbers requested.
According to an embodiment of the present disclosure, the method further comprises: when the line lock for the cache queue is not successfully acquired, the acquiring step is repeatedly performed until the line lock for the cache queue is successfully acquired.
According to an embodiment of the present disclosure, the method further comprises: receiving a request for allocating numbers to services, wherein the request comprises the types of the services; and when determining that a cache queue corresponding to the service exists according to the type of the service, allocating the number in the cache queue to the service.
According to the embodiment of the disclosure, when it is determined that there is no cache queue corresponding to the service according to the type of the service, it is determined that the service has a new service type, a number initial value, a prefix, and a number segment length acquired from a database corresponding to the service are legally verified, and when the legality verification passes, the number initial value, the prefix, and the number segment length are stored in the database in association with the type of the service.
According to an embodiment of the present disclosure, after storing the number initial value, the prefix, and the number segment length in the database, the method further includes: scanning the database at preset time intervals, determining the number aiming at the service according to the initial value of the number, the prefix and the number segment length when the new service type is scanned, creating a buffer queue corresponding to the service, and initializing the number into the created buffer queue.
Another aspect of the present disclosure provides an apparatus for assigning numbers to services, including: a snooping module configured to snoop a number of remaining numbers contained in a buffer queue for assigning numbers to the traffic; and a request module configured to request the number segment number from the database when the number is less than a predetermined threshold.
According to an embodiment of the present disclosure, the apparatus further comprises: a first obtaining module configured to obtain a row lock for the cache queue from a database; the second acquisition module is configured to acquire a number segment with a preset length from the database, wherein the number segment starts from a starting number to be allocated currently when the line lock aiming at the cache queue is acquired successfully; a determining module configured to determine all numbers using the number segments and prefixes identifying types of the services; and a write module configured to write all the determined numbers as the requested number segment numbers into the cache queue.
According to an embodiment of the disclosure, the second obtaining module is further configured to: when the line lock for the cache queue is not successfully acquired, the acquiring step is repeatedly performed until the line lock for the cache queue is successfully acquired.
According to an embodiment of the present disclosure, the apparatus further comprises: a receiving module configured to receive a request for assigning a number to a service, the request including a type of the service; and the allocation module is configured to allocate the number in the buffer queue to the service when the buffer queue corresponding to the service is determined to exist according to the type of the service.
According to an embodiment of the present disclosure, the apparatus further comprises: a first processing module configured to: when it is determined that the cache queue corresponding to the service does not exist according to the type of the service, determining that the service has a new service type, performing validity verification on a number initial value, a prefix and a number segment length acquired from a database corresponding to the service, and storing the number initial value, the prefix and the number segment length in the database in association with the type of the service when the validity verification passes.
According to an embodiment of the present disclosure, the apparatus further comprises: a second processing module configured to scan the database at predetermined time intervals after storing the initial value of the number, the prefix and the number segment length in the database, determine a number for the service according to the initial value of the number, the prefix and the number segment length when the new service type is scanned, create a cache queue corresponding to the service, and initialize the number into the created cache queue.
Another aspect of the disclosure provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method as described above.
Another aspect of the present disclosure provides a server for assigning numbers to services, including: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to carry out the method as described above.
According to the embodiment of the disclosure, the service access of quick and flexible configuration can be realized, so that the development cost brought by the maintenance of each service system is reduced; by utilizing the row lock, one can ensure that one and only one thread is successfully updated in the case of multiple threads; in addition, when the number segment is successfully acquired from the database, the current initial number to be allocated in the database is updated, so that the numbers acquired by each cache queue are not repeated; and finally, the threshold value for requesting the number segment number from the database is controlled by fully evaluating the frequency of acquiring the number when the service is accessed, so that the requester can be well ensured to directly acquire the non-repeated number from the cache queue in the server, and the performance is greatly improved.
Drawings
The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments of the present disclosure with reference to the accompanying drawings, in which:
fig. 1 illustrates an exemplary system architecture 100 for a method and apparatus for assigning numbers to services to which embodiments of the present disclosure may be applied; and
fig. 2 schematically illustrates a flow chart of a method 200 for assigning numbers to services according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow diagram of a method 300 for creating a buffer queue according to an embodiment of the present disclosure;
fig. 4 schematically shows a block diagram of an apparatus 400 for assigning numbers to services according to an embodiment of the present disclosure; and
FIG. 5 illustrates a block diagram of a computer system 500 suitable for use in implementing a terminal device of an embodiment of the disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that these descriptions are illustrative only and are not intended to limit the scope of the present disclosure. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The words "a", "an" and "the" and the like as used herein are also intended to include the meanings of "a plurality" and "the" unless the context clearly dictates otherwise. Furthermore, the terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs, unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Fig. 1 illustrates an exemplary system architecture 100 for a method and apparatus for assigning numbers to services to which embodiments of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server (for example only) providing support for shopping-like websites browsed by users using the terminal devices 101, 102, 103. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for assigning numbers to services provided in the embodiments of the present application is generally performed by the server 105, and accordingly, the apparatus for assigning numbers to services is generally disposed in the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Fig. 2 schematically shows a flow chart of a method 100 at a server for assigning numbers to services according to an embodiment of the present disclosure.
As shown in fig. 2, the method includes receiving a request for assigning a number to a service (e.g., a JAVA web application service), the request including a type of the service, in operation S201. The request may be initiated by the business system to the server via a remote procedure call Protocol (PRC) based.
Then, it is determined whether there is a buffer queue corresponding to the service according to the type of the service in operation S202.
When it is determined that there is a buffer queue corresponding to the service according to the type of the service, a number in the buffer queue, for example, a first number in the buffer queue, is allocated to the service in operation S203. The assigned number may then be returned to the business system in operation S204.
Further, when it is determined that there is no buffer queue corresponding to the service according to the type of the service, the method 200 proceeds to flow a to perform the following method for creating a buffer queue as illustrated in fig. 3.
In operation S205, the number of remaining numbers contained in the buffer queue for assigning numbers to the traffic is snooped.
It should be noted that the order of operations S203 and S205 is not limited to the order described in the present invention, that is, operations S205 may be performed before operations S203 and S204.
In operation S206, it is determined whether the number is less than a predetermined threshold.
In operation S207, when the number is less than a predetermined threshold, a number segment number is requested from a database (e.g., MYSQL database, ORACLE database, etc.). The predetermined threshold may be controlled by evaluating the number of approximate numbering required per minute at the time of traffic access.
When the number is not less than the predetermined threshold, the flow ends.
Next, in operation S208, a line lock for the cache queue is acquired from the database.
In step S209, it is determined whether a line lock for the cache queue is acquired from the database.
In operation S210, when the line lock for the cache queue is successfully acquired, a number segment of a predetermined length from the start number to be currently allocated is acquired from the database, and the start number to be currently allocated is updated to the next number of the last number in the acquired number segment. For example, there may be a plurality of buffer queues competing for a number segment in the database at the same time, so when one buffer queue in the plurality of buffer queues competes for a number segment in the database, after the number segment is allocated to the buffer queue, the number segment needs to be removed from the database, and the start number to be currently allocated in the database is updated to the next number in the database after the last number in the number segment, that is, the minimum number in the remaining numbers in the database, so that the number is not repeatedly allocated in the next competition.
When the line lock for the cache queue is not successfully acquired, the acquiring step is repeatedly executed until the line lock for the cache queue is successfully acquired.
In operation S211, all numbers are determined using the acquired number segments and prefixes identifying the types of services.
In operation S212, all the determined numbers are written into the buffer queue as the requested number segment numbers.
According to the embodiment of the disclosure, the service access with quick and flexible configuration can be realized, so that the development cost brought by the self maintenance of each service system is reduced; by utilizing the line lock, one can ensure that one and only one thread is successfully updated in the case of multiple threads; in addition, when the number segment is successfully acquired from the database, the current starting number to be allocated in the database is updated, so that the numbers acquired by each cache queue are not repeated; and finally, the threshold value for requesting the number segment number from the database is controlled by fully evaluating the frequency of acquiring the number when the service is accessed, so that the requester can be well ensured to directly acquire the non-repeated number from the cache queue in the server, and the performance is greatly improved.
Fig. 3 schematically shows a flow diagram of a method 300 for creating a buffer queue according to an embodiment of the present disclosure.
The method 300 starts with procedure a, when it is determined in operation S202 that there is no cache queue corresponding to a service according to the type of the service, it is determined in operation S301 that the service has a new service type, the initial value of the number, the prefix, and the length of the number segment corresponding to the service are legally verified (including verification that it is determined whether the initial value of the number, the length of the prefix, and the length of the number segment are empty, whether there is already a record of the same service type, etc.) by, for example, a parameter parser, and when the legality verification is passed, the initial value of the number, the length of the prefix, and the length of the number segment are stored in a database, for example, in a number table in the database, in association with the type of the service, so as to be persistent. In operation S301, when the validity verification fails, a creation failure message is returned. The initial value of the number, the prefix and the length of the number segment corresponding to the service can be configured by an administrator in a unified configuration page according to the service requirement.
Then, in operation S302, the database is scanned at predetermined intervals, when the new service type is scanned, a number for the service is determined according to the initial value of the number, the prefix, and the length of the number segment, a buffer queue corresponding to the service is created, and the number is initialized into the created buffer queue. In operation S302, the scanning operation may be completed by a timing scanner, for example, a spring quartz-based timing scanner. The timing scanner may scan the numbering table in the database every 10 minutes, for example.
After the buffer queue is created, operation S203 in the method 200 may be continuously performed to assign numbers to the traffic.
Fig. 4 schematically shows a block diagram of an apparatus 400 for assigning numbers to services according to an embodiment of the present disclosure.
As shown in fig. 4, the apparatus 400 may include a listening module 410 and a requesting module 420.
The snoop module 410 may be configured to snoop the number of remaining numbers contained in the buffer queue used to assign numbers to traffic.
The request module 420 may be configured to request a number segment number from the database when the number is less than a predetermined threshold.
The apparatus 400 may further include a first acquisition module configured to acquire a line lock for a cache queue from a database; the second acquisition module is configured to acquire a number segment with a preset length from the database starting from the starting number to be allocated when the line lock aiming at the cache queue is acquired successfully; a determining module configured to determine all numbers using the number segments and prefixes identifying types of the services; and a write module configured to write all the determined numbers as the requested number segment numbers into the buffer queue. The second obtaining module may be further configured to: when the line lock for the cache queue is not successfully acquired, the acquiring step is repeatedly performed until the line lock for the cache queue is successfully acquired.
The apparatus 400 may further comprise: the device comprises a receiving module and a distributing module. The receiving module may be configured to receive a request for assigning a number to a service, the request including a type of the service. The allocation module may be configured to allocate a number in the buffer queue to the traffic when it is determined that the buffer queue corresponding to the traffic exists according to the type of the traffic.
The apparatus 400 may further comprise: a first processing module configured to: when the cache queue corresponding to the service does not exist according to the type of the service, determining that the service has a new service type, carrying out validity verification on the initial value of the number, the prefix and the number segment length corresponding to the service, and storing the initial value of the number, the prefix and the number segment length and the type of the service in a database in a correlation mode when the validity verification passes.
The apparatus 400 may further comprise: and the second processing module is configured to scan the database at preset time intervals after the initial value of the number, the prefix and the number segment length are stored in the database, determine the number aiming at the service according to the initial value of the number, the prefix and the number segment length when a new service type is scanned, create a buffer queue corresponding to the service, and initialize the number into the created buffer queue.
The apparatus corresponds to the method 100. The above detailed description and explanation of the method 100 is equally applicable to the apparatus and will not be repeated here.
According to the embodiment of the disclosure, the service access with quick and flexible configuration can be realized, so that the development cost brought by the self maintenance of each service system is reduced; by utilizing the row lock, one can ensure that one and only one thread is successfully updated in the case of multiple threads; in addition, when the number segment is successfully acquired from the database, the current starting number to be allocated in the database is updated, so that the numbers acquired by each cache queue are not repeated; and finally, the threshold value for requesting the number segment number from the database is controlled by fully evaluating the frequency of acquiring the number when the service is accessed, so that the requester can be well ensured to directly acquire the non-repeated number from the cache queue in the server, and the performance is greatly improved.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use in implementing a terminal device of an embodiment of the present disclosure. The computer system illustrated in FIG. 5 is only one example and should not impose any limitations on the scope of use or functionality of embodiments of the disclosure.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU) 501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. A drive 510 is also connected to the I/O interface 505 as needed. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer-readable medium, the computer program comprising program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The above-described functions defined in the system of the present disclosure are executed when the computer program is executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium described herein can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The above-mentioned computer-readable medium carries one or more programs which, when executed by one of the apparatuses, cause the apparatuses to perform the method for assigning numbers to services according to an embodiment of the present disclosure.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.

Claims (6)

1. A method for assigning numbers to services, comprising:
receiving a request for assigning a number to a service, the request including a type of the service, wherein the number in a buffer queue is assigned to the service when it is determined that the buffer queue corresponding to the service exists according to the type of the service, and wherein the service is determined to have a new service type when it is determined that the buffer queue corresponding to the service does not exist according to the type of the service, legality-verifying a number initial value, a prefix, and a number segment length acquired from a database corresponding to the service, and storing the number initial value, the prefix, and the number segment length in the database in association with the type of the service when the legality-verifying is passed;
monitoring the number of the residual numbers contained in a buffer queue for distributing the numbers to the services;
requesting number segment numbering from the database when the number is less than a predetermined threshold, the predetermined threshold being controlled by evaluating the number of numbers to be numbered per minute at the time of service access;
acquiring a line lock aiming at the cache queue from the database;
when the line lock for the cache queue is successfully acquired, acquiring a number segment with a preset length from the database starting from a starting number to be allocated currently, and updating the starting number to be allocated currently to a number next to the last number in the acquired number segment,
when the line lock aiming at the cache queue is not successfully acquired, the step of acquiring the line lock is repeatedly executed until the line lock aiming at the cache queue is successfully acquired;
determining all numbers by using the number segments and prefixes for identifying the types of the services; and
and writing all the determined numbers into the cache queue as the number segment numbers requested.
2. The method of claim 1, wherein after storing the number initial value, the prefix, and the number segment length in the database, the method further comprises:
scanning the database at preset time intervals, determining the number aiming at the service according to the initial value of the number, the prefix and the number segment length when the new service type is scanned, creating a buffer queue corresponding to the service, and initializing the number into the created buffer queue.
3. An apparatus for assigning numbers to services, comprising:
a receiving module configured to receive a request for assigning a number to a service, the request including a type of the service;
the allocation module is configured to allocate the serial numbers in the cache queues to the services when the cache queues corresponding to the services are determined to exist according to the types of the services;
a first processing module configured to: when it is determined that the cache queue corresponding to the service does not exist according to the type of the service, determining that the service has a new service type, performing validity verification on a number initial value, a prefix and a number segment length acquired from a database corresponding to the service, and storing the number initial value, the prefix and the number segment length in the database in association with the type of the service when the validity verification passes;
a snooping module configured to snoop the number of remaining numbers contained in a buffer queue for assigning numbers to the traffic;
a request module configured to request a number segment number from the database when the number is less than a predetermined threshold, the predetermined threshold being controlled by evaluating the number of numbers that need to be numbered per minute at the time of service access;
a first obtaining module configured to obtain a row lock for the cache queue from the database;
a second acquiring module configured to acquire, when the line lock for the cache queue is successfully acquired, a number segment of a predetermined length from the database starting from a start number to be currently allocated and update the start number to be currently allocated as a number next to a last number in the acquired number segment,
when the line lock aiming at the cache queue is not successfully acquired, the step of acquiring the line lock is repeatedly executed until the line lock aiming at the cache queue is successfully acquired;
a determining module configured to determine all numbers using the number segments and prefixes identifying types of the services; and
a write module configured to write all determined numbers as requested number segment numbers into the cache queue.
4. The apparatus of claim 3, further comprising: a second processing module configured to scan the database at predetermined time intervals after storing the initial value of the number, the prefix and the number segment length in the database, determine a number for the service according to the initial value of the number, the prefix and the number segment length when the new service type is scanned, create a cache queue corresponding to the service, and initialize the number into the created cache queue.
5. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method of claim 1.
6. A server for assigning numbers to services, comprising:
one or more processors;
a storage device for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of claim 1.
CN201710665501.5A 2017-08-04 2017-08-04 Method and apparatus for assigning numbers to services Active CN109388626B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710665501.5A CN109388626B (en) 2017-08-04 2017-08-04 Method and apparatus for assigning numbers to services

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710665501.5A CN109388626B (en) 2017-08-04 2017-08-04 Method and apparatus for assigning numbers to services

Publications (2)

Publication Number Publication Date
CN109388626A CN109388626A (en) 2019-02-26
CN109388626B true CN109388626B (en) 2023-01-31

Family

ID=65413816

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710665501.5A Active CN109388626B (en) 2017-08-04 2017-08-04 Method and apparatus for assigning numbers to services

Country Status (1)

Country Link
CN (1) CN109388626B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111950232B (en) * 2019-05-16 2023-09-05 北京京东振世信息技术有限公司 Method and device for automatically switching number segments
CN113377548A (en) * 2020-03-10 2021-09-10 上海淘票儿信息科技有限公司 Identification generation method and device, computer equipment and storage medium
CN111741081A (en) * 2020-06-05 2020-10-02 安徽三实信息技术服务有限公司 Distributed server management system
CN111913956A (en) * 2020-06-28 2020-11-10 中国船舶重工集团公司第七一六研究所 Unified service coding method and device
CN112632117A (en) * 2020-12-30 2021-04-09 广州华多网络科技有限公司 Method and device for processing serial number data, electronic equipment and storage medium
CN112732760A (en) * 2021-01-07 2021-04-30 泰康保险集团股份有限公司 Distribution method, server and storage medium for report number under distributed environment
CN113743786A (en) * 2021-09-06 2021-12-03 携程科技(上海)有限公司 Order number distribution method, system, equipment and storage medium for multi-class service line
CN113806407A (en) * 2021-09-27 2021-12-17 武汉众邦银行股份有限公司 Method, device and storage medium for obtaining order numbers in batch based on cache

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104317749A (en) * 2014-10-31 2015-01-28 小米科技有限责任公司 Information writing method and device
CN106911780A (en) * 2017-02-28 2017-06-30 北京三快在线科技有限公司 Traffic ID generation method, apparatus and system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9465880B2 (en) * 2013-05-14 2016-10-11 International Business Machines Corporation Optimizing storage in a publish / subscribe environment
CN105183794B (en) * 2015-08-24 2018-12-14 用友网络科技股份有限公司 Business serial number generating means and method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104317749A (en) * 2014-10-31 2015-01-28 小米科技有限责任公司 Information writing method and device
CN106911780A (en) * 2017-02-28 2017-06-30 北京三快在线科技有限公司 Traffic ID generation method, apparatus and system

Also Published As

Publication number Publication date
CN109388626A (en) 2019-02-26

Similar Documents

Publication Publication Date Title
CN109388626B (en) Method and apparatus for assigning numbers to services
CN107943594B (en) Data acquisition method and device
US11146502B2 (en) Method and apparatus for allocating resource
CN108011949B (en) Method and apparatus for acquiring data
CN109657174B (en) Method and device for updating data
CN104954468A (en) Resource allocation method and resource allocation device
CN111225010A (en) Data processing method, data processing system and device
CN108764866B (en) Method and equipment for allocating resources and drawing resources
CN111062572A (en) Task allocation method and device
CN109150927B (en) File issuing method and device for file storage system
CN107918617B (en) Data query method and device
CN111382953A (en) Dynamic process generation method and device
CN112948138A (en) Method and device for processing message
CN109873731B (en) Test method, device and system
CN108696557B (en) Information processing system, method and device
CN113722007B (en) Configuration method, device and system of VPN branch equipment
CN113076343B (en) Data query method, device, equipment and storage medium
CN113138943B (en) Method and device for processing request
CN113127561B (en) Method and device for generating service single number, electronic equipment and storage medium
CN112559001B (en) Method and device for updating application
CN109547552B (en) API request processing method and device, storage medium and electronic equipment
CN109087097B (en) Method and device for updating same identifier of chain code
CN113742376A (en) Data synchronization method, first server and data synchronization system
CN113783916A (en) Information synchronization method and device
CN108696472B (en) Request processing method and device

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