CN107666499B - Information storage method and device for server - Google Patents

Information storage method and device for server Download PDF

Info

Publication number
CN107666499B
CN107666499B CN201610603428.4A CN201610603428A CN107666499B CN 107666499 B CN107666499 B CN 107666499B CN 201610603428 A CN201610603428 A CN 201610603428A CN 107666499 B CN107666499 B CN 107666499B
Authority
CN
China
Prior art keywords
data
server
information
local database
stored
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
CN201610603428.4A
Other languages
Chinese (zh)
Other versions
CN107666499A (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 CN201610603428.4A priority Critical patent/CN107666499B/en
Publication of CN107666499A publication Critical patent/CN107666499A/en
Application granted granted Critical
Publication of CN107666499B publication Critical patent/CN107666499B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application discloses an information storage method for a server. One embodiment of the method comprises: receiving an information storage request sent by a client, wherein the information storage request comprises information to be stored, the information to be stored comprises at least one piece of data, different data belong to different data types, and the data of each data type is stored by a corresponding server; transmitting data of a preset category in the information to be stored to a first server connected with the server; storing other data which do not belong to a preset category in the information to be stored into a local database, wherein the local database is a non-relational database; and respectively transmitting the other data extracted from the local database to the corresponding second servers according to the data types. The embodiment improves the throughput of the server in the information storage process, and realizes high availability of the server in the information storage process.

Description

Information storage method and device for server
Technical Field
The present application relates to the field of computers, and in particular, to the field of information storage, and more particularly, to an information storage method and apparatus for a server.
Background
Information storage is an information activity of storing information after processing and sorting in a specific carrier according to a certain format and sequence. The purpose is to facilitate information managers and information users to quickly and accurately identify, locate and retrieve information.
However, when information needs to be stored by relying on a plurality of servers, the existing information storage method generally transmits the information to each server in sequence to store the information, and thus, the existing information storage method has the problems of strong dependence on each server, low throughput and no high availability in the information storage process.
Disclosure of Invention
The present application aims to provide an improved information storage method and apparatus for a server to solve the technical problems mentioned in the above background section.
In a first aspect, the present application provides an information storage method for a server, the method including: receiving an information storage request sent by a client, wherein the information storage request comprises information to be stored, and the information to be stored comprises at least one category of data; transmitting data of a preset category in the information to be stored to a first server connected with the server; storing data of other categories, which do not belong to a preset category, in the information to be stored into a local database, wherein the local database is a non-relational database; and respectively transmitting the data of other types extracted from the local database to each second server connected with the server according to the data types.
In some embodiments, the transmitting the data of the preset category in the information to be stored to a first server connected to the server includes: sending a connection request to the first server; responding to the confirmation that the first server accepts the connection request, establishing connection with the first server, and transmitting data of a preset category in the information to be stored to the first server; and receiving the identification mark of the information to be stored returned by the first server.
In some embodiments, the storing, to a local database, data of other categories that do not belong to the preset category in the information to be stored includes: storing other types of data which do not belong to a preset type in the information to be stored to a local database in a key-value pair mode by taking the identification mark of the information to be stored and a field for describing the type of the data as a joint main key; and marking the data stored in the local database as a to-be-executed state.
In some embodiments, the transmitting the other categories of data extracted from the local database to the second servers connected to the server according to data categories respectively includes: inquiring data marked as a to-be-executed state in the local database according to a preset first time interval; and extracting the inquired data marked as the to-be-executed state, and respectively transmitting the extracted data to each second server connected with the server according to the data type.
In some embodiments, the extracting the queried data marked as the to-be-executed state and transmitting the extracted data to each second server connected to the server according to the data category respectively includes: for each inquired data marked as a to-be-executed state, sending a connection request to a corresponding second server according to the data type of the data; responding to the confirmation that the corresponding second server receives the connection request, establishing connection with the corresponding second server, extracting the data from the local database, locking the data in the local database, updating the to-be-executed state of the data into an executing state, and transmitting the data to the corresponding second server; and in response to the corresponding second server successfully receiving the data, updating the executing state of the data in the local database to an executing successful state, and unlocking the data.
In some embodiments, the transmitting the other categories of data extracted from the local database to the second servers connected to the server according to data categories respectively further includes: querying the locked data in the local database according to a preset second time interval; for each piece of inquired locked data, determining whether the locking duration of the data is greater than a preset locking duration; and in response to the fact that the locking duration of the data is larger than the preset locking duration, updating the executing state of the data to be the executing failure state, unlocking the data, and recording the executing failure times of the data.
In some embodiments, the transmitting the other categories of data extracted from the local database to the second servers connected to the server according to data categories respectively further includes: according to a preset third time interval, inquiring data marked as an execution failure state in the local database; for each piece of queried data marked as an execution failure state, determining whether the execution failure frequency of the data is smaller than a preset threshold value, and marking the data as a to-be-executed state in response to determining that the execution failure frequency is smaller than the threshold value; and generating prompt information of the abnormal data storage in response to the fact that the execution failure times are not smaller than the threshold value.
In a second aspect, the present application provides an information storage apparatus for a server, the apparatus comprising: the information storage device comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is configured to receive an information storage request sent by a client, the information storage request comprises information to be stored, and the information to be stored comprises at least one category of data; the first transmission unit is configured to transmit data of a preset category in the information to be stored to a first server connected with the server; the storage unit is configured to store data of other categories, which do not belong to a preset category, in the information to be stored into a local database, wherein the local database is a non-relational database; and the second transmission unit is configured to transmit the other types of data extracted from the local database to each second server connected with the server according to data types.
In some embodiments, the first transmission unit comprises: a sending module configured to send a connection request to the first server; the first transmission module is configured to respond to the confirmation that the first server accepts the connection request, establish connection with the first server, and transmit data of a preset category in the information to be stored to the first server; and the receiving module is configured to receive the identification of the information to be stored returned by the first server.
In some embodiments, the memory unit includes: the storage module is configured to store data of other categories, which do not belong to a preset category, in the information to be stored to a local database in a key-value pair mode by using the identification mark of the information to be stored and a field for describing the category of the data as a joint primary key; and the first marking module is configured to mark the data stored in the local database as a to-be-executed state.
In some embodiments, the second transmission unit comprises: the first query module is configured to query the data marked as the to-be-executed state in the local database according to a preset first time interval; and the second transmission module is configured to extract the queried data marked as the to-be-executed state and transmit the extracted data to each second server connected with the server according to the data types.
In some embodiments, the second transmission module comprises: the sending submodule is configured to send a connection request to the corresponding second server according to the data type of each piece of queried data marked as a to-be-executed state; the transmission submodule is configured to respond to the confirmation that the corresponding second server receives the connection request, establish connection with the corresponding second server, extract the data from the local database, lock the data in the local database, update the to-be-executed state of the data into an executing state, and transmit the data to the corresponding second server; and the marking submodule is configured to respond to the successful receiving of the data by the corresponding second server, update the executing state of the data in the local database to the executing successful state, and unlock the data.
In some embodiments, the second transmission unit further comprises: the second query module is configured to query the locked data in the local database according to a preset second time interval; the first determining module is configured to determine whether the locking duration of each piece of queried locked data is greater than a preset locking duration; and the second marking module updates the executing state of the data into the executing failure state, unlocks the data and records the executing failure times of the data in response to the fact that the locking duration of the data is greater than the preset locking duration.
In some embodiments, the second transmission unit further comprises: the third query module is configured to query the data marked as an execution failure state in the local database according to a preset third time interval; the second determining module is configured to determine, for each piece of queried data marked as an execution failure state, whether the number of execution failures of the piece of data is less than a preset threshold; the third marking module is used for marking the data into a to-be-executed state in response to the fact that the execution failure times are smaller than the threshold value; and the generation module is used for responding to the fact that the execution failure times are not smaller than the threshold value, and generating prompt information of the data storage abnormity.
According to the information storage method and device for the server, the data of the preset category in the information to be stored requested by the user are transmitted to the first server connected with the server, then the data of other categories which do not belong to the preset category are stored in the local database, and finally the data of other categories extracted from the local database are respectively transmitted to the second servers connected with the server according to the data categories, so that the dependency among the servers is reduced, the throughput of the server in the information storage process is improved, and the high availability of the server in the information storage process is realized.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of an information storage method for a server according to the present application;
FIG. 3 is a schematic diagram of an application scenario of an information storage method for a server according to the present application;
FIG. 4 is a flow diagram of yet another embodiment of an information storage method for a server according to the present application;
FIG. 5 is a schematic diagram of an embodiment of an information storage device for a server according to the present application;
FIG. 6 is a schematic block diagram of a computer system suitable for use in implementing a server according to embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 illustrates an exemplary system architecture 100 to which the information storage method for a server or the information storage apparatus for a server of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, a server 105, a network 106, and servers 107, 108, 109. Network 104 is the medium used to provide communication links between terminal devices 101, 102, 103 and server 105, and network 106 is the medium used to provide communication links between server 105 and servers 107, 108, 109. Network 104 and network 106 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, and 103 may be installed with various communication client applications, such as a web browser application, a shopping application, and a merchandise management application, through which a user enters information to be stored and sends the information to the network 104.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server that provides various services, such as a background management server that provides support for information to be stored entered on the terminal devices 101, 102, 103. The background management server can store, analyze and process the received data such as the information storage request, and the like, and can also interact with other servers to transmit the data and the like. The server 105 may be equipped with a local database, wherein the local database may be a non-relational database, such as a mongoDB database based on distributed file storage, where the MongoDB database is an existing database based on distributed file storage.
Servers 107, 108, 109 may be servers or clusters of servers that may provide various services, such as servers that provide support for different classes of data transmitted by server 106. Servers 107, 108, and 109 may store, analyze, and otherwise process the received data. It should be noted that the servers 107, 108, 109 may be various types of servers, and various types of databases may be installed in the servers 107, 108, 109.
It should be noted that the information storage method for the server provided in the embodiment of the present application is generally executed by the server 105, and accordingly, the information storage device for the server is generally disposed in the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 are merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of an information storage method for a server according to the present application is shown. The information storage method for the server comprises the following steps:
step 201, receiving an information storage request sent by a client, where the information storage request includes information to be stored.
In this embodiment, an electronic device (for example, the server 105 shown in fig. 1) on which the information storage method for the server operates may receive an information storage request from a terminal with which a user performs information entry by using a wired connection manner or a wireless connection manner, where the information storage request includes information to be stored, where the information to be stored includes at least one category of data. As an example, the information to be stored may be one or more commodity information created by a user using a terminal device, and the one or more commodity information includes at least one category of data, such as a basic information category, a price category, an advertisement category, an inventory category, an input price category, and the like. It should be noted that the wireless connection means may include, but is not limited to, a 3G/4G connection, a WiFi connection, a bluetooth connection, a WiMAX connection, a Zigbee connection, a uwb (ultra wideband) connection, and other wireless connection means now known or developed in the future.
Generally, a user can use a browser installed on a terminal to enter information to be stored, at this time, the user can directly input the information to be stored in a form of a web page, and click a submit button presented in the web browser and used for submitting the information to be stored to initiate a storage request of the information to be stored to a background application server, wherein the number of the forms in the web page can be multiple, and the user can enter different types of data in the forms in the web page. In this embodiment, the web page may include a web page in html format, xhtml format, asp format, php format, jsp format, shtml format, nsp format, xml format, or other format developed in the future (as long as the web page file in this format can be opened by a browser and the form contained in the web page file can be browsed).
Step 202, transmitting the data of the preset category in the information to be stored to a first server connected with the server.
In this embodiment, data may be divided into different categories in advance, and a category of data stored in a first server connected to the electronic device may be preset, where the first server may be a preset server of various types, and a connection manner between the electronic device and the first server may be a wired connection manner or a wireless connection manner. As an example, the information to be stored may be commodity information created by a user using a terminal device, and the category of the data included in the commodity information is data of a basic information category, a price category, an advertisement category, an inventory category, and a stock price category. The type of data transmitted to a first server connected to a commodity background management server is preset as a basic information type, where the data of the basic information type may be data describing basic information of a commodity, for example: trade name, shape, color, size, etc. It should be noted that the first server may be a server cluster including at least one server, and various types of databases may be installed in the first server.
In some optional implementation manners of this embodiment, the electronic device may first obtain an address and a port number of a first server connected to the electronic device, and send a connection request to the first server; then, in response to determining that the first server receives the connection request, establishing a connection with the first server, and transmitting the data of the preset type in the information to be stored received in step 201 to the first server.
It should be noted that the above-mentioned technology for establishing connection between servers is a well-known technology widely studied and applied at present, and is not described herein again.
And step 203, storing the data of other categories which do not belong to the preset category in the information to be stored into a local database.
In this embodiment, the electronic device may store data of other categories that do not belong to the preset category in step 201 in a storage manner supported by the local database to the local database.
And step 204, respectively transmitting the data of other types extracted from the local database to each second server connected with the server according to the data types.
In this embodiment, the type of the data stored in each second server connected to the electronic device may be preset, so that the data of each of the other types in the local database may be transmitted to the second server matched with the type of the data, where each second server may be various types of servers, and the connection between the electronic device and each second server may be a wired connection or a wireless connection. As an example, based on the data of the price class, the advertisement class and the inventory class stored in the local database in step 203, for each second server of the second servers connected to the electronic device, the class of the data matched with each server is preset, so that the data of the price class, the advertisement class and the inventory class can be stored in the second server corresponding to each class.
In this embodiment, the electronic device may store the other types of data in the local database asynchronously according to the data types, and asynchronously transmit the other types of data extracted from the local database to each second server connected to the server asynchronously according to the data types.
In some optional implementations of this embodiment, for each of the other types of data stored in the local database in step 203, the electronic device may perform the following steps: firstly, the electronic device may send a connection request to a corresponding second server according to the type of the data; secondly, in response to the confirmation that the corresponding second server receives the connection request, the electronic equipment establishes connection with the corresponding second server, extracts the data from the local database and transmits the data to the corresponding second server; and finally, responding to the successful receiving of the data by the corresponding second server, and marking the data in the local database as an execution success state. It should be noted that the second server may be at least one server or at least one server cluster, and the second server may have various types of databases installed therein.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the information storage method for a server according to the present embodiment. In the application scenario of fig. 3, a user uses a browser installed on a terminal to enter information to be stored, specifically, the user directly inputs information to be stored, such as a commodity name, a body color, a size, an advertisement word, and the like shown in fig. 3, in each form of a web page 301, and after the information to be stored is entered, the user clicks a submit button 302 presented in the web browser to submit the information to be stored to initiate a storage request of the information to be stored to a background application server; then, the background application server transmits the data input by the user in the basic information setting to a main server connected with the background application server; then storing data entered by the user in advertisement setting, price setting, promotion setting, inventory management and goods-entering price setting into a local database; and finally, respectively transmitting the data extracted from the local database to servers which are connected with the server and are respectively used for storing advertisement data, price data, promotion data, inventory data and stocking price data according to the data types.
In the method provided by the embodiment of the application, the data of the preset category in the information to be stored is transmitted to the first server connected with the server, the data of other categories not belonging to the preset category is stored in the local non-relational database, and the data of other categories extracted from the local database is transmitted to each second server connected with the server according to the data category, so that the dependency among the servers is reduced, the throughput of the server in the information storage process is improved, and the high availability of the server in the information storage process is realized.
With further reference to FIG. 4, a flow 400 of yet another embodiment of an information storage method for a server is shown. The process 400 of the information storage method for the server includes the following steps:
step 401, receiving an information storage request sent by a client, where the information storage request includes information to be stored.
In this embodiment, an electronic device (for example, the server 105 shown in fig. 1) on which the information storage method for the server operates may receive an information storage request from a terminal with which a user performs information entry by a wired connection manner or a wireless connection manner, where the information storage request includes information to be stored, where the information to be stored includes at least one category of data.
Step 402, transmitting data of a preset category in the information to be stored to a first server connected with the server.
In this embodiment, data may be divided into different data types in advance, and the data type transmitted to a first server connected to the electronic device (for example, the server 105 shown in fig. 1) may be preset, where the first server may be various preset types of servers, and the connection between the electronic device and the first server may be a wired connection or a wireless connection.
In this embodiment, the electronic device may first obtain an address and a port number of a first server connected to the electronic device, and send a connection request to the first server; in response to determining that the first server receives the connection request, establishing a connection with the first server, and transmitting the data of the preset type in the information to be stored, received in step 401, to the first server; and then, receiving the identification mark of the information to be stored returned by the first server.
And step 403, storing the data of other categories which do not belong to the preset category in the information to be stored into a local database, and marking the data as a state to be executed.
In this embodiment, based on the identification identifier of the information to be stored received in step 402, the electronic device may use the identification identifier of the information to be stored and a field for describing a category of data as a joint primary key, store, in a key-value pair manner, data of other categories that do not belong to the preset category in step 401 in the information to be stored in a local database, and mark the data stored in the local database as a state to be executed.
Step 404, querying data marked as a to-be-executed state in the local database according to a preset first time interval.
In this embodiment, a first time interval may be preset, where the first time interval is an interval duration of querying, by the electronic device, the data marked as the to-be-executed state in the local database every two times, and according to the time interval, the electronic device may query, in a cycle, the data marked as the to-be-executed state in the local database.
In some optional implementation manners of this embodiment, a first time interval is preset, where the first time interval is a time interval for querying all data marked as a to-be-executed state in the local database. The electronic device may query all data marked as a to-be-executed state in the local database according to the first time interval, where the first time interval may be any time duration, for example, 30 seconds, 1 minute, and the like.
In some optional implementation manners of this embodiment, first time intervals of the data of the respective categories may be preset according to the data categories, where the first time interval of the data of each category is a time interval for querying the data of the category marked as the to-be-executed state in the local database. The electronic device may asynchronously query each category of data marked as a to-be-executed state in the local database according to a first time interval of each category of data, where the first time interval of each category of data may be any time length.
And 405, extracting the inquired data marked as the to-be-executed state, and respectively transmitting the extracted data to each second server connected with the server according to the data type.
In this embodiment, the type of the data stored in each second server connected to the electronic device may be preset, so that the data of each of the other types in the local database may be transmitted to the second server matched with the type of the data, where each second server may be various types of servers, and the connection between the electronic device and each second server may be a wired connection or a wireless connection.
In this embodiment, the electronic device may asynchronously extract the data of the other types stored in the local database in the step 403 according to the data types, and asynchronously transmit the data of the other types extracted from the local database to each second server connected to the server according to the data types.
In this embodiment, for each data marked as the to-be-executed state in the local database, the following steps may be performed:
firstly, the electronic device may send a connection request to a corresponding second server according to the type of the data;
secondly, in response to the confirmation that the corresponding second server receives the connection request, the electronic device establishes connection with the corresponding second server, extracts the data from the local database, locks and marks the data in the local database into an execution state, and transmits the data to the corresponding second server;
and finally, responding to the successful receiving of the data by the corresponding second server, marking the data in the local database as an execution success state, and unlocking the data.
In this embodiment, after storing, in the information to be stored, data of another category that does not belong to the preset category in the local database and marking the data as a state to be executed, the electronic device may further perform the following steps:
step 406, querying the locked data in the local database according to a preset second time interval.
In this embodiment, a second time interval may be preset, where the second time interval is a duration of time between two times of querying, by the electronic device, the locked data in the local database. At the time interval, the electronic device may cycle through the locked data in the local database.
In some optional implementations of this embodiment, a second time interval is preset, where the second time interval is a time interval for querying all locked data in the local database. The electronic device may query all the locked data in the local database according to the second time interval, where the second time interval may be the same as the time interval of all the data marked as the to-be-executed state in the query preset in step 404, or may be any time length other than the time interval.
In some optional implementations of this embodiment, the second time interval of each category of data may be preset according to a data category, and the second time interval of each category of data is a time interval for querying the locked data of the category in the local database, and the electronic device may asynchronously query the locked data of the category in the local database according to the second time interval of each category of data, where the second time interval of each category of data may be the same as the time interval of the category of data in which the query preset in step 404 is marked as the to-be-executed state, or may be any time duration other than the time interval.
Step 407, determining whether the locking duration of each piece of queried locked data is greater than a preset locking duration; and in response to the fact that the locking duration of the data is larger than the preset locking duration, updating the executing state of the data to be the executing failure state, unlocking the data, and recording the executing failure times of the data.
In this embodiment, for each piece of data in the locked data queried in step 406, the electronic device may first calculate a locking duration of the data when querying the data; then, determining whether the locking duration of the data is greater than a preset locking duration, wherein the preset locking duration can be any duration set in advance; and in response to the fact that the locking duration is larger than the preset locking duration, the electronic equipment updates the executing state of the data to the executing failure state, unlocks the data, and records the executing failure times of the data.
In this embodiment, after storing, in the information to be stored, data of another category that does not belong to the preset category in the local database and marking the data as a state to be executed, the electronic device may further perform the following steps:
and step 408, querying the data marked as the execution failure state in the local database according to a preset third time interval.
In this embodiment, a third time interval may be preset, where the third time interval is an interval duration of querying, by the electronic device, the data marked as the execution failure state in the local database every two times, and according to the time interval, the electronic device may query the data marked as the execution failure state in the local database in a circulating manner.
In some optional implementations of this embodiment, a third time interval is preset, where the third time interval is a time interval for querying all data marked as an execution failure state in the local database. The electronic device may query all data marked as an execution failure state in the local database according to the third time interval, where the third time interval may be any time duration, for example, 30 seconds, 1 minute, and the like.
In some optional implementation manners of this embodiment, a third time interval of each category of data may be preset according to a data category, where the third time interval of each category of data is a time interval of querying the category of data marked as an execution failure state in the local database. The electronic device may asynchronously query the categories of data marked as the execution failure status in the local database according to the third time interval of the categories of data, where the third time interval of the categories of data may be the same as the time interval of the categories of data marked as the to-be-executed status in the query preset in step 404 or the time interval of the categories of data locked in the query preset in step 406, or may be any time length other than the time interval.
Step 409, determining whether the execution failure times of the data is less than a preset threshold value for each piece of queried data marked as an execution failure state; in response to determining that the number of execution failures is less than the threshold, marking the data as a pending execution state; and generating prompt information of the data storage exception in response to determining that the execution failure times are not less than the threshold value.
In this embodiment, for each piece of data that is queried in step 408 and marked as an execution failure state, the electronic device may first obtain the number of execution failures of the piece of data; then, determining whether the execution failure times of the data is less than a threshold, and in response to determining that the execution failure times is less than the threshold, marking the data in a to-be-executed state, wherein the threshold may be an acceptable maximum execution failure time set in advance; and in response to determining that the execution failure times are not less than the threshold value, the electronic equipment generates prompt information of the abnormal data storage.
As can be seen from fig. 4, compared with the embodiment corresponding to fig. 2, the flow 400 of the information storage method for a server in the present embodiment highlights the steps of querying the local database in a loop and marking the state of the data in the local database. Therefore, the scheme described in the embodiment can query the data in the local database for multiple times, so that the throughput of the server is further improved, and the high availability of the server in the information storage process is further ensured.
With further reference to fig. 5, as an implementation of the method shown in the above figures, the present application provides an embodiment of an information storage apparatus for a server, where the apparatus embodiment corresponds to the method embodiment shown in fig. 2, and the apparatus may be applied to various electronic devices.
As shown in fig. 5, the information storage apparatus 500 for a server according to the present embodiment includes: a receiving unit 501, a first transmission unit 502, a storage unit 503 and a second transmission unit 504. The receiving unit 501 is configured to receive an information storage request sent by a client, where the information storage request includes information to be stored, where the information to be stored includes at least one category of data; the first transmission unit 502 is configured to transmit data of a preset type in the information to be stored to a first server connected to the server; the storage unit 503 is configured to store data of other categories, which do not belong to a preset category, in the information to be stored in a local database, where the local database is a non-relational database; the second transmission unit 504 is configured to transmit the other types of data extracted from the local database to the second servers connected to the servers according to the data types.
In this embodiment, the receiving unit 501 of the information storage apparatus 500 for a server may receive an information storage request from a terminal with which a user performs information entry by a wired connection manner or a wireless connection manner, wherein information to be stored includes at least one category of data.
In this embodiment, the data may be divided into different data types in advance, and the type of the data stored in the first server connected to the information storage apparatus 500 for the server may be set in advance, where the first server may be a preset server of various types, and the connection mode with the first server may be a wired connection mode or a wireless connection mode. It should be noted that the first server may also be a server cluster including at least one server, and the server may be installed with various types of databases.
In some optional implementations of this embodiment, the first transmission unit 502 further includes: a sending module configured to send a connection request to the first server; a first transmission module, configured to establish a connection with the first server in response to determining that the first server accepts the connection request, and transmit data of a preset type in the information to be stored to the first server; and the receiving module is configured to receive the identification of the information to be stored, which is returned by the first server.
In this embodiment, the storage unit 503 of the information storage apparatus 500 for a server may store data of other categories, which do not belong to the preset category in the first transmission unit 502, in a storage manner supported by a local database to the local database.
In some optional implementation manners of this embodiment, the storage unit 503 further includes a storage module, configured to use the identification identifier of the information to be stored and a field for describing a category of data as a joint primary key, and store, in a key-value pair manner, data of other categories that do not belong to a preset category in the information to be stored in a local database; and the first marking module is configured to mark the data stored in the local database as a to-be-executed state.
In this embodiment, the category of the data matching each second server connected to the information storage apparatus 500 for the server may be preset, so that the data of each category of the other categories in the local database may be transmitted to the second server matching the category, wherein each second server may be various types of servers, and the connection manner with each second server may be a wired connection manner or a wireless connection manner.
In this embodiment, the second transmission unit 504 of the information storage apparatus 500 for a server may asynchronously extract the data of the other types stored in the local database by the storage unit 503 according to the data types, and asynchronously transmit the data of the other types extracted from the local database to each second server connected to the server according to the data types.
In some optional implementations of this embodiment, the second transmission unit 504 further includes: the first query module is configured to query the data marked as the to-be-executed state in the local database according to a preset first time interval; and the second transmission module is configured to extract the queried data marked as the to-be-executed state and transmit the extracted data to each second server connected with the server according to the data type.
In some optional implementations of this embodiment, the second transmission module 504 further includes: the sending submodule is configured to send a connection request to the corresponding second server according to the data type of each piece of queried data marked as a to-be-executed state; a transmission submodule configured to establish a connection with a corresponding second server in response to a confirmation that the corresponding second server receives the connection request, extract the data from the local database, lock the data in the local database, update a to-be-executed state of the data to an executing state, and transmit the data to the corresponding second server; and the marking submodule is configured to respond to the successful receiving of the data by the corresponding second server, update the executing state of the data in the local database to the executing successful state, and unlock the data.
In some optional implementations of this embodiment, the second transmission unit 504 further includes: the second query module is configured to query the locked data in the local database according to a preset second time interval; the first determining module is configured to determine whether the locking duration of each piece of queried locked data is greater than a preset locking duration; and the second marking module updates the executing state of the data into the executing failure state, unlocks the data and records the executing failure times of the data in response to the fact that the locking duration of the data is greater than the preset locking duration.
In some optional implementations of this embodiment, the second transmission unit 504 further includes: the third query module is configured to query the data marked as the execution failure state in the local database according to a preset third time interval; the second determining module is configured to determine, for each piece of queried data marked as an execution failure state, whether the number of execution failures of the piece of data is less than a preset threshold; the third marking module is used for marking the data into a to-be-executed state in response to the fact that the execution failure times are smaller than the threshold value; and the generating module is configured to generate prompt information of the abnormal data storage in response to the fact that the execution failure times are not smaller than the threshold value.
The apparatus provided in the foregoing embodiment of the present application transmits the data of the preset category in the information to be stored, which is received by the receiving unit 501, to the first server connected to the server through the first transmitting unit 502, stores the data of the other category, which does not belong to the preset category, in the local non-relational database through the storage unit 503, and transmits the data of the other category, which is extracted from the local database, to each second server connected to the server according to the data category through the second transmitting unit 504, so that the dependency between the servers is reduced, the throughput of the server in the information storage process is improved, and the high availability of the server in the information storage process is realized.
Referring now to FIG. 6, there is illustrated a schematic block diagram of a computer system 600 suitable for use in implementing the servers of the present application.
As shown in FIG. 6, computer system 600 includes a Central Processing Unit (CPU)601, which may be based on information stored in a Read Only Memory (ROM)602
The program or a program loaded from the storage section 608 into the Random Access Memory (RAM)603 performs various appropriate actions and processes. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 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 tangibly embodied on a machine-readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the method of the present application when executed by a Central Processing Unit (CPU) 601.
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 and/or flowchart illustration, and combinations of blocks in the block diagrams and/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.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a receiving unit, a first transmitting unit, a storage unit, and a second transmitting unit. The names of these units do not in some cases constitute a limitation on the units themselves, and for example, a receiving unit may also be described as a "unit that receives an information storage request sent by a client".
As another aspect, the present application also provides a non-volatile computer storage medium, which may be the non-volatile computer storage medium included in the apparatus in the above-described embodiments; or it may be a non-volatile computer storage medium that exists separately and is not incorporated into the terminal. The non-transitory computer storage medium stores one or more programs that, when executed by a device, cause the device to: receiving an information storage request sent by a client, wherein the information storage request comprises information to be stored, and the information to be stored comprises at least one category of data; transmitting data of a preset category in the information to be stored to a first server connected with the server; storing data of other categories, which do not belong to a preset category, in the information to be stored into a local database, wherein the local database is a non-relational database; and respectively transmitting the data of other types extracted from the local database to each second server connected with the server according to the data types.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by a person skilled in the art that the scope of the invention as referred to in the present application is not limited to the embodiments with a specific combination of the above-mentioned features, but also covers other embodiments with any combination of the above-mentioned features or their equivalents without departing from the inventive concept. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (14)

1. An information storage method for a server, the method comprising:
receiving an information storage request sent by a client, wherein the information storage request comprises information to be stored, and the information to be stored comprises at least one category of data;
transmitting data of a preset category in the information to be stored to a first server connected with the server, and receiving an identification mark of the information to be stored returned by the first server;
storing the data of other categories which do not belong to the preset category in the information to be stored to a local database, wherein the data comprises the following steps: storing other types of data which do not belong to a preset type in the information to be stored to a local database in a key-value pair mode by taking the identification mark of the information to be stored and a field for describing the type of the data as a joint main key; marking the data stored in the local database as a state to be executed; wherein the local database is a non-relational database;
and respectively transmitting the data of other types extracted from the local database to each second server connected with the server according to the data types.
2. The information storage method for the server according to claim 1, wherein the transmitting the data of the preset category in the information to be stored to a first server connected to the server includes:
sending a connection request to the first server;
and responding to the confirmation that the first server accepts the connection request, establishing connection with the first server, and transmitting the data of the preset category in the information to be stored to the first server.
3. The information storage method for the server according to claim 1, wherein the transmitting the other types of data extracted from the local database to the second servers connected to the server according to the data types respectively comprises:
inquiring data marked as a to-be-executed state in the local database according to a preset first time interval;
and extracting the inquired data marked as the to-be-executed state, and respectively transmitting the extracted data to each second server connected with the server according to the data type.
4. The information storage method for the server according to claim 3, wherein the extracting the queried data marked as the to-be-executed state and transmitting the extracted data to each second server connected to the server according to the data category respectively comprises:
for each inquired data marked as a to-be-executed state, sending a connection request to a corresponding second server according to the data type of the data;
responding to the confirmation that the corresponding second server accepts the connection request, establishing connection with the corresponding second server, extracting the data from the local database, locking the data in the local database, updating the to-be-executed state of the data into an executing state, and transmitting the data to the corresponding second server;
and in response to the corresponding second server successfully receiving the data, updating the executing state of the data in the local database to an executing successful state, and unlocking the data.
5. The information storage method for the server according to claim 4, wherein the transmitting the other types of data extracted from the local database to the second servers connected to the server according to the data types respectively further comprises:
querying the locked data in the local database according to a preset second time interval;
for each piece of inquired locked data, determining whether the locking duration of the data is greater than a preset locking duration;
and in response to the fact that the locking duration of the data is larger than the preset locking duration, updating the executing state of the data to be the executing failure state, unlocking the data, and recording the executing failure times of the data.
6. The information storage method for the server according to claim 5, wherein the transmitting the other types of data extracted from the local database to the second servers connected to the server according to the data types respectively further comprises:
according to a preset third time interval, inquiring data marked as an execution failure state in the local database;
for each piece of queried data marked as an execution failure state, determining whether the execution failure times of the data is smaller than a preset threshold value;
in response to determining that the number of execution failures is less than the threshold, marking the data as a pending execution state;
and generating prompt information of the abnormal data storage in response to the fact that the execution failure times are not smaller than the threshold value.
7. An information storage apparatus for a server, the apparatus comprising:
the information storage device comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is configured to receive an information storage request sent by a client, the information storage request comprises information to be stored, and the information to be stored comprises at least one category of data;
the first transmission unit is configured to transmit data of a preset category in the information to be stored to a first server connected with the server, and receive an identification mark of the information to be stored, which is returned by the first server;
the storage unit is configured to store data of other categories, which do not belong to a preset category, in the information to be stored in a local database, and includes: the storage module is configured to store data of other categories, which do not belong to a preset category, in the information to be stored to a local database in a key-value pair mode by using the identification mark of the information to be stored and a field for describing the category of the data as a joint primary key; the first marking module is configured to mark the data stored in the local database as a to-be-executed state; wherein the local database is a non-relational database;
and the second transmission unit is configured to transmit the other types of data extracted from the local database to each second server connected with the server according to data types.
8. The information storage apparatus for a server according to claim 7, wherein the first transmission unit includes:
a sending module configured to send a connection request to the first server;
and the first transmission module is configured to respond to the confirmation that the first server accepts the connection request, establish connection with the first server, and transmit the data of the preset category in the information to be stored to the first server.
9. The information storage apparatus for a server according to claim 7, wherein the second transmission unit includes:
the first query module is configured to query the data marked as the to-be-executed state in the local database according to a preset first time interval;
and the second transmission module is configured to extract the queried data marked as the to-be-executed state and transmit the extracted data to each second server connected with the server according to the data types.
10. The information storage device for a server according to claim 9, wherein the second transmission module comprises:
the sending submodule is configured to send a connection request to the corresponding second server according to the data type of each piece of queried data marked as a to-be-executed state;
the transmission submodule is configured to respond to the confirmation that the corresponding second server receives the connection request, establish connection with the corresponding second server, extract the data from the local database, lock the data in the local database, update the to-be-executed state of the data into an executing state, and transmit the data to the corresponding second server;
and the marking submodule is configured to respond to the successful receiving of the data by the corresponding second server, update the executing state of the data in the local database to the executing successful state, and unlock the data.
11. The information storage apparatus for a server according to claim 10, wherein the second transmission unit further comprises:
the second query module is configured to query the locked data in the local database according to a preset second time interval;
the first determining module is configured to determine whether the locking duration of each piece of queried locked data is greater than a preset locking duration;
and the second marking module updates the executing state of the data into the executing failure state, unlocks the data and records the executing failure times of the data in response to the fact that the locking duration of the data is greater than the preset locking duration.
12. The information storage apparatus for a server according to claim 11, wherein the second transmission unit further comprises:
the third query module is configured to query the data marked as an execution failure state in the local database according to a preset third time interval;
the second determining module is configured to determine, for each piece of queried data marked as an execution failure state, whether the number of execution failures of the piece of data is less than a preset threshold;
the third marking module is used for marking the data into a to-be-executed state in response to the fact that the execution failure times are smaller than the threshold value;
and the generation module is used for responding to the fact that the execution failure times are not smaller than the threshold value, and generating prompt information of the data storage abnormity.
13. A server, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
14. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN201610603428.4A 2016-07-28 2016-07-28 Information storage method and device for server Active CN107666499B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610603428.4A CN107666499B (en) 2016-07-28 2016-07-28 Information storage method and device for server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610603428.4A CN107666499B (en) 2016-07-28 2016-07-28 Information storage method and device for server

Publications (2)

Publication Number Publication Date
CN107666499A CN107666499A (en) 2018-02-06
CN107666499B true CN107666499B (en) 2021-01-26

Family

ID=61114193

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610603428.4A Active CN107666499B (en) 2016-07-28 2016-07-28 Information storage method and device for server

Country Status (1)

Country Link
CN (1) CN107666499B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109215190B (en) * 2018-08-23 2021-10-15 武汉普利商用机器有限公司 Method for uploading recorded information of intelligent door lock
CN109871416A (en) * 2019-02-28 2019-06-11 上海汽车集团股份有限公司 Data storage method, device and computer storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105515836A (en) * 2015-11-27 2016-04-20 小米科技有限责任公司 Log processing method, device and server
CN105718515A (en) * 2016-01-14 2016-06-29 神策网络科技(北京)有限公司 Data storage system and method and data analysis system and method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9483479B2 (en) * 2013-08-12 2016-11-01 Sap Se Main-memory based conceptual framework for file storage and fast data retrieval

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105515836A (en) * 2015-11-27 2016-04-20 小米科技有限责任公司 Log processing method, device and server
CN105718515A (en) * 2016-01-14 2016-06-29 神策网络科技(北京)有限公司 Data storage system and method and data analysis system and method

Also Published As

Publication number Publication date
CN107666499A (en) 2018-02-06

Similar Documents

Publication Publication Date Title
CN108960691B (en) Method and device for determining article stock for server system
US20190166216A1 (en) Information pushing method and device
CN108846753B (en) Method and apparatus for processing data
EP2682863A1 (en) Installing applications remotely
CN108388512B (en) Data processing method and server
CN105071976A (en) Data transmission method and device
CN107391277B (en) Information processing method and device
US10936360B2 (en) Methods and devices of batch process of content management
CN107862425B (en) Wind control data acquisition method, device and system and readable storage medium
CN105450705A (en) Service data processing method and apparatus
CN107666499B (en) Information storage method and device for server
CN113691635A (en) Method and device for calling micro service, electronic equipment and readable storage medium
CN111626806B (en) Data processing method and device and electronic equipment
CN107291923B (en) Information processing method and device
CN113434098A (en) Printing function implementation method, device, electronic equipment, system and storage medium
CN111125112A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN111611326A (en) Customer relation management database establishing method and system
CN111488386A (en) Data query method and device
CN114338094B (en) Method and device for acquiring request header information, electronic equipment and readable medium
CN114422586B (en) Event notification method, event notification device, computer equipment and storage medium
CN113807968B (en) Block chain user request processing method and device, entrusting server and storage medium
US20190138608A1 (en) External Change Detection
CN113760841B (en) Method and device for realizing distributed lock
CN112699251A (en) Data aggregation method and device, electronic equipment and storage medium
CN107707328B (en) Abstract information transmission 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