WO2011131066A1 - Internet of things system and buffer control method thereof - Google Patents

Internet of things system and buffer control method thereof Download PDF

Info

Publication number
WO2011131066A1
WO2011131066A1 PCT/CN2011/071883 CN2011071883W WO2011131066A1 WO 2011131066 A1 WO2011131066 A1 WO 2011131066A1 CN 2011071883 W CN2011071883 W CN 2011071883W WO 2011131066 A1 WO2011131066 A1 WO 2011131066A1
Authority
WO
WIPO (PCT)
Prior art keywords
cache
message
terminal
queue
file
Prior art date
Application number
PCT/CN2011/071883
Other languages
French (fr)
Chinese (zh)
Inventor
宋亚宁
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2011131066A1 publication Critical patent/WO2011131066A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W28/00Network traffic management; Network resource management
    • H04W28/02Traffic management, e.g. flow control or congestion control
    • H04W28/10Flow control between communication endpoints
    • H04W28/14Flow control between communication endpoints using intermediate storage
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/214Monitoring or handling of messages using selective forwarding

Definitions

  • the invention relates to the field of application of the Internet of Things, and particularly relates to an Internet of Things system and a control method thereof. Background technique
  • M2M Internet of Things
  • M2M servers often connect tens of thousands of terminals at the same time.
  • M2M Internet of Things
  • the server processes.
  • the M2M server cannot process one message and receive the next message. This may cause the message to be lost or blocked. Therefore, the message needs to be received first, cached, and then processed from the cache.
  • the cache mode of the message is memory cache and file cache.
  • the memory cache can be divided into a fixed-length memory space cache and a temporary allocated memory space cache according to the processing manner.
  • the M2M server For a fixed-length memory space cache, the M2M server allocates a fixed-length cache at startup. After receiving various messages from the terminal, the M2M server directly puts the message into an idle location in the previously allocated cache. However, during the operation of the M2M server, two extreme situations may occur. When the message volume of the M2M terminal is small, most of the memory in the cache space on the M2M server is idle, which easily causes waste of physical memory; and when M2M When the amount of terminal messages is extremely large, there may be a problem that the buffer space is occupied and the message cannot be continuously cached;
  • the M2M server does not allocate the cache space at the time of startup.
  • the interface layer of the M2M server receives the message of the M2M terminal, it temporarily operates.
  • the system applies for the memory.
  • the message of the M2M terminal is stored in the memory space of the temporary application.
  • the M2M server processes the message reported by the M2M terminal, the corresponding memory space is released.
  • the M2M server uses the M2M server to cache the memory space that can be avoided by the M2M terminal message.
  • the M2M server performs the memory application and release operation of the operating system for each M2M terminal, which consumes more system resources.
  • the maximum cache size that the entire M2M server can use is also limited by the size of the physical memory;
  • the M2M server saves the message reported by the M2M terminal in a file for caching.
  • the M2M server can save a large number of M2M terminal reporting messages.
  • the size of the hard disk of the host installed by the M2M server is limited, but the efficiency of the disk 10 is very low, which easily causes a large processing time of the M2M server to be used. Read and write disks, which will reduce the message processing performance of the M2M server.
  • the technical problem to be solved by the present invention is to provide an Internet of Things system and a cache control method thereof, which can provide high efficiency and unlimited cache space while improving memory utilization.
  • an embodiment of the present invention provides a method for controlling a cache in an Internet of Things system, including:
  • the system creates an IoT M2M terminal message cache queue, and adds the generated information of the M2M terminal message cache queue to the cache queue management information;
  • the system stores the message on the M2M terminal in the corresponding M2M terminal message cache queue through the memory cache mode and the file cache mode, or caches the message of the M2M terminal from the corresponding M2M terminal message. Take it out of the queue.
  • the method may further include: the system creating an M2M terminal message buffer queue, and adding the generated information of the M2M terminal message buffer queue to the cache queue management information, including the following steps:
  • the system initiates a request to create an M2M terminal message cache queue, which includes an M2M terminal message cache queue id;
  • the system determines that the M2M terminal message cache queue id does not exist, it scans whether there is already a cache file of the M2M terminal message cache queue id, and if so, obtains a start and end number of the cache file, and generates a newly created M2M.
  • the information of the terminal message cache queue which fills in the start and end numbers of the cache file;
  • the system adds the newly created information of the M2M terminal message cache queue to the cache queue management information.
  • the method may further include: the system, according to the cache queue management information, storing the message reported by the M2M terminal in the corresponding M2M terminal message cache queue by using the memory cache mode and the file cache manner, including the following steps:
  • the system receives the message reported by the M2M terminal, determines that the M2M terminal message cache queue to be inserted is legal, and determines whether the cache file exists in the M2M terminal message cache queue. If yes, step a2 is performed; otherwise, step a1 is performed;
  • Step a the system determines whether there is a free memory block in the M2M terminal message cache queue, if yes, step a3 is performed; otherwise, step a4 is performed;
  • Step a2 the system determines, according to the cache queue management information, whether the current cache file needs to create a new cache file, and if so, generates a new cache file according to the cache queue management information, and the M2M terminal is used.
  • the message is written to the free space header of the generated new cache file, and the process is exited; otherwise, the message on the M2M terminal is written into the free space header of the cache file, and the process is exited;
  • Step a3 The system copies the message reported by the M2M terminal to the memory block team End save, exit process;
  • Step a4 The system determines, according to the cache queue management information, whether the M2M terminal message cache queue can create a new memory block. If yes, apply for a memory block, add the memory address to the cache queue management information, and The message reported by the M2M terminal is copied to the memory block for saving, and the process is exited; otherwise, step a2 is performed.
  • the method may further include: the system, according to the cache queue management information, extracting, by using an in-memory cache mode and a file cache manner, the message of the M2M terminal from the corresponding M2M terminal message cache queue, including the following steps:
  • step b0 is performed
  • Step b0 the system determines whether there is a cache of the memory block in the current M2M terminal message cache queue, and if yes, step b3 is performed; otherwise, step bl is performed;
  • Step bl the system determines whether the cache file exists in the M2M terminal message cache queue, and if yes, executes step b2, otherwise exits the process;
  • Step b2 The system opens a cache file with the smallest file number, reads the cache file content, and copies the cache file content into the first memory block of the M2M terminal message cache queue;
  • Step b3 The system extracts the message of the M2M terminal from the memory block, and determines whether the message of the extracted M2M terminal reaches the preset number of messages of the M2M terminal, and if yes, exits the process, otherwise determines the M2M terminal message cache. Whether there is no message in the queue, if yes, exit the process, otherwise go to step b0.
  • the foregoing method may further include: the cache queue management information, including: M2M cache configuration information of the M2M system application, information of all M2M terminal message cache queues being used in the M2M system, and first M2M message cache queue list first address Information; where M2M cache configuration information includes the maximum allowable memory usage of all cache queues, the maximum record per queue The number of bars, the number of memory blocks allowed by the same type of cache, the memory block release rules, and the cache file save path information.
  • M2M cache configuration information includes the maximum allowable memory usage of all cache queues, the maximum record per queue The number of bars, the number of memory blocks allowed by the same type of cache, the memory block release rules, and the cache file save path information.
  • the embodiment of the present invention further provides an Internet of Things system, including: creating a management information module, a message storage module, and a message extraction module, where
  • the creating a management information module is configured to create an IoT M2M terminal message cache queue, and add the generated information of the M2M terminal message cache queue to the cache queue management information, and send the information to the message storage module and the Message extraction module
  • the message storage module is configured to store the message on the M2M terminal into the corresponding M2M terminal message cache queue according to the received cache queue management information by using a cache mode and a file cache mode;
  • the message extraction module is configured to: according to the received cache queue management information, the M2M terminal message is taken out from the corresponding M2M terminal message cache queue by using a cache mode and a file cache mode.
  • the system may further include: creating a management information module to create an M2M terminal message cache queue, and adding the generated information of the M2M terminal message cache queue to the cache queue management information, specifically:
  • the create and generate management information module initiates a request to create an M2M terminal message cache queue, which includes an M2M terminal message cache queue id; and determines whether the M2M terminal message cache queue id does not exist, and then scans whether the M2M terminal message cache queue id is already present.
  • the cache file if any, obtains the start and end numbers of the cache file, generates the newly created information of the M2M terminal message cache queue, and fills in the start and end numbers of the cache file; the newly created M2M terminal message cache The information of the queue is added to the cache queue management information.
  • the system may further include: the message storage module, according to the received cache queue management information, storing the message on the M2M terminal into the corresponding M2M terminal message cache queue by using a memory cache mode and a file cache manner, specifically Means:
  • the message storage module receives the message on the M2M terminal, and determines that the M2M terminal message cache queue to be inserted is legal, if it is determined that the cache file exists in the M2M terminal message cache queue, the current cache is determined according to the cache queue management information. Whether the file needs to create a new cache file, if yes, generate a new cache file according to the cache queue management information, and write the message reported by the M2M terminal to the free space header of the generated new cache file. Otherwise, the message reported by the M2M terminal is written to the free space header of the cache file;
  • Determining if there is no cache file in the M2M terminal message cache queue, determining whether there is a free memory block in the M2M terminal message cache queue, and if yes, copying the message reported by the M2M terminal to the end of the memory block If the cache queue management information is used, it is determined whether the M2M terminal message cache queue can create a new memory block. If yes, apply for a memory block, add the memory address to the cache queue management information, and report the M2M terminal. The message is copied to the memory block and saved.
  • the system may further include: the message extraction module, according to the received cache queue management information, the M2M terminal message is taken out from the corresponding M2M terminal message cache queue by using a memory cache mode and a file cache mode, specifically Means:
  • the message extraction module determines that the M2M terminal message cache queue to be extracted is legal, it determines that the extracted current M2M terminal message cache queue has a memory block cache, and then extracts the M2M terminal message from the memory block to determine the extracted M2M. If the message of the terminal has reached the preset number of messages of the M2M terminal, exit, otherwise, if the M2M terminal message cache queue has no message, exit;
  • the content of the cache file is sent to the first memory block of the M2M terminal message cache queue.
  • the message of the M2M terminal is extracted from the memory block, and the number of messages of the M2M terminal that has been reached by the preset M2M terminal is determined.
  • Retreat If yes, it is judged that if there is no message in the M2M terminal message buffer queue, it will exit.
  • the system may further include: the cache queue management information in the creating and generating management information module, including: M2M cache configuration information of the M2M system application, information of all M2M terminal message cache queues being used in the M2M system, and All M2M message cache queue list first address information; wherein, M2M cache configuration information includes the maximum allowable memory size of all cache queues, the maximum number of records per queue, the number of memory blocks allowed by the same type of cache, the memory block release rules, and the cache.
  • M2M cache configuration information includes the maximum allowable memory size of all cache queues, the maximum number of records per queue, the number of memory blocks allowed by the same type of cache, the memory block release rules, and the cache.
  • File save path information including: M2M cache configuration information of the M2M system application, information of all M2M terminal message cache queues being used in the M2M system, and All M2M message cache queue list first address information; wherein, M2M cache configuration information includes the maximum allowable memory size of all cache queues, the maximum
  • the embodiment of the present invention combines the memory and the file storage cache in two ways, and uses the memory block as a basic unit to apply and release the memory, and on the one hand, provides the high-speed access capability of the memory, and It avoids the system consumption caused by frequent memory application and release, and uses the file as an extended storage method, so that the method can theoretically save unlimited messages interacting with the M2M terminal, and the storage capacity is only related to the size of the physical hard disk. It provides high efficiency and unlimited cache space while improving memory utilization without wasting physical memory space. . DRAWINGS
  • FIG. 1 is a schematic diagram of a storage location cached in an M2M system according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for controlling a cache in an Internet of Things system according to an embodiment of the present invention
  • Figure 2 is a flow chart of the M2M terminal message buffer queue
  • Figure 4 is a flowchart of the M2M terminal message entering the queue in the embodiment of the present invention
  • FIG. 5 is a flowchart of a M2M terminal message out queue in the embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of an Internet of Things system according to an embodiment of the present invention. detailed description
  • M2M terminal message buffer queues are allowed to be established.
  • the information of all M2M terminal message buffer queues is managed by a doubly linked list.
  • Each queue corresponds to a M2M terminal reporting message.
  • Each queue can store M2M terminal reporting messages by using memory + file.
  • the system uses memory blocks as memory. The unit manages, and the application and release of the memory are all in a single memory block, which effectively improves the memory utilization; the size of the cache file is consistent with the size of the memory block, and when the message needs to be obtained from the file, the entire file is mapped.
  • the cache file When it is processed into memory, when the message in the file is obtained again in the future, it is processed from the memory, and the cache file is no longer operated, thereby improving the access efficiency.
  • the system designs the cache file size and the memory block size to be consistent, which can effectively improve the mapping copy from file to memory.
  • the M2M cache file needs to be copied to the M2M cache memory block, only one binary read of the file is required. Take, and then copy to the memory block, improve the file-to-memory content replication efficiency; the file naming rules in the system is through the M2M message cache queue id file number, the file number is accumulated from 0, thus ensuring the system to the file Save in FIFO order.
  • the cache queue management information includes: M2M cache configuration information of the M2M system application, information of all M2M terminal message cache queues used in the M2M system, and first M2M message cache queue list first address information.
  • the M2M cache configuration information includes the maximum allowed memory size of all cache queues, the maximum number of records per queue, the number of memory blocks allowed by the same type of cache, the memory block release rule, and the cache file save path information. The above information is set when the system is initialized.
  • the process of creating an M2M terminal message buffer queue mainly includes setting configuration information of the following queues: M2M terminal message queue id, single message length in the M2M terminal message queue, and M2M terminal message memory usage related information, that is, the maximum useable How many M2M servers cache memory blocks, M2M terminal message files use related information, that is, the start number of the file, the pointer of the M2M terminal message, the pointer of the current queue before and after the queue, and so on.
  • Each message in a single queue of M2M terminal messages is stored at a fixed length.
  • Each queue can contain a memory cache of 1 to N memory blocks and a file cache of unlimited files.
  • Caching, queues, memory The relationship between the memory block and the file can be as shown in Figure 1.
  • Each cache queue stores M2M in memory cache mode + file cache mode. The message reported by the terminal, wherein the memory portion is managed
  • the message in-cache queue processing flow controls the M2M server interface layer to store the message received from the M2M terminal in the corresponding M2M terminal message queue, and selects the queue id corresponding to the M2M terminal reporting message, according to the cache queue management information,
  • the message reported by the M2M terminal is inserted into the memory of the corresponding queue or the end of the file cache, which involves operations such as requesting a memory block and generating a cache file.
  • the message out cache queue processing flow controls the M2M server message processing application to take the message out of the M2M terminal message queue of the system, select the queue id corresponding to the M2M terminal report message, and according to the cache queue management information, from the currently operating
  • the memory block front end of the M2M terminal message queue takes out the message and returns it to the M2M server message processing application.
  • the message out cache queue processing process involves operations such as copying the cache file of the M2M terminal message queue to the cache memory block and releasing the memory block in the system.
  • FIG. 2 is a schematic flowchart of a method for controlling a cache in an Internet of Things system according to an embodiment of the present invention. As shown in FIG. 2, the method includes the following steps:
  • Step 100 The IoT system creates a M2M terminal message cache queue, and adds the generated information of the M2M terminal message cache queue to the cache queue management information.
  • FIG. 3 is a flowchart of creating a M2M terminal message cache queue according to an embodiment of the present invention. As shown in FIG. 3, creating a M2M terminal message cache queue specifically includes the following steps:
  • Step 301 The system initiates an M2M terminal message cache queue request by using an interface layer application, where the M2M terminal message cache queue id is included;
  • Step 302 the system determines whether the M2M terminal message cache queue id exists, and if so, the process ends; otherwise, step 303 is performed; Step 303: Scan whether there is already a cache file of the M2M terminal message cache queue id, and if yes, obtain the start and end numbers of the cache file, and generate information of the newly created M2M terminal message cache queue, where the cache file is filled. Start and end numbers;
  • Step 304 The system adds the newly added information of the M2M terminal message cache queue to the cache queue management information.
  • the system adds the newly added information of the M2M terminal message cache queue to the M2M terminal message buffer queue doubly linked list in the cache queue management information.
  • Step 200 The system stores the message on the M2M terminal in the corresponding M2M terminal message cache queue, or the M2M terminal message from the corresponding M2M terminal message, according to the cache queue management information, by using the memory cache mode and the file cache mode. Take it out of the cache queue.
  • the system saves the message of the M2M terminal to the corresponding M2M terminal message cache queue by using the memory cache mode and the file cache mode according to the cache queue management information, and specifically includes the following steps:
  • Step 400 The system receives the message reported by the M2M terminal, determines that the M2M terminal message cache queue to be inserted is legal, and further determines whether the cache file exists in the M2M terminal message cache queue. If yes, step 402 is performed; Step 401;
  • Step 401 The system determines whether there is a free memory block in the M2M terminal message cache queue, if yes, step 403 is performed; otherwise, step 404 is performed;
  • Step 402 The system determines, according to the cache queue management information, whether a current cache file needs to create a new cache file, and if yes, generates a new cache file according to the cache queue management information, where the M2M terminal is The message is written to the free space header of the generated new cache file, and the process is exited; otherwise, the message on the M2M terminal is written into the free space header of the cache file, and the process is exited;
  • Step 403 The system copies the message reported by the M2M terminal to the end of the memory block, and exits the process.
  • the process of taking the M2M terminal message from the corresponding M2M terminal message cache queue by using the memory cache mode and the file cache mode according to the cache queue management information includes the following steps:
  • Step 500 If the system determines that the M2M terminal message cache queue to be extracted is legal, step 501 is performed;
  • Step 501 The system determines whether there is a cache of a memory block in the current M2M terminal message cache queue, and if yes, step 504 is performed, otherwise step 502 is performed;
  • Step 502 The system determines whether the cache file exists in the M2M terminal message cache queue. If yes, step 503 is performed; otherwise, the process is exited;
  • Step 503 The system opens a cache file with the smallest file number in a binary manner, reads the cache file content, and copies the cache file content into the first memory block of the M2M terminal message cache queue.
  • Step 504 The system extracts the message of the M2M terminal from the memory block, and determines whether the message of the extracted M2M terminal reaches the preset number of M2M terminal messages, and if yes, exits the process, otherwise step 505 is performed;
  • Step 505 The system determines whether there is no message in the M2M terminal message buffer queue. If yes, the process is exited. Otherwise, step 501 is performed.
  • an Internet of Things system includes: creating a generation management information module, a message storage module, and a message extraction module, where
  • the creating a management information module is used to create an Internet of Things M2M terminal message cache team Columns, and the information of the generated M2M terminal message buffer queue is added to the cache queue management information, and sent to the message storage module and the message extraction module;
  • the message storage module is configured to store the message on the M2M terminal into the corresponding M2M terminal message cache queue according to the received cache queue management information by using a cache mode and a file cache mode;
  • the message extraction module is configured to: according to the received cache queue management information, the M2M terminal message is taken out from the corresponding M2M terminal message cache queue by using a cache mode and a file cache mode.
  • the creating a management information module creates an M2M terminal message cache queue, and adds the generated information of the M2M terminal message cache queue to the cache queue management information, specifically: the creating and generating a management information module initiates a creation of an M2M terminal.
  • a message cache queue request which includes an M2M terminal message cache queue id; determining that the M2M terminal message cache queue id does not exist, then scanning whether the M2M terminal message cache queue id cache file exists, and if so, acquiring the cache file
  • the start and end numbers are generated, and the newly created information of the M2M terminal message cache queue is filled in, and the start and end numbers of the cache file are filled in; the newly added information of the M2M terminal message cache queue is added to the cache queue management information.
  • the message storage module stores the message on the M2M terminal in the corresponding M2M terminal message cache queue according to the received cache queue management information, by means of a memory cache mode and a file cache mode, specifically:
  • the message storage module receives the message on the M2M terminal, and determines that the M2M terminal message cache queue to be inserted is legal, if it is determined that the cache file exists in the M2M terminal message cache queue, the current cache is determined according to the cache queue management information. Whether the file needs to create a new cache file, if yes, generate a new cache file according to the cache queue management information, and write the message reported by the M2M terminal to the free space header of the generated new cache file.
  • the message reported by the M2M terminal is written to the free space header of the cache file; Determining, if there is no cache file in the M2M terminal message cache queue, determining whether there is a free memory block in the M2M terminal message cache queue, and if yes, copying the message reported by the M2M terminal to the end of the memory block If the M2M terminal message cache queue is newly created, the memory module is requested to be added to the cache queue management information, and the memory address is added to the cache queue management information, and the M2M terminal is reported. The message is copied to the memory block and saved.
  • the message extraction module extracts the message of the M2M terminal from the corresponding M2M terminal message cache queue according to the received cache queue management information by using the memory cache mode and the file cache mode, which specifically refers to:
  • the message extraction module determines that the M2M terminal message cache queue to be extracted is legal, it determines that the extracted current M2M terminal message cache queue has a memory block cache, and then extracts the M2M terminal message from the memory block to determine the extracted M2M. If the message of the terminal has reached the preset number of messages of the M2M terminal, exit, otherwise, if the M2M terminal message cache queue has no message, exit;
  • the content of the cache file is sent to the first memory block of the M2M terminal message cache queue.
  • the message of the M2M terminal is extracted from the memory block, and the number of messages of the M2M terminal that has been reached by the preset M2M terminal is determined. , then exit, otherwise it is judged that if there is no message in the M2M terminal message buffer queue, it will exit.
  • the cache queue management information in the creation and management information module includes: M2M cache configuration information of the M2M system application, information of all M2M terminal message cache queues used in the M2M system, and first address information of all M2M message cache queue list entries.
  • the M2M cache configuration information includes the maximum allowed memory size of all cache queues, the maximum number of records per queue, the number of memory blocks allowed by the same type of cache, the memory block release rules, and the cache file save. Path information.
  • the cache method for processing massive messages in an M2M server application combines two methods of memory and file storage cache, and uses a memory block as a basic unit for memory application and release, which is provided on the one hand
  • the high-speed access capability of memory avoids the system consumption caused by frequent memory application and release.
  • the file is used as an extended storage method, so that the method can theoretically save unlimited messages interacting with the M2M terminal.
  • the storage capacity is only related to the physical hard disk size.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

A method for controlling the buffer in the internet of things system is disclosed in the present invention. The method includes: the internet of things system creates a Machine-To-Machine (M2M) terminal message buffer queue, and adds the generated information of the M2M terminal message buffer queue in the buffer queue management information (100); according to the buffer queue management information, the system stores the message reported by the M2M terminal in the corresponding M2M terminal message buffer queue by the memory buffer mode and the file buffer mode, or extracts the message of the M2M terminal from the corresponding M2M terminal message buffer queue (200). Accordingly, the internet of things system is also disclosed in the present invention. The application of the present invention can provide the high efficiency and the unrestricted buffer space and also improve the memory utilization rate.

Description

一种物联网系统及其中緩存的控制方法 技术领域  IoT system and control method thereof in cache
本发明涉及物联网应用领域, 具体涉及一种物联网系统及其中緩存的 控制方法。 背景技术  The invention relates to the field of application of the Internet of Things, and particularly relates to an Internet of Things system and a control method thereof. Background technique
在计算机技术飞速发展的今天, 物联网越来越成为一个未来互联网发 展的一个方向, 在 M2M (物联网 )应用中, M2M服务器往往同时连接了 上万个终端, 同一时刻有大量的消息需要 M2M服务器处理, 此时 M2M服 务器不能处理完一个消息再接收下一条消息, 这样可能造成消息丟失或者 阻塞的问题, 因此就需要先将消息接收下来, 进行緩存, 再从緩存中获取 消息处理。  Today, with the rapid development of computer technology, the Internet of Things has become a direction of future Internet development. In M2M (Internet of Things) applications, M2M servers often connect tens of thousands of terminals at the same time. At the same time, there are a large number of messages requiring M2M. The server processes. At this time, the M2M server cannot process one message and receive the next message. This may cause the message to be lost or blocked. Therefore, the message needs to be received first, cached, and then processed from the cache.
在传统的 M2M服务器中, 对消息的緩存方式有内存緩存和文件緩存, 其中, 内存緩存根据处理方式又可以分为以定长内存空间緩存和临时分配 内存空间緩存。  In the traditional M2M server, the cache mode of the message is memory cache and file cache. The memory cache can be divided into a fixed-length memory space cache and a temporary allocated memory space cache according to the processing manner.
对于定长内存空间緩存的方式, M2M服务器在启动时即分配好固定长 度的緩存, M2M服务器接收到终端的各种消息后, 直接将消息放入事先分 配好的緩存中的空闲位置。但是,在 M2M服务器运行过程中可能会出现比 较极端的两种情况, 当 M2M终端消息量小的时候, M2M服务器上緩存空 间的内存大部分都空闲, 容易造成了物理内存的浪费; 而当 M2M终端消息 量极大的时候, 又可能出现由于緩存空间被占满而无法继续緩存消息的问 题;  For a fixed-length memory space cache, the M2M server allocates a fixed-length cache at startup. After receiving various messages from the terminal, the M2M server directly puts the message into an idle location in the previously allocated cache. However, during the operation of the M2M server, two extreme situations may occur. When the message volume of the M2M terminal is small, most of the memory in the cache space on the M2M server is idle, which easily causes waste of physical memory; and when M2M When the amount of terminal messages is extremely large, there may be a problem that the buffer space is occupied and the message cannot be continuously cached;
对于临时分配内存空间緩存的方式, M2M服务器在启动时并不分配緩 存空间, 当 M2M服务器的接口层每次收到 M2M终端的消息后临时向操作 系统申请内存, 申请成功后将 M2M 终端的消息存入临时申请的内存空间 中, 当 M2M服务器将 M2M终端上报的一条消息处理完成后立即释放对应 内存空间。 M2M服务器使用这种方式进行 M2M终端消息的緩存可以避免 的内存空间的浪费, 但是 M2M服务器对每条 M2M终端上报的消息都进行 操作系统的内存申请和释放操作, 从而会消耗较多的系统资源, 并且整个 M2M服务器能够使用的最大緩存大 d、也会受到物理内存大小的限制; For the mode of temporarily allocating the memory space cache, the M2M server does not allocate the cache space at the time of startup. When the interface layer of the M2M server receives the message of the M2M terminal, it temporarily operates. The system applies for the memory. After the application is successful, the message of the M2M terminal is stored in the memory space of the temporary application. When the M2M server processes the message reported by the M2M terminal, the corresponding memory space is released. The M2M server uses the M2M server to cache the memory space that can be avoided by the M2M terminal message. However, the M2M server performs the memory application and release operation of the operating system for each M2M terminal, which consumes more system resources. And the maximum cache size that the entire M2M server can use is also limited by the size of the physical memory;
对于纯文件緩存的方式, M2M服务器将 M2M终端上报的消息保存在 文件中进行緩存。 该方法上可以使 M2M服务器保存大量的 M2M终端上报 消息,理论上只受 M2M服务器所安装主机的硬盘大小的限制,但是磁盘 10 的效率非常低,从而容易导致 M2M服务器大量的处理时间被用于了读写磁 盘, 从而会降低 M2M服务器的消息处理性能。  For the pure file cache mode, the M2M server saves the message reported by the M2M terminal in a file for caching. In this method, the M2M server can save a large number of M2M terminal reporting messages. In theory, only the size of the hard disk of the host installed by the M2M server is limited, but the efficiency of the disk 10 is very low, which easily causes a large processing time of the M2M server to be used. Read and write disks, which will reduce the message processing performance of the M2M server.
可以看出,当前需要一种新的 M2M系统中的緩存方式,在提供高效率、 无限制的緩存空间的同时又能提高内存利用率, 不造成物理内存空间的浪 费。 发明内容  It can be seen that there is a need for a new cache mode in the M2M system, which provides high efficiency and unlimited cache space while improving memory utilization without causing waste of physical memory space. Summary of the invention
本发明所要解决的技术问题是提供一种物联网系统及其中緩存的控制 方法, 能够在提供高效率、 无限制的緩存空间的同时, 又能提高内存利用 率。  The technical problem to be solved by the present invention is to provide an Internet of Things system and a cache control method thereof, which can provide high efficiency and unlimited cache space while improving memory utilization.
为了解决上述问题, 本发明实施例提供了一种物联网系统中緩存的控 制方法, 包括:  In order to solve the above problem, an embodiment of the present invention provides a method for controlling a cache in an Internet of Things system, including:
所述系统创建一物联网 M2M 终端消息緩存队列, 并将生成后的该 M2M终端消息緩存队列的信息加入緩存队列管理信息;  The system creates an IoT M2M terminal message cache queue, and adds the generated information of the M2M terminal message cache queue to the cache queue management information;
所述系统根据所述緩存队列管理信息, 通过内存緩存方式和文件緩存 方式将 M2M终端上 ^艮的消息存入对应的 M2M终端消息緩存队列, 或者将 M2M终端的消息从对应的 M2M终端消息緩存队列中取出。 优选的,上述方法还可包括,所述系统创建一 M2M终端消息緩存队列, 并将生成后的该 M2M终端消息緩存队列的信息加入緩存队列管理信息,包 括以下步骤: According to the cache queue management information, the system stores the message on the M2M terminal in the corresponding M2M terminal message cache queue through the memory cache mode and the file cache mode, or caches the message of the M2M terminal from the corresponding M2M terminal message. Take it out of the queue. Preferably, the method may further include: the system creating an M2M terminal message buffer queue, and adding the generated information of the M2M terminal message buffer queue to the cache queue management information, including the following steps:
所述系统发起一创建 M2M终端消息緩存队列请求, 其中包含 M2M终 端消息緩存队列 id;  The system initiates a request to create an M2M terminal message cache queue, which includes an M2M terminal message cache queue id;
所述系统判断该 M2M终端消息緩存队列 id若不存在, 则扫描是否已 经有该 M2M终端消息緩存队列 id的緩存文件, 若有, 则获取緩存文件的 起始、 结束编号, 生成新建的该 M2M终端消息緩存队列的信息, 其中填入 緩存文件的起始和结束编号;  If the system determines that the M2M terminal message cache queue id does not exist, it scans whether there is already a cache file of the M2M terminal message cache queue id, and if so, obtains a start and end number of the cache file, and generates a newly created M2M. The information of the terminal message cache queue, which fills in the start and end numbers of the cache file;
所述系统将新建的该 M2M 终端消息緩存队列的信息加入緩存队列管 理信息。  The system adds the newly created information of the M2M terminal message cache queue to the cache queue management information.
优选的, 上述方法还可包括, 所述系统根据所述緩存队列管理信息, 通过内存緩存方式和文件緩存方式将 M2M 终端上报的消息存入对应的 M2M终端消息緩存队列, 包括以下步骤:  Preferably, the method may further include: the system, according to the cache queue management information, storing the message reported by the M2M terminal in the corresponding M2M terminal message cache queue by using the memory cache mode and the file cache manner, including the following steps:
所述系统收到 M2M终端上报的消息, 判断需要插入的 M2M终端消息 緩存队列如果合法,则判断该 M2M终端消息緩存队列是否已经存在緩存文 件, 如果有, 则执行步骤 a2; 否则执行步骤 al ;  The system receives the message reported by the M2M terminal, determines that the M2M terminal message cache queue to be inserted is legal, and determines whether the cache file exists in the M2M terminal message cache queue. If yes, step a2 is performed; otherwise, step a1 is performed;
步骤 al、 所述系统判断所述 M2M终端消息緩存队列中是否有空闲的 内存块, 如果有, 则执行步骤 a3; 否则执行步骤 a4;  Step a, the system determines whether there is a free memory block in the M2M terminal message cache queue, if yes, step a3 is performed; otherwise, step a4 is performed;
步骤 a2、 所述系统根据所述緩存队列管理信息, 判断当前緩存文件是 否需要创建新的緩存文件, 如果是, 则根据所述緩存队列管理信息生成一 新的緩存文件,将所述 M2M终端上 的消息写入生成的该新的緩存文件的 空闲空间头部, 退出流程; 否则将所述 M2M终端上 的消息写入所述緩存 文件的空闲空间头部, 退出流程;  Step a2, the system determines, according to the cache queue management information, whether the current cache file needs to create a new cache file, and if so, generates a new cache file according to the cache queue management information, and the M2M terminal is used. The message is written to the free space header of the generated new cache file, and the process is exited; otherwise, the message on the M2M terminal is written into the free space header of the cache file, and the process is exited;
步骤 a3、 所述系统将所述 M2M终端上报的消息拷贝到所述内存块队 尾保存, 退出流程; Step a3: The system copies the message reported by the M2M terminal to the memory block team End save, exit process;
步骤 a4、 所述系统根据所述緩存队列管理信息, 判断该 M2M终端消 息緩存队列是否可以新建内存块, 如果是, 则申请一内存块, 将内存地址 加入所述緩存队列管理信息,并将该 M2M终端上报的消息拷贝到该内存块 保存, 退出流程; 否则执行步骤 a2。  Step a4: The system determines, according to the cache queue management information, whether the M2M terminal message cache queue can create a new memory block. If yes, apply for a memory block, add the memory address to the cache queue management information, and The message reported by the M2M terminal is copied to the memory block for saving, and the process is exited; otherwise, step a2 is performed.
优选的, 上述方法还可包括, 所述系统根据所述緩存队列管理信息, 通过内存緩存方式和文件緩存方式将 M2M终端的消息从对应的 M2M终端 消息緩存队列中取出, 包括以下步骤:  Preferably, the method may further include: the system, according to the cache queue management information, extracting, by using an in-memory cache mode and a file cache manner, the message of the M2M terminal from the corresponding M2M terminal message cache queue, including the following steps:
所述系统判断需要提取的 M2M终端消息緩存队列如果合法,则执行步 骤 b0;  If the system determines that the M2M terminal message cache queue to be extracted is legal, step b0 is performed;
步骤 b0、 所述系统判断提取的当前 M2M终端消息緩存队列是否存在 有内存块的緩存, 如果是, 则执行步骤 b3 , 否则执行步骤 bl,;  Step b0, the system determines whether there is a cache of the memory block in the current M2M terminal message cache queue, and if yes, step b3 is performed; otherwise, step bl is performed;
步骤 bl、 所述系统判断所述 M2M终端消息緩存队列是否存在緩存文 件, 如果是, 则执行步骤 b2, 否则退出流程,;  Step bl, the system determines whether the cache file exists in the M2M terminal message cache queue, and if yes, executes step b2, otherwise exits the process;
步骤 b2、 所述系统打开文件编号最小的一緩存文件, 读取该緩存文件 内容,并拷贝该緩存文件内容到所述 M2M终端消息緩存队列的第一个内存 块中;  Step b2: The system opens a cache file with the smallest file number, reads the cache file content, and copies the cache file content into the first memory block of the M2M terminal message cache queue;
步骤 b3、 所述系统从内存块中提取 M2M 终端的消息, 判断提取的 M2M终端的消息是否达到预设的 M2M终端的消息的条数, 如果是, 则退 出流程,否则判断该 M2M终端消息緩存队列中是否已经没有消息,如果是, 则退出流程, 否则执行步骤 b0。  Step b3: The system extracts the message of the M2M terminal from the memory block, and determines whether the message of the extracted M2M terminal reaches the preset number of messages of the M2M terminal, and if yes, exits the process, otherwise determines the M2M terminal message cache. Whether there is no message in the queue, if yes, exit the process, otherwise go to step b0.
优选的, 上述方法还可包括, 所述緩存队列管理信息, 包括: M2M系 统应用的 M2M緩存配置信息、 M2M系统中所有正使用的 M2M终端消息 緩存队列的信息以及所有 M2M消息緩存队列链表首地址信息;其中, M2M 緩存配置信息包括所有緩存队列最大允许使用内存量、 每条队列最大记录 条数、 同一类型緩存允许的内存块个数、 内存块释放规则和緩存文件保存 路径信息。 Preferably, the foregoing method may further include: the cache queue management information, including: M2M cache configuration information of the M2M system application, information of all M2M terminal message cache queues being used in the M2M system, and first M2M message cache queue list first address Information; where M2M cache configuration information includes the maximum allowable memory usage of all cache queues, the maximum record per queue The number of bars, the number of memory blocks allowed by the same type of cache, the memory block release rules, and the cache file save path information.
本发明实施例还提供了一种物联网系统, 包括: 创建生成管理信息模 块、 消息储存模块和消息提取模块, 其中,  The embodiment of the present invention further provides an Internet of Things system, including: creating a management information module, a message storage module, and a message extraction module, where
所述创建生成管理信息模块,用于创建一物联网 M2M终端消息緩存队 列, 并将生成后的该 M2M 终端消息緩存队列的信息加入緩存队列管理信 息, 并发送给所述消息储存模块和所述消息提取模块;  The creating a management information module is configured to create an IoT M2M terminal message cache queue, and add the generated information of the M2M terminal message cache queue to the cache queue management information, and send the information to the message storage module and the Message extraction module
所述消息储存模块, 用于根据接收的所述緩存队列管理信息, 通过内 存緩存方式和文件緩存方式将 M2M终端上 ^艮的消息存入对应的 M2M终端 消息緩存队列;  The message storage module is configured to store the message on the M2M terminal into the corresponding M2M terminal message cache queue according to the received cache queue management information by using a cache mode and a file cache mode;
所述消息提取模块, 用于根据接收的所述緩存队列管理信息, 通过内 存緩存方式和文件緩存方式将 M2M终端的消息从对应的 M2M终端消息緩 存队列中取出。  The message extraction module is configured to: according to the received cache queue management information, the M2M terminal message is taken out from the corresponding M2M terminal message cache queue by using a cache mode and a file cache mode.
优选的, 上述系统还可包括, 所述创建生成管理信息模块创建一 M2M 终端消息緩存队列,并将生成后的该 M2M终端消息緩存队列的信息加入緩 存队列管理信息, 具体是指:  Preferably, the system may further include: creating a management information module to create an M2M terminal message cache queue, and adding the generated information of the M2M terminal message cache queue to the cache queue management information, specifically:
所述创建生成管理信息模块发起一创建 M2M终端消息緩存队列请求, 其中包含 M2M终端消息緩存队列 id; 判断该 M2M终端消息緩存队列 id 若不存在, 则扫描是否已经有该 M2M终端消息緩存队列 id的緩存文件, 若有, 则获取緩存文件的起始、 结束编号, 生成新建的该 M2M终端消息緩 存队列的信息, 其中填入緩存文件的起始和结束编号; 将新建的该 M2M终 端消息緩存队列的信息加入緩存队列管理信息。  The create and generate management information module initiates a request to create an M2M terminal message cache queue, which includes an M2M terminal message cache queue id; and determines whether the M2M terminal message cache queue id does not exist, and then scans whether the M2M terminal message cache queue id is already present. The cache file, if any, obtains the start and end numbers of the cache file, generates the newly created information of the M2M terminal message cache queue, and fills in the start and end numbers of the cache file; the newly created M2M terminal message cache The information of the queue is added to the cache queue management information.
优选的, 上述系统还可包括, 所述消息储存模块根据接收的所述緩存 队列管理信息,通过内存緩存方式和文件緩存方式将 M2M终端上 的消息 存入对应的 M2M终端消息緩存队列, 具体是指: 所述消息储存模块收到 M2M终端上 的消息, 判断需要插入的 M2M 终端消息緩存队列如果合法,则判断该 M2M终端消息緩存队列若存在緩存 文件, 则根据所述緩存队列管理信息, 判断当前緩存文件是否需要创建新 的緩存文件, 如果是, 则根据所述緩存队列管理信息生成一新的緩存文件, 将所述 M2M终端上报的消息写入生成的该新的緩存文件的空闲空间头部, 否则将所述 M2M终端上报的消息写入所述緩存文件的空闲空间头部; Preferably, the system may further include: the message storage module, according to the received cache queue management information, storing the message on the M2M terminal into the corresponding M2M terminal message cache queue by using a memory cache mode and a file cache manner, specifically Means: The message storage module receives the message on the M2M terminal, and determines that the M2M terminal message cache queue to be inserted is legal, if it is determined that the cache file exists in the M2M terminal message cache queue, the current cache is determined according to the cache queue management information. Whether the file needs to create a new cache file, if yes, generate a new cache file according to the cache queue management information, and write the message reported by the M2M terminal to the free space header of the generated new cache file. Otherwise, the message reported by the M2M terminal is written to the free space header of the cache file;
判断该 M2M终端消息緩存队列若不存在緩存文件, 则判断所述 M2M 终端消息緩存队列中是否有空闲的内存块, 若有, 则将所述 M2M终端上报 的消息拷贝到所述内存块队尾保存; 否则根据所述緩存队列管理信息, 判 断该 M2M终端消息緩存队列是否可以新建内存块,如果是, 则申请一内存 块,将内存地址加入所述緩存队列管理信息, 并将该 M2M终端上报的消息 拷贝到该内存块保存。  Determining, if there is no cache file in the M2M terminal message cache queue, determining whether there is a free memory block in the M2M terminal message cache queue, and if yes, copying the message reported by the M2M terminal to the end of the memory block If the cache queue management information is used, it is determined whether the M2M terminal message cache queue can create a new memory block. If yes, apply for a memory block, add the memory address to the cache queue management information, and report the M2M terminal. The message is copied to the memory block and saved.
优选的, 上述系统还可包括, 所述消息提取模块根据接收的所述緩存 队列管理信息,通过内存緩存方式和文件緩存方式将 M2M终端的消息从对 应的 M2M终端消息緩存队列中取出, 具体是指:  Preferably, the system may further include: the message extraction module, according to the received cache queue management information, the M2M terminal message is taken out from the corresponding M2M terminal message cache queue by using a memory cache mode and a file cache mode, specifically Means:
所述消息提取模块判断需要提取的 M2M终端消息緩存队列如果合法, 则判断提取的当前 M2M终端消息緩存队列若存在有内存块的緩存,则从内 存块中提取 M2M终端的消息,判断提取的 M2M终端的消息若已达到预设 的 M2M终端的消息的条数, 则退出, 否则判断该 M2M终端消息緩存队列 中若已经没有消息, 则退出;  If the message extraction module determines that the M2M terminal message cache queue to be extracted is legal, it determines that the extracted current M2M terminal message cache queue has a memory block cache, and then extracts the M2M terminal message from the memory block to determine the extracted M2M. If the message of the terminal has reached the preset number of messages of the M2M terminal, exit, otherwise, if the M2M terminal message cache queue has no message, exit;
判断提取的当前 M2M终端消息緩存队列若没有存在内存块的緩存,则 判断所述 M2M终端消息緩存队列若存在緩存文件,则打开文件编号最小的 一緩存文件,读取该緩存文件内容, 并拷贝该緩存文件内容到所述 M2M终 端消息緩存队列的第一个内存块中; 从内存块中提取 M2M终端的消息, 判 断提取的 M2M终端的消息若已达到预设的 M2M终端的消息的条数,则退 出, 否则判断该 M2M终端消息緩存队列中若已经没有消息, 则退出。 Determining, if there is no cache of the memory block in the current M2M terminal message cache queue, determining that the cache file exists in the M2M terminal message cache queue, opening a cache file with the smallest file number, reading the cache file content, and copying The content of the cache file is sent to the first memory block of the M2M terminal message cache queue. The message of the M2M terminal is extracted from the memory block, and the number of messages of the M2M terminal that has been reached by the preset M2M terminal is determined. Retreat If yes, it is judged that if there is no message in the M2M terminal message buffer queue, it will exit.
优选的, 上述系统还可包括, 所述创建生成管理信息模块中所述緩存 队列管理信息, 包括: M2M系统应用的 M2M緩存配置信息、 M2M系统中 所有正使用的 M2M终端消息緩存队列的信息以及所有 M2M消息緩存队列 链表首地址信息; 其中, M2M緩存配置信息包括所有緩存队列最大允许使 用内存量、 每条队列最大记录条数、 同一类型緩存允许的内存块个数、 内 存块释放规则和緩存文件保存路径信息。  Preferably, the system may further include: the cache queue management information in the creating and generating management information module, including: M2M cache configuration information of the M2M system application, information of all M2M terminal message cache queues being used in the M2M system, and All M2M message cache queue list first address information; wherein, M2M cache configuration information includes the maximum allowable memory size of all cache queues, the maximum number of records per queue, the number of memory blocks allowed by the same type of cache, the memory block release rules, and the cache. File save path information.
与现有技术相比, 本发明实施例结合内存与文件存储緩存的两种方式, 使用内存块为基本单位进行内存的申请、 释放, 一方面即提供了内存这种 高速存取的能力, 又避免了频繁进行内存申请、 释放所带来的系统消耗, 另外使用文件作为扩展的存储方式, 使该方法理论上可以保存无限的与 M2M终端交互的消息,保存容量只与物理硬盘大小有关,既可提供高效率、 无限制的緩存空间的同时又能提高内存利用率, 不造成物理内存空间的浪 费。。 附图说明  Compared with the prior art, the embodiment of the present invention combines the memory and the file storage cache in two ways, and uses the memory block as a basic unit to apply and release the memory, and on the one hand, provides the high-speed access capability of the memory, and It avoids the system consumption caused by frequent memory application and release, and uses the file as an extended storage method, so that the method can theoretically save unlimited messages interacting with the M2M terminal, and the storage capacity is only related to the size of the physical hard disk. It provides high efficiency and unlimited cache space while improving memory utilization without wasting physical memory space. . DRAWINGS
图 1 是本发明实施例中緩存在 M2M系统中的存储位置示意图; 图 2是本发明实施例所述物联网系统中緩存的控制方法的流程图; 图 3是本发明实施例所述创建一 M2M终端消息緩存队列的流程图; 图 4是本发明实施例中 M2M终端消息入队列的流程图;  1 is a schematic diagram of a storage location cached in an M2M system according to an embodiment of the present invention; FIG. 2 is a flowchart of a method for controlling a cache in an Internet of Things system according to an embodiment of the present invention; Figure 2 is a flow chart of the M2M terminal message buffer queue; Figure 4 is a flowchart of the M2M terminal message entering the queue in the embodiment of the present invention;
图 5是本发明实施例中 M2M终端消息出队列的流程图;  5 is a flowchart of a M2M terminal message out queue in the embodiment of the present invention;
图 6是本发明实施例所述物联网系统的结构示意图。 具体实施方式  FIG. 6 is a schematic structural diagram of an Internet of Things system according to an embodiment of the present invention. detailed description
下面结合附图和具体实施方式对本发明作进一步说明。  The invention is further described below in conjunction with the drawings and specific embodiments.
本发明实施例的物联网系统中允许建立多个 M2M终端消息緩存队列, 所有 M2M终端消息緩存队列的信息以一个双向链表来进行管理,每个队列 对应一种 M2M终端上报消息, 每个队列都可以使用内存 +文件的方式存储 M2M终端上报消息, 系统以内存使用块作为单位进行管理, 内存的申请、 释放都以单个内存块为单位, 有效的提高了内存利用率; 緩存文件的大小 与内存块大小一致, 当需要从文件中获取消息时, 釆用将整个文件映射入 内存的方式处理, 以后再次获取该文件中的消息时, 则从内存中处理, 不 再操作緩存文件, 提高了访问效率。 其中, 系统将緩存文件大小与内存块 大小设计成一致, 可以有效的提高从文件到内存的映射拷贝工作, 当需要 进行 M2M緩存文件到 M2M緩存内存块拷贝时, 只需要对文件进行一次二 进制读取, 然后拷贝到内存块中即可, 提高了文件到内存的内容复制效率; 系统中文件命名规则是通过 M2M消息緩存队列 id文件编号,文件编号从 0 开始累加, 这样就保证了系统对文件保存有先进先出的顺序。 In the Internet of Things system of the embodiment of the present invention, multiple M2M terminal message buffer queues are allowed to be established. The information of all M2M terminal message buffer queues is managed by a doubly linked list. Each queue corresponds to a M2M terminal reporting message. Each queue can store M2M terminal reporting messages by using memory + file. The system uses memory blocks as memory. The unit manages, and the application and release of the memory are all in a single memory block, which effectively improves the memory utilization; the size of the cache file is consistent with the size of the memory block, and when the message needs to be obtained from the file, the entire file is mapped. When it is processed into memory, when the message in the file is obtained again in the future, it is processed from the memory, and the cache file is no longer operated, thereby improving the access efficiency. The system designs the cache file size and the memory block size to be consistent, which can effectively improve the mapping copy from file to memory. When the M2M cache file needs to be copied to the M2M cache memory block, only one binary read of the file is required. Take, and then copy to the memory block, improve the file-to-memory content replication efficiency; the file naming rules in the system is through the M2M message cache queue id file number, the file number is accumulated from 0, thus ensuring the system to the file Save in FIFO order.
所述緩存队列管理信息, 包括: M2M系统应用的 M2M緩存配置信息、 M2M 系统中所有正使用的 M2M终端消息緩存队列的信息以及所有 M2M 消息緩存队列链表首地址信息。 其中, M2M緩存配置信息包括所有緩存队 列最大允许使用内存量、 每条队列最大记录条数、 同一类型緩存允许的内 存块个数、 内存块释放规则和緩存文件保存路径信息。 上述信息在系统初 始化时设置。  The cache queue management information includes: M2M cache configuration information of the M2M system application, information of all M2M terminal message cache queues used in the M2M system, and first M2M message cache queue list first address information. The M2M cache configuration information includes the maximum allowed memory size of all cache queues, the maximum number of records per queue, the number of memory blocks allowed by the same type of cache, the memory block release rule, and the cache file save path information. The above information is set when the system is initialized.
其中, 所述创建一 M2M终端消息緩存队列的流程, 主要设置以下一些 队列的配置信息: M2M终端消息队列 id, M2M终端消息队列中单条消息 长度, M2M终端消息内存使用相关信息, 即最多可使用多少个 M2M服务 器緩存内存块, M2M 终端消息文件使用相关信息, 即文件的起始编号, M2M终端消息当前队列的前后队列双向链表的指针等信息。 M2M终端消 息的单一队列里每条消息都按定长保存, 每个队列可以包含 1到 N个内存 块的内存緩存和无限制文件个数的文件緩存。 在系统中緩存、 队列、 内存、 内存块、 和文件之间的关系可以如图 1所示, M2M服务器中存在一个緩存 模块, 一个緩存模块中可以有多个緩存队列, 每个緩存队列都以内存緩存 方式 + 文件緩存方式存储 M2M终端上报的消息,其中内存部分又以块方式 管理。 The process of creating an M2M terminal message buffer queue mainly includes setting configuration information of the following queues: M2M terminal message queue id, single message length in the M2M terminal message queue, and M2M terminal message memory usage related information, that is, the maximum useable How many M2M servers cache memory blocks, M2M terminal message files use related information, that is, the start number of the file, the pointer of the M2M terminal message, the pointer of the current queue before and after the queue, and so on. Each message in a single queue of M2M terminal messages is stored at a fixed length. Each queue can contain a memory cache of 1 to N memory blocks and a file cache of unlimited files. Caching, queues, memory, The relationship between the memory block and the file can be as shown in Figure 1. There is a cache module in the M2M server. There can be multiple cache queues in one cache module. Each cache queue stores M2M in memory cache mode + file cache mode. The message reported by the terminal, wherein the memory portion is managed in blocks.
其中, 所述消息入緩存队列处理流程控制 M2M 服务器接口层将从 M2M终端接收到的消息存入对应的 M2M终端消息队列中 , 选取 M2M终 端上报消息对应的队列 id,根据该緩存队列管理信息,将 M2M终端上报的 消息插入到对应队列的内存或者文件緩存的尾部, 其中涉及内存块的申请 和緩存文件的生成等操作。  The message in-cache queue processing flow controls the M2M server interface layer to store the message received from the M2M terminal in the corresponding M2M terminal message queue, and selects the queue id corresponding to the M2M terminal reporting message, according to the cache queue management information, The message reported by the M2M terminal is inserted into the memory of the corresponding queue or the end of the file cache, which involves operations such as requesting a memory block and generating a cache file.
其中,所述消息出緩存队列处理流程控制 M2M服务器消息处理应用将 消息从系统的 M2M终端消息队列中取出, 选取 M2M终端上报消息对应的 队列 id,根据该緩存队列管理信息,从当前正在操作的 M2M终端消息队列 的内存块前端取出消息,返回给 M2M服务器消息处理应用, 消息出緩存队 列处理流程涉及系统中 M2M 终端消息队列的緩存文件到緩存内存块的拷 贝和内存块的释放等操作。  The message out cache queue processing flow controls the M2M server message processing application to take the message out of the M2M terminal message queue of the system, select the queue id corresponding to the M2M terminal report message, and according to the cache queue management information, from the currently operating The memory block front end of the M2M terminal message queue takes out the message and returns it to the M2M server message processing application. The message out cache queue processing process involves operations such as copying the cache file of the M2M terminal message queue to the cache memory block and releasing the memory block in the system.
图 2所示为本发明实施例所述物联网系统中緩存的控制方法流程示意 图, 如图 2所示, 该方法包括以下步骤:  FIG. 2 is a schematic flowchart of a method for controlling a cache in an Internet of Things system according to an embodiment of the present invention. As shown in FIG. 2, the method includes the following steps:
步骤 100、 物联网系统创建一 M2M终端消息緩存队列, 并将生成后的 该 M2M终端消息緩存队列的信息加入緩存队列管理信息;  Step 100: The IoT system creates a M2M terminal message cache queue, and adds the generated information of the M2M terminal message cache queue to the cache queue management information.
图 3是本发明实施例所述创建一 M2M终端消息緩存队列的流程图,如 图 3所示, 创建一 M2M终端消息緩存队列具体包括以下步骤:  FIG. 3 is a flowchart of creating a M2M terminal message cache queue according to an embodiment of the present invention. As shown in FIG. 3, creating a M2M terminal message cache queue specifically includes the following steps:
步骤 301、 所述系统通过接口层应用发起一创建 M2M终端消息緩存队 列请求, 其中包含 M2M终端消息緩存队列 id;  Step 301: The system initiates an M2M terminal message cache queue request by using an interface layer application, where the M2M terminal message cache queue id is included;
步骤 302、所述系统判断该 M2M终端消息緩存队列 id是否存在,如果 是, 则结束流程, 否则, 执行步骤 303; 步骤 303、 扫描是否已经有该 M2M终端消息緩存队列 id的緩存文件, 若有, 则获取緩存文件的起始和结束编号, 生成新建的该 M2M终端消息緩 存队列的信息, 其中填入緩存文件的起始和结束编号; Step 302, the system determines whether the M2M terminal message cache queue id exists, and if so, the process ends; otherwise, step 303 is performed; Step 303: Scan whether there is already a cache file of the M2M terminal message cache queue id, and if yes, obtain the start and end numbers of the cache file, and generate information of the newly created M2M terminal message cache queue, where the cache file is filled. Start and end numbers;
步骤 304、 所述系统将新建的该 M2M终端消息緩存队列的信息加入緩 存队列管理信息。  Step 304: The system adds the newly added information of the M2M terminal message cache queue to the cache queue management information.
所述系统是将新建的该 M2M 终端消息緩存队列的信息加入緩存队列 管理信息中 M2M终端消息緩存队列双向链表。  The system adds the newly added information of the M2M terminal message cache queue to the M2M terminal message buffer queue doubly linked list in the cache queue management information.
步骤 200、 系统根据所述緩存队列管理信息, 通过内存緩存方式和文件 緩存方式将 M2M终端上 ^艮的消息存入对应的 M2M终端消息緩存队列, 或 者将 M2M终端的消息从对应的 M2M终端消息緩存队列中取出。  Step 200: The system stores the message on the M2M terminal in the corresponding M2M terminal message cache queue, or the M2M terminal message from the corresponding M2M terminal message, according to the cache queue management information, by using the memory cache mode and the file cache mode. Take it out of the cache queue.
如图 4所示, 系统根据所述緩存队列管理信息, 通过内存緩存方式和 文件緩存方式将 M2M终端上 ^艮的消息存入对应的 M2M终端消息緩存队列 的流程, 具体包括以下步骤:  As shown in FIG. 4, the system saves the message of the M2M terminal to the corresponding M2M terminal message cache queue by using the memory cache mode and the file cache mode according to the cache queue management information, and specifically includes the following steps:
步骤 400、所述系统收到 M2M终端上报的消息,判断需要插入的 M2M 终端消息緩存队列合法,则进一步判断该 M2M终端消息緩存队列是否已经 存在緩存文件, 如果有, 则执行步骤 402; 否则执行步骤 401 ;  Step 400: The system receives the message reported by the M2M terminal, determines that the M2M terminal message cache queue to be inserted is legal, and further determines whether the cache file exists in the M2M terminal message cache queue. If yes, step 402 is performed; Step 401;
步骤 401、 所述系统判断所述 M2M终端消息緩存队列中是否有空闲的 内存块, 如果有, 则执行步骤 403; 否则执行步骤 404;  Step 401: The system determines whether there is a free memory block in the M2M terminal message cache queue, if yes, step 403 is performed; otherwise, step 404 is performed;
步骤 402、 所述系统根据所述緩存队列管理信息, 判断当前緩存文件是 否需要创建新的緩存文件, 如果是, 则根据所述緩存队列管理信息生成一 新的緩存文件,将所述 M2M终端上 的消息写入生成的该新的緩存文件的 空闲空间头部, 退出流程; 否则将所述 M2M终端上 的消息写入所述緩存 文件的空闲空间头部, 退出流程;  Step 402: The system determines, according to the cache queue management information, whether a current cache file needs to create a new cache file, and if yes, generates a new cache file according to the cache queue management information, where the M2M terminal is The message is written to the free space header of the generated new cache file, and the process is exited; otherwise, the message on the M2M terminal is written into the free space header of the cache file, and the process is exited;
步骤 403、 所述系统将所述 M2M终端上报的消息拷贝到所述内存块队 尾保存, 退出流程; 步骤 404、 所述系统根据所述緩存队列管理信息, 判断该 M2M终端消 息緩存队列是否新建内存块, 如果是, 则申请一内存块, 将内存地址加入 所述緩存队列管理信息中 M2M终端消息緩存队列双向链表, 并将该 M2M 终端上报的消息拷贝到该内存块保存, 退出流程; 否则执行步骤 402。 Step 403: The system copies the message reported by the M2M terminal to the end of the memory block, and exits the process. Step 404: The system determines, according to the cache queue management information, whether the M2M terminal message cache queue is a new memory block. If yes, apply for a memory block, and add the memory address to the cache queue management information in the M2M terminal message cache. Queue the doubly linked list, and copy the message reported by the M2M terminal to the memory block to save, and exit the process; otherwise, go to step 402.
如图 5 所示, 系统根据所述緩存队列管理信息, 通过内存緩存方式和 文件緩存方式将 M2M终端的消息从对应的 M2M终端消息緩存队列中取出 的流程, 具体包括以下步骤:  As shown in FIG. 5, the process of taking the M2M terminal message from the corresponding M2M terminal message cache queue by using the memory cache mode and the file cache mode according to the cache queue management information includes the following steps:
步骤 500、所述系统判断需要提取的 M2M终端消息緩存队列如果合法, 则执行步骤 501 ;  Step 500: If the system determines that the M2M terminal message cache queue to be extracted is legal, step 501 is performed;
步骤 501、 所述系统判断提取的当前 M2M终端消息緩存队列是否存在 有内存块的緩存, 如果是, 则执行步骤 504, 否则执行步骤 502;  Step 501: The system determines whether there is a cache of a memory block in the current M2M terminal message cache queue, and if yes, step 504 is performed, otherwise step 502 is performed;
步骤 502、 所述系统判断所述 M2M终端消息緩存队列是否存在緩存文 件, 如果是, 则执行步骤 503 , 否则退出流程;  Step 502: The system determines whether the cache file exists in the M2M terminal message cache queue. If yes, step 503 is performed; otherwise, the process is exited;
步骤 503、 所述系统以二进制方式打开文件编号最小的一緩存文件,读 取该緩存文件内容,并拷贝该緩存文件内容到所述 M2M终端消息緩存队列 的第一个内存块中;  Step 503: The system opens a cache file with the smallest file number in a binary manner, reads the cache file content, and copies the cache file content into the first memory block of the M2M terminal message cache queue.
步骤 504、 所述系统从内存块中提取 M2M 终端的消息, 判断提取的 M2M终端的消息是否达到预设的 M2M终端消息的条数, 如果是, 则退出 流程, 否则执行步骤 505;  Step 504: The system extracts the message of the M2M terminal from the memory block, and determines whether the message of the extracted M2M terminal reaches the preset number of M2M terminal messages, and if yes, exits the process, otherwise step 505 is performed;
步骤 505、 所述系统判断该 M2M终端消息緩存队列中是否已经没有消 息, 如果是, 则退出流程, 否则执行步骤 501。  Step 505: The system determines whether there is no message in the M2M terminal message buffer queue. If yes, the process is exited. Otherwise, step 501 is performed.
图 6是本发明实施例所述物联网系统的结构示意图, 如图 6所示, 一 种物联网系统, 包括: 创建生成管理信息模块、 消息储存模块和消息提取 模块, 其中,  6 is a schematic structural diagram of an Internet of Things system according to an embodiment of the present invention. As shown in FIG. 6, an Internet of Things system includes: creating a generation management information module, a message storage module, and a message extraction module, where
所述创建生成管理信息模块,用于创建一物联网 M2M终端消息緩存队 列, 并将生成后的该 M2M 终端消息緩存队列的信息加入緩存队列管理信 息, 并发送给所述消息储存模块和所述消息提取模块; The creating a management information module is used to create an Internet of Things M2M terminal message cache team Columns, and the information of the generated M2M terminal message buffer queue is added to the cache queue management information, and sent to the message storage module and the message extraction module;
所述消息储存模块, 用于根据接收的所述緩存队列管理信息, 通过内 存緩存方式和文件緩存方式将 M2M终端上 ^艮的消息存入对应的 M2M终端 消息緩存队列;  The message storage module is configured to store the message on the M2M terminal into the corresponding M2M terminal message cache queue according to the received cache queue management information by using a cache mode and a file cache mode;
所述消息提取模块, 用于根据接收的所述緩存队列管理信息, 通过内 存緩存方式和文件緩存方式将 M2M终端的消息从对应的 M2M终端消息緩 存队列中取出。  The message extraction module is configured to: according to the received cache queue management information, the M2M terminal message is taken out from the corresponding M2M terminal message cache queue by using a cache mode and a file cache mode.
所述创建生成管理信息模块创建一 M2M终端消息緩存队列,并将生成 后的该 M2M终端消息緩存队列的信息加入緩存队列管理信息, 具体是指: 所述创建生成管理信息模块发起一创建 M2M终端消息緩存队列请求, 其中包含 M2M终端消息緩存队列 id; 判断该 M2M终端消息緩存队列 id 若不存在, 则扫描是否已经有该 M2M终端消息緩存队列 id的緩存文件, 若有, 则获取緩存文件的起始、 结束编号, 生成新建的该 M2M终端消息緩 存队列的信息, 其中填入緩存文件的起始和结束编号; 将新建的该 M2M终 端消息緩存队列的信息加入緩存队列管理信息。  The creating a management information module creates an M2M terminal message cache queue, and adds the generated information of the M2M terminal message cache queue to the cache queue management information, specifically: the creating and generating a management information module initiates a creation of an M2M terminal. a message cache queue request, which includes an M2M terminal message cache queue id; determining that the M2M terminal message cache queue id does not exist, then scanning whether the M2M terminal message cache queue id cache file exists, and if so, acquiring the cache file The start and end numbers are generated, and the newly created information of the M2M terminal message cache queue is filled in, and the start and end numbers of the cache file are filled in; the newly added information of the M2M terminal message cache queue is added to the cache queue management information.
所述消息储存模块根据接收的所述緩存队列管理信息, 通过内存緩存 方式和文件緩存方式将 M2M终端上 ^艮的消息存入对应的 M2M终端消息緩 存队列, 具体是指:  The message storage module stores the message on the M2M terminal in the corresponding M2M terminal message cache queue according to the received cache queue management information, by means of a memory cache mode and a file cache mode, specifically:
所述消息储存模块收到 M2M终端上 的消息, 判断需要插入的 M2M 终端消息緩存队列如果合法,则判断该 M2M终端消息緩存队列若存在緩存 文件, 则根据所述緩存队列管理信息, 判断当前緩存文件是否需要创建新 的緩存文件, 如果是, 则根据所述緩存队列管理信息生成一新的緩存文件, 将所述 M2M终端上报的消息写入生成的该新的緩存文件的空闲空间头部, 否则将所述 M2M终端上报的消息写入所述緩存文件的空闲空间头部; 判断该 M2M终端消息緩存队列若不存在緩存文件, 则判断所述 M2M 终端消息緩存队列中是否有空闲的内存块, 若有, 则将所述 M2M终端上报 的消息拷贝到所述内存块队尾保存; 否则根据所述緩存队列管理信息, 判 断该 M2M终端消息緩存队列是否新建内存块, 如果是, 则申请一内存块, 将内存地址加入所述緩存队列管理信息,并将该 M2M终端上报的消息拷贝 到该内存块保存。 The message storage module receives the message on the M2M terminal, and determines that the M2M terminal message cache queue to be inserted is legal, if it is determined that the cache file exists in the M2M terminal message cache queue, the current cache is determined according to the cache queue management information. Whether the file needs to create a new cache file, if yes, generate a new cache file according to the cache queue management information, and write the message reported by the M2M terminal to the free space header of the generated new cache file. Otherwise, the message reported by the M2M terminal is written to the free space header of the cache file; Determining, if there is no cache file in the M2M terminal message cache queue, determining whether there is a free memory block in the M2M terminal message cache queue, and if yes, copying the message reported by the M2M terminal to the end of the memory block If the M2M terminal message cache queue is newly created, the memory module is requested to be added to the cache queue management information, and the memory address is added to the cache queue management information, and the M2M terminal is reported. The message is copied to the memory block and saved.
所述消息提取模块根据接收的所述緩存队列管理信息, 通过内存緩存 方式和文件緩存方式将 M2M终端的消息从对应的 M2M终端消息緩存队列 中取出, 具体是指:  The message extraction module extracts the message of the M2M terminal from the corresponding M2M terminal message cache queue according to the received cache queue management information by using the memory cache mode and the file cache mode, which specifically refers to:
所述消息提取模块判断需要提取的 M2M终端消息緩存队列如果合法, 则判断提取的当前 M2M终端消息緩存队列若存在有内存块的緩存,则从内 存块中提取 M2M终端的消息,判断提取的 M2M终端的消息若已达到预设 的 M2M终端的消息的条数, 则退出, 否则判断该 M2M终端消息緩存队列 中若已经没有消息, 则退出;  If the message extraction module determines that the M2M terminal message cache queue to be extracted is legal, it determines that the extracted current M2M terminal message cache queue has a memory block cache, and then extracts the M2M terminal message from the memory block to determine the extracted M2M. If the message of the terminal has reached the preset number of messages of the M2M terminal, exit, otherwise, if the M2M terminal message cache queue has no message, exit;
判断提取的当前 M2M终端消息緩存队列若没有存在内存块的緩存,则 判断所述 M2M终端消息緩存队列若存在緩存文件,则打开文件编号最小的 一緩存文件,读取该緩存文件内容, 并拷贝该緩存文件内容到所述 M2M终 端消息緩存队列的第一个内存块中; 从内存块中提取 M2M终端的消息, 判 断提取的 M2M终端的消息若已达到预设的 M2M终端的消息的条数,则退 出, 否则判断该 M2M终端消息緩存队列中若已经没有消息, 则退出。  Determining, if there is no cache of the memory block in the current M2M terminal message cache queue, determining that the cache file exists in the M2M terminal message cache queue, opening a cache file with the smallest file number, reading the cache file content, and copying The content of the cache file is sent to the first memory block of the M2M terminal message cache queue. The message of the M2M terminal is extracted from the memory block, and the number of messages of the M2M terminal that has been reached by the preset M2M terminal is determined. , then exit, otherwise it is judged that if there is no message in the M2M terminal message buffer queue, it will exit.
所述创建生成管理信息模块中所述緩存队列管理信息, 包括: M2M系 统应用的 M2M緩存配置信息、 M2M系统中所有正使用的 M2M终端消息 緩存队列的信息以及所有 M2M消息緩存队列链表首地址信息;其中, M2M 緩存配置信息包括所有緩存队列最大允许使用内存量、 每条队列最大记录 条数、 同一类型緩存允许的内存块个数、 内存块释放规则和緩存文件保存 路径信息。 The cache queue management information in the creation and management information module includes: M2M cache configuration information of the M2M system application, information of all M2M terminal message cache queues used in the M2M system, and first address information of all M2M message cache queue list entries. The M2M cache configuration information includes the maximum allowed memory size of all cache queues, the maximum number of records per queue, the number of memory blocks allowed by the same type of cache, the memory block release rules, and the cache file save. Path information.
本发明实施例所述的在 M2M服务器应用中处理海量消息的高速緩存 方法, 结合了内存与文件存储緩存的两种方式, 使用内存块为基本单位进 行内存的申请、 释放, 一方面即提供了内存这种高速存取的能力, 又避免 了频繁进行内存申请、 释放所带来的系统消耗, 另外使用文件作为扩展的 存储方式,使该方法理论上可以保存无限的与 M2M终端交互的消息,保存 容量只与物理硬盘大小有关。  The cache method for processing massive messages in an M2M server application according to an embodiment of the present invention combines two methods of memory and file storage cache, and uses a memory block as a basic unit for memory application and release, which is provided on the one hand The high-speed access capability of memory avoids the system consumption caused by frequent memory application and release. In addition, the file is used as an extended storage method, so that the method can theoretically save unlimited messages interacting with the M2M terminal. The storage capacity is only related to the physical hard disk size.
以上所述, 仅为本发明较佳的具体实施方式, 但本发明的保护范围并 不局限于此, 任何熟悉该技术的人在本发明所揭露的技术范围内, 可轻易 想到的变化或替换, 都应涵盖在本发明的保护范围之内。 因此, 本发明的 保护范围应该以权利要求的保护范围为准。  The above is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope of the present invention. All should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the claims.

Claims

权利要求书 Claim
1、 一种物联网系统中緩存的控制方法, 其特征在于, 该方法包括: 物联网系统创建一物联网 M2M终端消息緩存队列,并将生成后的所述 A method for controlling a cache in an Internet of Things system, the method comprising: the Internet of Things system creates an Internet of Things M2M terminal message cache queue, and generates the generated
M2M终端消息緩存队列的信息加入緩存队列管理信息; The information of the M2M terminal message buffer queue is added to the cache queue management information;
所述系统根据所述緩存队列管理信息, 通过内存緩存方式和文件緩存 方式将 M2M终端上报的消息存入对应的 M2M终端消息緩存队列, 或者, 将 M2M终端的消息从对应的 M2M终端消息緩存队列中取出。  The system stores the message reported by the M2M terminal in the corresponding M2M terminal message buffer queue according to the cache queue management information, or the M2M terminal message cache queue from the corresponding M2M terminal message cache queue. Take out.
2、如权利要求 1所述的控制方法, 其特征在于, 所述系统创建一 M2M 终端消息緩存队列,并将生成后的该 M2M终端消息緩存队列的信息加入緩 存队列管理信息为:  The control method according to claim 1, wherein the system creates an M2M terminal message buffer queue, and adds the generated information of the M2M terminal message buffer queue to the cache queue management information as:
所述系统发起一创建 M2M终端消息緩存队列请求, 其中包含 M2M终 端消息緩存队列 id;  The system initiates a request to create an M2M terminal message cache queue, which includes an M2M terminal message cache queue id;
所述系统判断该 M2M终端消息緩存队列 id不存在, 则扫描是否已经 有该 M2M终端消息緩存队列 id的緩存文件,已经有该 M2M终端消息緩存 队列 id 的緩存文件, 则获取緩存文件的起始、 结束编号, 生成新建的该 M2M终端消息緩存队列的信息, 其中填入緩存文件的起始和结束编号; 所述系统将新建的该 M2M 终端消息緩存队列的信息加入緩存队列管 理信息。  The system determines that the M2M terminal message cache queue id does not exist, and scans whether there is already a cache file of the M2M terminal message cache queue id, and if the M2M terminal message cache queue id has a cache file, the start of the cache file is obtained. And ending the number, generating the newly created information of the M2M terminal message cache queue, and filling in the start and end numbers of the cache file; the system adds the newly added information of the M2M terminal message cache queue to the cache queue management information.
3、 如权利要求 2所述的控制方法, 其特征在于, 所述系统根据所述緩 存队列管理信息,通过内存緩存方式和文件緩存方式将 M2M终端上 的消 息存入对应的 M2M终端消息緩存队列为:  The control method according to claim 2, wherein the system stores the message on the M2M terminal into the corresponding M2M terminal message buffer queue by using the memory cache mode and the file cache mode according to the cache queue management information. For:
所述系统收到 M2M终端上报的消息, 判断需要插入的 M2M终端消息 緩存队列合法,则进一步判断所述 M2M终端消息緩存队列是否已经存在緩 存文件, 所述 M2M终端消息緩存队列已经存在緩存文件, 则执行步骤 a2; 否则执行步骤 al ; 步骤 al、 所述系统判断所述 M2M终端消息緩存队列中是否有空闲的 内存块, 所述 M2M终端消息緩存队列中有空闲的内存块, 则执行步骤 a3; 否则执行步骤 a4; The system receives the message reported by the M2M terminal, determines that the M2M terminal message cache queue to be inserted is legal, and further determines whether the cache file exists in the M2M terminal message cache queue, and the cache file exists in the M2M terminal message cache queue. Then perform step a2; otherwise, perform step a1; Step a, the system determines whether there is a free memory block in the M2M terminal message buffer queue, and there is a free memory block in the M2M terminal message buffer queue, then step a3 is performed; otherwise, step a4 is performed;
步骤 a2、 所述系统根据所述緩存队列管理信息, 判断当前緩存文件是 否需要创建新的緩存文件, 当前緩存文件需要创建新的緩存文件, 则根据 所述緩存队列管理信息生成一新的緩存文件,将所述 M2M终端上报的消息 写入生成的该新的緩存文件的空闲空间头部, 退出流程; 否则将所述 M2M 终端上报的消息写入所述緩存文件的空闲空间头部, 退出流程;  Step a2: The system determines, according to the cache queue management information, whether the current cache file needs to create a new cache file, and the current cache file needs to create a new cache file, and generates a new cache file according to the cache queue management information. The message reported by the M2M terminal is written to the free space header of the generated new cache file, and the process is exited; otherwise, the message reported by the M2M terminal is written into the free space header of the cache file, and the process is exited. ;
步骤 a3、 所述系统将所述 M2M终端上报的消息拷贝到所述内存块队 尾保存, 退出流程;  Step a3: The system copies the message reported by the M2M terminal to the end of the memory block, and exits the process;
步骤 a4、 所述系统根据所述緩存队列管理信息, 判断该 M2M终端消 息緩存队列是否可以新建内存块,该 M2M终端消息緩存队列可以新建内存 块,则申请一内存块,将内存地址加入所述緩存队列管理信息,并将该 M2M 终端上报的消息拷贝到该内存块保存, 退出流程; 否则执行步骤 a2。  Step a4: The system determines, according to the cache queue management information, whether the M2M terminal message cache queue can create a new memory block, and the M2M terminal message cache queue can create a new memory block, and then apply for a memory block, and add the memory address to the The queue management information is cached, and the message reported by the M2M terminal is copied to the memory block to be saved, and the process is exited; otherwise, step a2 is performed.
4、 如权利要求 2所述的控制方法, 其特征在于, 所述系统根据所述緩 存队列管理信息,通过内存緩存方式和文件緩存方式将 M2M终端的消息从 对应的 M2M终端消息緩存队列中取出为:  The control method according to claim 2, wherein the system extracts the M2M terminal message from the corresponding M2M terminal message cache queue by using the memory cache mode and the file cache mode according to the cache queue management information. For:
所述系统判断需要提取的 M2M 终端消息緩存队列合法, 则执行步骤 b0;  The system determines that the M2M terminal message buffer queue to be extracted is legal, and then performs step b0;
步骤 b0、 所述系统判断提取的当前 M2M终端消息緩存队列是否存在 有内存块的緩存, 当前 M2M终端消息緩存队列存在有内存块的緩存, 则执 行步骤 b3 , 否则执行步骤 bl ;  Step b0: The system determines whether there is a cache of the memory block in the current M2M terminal message cache queue. If there is a memory block cache in the current M2M terminal message cache queue, step b3 is performed, otherwise step bl is performed;
步骤 bl、 所述系统判断所述 M2M终端消息緩存队列是否存在緩存文 件, 如果是, 所述 M2M终端消息緩存队列存在緩存文件, 则执行步骤 b2, 否则退出流程; 步骤 b2、 所述系统打开文件编号最小的一緩存文件, 读取该緩存文件 内容,并拷贝该緩存文件内容到所述 M2M终端消息緩存队列的第一个内存 块中; Step bl, the system determines whether the cache file exists in the M2M terminal message cache queue. If yes, the M2M terminal message cache queue has a cache file, and step b2 is performed; otherwise, the process is exited; Step b2: The system opens a cache file with the smallest file number, reads the cache file content, and copies the cache file content into the first memory block of the M2M terminal message cache queue;
步骤 b3、 所述系统从内存块中提取 M2M 终端的消息, 判断提取的 M2M终端的消息是否达到预设的 M2M终端的消息的条数, M2M终端的消 息达到预设的 M2M终端的消息的条数, 则退出流程, 否则进一步判断所述 M2M终端消息緩存队列中是否已经没有消息, M2M终端消息緩存队列中 已经没有消息, 则退出流程, 否则执行步骤 b0。  Step b3: The system extracts a message of the M2M terminal from the memory block, and determines whether the message of the extracted M2M terminal reaches the preset number of messages of the M2M terminal, and the message of the M2M terminal reaches the message of the preset M2M terminal. If the number is exceeded, the process is exited. Otherwise, it is further determined whether there is no message in the M2M terminal message buffer queue. If there is no message in the M2M terminal message buffer queue, the process is exited, otherwise step b0 is performed.
5、 如权利要求 1至 4任一项所述的控制方法, 其特征在于, 所述緩存队列管理信息包括: M2M系统应用的 M2M緩存配置信息、 M2M 系统中所有正使用的 M2M终端消息緩存队列的信息以及所有 M2M 消息緩存队列链表首地址信息; 其中, M2M緩存配置信息包括所有緩存队 列最大允许使用内存量、 每条队列最大记录条数、 同一类型緩存允许的内 存块个数、 内存块释放规则和緩存文件保存路径信息。  The control method according to any one of claims 1 to 4, wherein the cache queue management information comprises: M2M cache configuration information of an M2M system application, and all M2M terminal message cache queues being used in the M2M system. Information and the first address information of all M2M message cache queues; wherein the M2M cache configuration information includes the maximum allowed memory size of all cache queues, the maximum number of records per queue, the number of memory blocks allowed by the same type of cache, and the release of memory blocks. Rules and cache files save path information.
6、 一种物联网系统, 其特征在于, 该系统包括: 创建生成管理信息模 块、 消息储存模块和消息提取模块, 其中,  An Internet of Things system, the system comprising: creating a management information module, a message storage module, and a message extraction module, wherein
所述创建生成管理信息模块,用于创建一物联网 M2M终端消息緩存队 列, 并将生成后的该 M2M 终端消息緩存队列的信息加入緩存队列管理信 息, 并发送给所述消息储存模块和所述消息提取模块;  The creating a management information module is configured to create an IoT M2M terminal message cache queue, and add the generated information of the M2M terminal message cache queue to the cache queue management information, and send the information to the message storage module and the Message extraction module
所述消息储存模块, 用于根据接收的所述緩存队列管理信息, 通过内 存緩存方式和文件緩存方式将 M2M终端上 ^艮的消息存入对应的 M2M终端 消息緩存队列;  The message storage module is configured to store the message on the M2M terminal into the corresponding M2M terminal message cache queue according to the received cache queue management information by using a cache mode and a file cache mode;
所述消息提取模块, 用于根据接收的所述緩存队列管理信息, 通过内 存緩存方式和文件緩存方式将 M2M终端的消息从对应的 M2M终端消息緩 存队列中取出。 The message extraction module is configured to: according to the received cache queue management information, the M2M terminal message is taken out from the corresponding M2M terminal message cache queue by using an in-memory cache mode and a file cache manner.
7、 如权利要求 6所述的物联网系统, 其特征在于, 所述创建生成管理 信息模块创建一 M2M终端消息緩存队列, 并将生成后的该 M2M终端消息 緩存队列的信息加入緩存队列管理信息为: The IoT system according to claim 6, wherein the creation and generation management information module creates an M2M terminal message buffer queue, and adds the generated information of the M2M terminal message buffer queue to the cache queue management information. For:
所述创建生成管理信息模块发起一创建 M2M终端消息緩存队列请求, 其中包含 M2M终端消息緩存队列 id; 判断该 M2M终端消息緩存队列 id 若不存在, 则扫描是否已经有该 M2M终端消息緩存队列 id的緩存文件, 若有, 则获取緩存文件的起始、 结束编号, 生成新建的该 M2M终端消息緩 存队列的信息, 其中填入緩存文件的起始和结束编号; 将新建的该 M2M终 端消息緩存队列的信息加入緩存队列管理信息。  The create and generate management information module initiates a request to create an M2M terminal message cache queue, which includes an M2M terminal message cache queue id; and determines whether the M2M terminal message cache queue id does not exist, and then scans whether the M2M terminal message cache queue id is already present. The cache file, if any, obtains the start and end numbers of the cache file, generates the newly created information of the M2M terminal message cache queue, and fills in the start and end numbers of the cache file; the newly created M2M terminal message cache The information of the queue is added to the cache queue management information.
8、 如权利要求 7所述的物联网系统, 其特征在于, 所述消息储存模块 根据接收的所述緩存队列管理信息, 通过内存緩存方式和文件緩存方式将 M2M终端上 ^艮的消息存入对应的 M2M终端消息緩存队列为:  The object-to-network system of claim 7, wherein the message storage module stores the message on the M2M terminal through the memory buffer mode and the file cache mode according to the received cache queue management information. The corresponding M2M terminal message cache queue is:
所述消息储存模块收到 M2M终端上 的消息, 判断需要插入的 M2M 终端消息緩存队列如果合法,则判断该 M2M终端消息緩存队列若存在緩存 文件, 则根据所述緩存队列管理信息, 判断当前緩存文件是否需要创建新 的緩存文件, 如果是, 则根据所述緩存队列管理信息生成一新的緩存文件, 将所述 M2M终端上报的消息写入生成的该新的緩存文件的空闲空间头部, 否则将所述 M2M终端上报的消息写入所述緩存文件的空闲空间头部;  The message storage module receives the message on the M2M terminal, and determines that the M2M terminal message cache queue to be inserted is legal, if it is determined that the cache file exists in the M2M terminal message cache queue, the current cache is determined according to the cache queue management information. Whether the file needs to create a new cache file, if yes, generate a new cache file according to the cache queue management information, and write the message reported by the M2M terminal to the free space header of the generated new cache file. Otherwise, the message reported by the M2M terminal is written to the free space header of the cache file;
判断该 M2M终端消息緩存队列若不存在緩存文件, 则判断所述 M2M 终端消息緩存队列中是否有空闲的内存块, 若有, 则将所述 M2M终端上报 的消息拷贝到所述内存块队尾保存; 否则根据所述緩存队列管理信息, 判 断该 M2M终端消息緩存队列是否可以新建内存块,如果是, 则申请一内存 块,将内存地址加入所述緩存队列管理信息, 并将该 M2M终端上报的消息 拷贝到该内存块保存。  Determining, if there is no cache file in the M2M terminal message cache queue, determining whether there is a free memory block in the M2M terminal message cache queue, and if yes, copying the message reported by the M2M terminal to the end of the memory block If the cache queue management information is used, it is determined whether the M2M terminal message cache queue can create a new memory block. If yes, apply for a memory block, add the memory address to the cache queue management information, and report the M2M terminal. The message is copied to the memory block and saved.
9、 如权利要求 7所述的物联网系统, 其特征在于, 所述消息提取模块 根据接收的所述緩存队列管理信息, 通过内存緩存方式和文件緩存方式将9. The Internet of Things system of claim 7, wherein the message extraction module According to the received cache queue management information, through the memory cache mode and the file cache mode
M2M终端的消息从对应的 M2M终端消息緩存队列中取出为: The message of the M2M terminal is taken out from the corresponding M2M terminal message buffer queue as:
所述消息提取模块判断需要提取的 M2M终端消息緩存队列如果合法, 则判断提取的当前 M2M终端消息緩存队列若存在有内存块的緩存,则从内 存块中提取 M2M终端的消息,判断提取的 M2M终端的消息若已达到预设 的 M2M终端的消息的条数, 则退出, 否则判断该 M2M终端消息緩存队列 中若已经没有消息, 则退出;  If the message extraction module determines that the M2M terminal message cache queue to be extracted is legal, it determines that the extracted current M2M terminal message cache queue has a memory block cache, and then extracts the M2M terminal message from the memory block to determine the extracted M2M. If the message of the terminal has reached the preset number of messages of the M2M terminal, exit, otherwise, if the M2M terminal message cache queue has no message, exit;
判断提取的当前 M2M终端消息緩存队列若没有存在内存块的緩存,则 判断所述 M2M终端消息緩存队列若存在緩存文件,则打开文件编号最小的 一緩存文件,读取该緩存文件内容, 并拷贝该緩存文件内容到所述 M2M终 端消息緩存队列的第一个内存块中; 从内存块中提取 M2M终端的消息, 判 断提取的 M2M终端的消息若已达到预设的 M2M终端的消息的条数,则退 出, 否则判断该 M2M终端消息緩存队列中若已经没有消息, 则退出。  Determining, if there is no cache of the memory block in the current M2M terminal message cache queue, determining that the cache file exists in the M2M terminal message cache queue, opening a cache file with the smallest file number, reading the cache file content, and copying The content of the cache file is sent to the first memory block of the M2M terminal message cache queue. The message of the M2M terminal is extracted from the memory block, and the number of messages of the M2M terminal that has been reached by the preset M2M terminal is determined. , then exit, otherwise it is judged that if there is no message in the M2M terminal message buffer queue, it will exit.
10、 如权利要求 6至 9任一所述的物联网系统, 其特征在于, 所述创 建生成管理信息模块中所述緩存队列管理信息包括: M2M系统应用的 M2M 緩存配置信息、 M2M系统中所有正使用的 M2M终端消息緩存队列的信息 以及所有 M2M消息緩存队列链表首地址信息; 其中, M2M緩存配置信息 包括所有緩存队列最大允许使用内存量、 每条队列最大记录条数、 同一类 型緩存允许的内存块个数、 内存块释放规则和緩存文件保存路径信息。  The IoT system according to any one of claims 6 to 9, wherein the cache queue management information in the create and generate management information module includes: M2M cache configuration information of the M2M system application, and all in the M2M system. The M2M terminal message cache queue information and the M2M message cache queue list first address information are used. The M2M cache configuration information includes the maximum allowable memory size of all cache queues, the maximum number of records per queue, and the same type of cache allowable. Number of memory blocks, memory block release rules, and cache file save path information.
PCT/CN2011/071883 2010-04-19 2011-03-16 Internet of things system and buffer control method thereof WO2011131066A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201010151031.9 2010-04-19
CN201010151031.9A CN102223681B (en) 2010-04-19 2010-04-19 IOT system and cache control method therein

Publications (1)

Publication Number Publication Date
WO2011131066A1 true WO2011131066A1 (en) 2011-10-27

Family

ID=44780077

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/071883 WO2011131066A1 (en) 2010-04-19 2011-03-16 Internet of things system and buffer control method thereof

Country Status (2)

Country Link
CN (1) CN102223681B (en)
WO (1) WO2011131066A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10091100B1 (en) 2016-03-24 2018-10-02 EMC IP Holding Company LLC Network functions virtualization infrastructure comprising virtual switch for internet of things data

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102663096B (en) * 2012-04-11 2015-12-16 北京像素软件科技股份有限公司 A kind of method reading data based on Data cache technology
CN103593307B (en) * 2013-11-25 2016-04-20 湖南强军科技有限公司 A kind of method and apparatus of electromagnetic prospecting system process image data
CN105187293A (en) * 2015-07-23 2015-12-23 柳州正高科技有限公司 Method for storing Internet of Things temporary message
CN105138410A (en) * 2015-08-31 2015-12-09 北京锐安科技有限公司 Message queue achievement method and device based on disk buffer
US9537914B1 (en) * 2015-12-01 2017-01-03 International Business Machines Corporation Vehicle domain multi-level parallel buffering and context-based streaming data pre-processing system
CN105791439A (en) * 2016-04-29 2016-07-20 中国农业银行股份有限公司 Data processing method, data receiving apparatus and data processing system
CN107193933A (en) * 2017-05-18 2017-09-22 广东芬尼克兹节能设备有限公司 A kind of source pump Mobile Server control system and method
CN109688085B (en) * 2017-10-19 2021-11-02 中兴通讯股份有限公司 Transmission control protocol proxy method, storage medium and server
CN110018969B (en) * 2019-03-08 2023-06-02 平安科技(深圳)有限公司 Data caching method, device, computer equipment and storage medium
CN110417629A (en) * 2019-07-26 2019-11-05 深圳市浩科电子有限公司 The method and system of one kind of multiple different types of internet of things equipment access Internet of Things
CN110865887B (en) * 2019-11-25 2024-04-16 中科数金(河南)科技有限公司 Direct output short message storage output method
CN113312187B (en) * 2021-06-02 2023-06-16 福建天晴数码有限公司 Message multithreading consumption order confirmation method and device based on doubly linked list

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070204276A1 (en) * 2006-02-27 2007-08-30 Bea Systems, Inc. Method and apparatus for buffering requests to web services using annotations
CN101127808A (en) * 2006-08-18 2008-02-20 虹光精密工业(苏州)有限公司 Media processing device with queue management function
CN101286878A (en) * 2008-04-22 2008-10-15 中兴通讯股份有限公司 Management method of memory pool for terminal
CN101459924A (en) * 2007-12-10 2009-06-17 中兴通讯股份有限公司 Method, apparatus and system for GSM system service tracking and exception management

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101576855B (en) * 2009-06-19 2011-05-04 深圳市科陆电子科技股份有限公司 Data storing system and method based on cache

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070204276A1 (en) * 2006-02-27 2007-08-30 Bea Systems, Inc. Method and apparatus for buffering requests to web services using annotations
CN101127808A (en) * 2006-08-18 2008-02-20 虹光精密工业(苏州)有限公司 Media processing device with queue management function
CN101459924A (en) * 2007-12-10 2009-06-17 中兴通讯股份有限公司 Method, apparatus and system for GSM system service tracking and exception management
CN101286878A (en) * 2008-04-22 2008-10-15 中兴通讯股份有限公司 Management method of memory pool for terminal

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10091100B1 (en) 2016-03-24 2018-10-02 EMC IP Holding Company LLC Network functions virtualization infrastructure comprising virtual switch for internet of things data

Also Published As

Publication number Publication date
CN102223681B (en) 2015-06-03
CN102223681A (en) 2011-10-19

Similar Documents

Publication Publication Date Title
WO2011131066A1 (en) Internet of things system and buffer control method thereof
JP6961844B2 (en) Storage volume creation method and device, server, and storage medium
JP2012517644A (en) Storage system using high-speed storage device as cache
TW201030516A (en) Hybrid memory device
WO2014000300A1 (en) Data buffer device, data storage system and method
CN109614377A (en) File delet method, device, equipment and the storage medium of distributed file system
WO2013170730A1 (en) Dma transmission method and system
WO2015078194A1 (en) Configuration method and device for hash database
WO2014180232A1 (en) Method and device for responding to a request, and distributed file system
US20120265924A1 (en) Elastic data techniques for managing cache storage using ram and flash-based memory
WO2012126229A1 (en) Distributed cache system data access method and device
US20230122315A1 (en) Data Management Method for Application, System, and Computer Device
EP3531666A1 (en) Management method and apparatus for storage device in storage system
CN112783445A (en) Data storage method, device, system, electronic equipment and readable storage medium
JP2021144731A (en) File directory traversal method, apparatus, facility, medium, and program
JP5893028B2 (en) System and method for efficient sequential logging on a storage device that supports caching
WO2014190622A1 (en) Off-line message storage method and server
WO2022037016A1 (en) Method and system for storing tree structure data, and related apparatus
TWI722392B (en) Memory device
KR102063281B1 (en) Methods and devices for accessing files, and storage systems
WO2012171363A1 (en) Method and equipment for data operation in distributed cache system
WO2019109209A1 (en) Data replacement method for memory, server node, and data storage system
US9069821B2 (en) Method of processing files in storage system and data server using the method
CN107704596A (en) A kind of method, apparatus and equipment for reading file
CN114265791A (en) Data scheduling method, chip and electronic equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11771519

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11771519

Country of ref document: EP

Kind code of ref document: A1