Vehicle event reporting processing method and device, server and storage medium
By deploying memory queues and threads in the server, using a hash function to calculate vehicle identifiers to determine the event queue, and processing events sequentially, the problem of inconsistent status caused by the out-of-order processing of vehicle-reported events was solved, and the correct display of vehicle status and location information was achieved.
Patent Information
- Application Number
- CN202310538454.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-11
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-05-11
AI Technical Summary
In existing technologies, when vehicle-reported events are processed concurrently by multiple threads, the orderliness of the events cannot be guaranteed, resulting in discrepancies between the vehicle status or location information and the actual situation, and the inability to correctly display the real-time status of the vehicle.
By deploying memory queues and threads in the server, using a hash function to calculate vehicle identifiers to determine the memory queue for events, and using the thread corresponding to the queue to process events sequentially, the orderly processing of events for the same vehicle is ensured.
This system enables the orderly processing of vehicle-reported events in a multi-threaded environment, ensuring the correct display of the real-time status of each vehicle and resolving the issue of discrepancies between vehicle status and location information.
Smart Images

Figure CN116567030B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle technology, and in particular to a method, apparatus, server, and storage medium for processing vehicle-reported events. Background Technology
[0002] The TSP (Telematics Service Provider) platform receives vehicle status events, notification events, and periodic events reported by vehicles to update information such as vehicle status or location. Due to the large number of vehicles and the high frequency of event reporting, the relevant technologies usually require multiple parallel threads to process these reported events.
[0003] However, when uploading vehicle status events, data for the same vehicle may exist in different queues. During data processing, the orderliness of consumption cannot be guaranteed, which can easily lead to discrepancies between the vehicle status or location information and the actual situation, making it impossible to correctly display the current vehicle status on the TSP platform. Summary of the Invention
[0004] This application provides a method, apparatus, server, and storage medium for processing vehicle-reported events, in order to solve the problems of related technologies that use multiple threads to process vehicle-reported events concurrently, which cannot guarantee that the events reported by the vehicles can be processed in an orderly manner and are prone to errors in the real-time status of the vehicles.
[0005] The first aspect of this application provides a method for processing vehicle-reported events. The method is applied to a server, which deploys one or more consumer services, each of which deploys one or more memory queues. The method includes the following steps: obtaining one or more vehicle-reported events and vehicle identifiers; determining the memory queue to retrieve the events based on the vehicle identifier, and retrieving the events into the memory queue corresponding to the vehicle identifier, and identifying the thread in the same consumer service corresponding to the memory queue; and using the thread corresponding to the memory queue to process the events in the memory queue sequentially.
[0006] Optionally, in one embodiment of this application, determining the memory queue for pulling the event based on the vehicle identifier includes: calculating a first hash value of the vehicle identifier; and taking the modulo of the number of memory queues deployed in the consumption service based on the first hash value to obtain the memory queue corresponding to the vehicle identifier.
[0007] Optionally, in one embodiment of this application, calculating the first hash value of the vehicle identifier includes: calculating the first hash value of the vehicle identifier using the FNV-1 hash function.
[0008] Optionally, in one embodiment of this application, each consumer service may further include one or more memory partitions.
[0009] Optionally, in one embodiment of this application, the step of pulling the event into the memory queue corresponding to the vehicle identifier includes: pulling the event from the memory partition into the memory queue corresponding to the vehicle identifier.
[0010] Optionally, in one embodiment of this application, before pulling events from the memory partition to the memory queue corresponding to the vehicle identifier, the method further includes: calculating a second hash value of the vehicle identifier; and taking the modulo of the number of memory partitions deployed in the consumption service based on the second hash value to obtain the memory partition corresponding to the vehicle identifier.
[0011] Optionally, in one embodiment of this application, calculating the second hash value of the vehicle identifier includes: calculating the second hash value of the vehicle identifier using a hash algorithm of multiplication and rotation.
[0012] A second aspect of this application provides a processing apparatus for vehicle-reported events. The apparatus is applied to a server, which deploys one or more consumer services, each consumer service deploying one or more memory queues. The apparatus includes: an acquisition module for acquiring one or more vehicle-reported events and vehicle identifiers; a determination module for determining the memory queue to retrieve the events based on the vehicle identifier, retrieving the events from the memory queue corresponding to the vehicle identifier, and identifying the thread corresponding to the memory queue within the same consumer service; and a processing module for sequentially processing the events in the memory queue using the thread corresponding to the memory queue.
[0013] Optionally, in one embodiment of this application, the determining module is further configured to calculate a first hash value of the vehicle identifier; and to take the modulo of the number of memory queues deployed in the consumption service based on the first hash value to obtain the memory queue corresponding to the vehicle identifier.
[0014] Optionally, in one embodiment of this application, the determining module is further configured to calculate a first hash value of the vehicle identifier using the FNV-1 hash function.
[0015] Optionally, in one embodiment of this application, each consumer service may further include one or more memory partitions.
[0016] Optionally, in one embodiment of this application, the determining module is further configured to pull events from the memory partition into the memory queue corresponding to the vehicle identifier.
[0017] Optionally, in one embodiment of this application, it further includes: a calculation module, configured to calculate a second hash value of the vehicle identifier before pulling events from the memory partition to the memory queue corresponding to the vehicle identifier; and to obtain the memory partition corresponding to the vehicle identifier by taking the modulo of the number of memory partitions deployed in the consumption service based on the second hash value.
[0018] Optionally, in one embodiment of this application, the calculation module is further configured to calculate a second hash value of the vehicle identifier using a hash algorithm of multiplication and rotation.
[0019] A third aspect of this application provides a server, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the vehicle reporting event processing method as described in the above embodiments.
[0020] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the vehicle reporting event processing method as described in the above embodiments.
[0021] Therefore, this application has at least the following beneficial effects:
[0022] This application embodiment can acquire events and vehicle identifiers reported by one or more vehicles; determine a memory queue for pulling events based on the vehicle identifier, pull the events into the memory queue corresponding to the vehicle identifier, and process the events in the memory queue sequentially using the thread corresponding to the queue. While processing multiple threads, it can process the events reported by vehicles in an orderly manner, ensuring the correct real-time status of each vehicle. Therefore, it solves the problems of related technologies that rely solely on multiple threads to concurrently process vehicle-reported events, which cannot guarantee the orderly processing of vehicle-reported events and easily leads to errors in the real-time status of vehicles.
[0023] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0024] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0025] Figure 1 This is a flowchart of a method for processing vehicle-reported events according to an embodiment of this application;
[0026] Figure 2 This is an example diagram illustrating the flow of a vehicle reporting event according to an embodiment of this application;
[0027] Figure 3 This is a block diagram of a vehicle reporting event processing device according to an embodiment of this application;
[0028] Figure 4 This is a schematic diagram of the server structure according to an embodiment of this application. Detailed Implementation
[0029] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0030] The following description, with reference to the accompanying drawings, outlines a method, apparatus, server, and storage medium for processing vehicle-reported events according to embodiments of this application. Addressing the problems mentioned in the background section, this application provides a method for processing vehicle-reported events. This method is applied to a server, which deploys one or more consumer services. Each consumer service deploys one or more memory queues. In this method, one or more vehicle-reported events and vehicle identifiers are obtained; the memory queue for pulling events is determined based on the vehicle identifier, and the events are pulled into the memory queue corresponding to the vehicle identifier. The events in the memory queue are then processed sequentially using a thread corresponding to that queue. This allows for the orderly processing of vehicle-reported events while multiple threads are involved, ensuring the correct real-time status of each vehicle. This solves the problems of related technologies that rely solely on multiple threads to concurrently process vehicle-reported events, which cannot guarantee the orderly processing of these events and can easily lead to errors in the real-time status of vehicles.
[0031] Specifically, Figure 1 This is a flowchart illustrating a method for processing vehicle-reported events provided in an embodiment of this application.
[0032] like Figure 1 As shown, the handling method for the incident reported by this vehicle includes the following steps:
[0033] In step S101, events and vehicle identifiers reported by one or more vehicles are obtained.
[0034] Vehicle identification may include vehicle VIN code, vehicle number, etc.
[0035] It is understood that events reported by vehicles can be used to update information such as vehicle status and location. In this application embodiment, events reported by one or more vehicles and vehicle identifiers can be obtained, and a memory queue for pulling events can be determined based on the vehicle identifiers to ensure that events reported by the same vehicle can be processed in an orderly manner.
[0036] In step S102, the memory queue for pulling events is determined based on the vehicle identifier, and the events are pulled into the memory queue corresponding to the vehicle identifier. The thread corresponding to the memory queue in the same consumption service is also identified.
[0037] In one embodiment of this application, determining the memory queue for a fetch event based on a vehicle identifier includes: calculating a first hash value for the vehicle identifier; and taking the modulo of the first hash value with the number of memory queues deployed in the consumption service to obtain the memory queue corresponding to the vehicle identifier.
[0038] This application embodiment can deploy one or more consumer services, and each consumer service can deploy one or more memory queues. After obtaining the event reported by the vehicle, the memory queue corresponding to the vehicle identifier is determined, and the event reported by the vehicle is put into the memory queue.
[0039] Specifically, this embodiment of the application can use the FNV-1 hash function to calculate the first hash value of the vehicle identifier, and perform a modulo operation on the number of created memory queues to obtain the queue number. The queue number obtained after calculation is the same for the same vehicle identifier, and the memory queue is determined according to the queue number corresponding to the vehicle identifier. In actual execution, each consumer service also deploys one or more memory partitions. This embodiment of the application can pull events from the memory partitions to the memory queue corresponding to the vehicle identifier to ensure that events reported by the same vehicle can be processed in an orderly manner and the real-time status of the vehicle can be displayed correctly.
[0040] In step S103, the events in the memory queue are processed sequentially using the thread corresponding to the memory queue.
[0041] In this embodiment, each memory queue has a unique number, and a thread with the same number will process the messages in it. Therefore, after the event is pulled into the memory queue corresponding to the vehicle identifier, the thread corresponding to the queue can be used to process the events reported by the vehicle. While multiple threads are processing, the events reported by the vehicle can be processed in an orderly manner, ensuring the correctness of the real-time status of each vehicle.
[0042] In one embodiment of this application, before pulling events from the memory partition to the memory queue corresponding to the vehicle identifier, the method further includes: calculating a second hash value of the vehicle identifier; and taking the modulo of the number of memory partitions deployed in the consumption service based on the second hash value to obtain the memory partition corresponding to the vehicle identifier.
[0043] In this embodiment, events reported by vehicles can be placed in Kafka. When an event is sent to Kafka, a custom Kafka distribution strategy can be used, namely, using a multiplication and rotation hash algorithm (Murmur2) to calculate the second hash value of the vehicle identifier, and taking the modulo of the number of memory partitions deployed in the consumer service to obtain the partition parameter key value. Kafka will send events with the same key to the same memory partition. Messages are ordered within the same partition. Each vehicle identifier will have the same partition parameter key value after going through the same algorithm, thus ensuring that events reported by the same vehicle will be sent to the same memory partition, thereby ensuring that events of the same vehicle sent to Kafka are ordered.
[0044] In summary, this embodiment utilizes Kafka as a message queue, deploys a producer service, and after receiving events reported by vehicles, sends them to Kafka. A consumer service is also deployed, creating multiple in-memory queues to retrieve events from Kafka and place them in the in-memory queues for processing by the corresponding threads. Figure 2 The diagram illustrates the flow of vehicle-reported events. Events from the same vehicle are sent to Kafka in sequence. After being retrieved, the events are also placed into an in-memory queue in an orderly manner, with only one in-memory queue corresponding to each vehicle. Furthermore, each consumer service has multiple threads processing messages, and multiple consumer services can be deployed to process events from multiple partitions in parallel, thereby increasing processing capacity.
[0045] The vehicle-reported event processing method proposed in this application involves acquiring one or more vehicle-reported events and vehicle identifiers; determining a memory queue for pulling events based on the vehicle identifiers; pulling events into the memory queue corresponding to the vehicle identifiers; and sequentially processing the events in the memory queue using the thread corresponding to the queue. This multi-threaded processing ensures that vehicle-reported events are processed in an orderly manner, guaranteeing the correct real-time status of each vehicle. Therefore, this method solves the problems of related technologies that rely solely on multiple threads to concurrently process vehicle-reported events, which cannot guarantee orderly processing and can easily lead to errors in the real-time status of vehicles.
[0046] Next, referring to the accompanying drawings, a processing apparatus for vehicle reporting events according to an embodiment of this application is described. This apparatus is applied to a server, which has one or more consumer services deployed on it, and each consumer service has one or more memory queues deployed on it.
[0047] Figure 3 This is a block diagram of a vehicle reporting event processing device according to an embodiment of this application.
[0048] like Figure 3As shown, the vehicle-reported event processing device 10 includes: an acquisition module 100, a determination module 200, and a processing module 300.
[0049] The acquisition module 100 is used to acquire events and vehicle identifiers reported by one or more vehicles; the determination module 200 is used to determine the memory queue for pulling events based on the vehicle identifier, pull the events into the memory queue corresponding to the vehicle identifier, and identify the thread corresponding to the memory queue in the same consumption service; the processing module 300 is used to process the events in the memory queue sequentially using the thread corresponding to the memory queue.
[0050] In one embodiment of this application, the determining module 200 is further configured to calculate a first hash value of the vehicle identifier; and to obtain the memory queue corresponding to the vehicle identifier by taking the modulo of the number of memory queues deployed in the consumption service based on the first hash value.
[0051] In one embodiment of this application, the determining module 200 is further configured to calculate a first hash value of the vehicle identifier using the FNV-1 hash function.
[0052] Optionally, in one embodiment of this application, each consumer service is further configured with one or more memory partitions, and the determination module 200 is further configured to pull events from the memory partitions into the memory queue corresponding to the vehicle identifier.
[0053] In one embodiment of this application, the apparatus 10 of this application embodiment further includes: a computing module.
[0054] The calculation module is used to calculate the second hash value of the vehicle identifier before pulling events from the memory partition to the memory queue corresponding to the vehicle identifier; and to obtain the memory partition corresponding to the vehicle identifier by taking the modulo of the number of memory partitions deployed in the consumption service based on the second hash value.
[0055] In one embodiment of this application, the calculation module is further configured to calculate a second hash value of the vehicle identifier using a hash algorithm involving multiplication and rotation.
[0056] It should be noted that the explanation of the above-described method for processing vehicle-reported events also applies to the processing device for vehicle-reported events in this embodiment, and will not be repeated here.
[0057] The vehicle event reporting processing apparatus according to the embodiments of this application obtains one or more vehicle-reported events and vehicle identifiers; determines a memory queue for pulling events based on the vehicle identifiers, pulls the events into the memory queue corresponding to the vehicle identifiers, and processes the events in the memory queue sequentially using the thread corresponding to the queue. This allows for orderly processing of vehicle-reported events while multiple threads are involved, ensuring the correct real-time status of each vehicle. Therefore, it solves the problems of related technologies that rely solely on multiple threads to concurrently process vehicle-reported events, which cannot guarantee orderly processing of the events and easily leads to errors in the real-time status of vehicles.
[0058] Figure 4 A schematic diagram of the structure of a server provided in an embodiment of this application. The server may include:
[0059] The memory 401, the processor 402, and the computer program stored on the memory 401 and capable of running on the processor 402.
[0060] When the processor 402 executes the program, it implements the vehicle reporting event processing method provided in the above embodiments.
[0061] Furthermore, the server also includes:
[0062] Communication interface 403 is used for communication between memory 401 and processor 402.
[0063] The memory 401 is used to store computer programs that can run on the processor 402.
[0064] The memory 401 may include high-speed RAM (Random Access Memory) memory, and may also include non-volatile memory, such as at least one disk storage.
[0065] If the memory 401, processor 402, and communication interface 403 are implemented independently, then the communication interface 403, memory 401, and processor 402 can be interconnected via a bus to complete communication between them. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 4 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0066] Optionally, in a specific implementation, if the memory 401, processor 402, and communication interface 403 are integrated on a single chip, then the memory 401, processor 402, and communication interface 403 can communicate with each other through an internal interface.
[0067] Processor 402 may be a CPU (Central Processing Unit), an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement embodiments of this application.
[0068] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described method for processing vehicle reporting events.
[0069] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0070] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0071] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0072] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (FPGAs), field-programmable gate arrays (FPGAs), etc.
[0073] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0074] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A method for handling vehicle reporting events, characterized in that The method is applied to a server, the server is deployed with one or more consumer services, and each consumer service is deployed with one or more memory queues, wherein the method comprises the following steps: obtaining one or more events and vehicle identifiers reported by vehicles; determining a memory queue to pull the events according to the vehicle identifiers, pulling the events into the memory queue corresponding to the vehicle identifiers, and identifying a thread corresponding to the memory queue in the same consumer service; processing the events in the memory queue in turn by using the thread corresponding to the memory queue; The determination of the memory queue to pull the events according to the vehicle identifiers comprises: calculating a first hash value of the vehicle identifier; and performing modulo operation on the number of memory queues deployed in the consumer service according to the first hash value to obtain the memory queue corresponding to the vehicle identifier; each consumer service is further deployed with one or more memory partitions, and events are pulled from the memory partitions into the memory queue corresponding to the vehicle identifier; Before pulling the events from the memory partitions into the memory queue corresponding to the vehicle identifier, the second hash value of the vehicle identifier is calculated, and modulo operation is performed on the number of memory partitions deployed in the consumer service according to the second hash value to obtain the memory partition corresponding to the vehicle identifier.
2. The method of claim 1, wherein, The calculation of the first hash value of the vehicle identifier comprises: calculating the first hash value of the vehicle identifier by using the FNV-1 hash function.
3. The method of claim 1, wherein, The calculation of the second hash value of the vehicle identifier comprises: calculating the second hash value of the vehicle identifier by using the multiplication and rotation hash algorithm.
4. A processing device for vehicle reported events, characterized in that The device is applied to a server, the server is deployed with one or more consumer services, and each consumer service is deployed with one or more memory queues, wherein the device comprises: an obtaining module for obtaining one or more events and vehicle identifiers reported by vehicles; a determining module for determining a memory queue to pull the events according to the vehicle identifiers, pulling the events into the memory queue corresponding to the vehicle identifiers, and identifying a thread corresponding to the memory queue in the same consumer service; a processing module for processing the events in the memory queue in turn by using the thread corresponding to the memory queue; The determination module is further used for: calculating a first hash value of the vehicle identifier; and performing modulo operation on the number of memory queues deployed in the consumer service according to the first hash value to obtain the memory queue corresponding to the vehicle identifier; each consumer service is further deployed with one or more memory partitions, and the determining module is further used for pulling events from the memory partitions into the memory queue corresponding to the vehicle identifier; a calculating module for calculating a second hash value of the vehicle identifier before pulling the events from the memory partitions into the memory queue corresponding to the vehicle identifier; and performing modulo operation on the number of memory partitions deployed in the consumer service according to the second hash value to obtain the memory partition corresponding to the vehicle identifier.
5. A server, characterized by comprises: A memory, a processor, and a computer program stored on the memory and executable on the processor, the processor executing the program to implement the method of processing a vehicle reported event according to any one of claims 1-3.
6. A computer readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor for implementing the method of processing a vehicle reported event according to any one of claims 1-3.
Citation Information
Patent Citations
Message processing method and device, electronic equipment and storage medium
CN114610504A
Rapid real-time early warning method based on Spark Streaming
CN115168659A