Rail transit integrated monitoring system process authorization and access control method and system
By deploying a process authorization module in the rail transit integrated monitoring system and using a communication method developed in C++, the problems of inflexible business deployment and insufficient real-time performance were solved, achieving efficient data transmission and millisecond-level response across operating system platforms.
Patent Information
- Application Number
- CN202411149448.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-08-21
AI Technical Summary
The existing integrated monitoring system for rail transit is not flexible in its deployment on cloud platforms, and cannot meet the requirements for elastic expansion and redundancy of the business. Moreover, the existing technology cannot meet the real-time requirements of the integrated monitoring system for millisecond-level response.
A process authorization module is deployed in the rail transit integrated monitoring system. By authorizing and controlling access to business processes on any node, a communication thread developed in C++ is used to perform character format normalization and binary conversion. Data transmission is carried out using TCP and UDP protocols, thereby solving byte order issues across operating system platforms and improving business processing efficiency.
It enables real-time interaction between different nodes, reduces message transmission and parsing time, meets the millisecond-level response requirements of the integrated monitoring system, and improves the overall efficiency and performance of the system.
Smart Images

Figure CN118656854B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of rail transit integrated monitoring systems, and in particular to a rail transit integrated monitoring system process authorization and access control method and system. Background Art
[0002] The Integrated Supervisory Control System (ISCS) for rail transit is a typical industrial control distributed system. The current integrated monitoring system architecture basically adopts the distributed structure of "control center-station", running two redundant real-time nodes in the control center to deploy control center services (hereinafter referred to as ISCS center nodes), and running two redundant real-time nodes in each station to deploy current station services (hereinafter referred to as ISCS station nodes).
[0003] With the widespread application of urban rail cloud in the rail transit industry, the above architecture has been improved in line with the requirements of intensive development: a cloud platform is built in the control center area to build a data center, and the ISCS station nodes that were previously deployed in various stations are centrally deployed together with the ISCS center nodes in the virtual machine of the data center cloud platform. The system structure and business processes continue the traditional station-center two-level deployment method.
[0004] Under this solution architecture, although all businesses are centrally deployed in virtual machines on the cloud platform, it cannot flexibly meet the elastic expansion of businesses. There are several main problems that have not been fundamentally solved:
[0005] 1. ISCS services are still deployed as a whole machine: all services are deployed on nodes (virtual machines) as a whole machine, rather than being differentiated according to the processes in the service;
[0006] 2. Redundancy of all services is based on whole machine redundancy: Currently, comprehensive monitoring services are dual-machine redundant, which cannot improve the reliability of important business processes;
[0007] 3. Business cannot be adjusted and expanded dynamically: Currently, all configurations are deeply tied to business virtual machines and cannot be flexibly configured.
[0008] Some integrated monitoring manufacturers have begun to use dubbo (distributed service framework) and zookeeper (distributed registration center) to implement microservice frameworks, trying to solve the above three problems; however, since the dubbo framework is based on the Java language, the Java language uses the Java virtual machine to solve the problem of inconsistent byte order between the client and the server across operating system platforms. Since there is an extra layer of Java virtual machine on the application software, the business response and real-time performance cannot meet the millisecond-level response requirements of industrial control of the integrated monitoring system (the application software of the traditional integrated monitoring system is basically all developed in C++); and the language used by the zookeeper registration center is It is the HTTP protocol, which transmits data in XML or JSON format through a universal RESTFUL interface. Since the above two texts themselves have a large number of formats, the size of the actual transmitted message is several times or even dozens of times the effective transmitted message, which obviously affects the network bandwidth and data transmission efficiency. In addition, due to the complexity of the above two formats, it is necessary to call a universal parsing interface to parse the received message and identify the valid fields. The communicating parties need tens of milliseconds or even more time to parse the message, which will cause a large amount of data blockage in the transmission of large data traffic, and the communication efficiency and message processing cannot meet the requirements of the comprehensive monitoring system for real-time processing. Summary of the invention
[0009] Purpose of the invention: In view of the deficiencies in the prior art, the present invention provides a method and system for process authorization and access control of a rail transit integrated monitoring system, which not only solves the byte order problem across operating system platforms, but also can meet the millisecond-level requirements of the integrated monitoring system in terms of business processing efficiency.
[0010] Technical solution: In the first aspect, a rail transit integrated monitoring system process authorization and access control method includes:
[0011] Step 1: Deploy a process authorization module on any node in the rail transit integrated monitoring system to authorize business processes and control access to customer processes. The node where the process authorization module is deployed is called an authorization node.
[0012] Step 2: When a business process on any node is started, its basic thread reads the monitoring object information from the configuration file and writes the information into the business shared memory. Its communication thread obtains the data in the business shared memory, normalizes the character format and converts it into binary, and then makes an authorization request to the process authorization module through unicast. The registration thread of the process authorization module decides whether to authorize the business process based on the authorization policy and load balancing, and writes the authorization result into the authorization shared memory.
[0013] Step 3: Before accessing the service process, the query thread of the client process on any node reads the target service process information from the configuration file and writes it into the client shared memory, performs character format normalization and binary conversion, and then sends a query request to the process authorization module through the TCP link; the listening thread of the process authorization module accepts the query request of the client process, retrieves the information of the target service process from the authorized shared memory, performs character format normalization and binary conversion, and then replies the minimum load node information to the client process through the TCP link; the query thread of the client process receives the reply of the process authorization module and updates the service information in the client shared memory;
[0014] Step 4: The access thread of the client process obtains the main node IP and service port of the target business process from the updated client shared memory according to the reply of the process authorization module, performs character format normalization and binary conversion, and then sends a service request to the business process through the remote procedure call RPC connection; the service thread of the business process listens to the RPC request of the client process, executes the corresponding business logic after receiving the request, and returns the processing result to the client process through the RPC connection;
[0015] Step 5: During the entire authorization and access control process, the keep-alive thread of the business process maintains connection with the process authorization module through heartbeat communication. At the same time, the synchronization thread of the process authorization module synchronizes information between authorization nodes through multicast to ensure the real-time and consistency of authorization information.
[0016] Preferably, the basic thread of the business process reads the monitoring object information from the configuration file and writes the information into the business shared memory, as follows:
[0017] The basic thread of the business process reads the target field related information from the configuration file through the instance method of the class, obtains the current monitoring object information and the belonging node information, the current monitoring object information includes one or more of the process identifier, line information, station information, professional description, equipment information, equipment type, operation authority, operation and maintenance information, static attributes and dynamic attributes, the belonging node information includes one or more of the node name, node IP, timeout time, and writes this information into the process data structure;
[0018] The process information in the process data structure is written into area block 1 in the business shared memory in a read-write state through the shared memory operation interface.
[0019] Preferably, the communication thread of the service process copies the data in the service shared memory to perform character format normalization and binary conversion, and then makes an authorization request to the process authorization module in a unicast manner, as follows:
[0020] The communication thread of the business process periodically accesses the area block 1 in the business shared memory in a read-only manner, obtains the information in the process data structure, and maps the process data to the private data memory of this thread through the memory copy function. Through the lossless memory copy method, all the original structure data is converted into normalized string data, and all the strings are converted into binary data through the C++ language encoding conversion interface;
[0021] Then, the configuration file is read to obtain the pre-configured process authorization related information of the current node, and the sending interface is called to send UDP unicast to all nodes where the process authorization modules in the system are located to apply for process authorization. After that, within the specified timeout period, the receiving interface is called in a blocking manner to wait for a reply.
[0022] If a reply message is received from the process authorization module within the timeout period, the authorization is successful, and the relevant information about the authorization node in the reply message is written into the reply data structure. Then, the reply data in the reply data structure is written into the area block 2 in the business shared memory in a read-write state through the shared memory operation interface;
[0023] If no information is received within the time limit, the receiving interface throws an exception, the system records a failure log, and prompts that the registration failed.
[0024] Preferably, the registration thread of the process authorization module determines whether to authorize the business process according to the authorization policy and load balancing, and the method is as follows:
[0025] The registration thread of the authorization module first applies for several socket communication objects, binds each socket to a receiving port, and calls the receiving interface in a non-blocking polling manner to receive the authorization request of the business process;
[0026] If there is a socket receiving interface with a non-zero return value, the message in the receiving interface is obtained, and the binary data in the message is converted into a process data structure through the C++ language decoding and conversion interface, and the process identifier and node IP are obtained from the data structure, and the current process identifier and node IP information are queried in the authorized shared area block A. If obtained, the access time is updated; if not obtained, the load balancing is used to determine which authorization node will reply to the authorization request. The load balancing judgment method is as follows: obtain the authorization node field of all data records, and arrange them in descending order according to the number of data records, and store the counted authorization node names in the authorization node list; perform a delayed comparison between the authorization nodes in the authorization node list and the current authorization node in turn until the current node is found, and call the sending interface to send a reply message to the port that received this message in UDP unicast mode;
[0027] After replying to the business process, a new sub-area is added to the area block A of the authorized shared memory to store the process data structure corresponding to the process identifier and node IP, and the current time and current authorized node name just obtained are written to the current data record.
[0028] Preferably, the query thread of the client node reads the target service process information from the configuration file and writes it into the client shared memory, performs character format normalization and binary conversion, and then sends a query request to the process authorization module through a TCP link, the method is as follows:
[0029] The class object of the query thread of the client process reads the relevant information of the relevant fields from the configuration file, obtains the information of the required target process, builds the request data structure, and writes it into the area block I of the client shared memory of the client process;
[0030] The class object reads the process authorization field related information from the configuration file, obtains the IP information and port information of the nodes where all process authorization modules are located, and stores them in the private memory authorization node list;
[0031] The query thread creates a TCP socket, obtains the node IP and port from the authorized node list, calls the connection interface in a blocking manner, and establishes a TCP link to the node where the process authorization module is located;
[0032] The class object accesses the area block I in the client shared memory, obtains the request data structure information, and maps the request data to the private data memory of this thread through the memory copy function. Through the lossless memory copy method, all the original structure data is converted into normalized string data, and all the strings are converted into binary data through the C++ language encoding conversion interface. Then, the TCP socket is used to send the request to the authorized node that establishes the TCP link.
[0033] Receive the response of the process authorization module by polling the TCP socket, and decode the received binary data into the process data structure through the C++ language decoding and conversion interface, search and update the timestamp of the corresponding process information in the shared memory, and add a new process information sub-area and store the data if it is not found.
[0034] Preferably, the listening thread of the process authorization module accepts the query request of the client process, retrieves the information of the target business process from the authorized shared memory, performs character format normalization and binary conversion, and then replies the minimum load node information to the client process through the TCP link, the method is as follows:
[0035] The class object of the listening thread of the process authorization module creates a TCP listening socket, binds the port and starts listening, and initializes the thread pool object, setting the number of threads and the triggering method;
[0036] The listening socket polls the connection request of the client process. When there is no new request, the listening thread sleeps for a short time; when there is a new request, the connection is accepted and a thread is extracted from the thread pool to handle the connection;
[0037] The newly extracted thread receives the TCP request message from the client process and parses it into a request data structure. It searches for relevant data in the authorized shared memory according to the process identifier in the request, obtains the node IP and port, and sorts them in descending order. It obtains the IP address with the least statistics as the node with the least load.
[0038] The class object of the newly extracted thread packs the sorted node information, process identifier and port into a reply data structure, converts it into a string format through lossless memory copy, converts the string into binary data through the C++ language encoding conversion interface, and sends a reply to the client process through the TCP link.
[0039] Preferably, the access thread of the client process obtains the master node IP and service port of the target business process from the updated client shared memory according to the reply of the process authorization module, performs character format normalization and binary conversion, and then sends a service request to the business process through a remote procedure call RPC connection, the method is as follows:
[0040] The access thread of the client process periodically reads the process information in the client shared memory, obtains the IP and port of the main node where the target business process is located, and the device information and operation permissions in the request data structure, and then converts all this information into normalized string data through lossless memory copy, and converts all strings into binary data through the C++ language encoding conversion interface;
[0041] The access thread creates a remote procedure call (RPC) object and uses it to send a synchronous real-time request to the master node and port. If the RPC request returns within the specified time, the query thread writes the returned information to another area in the client's shared memory. If the request times out and does not return, the query thread records a failure log and prompts information about the process failure. It then decides whether to resend the RPC request or ignore the failure based on the client process's operation.
[0042] Preferably, the service thread of the business process listens to the RPC request of the client process, executes the corresponding business logic after receiving the request, and returns the processing result to the client process through the RPC connection, as follows:
[0043] The class object of the service thread of the business process creates a remote call socket based on the TCP protocol, binds a fixed receiving port, and starts listening for connection requests from the client process;
[0044] The remote call socket polls the client process's connection request. If there is no new request, the service thread will sleep for a short time. If there is a new request, the connection will be accepted and the service socket of the client process will be obtained.
[0045] The service socket receives the TCP request message from the client process. If the request is valid, it obtains the RPC request message and parses it into a request data structure. It obtains relevant data from the shared memory according to the process identifier in the request and packages it into a process data structure. It then converts this data into a string format through lossless memory copying and converts it into binary data through the C++ language encoding conversion interface. The service socket then calls the corresponding interface to respond. If the request is invalid, the service socket calls the corresponding interface to close the connection and records a failure log.
[0046] Preferably, the keep-alive thread of the business process maintains connection with the process authorization module through heartbeat communication, and the method is as follows:
[0047] The keep-alive thread of the business process is bound to a receiving port, and receives the heartbeat reply message sent by the authorized node through non-blocking polling. If it is received, it reads the message content, obtains the message sending time and updates the refresh time in the reply data structure; if it is not received, it accesses the reply data structure in the business shared memory, obtains the message refresh time and compares it with the current time to determine whether it exceeds the predefined timeout time. If it exceeds the timeout time, the reply data in the corresponding area block is deleted. If it is less than the timeout time, a heartbeat message is sent to the authorized node through the UDP protocol, including the source IP, source process, sending time, dynamic attributes of the monitoring data object and operation permissions;
[0048] The heartbeat thread of the process authorization module is bound to a receiving port, and receives the heartbeat message sent by the business process through non-blocking polling. If it is received, the message content is read and the refresh time of the corresponding process in the authorized shared memory is updated. If it is not received, the refresh time and timeout time of each process identifier in the authorized shared memory are accessed and compared with the current time to determine whether the timeout time is exceeded. If the timeout time is exceeded, the sub-area of the corresponding process information in the authorized shared memory is deleted, and polling is performed in sequence until all processes are traversed.
[0049] Preferably, the synchronization thread of the process authorization module realizes information synchronization between authorization nodes through multicast, and the method is as follows:
[0050] The multicast class object of the synchronization thread of the process authorization module first reads the multicast field related information from the configuration file, including the multicast address and multicast port; then creates a multicast socket, binds the multicast port, and actively adds the multicast address to the multicast group to complete the multicast subscription;
[0051] The multicast class object reads the process data structure from the authorized shared memory area block A, stores it in the process list, and then polls in sequence. Through the memory copy function, the process information of each process identifier in the authorized shared memory area block A is mapped to the process list in the private data memory of this thread. Through the lossless memory copy method, all the data in the process list is converted into normalized string data, and all the strings are converted into binary data through the C++ language encoding conversion interface. Then, IGMP protocol messages are sent to all authorized nodes for multicast distribution.
[0052] Receive multicast messages through multicast sockets. If received, get the message, convert the binary data in the message into process data structure through C++ language decoding conversion interface, and then store it in the process list in sequence through lossless memory copy;
[0053] The multicast class object takes a process identifier from the process list, loops through each process identifier from the authorized shared memory area block A for comparison, and if a match is found, continues. If no match is found during the traversal, a new sub-area is added to the authorized shared memory area block A, and all process information of the processes in the process list is stored in the current sub-area, and then continues to process the next process identifier in the process list.
[0054] In a second aspect, a rail transit integrated monitoring system process authorization and access control system includes: a business node, a client node, and an authorization node, wherein the business node is any node running a business process of the integrated monitoring system, the client node is any node running a client process, and the authorization node is any node deployed with a process authorization module, wherein the process authorization module is used to authorize the business process and perform access control on the client process;
[0055] The business process includes a basic thread, a communication thread, a service thread and a keep-alive thread; the process authorization module is an authorization process, including a registration thread, a heartbeat thread, a synchronization thread and a listening thread; the client process includes a query thread and an access thread;
[0056] When the business process is started, its basic thread reads the monitoring object information from the configuration file and writes the information into the business shared memory. Its communication thread copies the data in the business shared memory, normalizes the character format and converts it into binary, and then makes an authorization request to the process authorization module through unicast. The registration thread of the process authorization module decides whether to authorize the business process according to the authorization policy and load balancing, and writes the authorization result into the authorization shared memory.
[0057] Before accessing the service process, the client process reads the target service process information from the configuration file and writes it into the client shared memory, performs character format normalization and binary conversion, and then sends a query request to the process authorization module through a TCP link; the listening thread of the process authorization module accepts the query request of the client process, retrieves the information of the target service process from the authorized shared memory, performs character format normalization and binary conversion, and then replies the minimum load node information to the client process through a TCP link; the query thread of the client process receives the reply of the process authorization module and updates the service information in the client shared memory;
[0058] The access thread of the client process obtains the main node IP and service port of the target business process from the updated client shared memory according to the reply of the process authorization module, performs character format normalization and binary conversion, and then sends a service request to the business process through a remote procedure call RPC connection; the service thread of the business process listens to the RPC request of the client process, executes the corresponding business logic after receiving the request, and returns the processing result to the client process through the RPC connection;
[0059] During the entire authorization and access control process, the keep-alive thread of the business process maintains connection with the process authorization module through heartbeat communication. At the same time, the synchronization thread of the process authorization module synchronizes information between authorization nodes through multicast to ensure the real-time and consistency of authorization information.
[0060] In a third aspect, the present invention further provides a computer device comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the programs are executed by the processors, the steps of the rail transit integrated monitoring system process authorization and access control method as described in the first aspect are implemented.
[0061] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the rail transit integrated monitoring system process authorization and access control method as described in the first aspect.
[0062] Beneficial effect: The present invention designs a process authorization module and deploys this module on any node (virtual machine / physical machine). This node has functions such as authorization, external communication and cluster sharing. The comprehensive monitoring business process running on any node needs to request authorization from the process authorization module. Only when the authorization is successful can it be further used. When the client process needs to access the business process, the client process first needs to obtain the target business process running main node IP and service port from the process authorization module. The client process accesses the business through the main node IP and service port. These processes are all developed based on the C++ language. While solving the cross-operating system platform byte order, the business processing efficiency can meet the millisecond-level requirements of the comprehensive monitoring system. The external communication thread and the cluster sharing thread treat the transmission message as a normalized character format and through binary conversion, and transmit the message through the TCP protocol and the UDP protocol respectively, so that the data can interact in real time between different processes between different nodes, greatly reducing the time spent on message transmission and message parsing, and realizing the authorization and access of the comprehensive monitoring system process based on the C++ language and the transport layer protocol. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 It is a node data flow chart for the rail transit integrated monitoring system to implement process authorization and access control;
[0064] Figure 2 It is an example of all the information contents of the data object of process monitoring. DETAILED DESCRIPTION
[0065] The comprehensive monitoring system in the present invention does not deploy services at the station-center two levels. A process authorization module is designed and deployed on any node (virtual machine / physical machine). The comprehensive monitoring service process running on any node needs to send a request for authorization to the process authorization module. Only when the authorization is successful can it be further used. When the client process needs to access the service process, the client process first needs to obtain the target service process running master node IP and service port from the process authorization module. The client process accesses the service through the master node IP and service port.
[0066] Reference Figure 1, the method mainly involves three types of processes, namely business process, authorization process and client process, where the node where the business process runs is called business node, the node where the authorization process runs is called authorization node, and the node where the client process runs is called client node. These three processes can be configured on different nodes or on the same node. Since the authorization process has only one instance, which is different from the business process and client process (due to their different functions, they can have multiple instances), the following uses modules to describe it, that is, the process authorization module, also called the authorization module, which is a single process to distinguish it from the business and client processes.
[0067] The business process starts four threads, namely: the basic thread (BASE_THREAD), which is responsible for obtaining the current monitoring object information; the communication thread (COM_THREAD), which applies for authorization to the authorization module; the keepalive thread (KEEPALIVE_THREAD), which performs heartbeat communication with the authorization node; and the service thread (SERVICE_THREAD), which provides remote call services to the client process.
[0068] The authorization module is actually also a process, which starts four threads, namely: process registration thread (REG_THREAD), which is responsible for receiving authorization process requests and replies; heartbeat thread (HEARTBEAT_THREAD), which performs heartbeat communication with the business process; synchronization thread (SYNCHRON_THREAD): responsible for information synchronization between authorization module nodes; listening thread for client process access (LISTEN_THREAD), which is also called listening process, for client process access services.
[0069] The client process starts two threads: the query thread (REQUIRE_THREAD), which is responsible for obtaining the target process host IP and port; the access thread (ACCESS_THREAD), which sends a remote call service request to the target process to implement the remote call of the service.
[0070] According to an embodiment of the present invention, the main process of the authorization module authorizing the business process and performing access control on the client process is as follows:
[0071] (1) When a business process is started, its basic thread reads the monitoring object information from the configuration file and writes the information into the business shared memory. Its communication thread copies the data in the business shared memory, normalizes the character format and converts it into binary, and then makes an authorization request to the process authorization module via unicast.
[0072] (2) The registration thread of the process authorization module decides whether to authorize the business process based on the authorization policy and load balancing, and writes the authorization result into the authorization shared memory;
[0073] (3) Before a client process accesses a business process, its query thread reads the target business process information from the configuration file and writes it into the client shared memory, performs character format normalization and binary conversion, and then sends a query request to the process authorization module through a TCP link;
[0074] (iv) The listening thread of the process authorization module accepts the query request of the client process, retrieves the information of the target business process from the authorized shared memory, performs character format normalization and binary conversion, and then replies the minimum load node information to the client process through the TCP link;
[0075] (V) The query thread of the client process receives the response from the process authorization module and updates the service information in the client shared memory;
[0076] (VI) The access thread of the client process obtains the master node IP and service port of the target business process from the updated client shared memory according to the reply of the process authorization module, performs character format normalization and binary conversion, and then sends a service request to the business process through a remote procedure call (RPC) connection;
[0077] (VII) The service thread of the business process listens to the RPC request of the client process, executes the corresponding business logic after receiving the request, and returns the processing result to the client process through the RPC connection;
[0078] (VIII) During the entire authorization and access control process, the keep-alive thread of the business process and the process authorization module maintain connection through heartbeat communication. At the same time, the synchronization thread of the process authorization module synchronizes information between authorization nodes through multicast to ensure the real-time and consistency of authorization information.
[0079] These processes are all developed based on the C++ language. While solving the byte order problem across operating system platforms, the business processing efficiency can meet the millisecond-level requirements of the comprehensive monitoring system. At the same time, the character format of the transmitted messages is normalized and binary converted, and the messages are transmitted through the TCP protocol and UDP protocol respectively, so that data can interact in real time between different processes between different nodes, greatly reducing the time spent on message transmission and message parsing, and realizing the authorization and access of the comprehensive monitoring system process based on the C++ language and transport layer protocol.
[0080] In order to have a clearer understanding of the above invention content and beneficial effects, the following takes the alarm_server process as an example to specifically explain the process of authorization and access in the business process side, the authorization module side and the client process side. The alarm_server is a business process, which is mainly responsible for receiving alarms sent by various business processes, and checking, classifying and sorting the alarms. After these processes, the alarms are stored and then sent to the human-machine interface.
[0081] 1. Business Process Authorization Process
[0082] The business process authorization process involves business processes and authorization modules, which are described as follows.
[0083] 1. Business process side process
[0084] Step 1: Get the monitored object information and create a process data structure, and write it into shared memory.
[0085] The class object GetInfo in the BASE_THREAD of the business process first reads the Object field related information from the configuration file config.sys to obtain all the information of the data object monitored by the current process and the basic information of the node to which it belongs. Figure 2 , all information of the data object monitored by the process includes: process identifier (identifier), line information (line), station information (station), professional description (system), equipment information (dev), equipment type (devType), operation authority (operation), operation and maintenance information (maintenance), static properties (staticProperty) and dynamic properties (dynamicProperty); basic information of the node includes static properties such as node name (nodes), node IP (ipAdrress), timeout (timeout). This information is written into the PROC_INFO structure (hereinafter referred to as process data), and then the process information of PROC_INFO is written into the area block 1 in the shared memory SHARE_MEMORY in a read-write state through the shared memory operation interface SharedMemory interface.
[0086] In the context of the present invention, the shared memory deployed on the business node is called business shared memory, the shared memory deployed on the authorization node is called authorization shared memory, and the shared memory deployed on the customer node is called customer shared memory. The role of shared memory is to speed up the process operation efficiency, but these shared memories must be divided into regional blocks according to functions and roles to store different data. In the present invention, the business shared memory is divided into regional blocks 1 and regional blocks 2, the authorization shared memory uses regional block A, and the customer shared memory uses regional blocks I, II, and III. The specific process below is described in terms of regional blocks, so there is no special distinction between business shared memory, authorization shared memory, and customer shared memory, because they can be clearly distinguished from the regional block identifier.
[0087] Step 2: Apply for authorization from the process authorization module.
[0088] 2.1 The COM_THREAD of the business process periodically calls the AttachShm interface in a read-only manner to access the area block 1 in SHARE_MEMORY, obtains the PROC_INFO information, and maps the process data to the private data memory (PRIVIRE_MEMORY) of this thread through the memory copy function Memcpy. Through the lossless memory copy method, all the original structure data are converted into normalized string data, and all the strings (CHAR) are converted into binary (BYTE) data through the C++ language encoding (ENCODE) conversion interface; because BYTE data is based on a single-byte encoding storage method, there is no problem of byte order conversion at the data level for different operating systems. The communicating parties do not need to perform byte order conversion according to the characteristics of the operating system platform when receiving and sending data, and have direct operability;
[0089] 2.2 Then, by reading the configuration file config.sys, obtain the information related to the process authorization AuthM pre-configured in this node, and call the sendTo interface to send UDP unicast to all nodes where the process authorization modules in the system are located (the request port starts from 10000, each process port is unique, and increases in sequence), apply for process authorization, and then within the specified timeout period (timeout), call the receiveFrom interface in a blocking manner and wait for a reply. When the message received from the authorization module is marked as REQUEST and the message size is 100BYTE registration request, the authorization is successful, and the information related to the authorization node in the reply message (node IP, port, reply time, etc.) is written into the REPLY_INFO structure (hereinafter referred to as the reply data), and then the reply data of REPLY_INFO is written into the shared memory SHARE_MEMORY in a read-write state through the SharedMemory interface. Area block 2;
[0090] 2.3 If the information is not received within the timeout period, receiveFrom throws an exception, the system records the failure log, and sends the configuration prompt to the terminal, indicating that the registration failed, and decides whether to resend the application for authorization or exit the process based on the pre-configured information. The timeout period can be dynamically configured. If the registration has been successful, the reply from other nodes is ignored by the process.
[0091] Step 3: Maintain connection with the authorization module through the heartbeat mechanism.
[0092] 3.1 The KEEPALIVE_THREAD of the business process first binds the receiving port through the bind interface, and calls receiveFrom in a non-blocking manner to poll and receive the heartbeat reply message with a message identifier of HEARTBEAT and a message size of 50 BYTE replied by the authorization node through port 10700;
[0093] 3.2 If receiveFrom has a return value, read the message content, obtain the data of the sendTime field in the message, and write it into the refreshTime field in the REPLY_INFO data through the AttachShm interface;
[0094] 3.3 If receiveFrom returns 0, the AttachShm interface is periodically called in a read-write mode to access the area block 2 in SHARE_MEMORY to obtain the data of REPLY_INFO. First, the time interface is called to obtain the current time, and then compared with the message refresh time (refreshTime) of the REPLY_INFO data to determine whether it is less than the predefined timeout period;
[0095] 3.4 If it is greater, call the DelShm interface to delete the REPLY_INFO data in the corresponding area block 2;
[0096] 3.5 If it is less than, the sendTo interface is called to send a HEARTBEAT message to the authorized node in real time through a fixed port (port number 10700) to the authorized node IP. The message content includes: source IP (sourceIP), source process (sourceProc), message sending time (sendTime), dynamic properties (dynamicProperty) of the current process monitoring data object, and operation permissions (operation) and other information. The message is transmitted in UDP protocol.
[0097] 2. Authorization module side process
[0098] Step 1: Receive and process the authorization request of the business process to complete the business process authorization.
[0099] 1.1 The REG_THREAD of the authorization module first applies for several socket communication objects. The socket is bound to the receiving port through bind (the initial port number is 10000, and each socket object is incremented by 1 in turn. Each port number corresponds to the same business process). ReceiveFrom is called in a non-blocking polling manner to receive the authorization request of the business process.
[0100] 1.2 If there is a non-zero return value of receiveFrom of the socket, the packet message in receiveFrom is obtained, and the BYTE data in the message is converted into data of the PROC_INFO structure through the C++ language decoding (DECODE) conversion interface, and the process identifier (identifier) and node IP (ipAdrress) are obtained from PROC_INFO. The following takes the process alarm_server running on the node RUN_NODE1 (IP is 100.100.100.100) as an example to explain, and through the double keyword (doubleKey) loop traversal, find and obtain the field with identifier alarm_server and node IP 100.100.100.100 in the shared memory SHARE_MEMORY area block A. If found, the time interface is called to obtain the current time, and then the AttachShm interface is called to write the current time just obtained to the refreshTime field to update the refresh access time;
[0101] 1.3 If it cannot be found, a load balancing judgment is required to determine which authorization node will respond to the authorization request. First, the AttachShm interface is called to obtain the authorization node (authNode) field of all data records, and sort them in descending order, that is, arrange them from small to large according to the number of data records, and store the counted authNode names in the list AuthNodeList;
[0102] 1.4 Prepare a reply message. The message structure includes a message identifier of REQUEST and a message size of 100 BYTE CHAR. The 100 BYTE CHAR is converted into binary (BYTE) data through the C++ language encoding (ENCODE) conversion interface and is ready to be sent.
[0103] 1.5 Get the authorization node name from AuthNodeList in turn, call the strncmp interface to compare with the current authorization node. If the node name is the current node, immediately call the sendTo interface to reply UDP unicast to the port that received this message (port 10000 in the above case).
[0104] 1.6 If the node name of the current authNode field is not the current node, poll the next authNode field node and perform +1 on the statistical num (the initial statistical num is 0) until the current node is found. At this time, delay num cycles (the general cycle is predefined as 100ms), and then call the sendTo interface to reply UDP unicast to the port that received this message (port 10000 in the above example).
[0105] 1.7 If the current node is still not found after traversing AuthNodeList, the sendTo interface is immediately called to reply UDP unicast to the port that received this message (port 10000 in the above example).
[0106] 1.8 After replying to the business process, continue to call the AddShm interface to add a new sub-area in the shared memory SHARE_MEMORY area block A, store the PROC_INFO information of the process identifier (identifier) and node IP (ipAdrress) doubleKey alarm_server and 100.100.100.100 respectively, and write the current time just obtained in the refreshTime field on the current data record by calling the Write interface and write the current authorized node name in the authNode field by calling the Write interface; when the AddShm interface is called successfully, the business process authorization registration is completed.
[0107] Step 2: Maintain the real-time and consistency of process status through the heartbeat mechanism.
[0108] 2.1 The HEARTBEAT_THREAD of the authorization module first binds the receiving port through the bind interface, and calls the receiveFrom interface in a non-blocking manner to poll and receive the message sent by the business process through port 10700. The message is marked as HEARTBEAT and the message size is 150 BYTE heartbeat message;
[0109] 2.2 If receiveFrom has a return value, read the message content. Take the process alarm_server as an example. Through loop traversal, obtain the field with identifier alarm_server and node IP 100.100.100.100 in the shared memory SHARE_MEMORY area block A. If found, call the AttachShm interface to write the data of the sendTime field in the message to the refreshTime field to update the refresh access time; at the same time, call the sendTo interface to reply to the business process with a heartbeat reply message with the identifier HEARTBEAT and a message size of 50 BYTE;
[0110] 2.3 If receiveFrom returns 0, the AttachShm interface is called cyclically to obtain the refreshTime and timeout of each process identifier (identifier) in the shared memory SHARE_MEMORY area block A, and the time interface is called to obtain the current time currentTime; the difference between refreshTime and currentTime is compared with the timeout time. If the timeout time is exceeded, it means that the current process has not received the HEARTBEAT heartbeat message for a long time. The business process may have exited or failed on the business node. It is necessary to clear the process information on the authorization node, then call the DelShm interface to delete all information in the sub-area corresponding to the identifier in the SHARE_MEMORY area block A, and then poll in sequence until all identifiers in the shared memory are traversed.
[0111] Step 3: Information synchronization between authorized nodes.
[0112] 3.1 The SYNCHRON_THREAD of the authorization module is responsible for information synchronization between authorization module nodes. The class object MulticastObject first reads the multicast field related information from the configuration file config.sys, including but not limited to the multicast address (MultiIP), multicast port (MultiPort), etc.; then applies for the multicast socket multisock, binds the MultiPort through the bind interface, waits to receive the multicast message, and then calls the joinGroup interface to actively add the MultiIP to the multicast group to complete the multicast subscription;
[0113] 3.2 MulticastObject first calls the AttachShm interface and sets the acquisition condition to "authNode field = current node" information, then reads PROC_INFO from the shared memory SHARE_MEMORY area block A and stores it in ProcInfoList, then polls in sequence, maps the PROC_INFO of each process identifier (identifier) in the SHARE_MEMORY area block A to the ProcInfoList in the private data memory (PRIVIRE_MEMORY) of this thread through the Memcpy method, and converts all the data in ProcInfoList into normalized string data through lossless memory copy, and converts all the strings (CHAR) into binary (BYTE) data through the C++ language encoding (ENCODE) conversion interface, and then calls the sendTo interface to send IGMP protocol messages for multicast distribution to all authorized nodes;
[0114] 3.3 multisock calls the poll interface to receive multicast messages. When poll>0, it calls the receiveFrom interface to obtain the packet message in receiveFrom. Through the DECODE interface, it converts the BYTE data in the message into data of the PROC_INFO structure, and then stores it in the ProcInfoList in sequence through the Memcpy method.
[0115] 3.4 Then MulticastObject takes a process identifier (alarm_server) from ProcInfoList, loops through each process identifier (identifier) from the shared memory SHARE_MEMORY area block A for comparison, and if a match is found, continues. If no match is found, the AddShm interface is called to add a new sub-area in the shared memory SHARE_MEMORY area block A, and all the PROC_INFO information of alarm_server in ProcInfoList is stored in the current sub-area, and then the next process identifier is taken out from ProcInfoList, and step 3.4 is repeated.
[0116] 2. Client process access process
[0117] The client process access process involves the processing of the client process, authorization module and business process, which are described as follows.
[0118] 1. Client process side process
[0119] Step 1: Get the target process host IP and port.
[0120] 1.1 The client process's REQUIRE_THREAD class object GetServiceInfo first reads the relevant information of the relevant Service field from the configuration file config.sys, obtains the required target process information (including process identifier (identifier), device information (dev) and operation permissions (operation)), and writes it into the REQUIRE_INFO structure (hereinafter referred to as this data as request data). Then, through the SharedMemory interface, the request information of REQUIRE_INFO is written into the area block I in the client process's shared memory SHARE_MEMORY in a read-write state.
[0121] 1.2 The class object GetServiceInfo reads the process authorization AuthM field related information from the configuration file config.sys, obtains the IP information and port information of the nodes where all process authorization modules are located, and stores them in the private memory AuthMList;
[0122] 1.3 REQUIRE_THREAD applies for a TCP socket, obtains the node IP and port from AuthMList, calls the connect interface in a blocking manner, establishes a TCP link to the node where the process authorization module is located, and sends a service query request;
[0123] 1.4 If the timeout period is exceeded, connect throws an exception, and REQUIRE_THREAD obtains the next node IP and port from AuthMList in order, repeats step 1.3, and the connect return value is > 0, successfully establishing a TCP link with the authorized node;
[0124] 1.5 class object GetServiceInfo calls AttachShm interface in read-only mode to access area block I in SHARE_MEMORY, obtains REQUIRE_INFO information, and maps process data to the private data memory (PRIVIRE_MEMORY) of this thread through Memcpy. Through lossless memory copy, all original structure data are converted into normalized string data, and through C++ language encoding (ENCODE) conversion interface, all strings (CHAR) are converted into binary (BYTE) data. Then, TCPsocket in step 1.3 is used to call sendBytes interface to send a request to the authorized node that establishes TCP link.
[0125] 1.6 TCPsocket calls the poll interface to receive the TCP reply message from the authorization module. When poll>0, the receiveBytes interface is called to obtain the reply packet message, and the BYTE data in the message is converted into data of the PROC_INFO structure through the DECODE interface. Taking the process alarm_server as an example, the field with the identifier of alarm_server in the shared memory SHARE_MEMORY area block II is searched and traversed in a loop. If found, the time interface is called to obtain the current time currentTime, and then the currentTime is written to the refreshTime field by calling the AttachShm interface to update the refresh time;
[0126] 1.7 If not found, call the AddShm interface to add a new sub-area in the shared memory SHARE_MEMORY area block II, store all the PROC_INFO information of alarm_server in the current sub-area and return.
[0127] Step 2: Send a remote call service request to the target process to implement the remote call of the service.
[0128] 2.1 The AccessObject object of the ACCESS_THREAD of the client process periodically calls the AttachShm interface in a read-only manner to access the area block II in SHARE_MEMORY, obtains the IP and port of the main node where the alarm_server process is located, and then continues to periodically call the AttachShm interface in a read-only manner to access the area block I in SHARE_MEMORY, and obtains the device information (dev) and operation permissions (operation) in REQUIRE_INFO. Taking the alarm_window client process as an example, the device information (dev) and operation permissions (operation) in its REQUIRE_INFO correspond to the alarm information of the device required and the operation of this alarm information (such as alarm push map or alarm flashing), and then converts all REQUIRE_INFO into normalized string data through the Memcpy method, and converts all strings (CHAR) into binary (BYTE) data through the ENCODE interface;
[0129] 2.2 ACCESS_THREAD applies for an RPC (remote call) object, sends a synchronous real-time request to the master node IP and port by calling the RPCRequest interface, and waits for the RPCRequest to return in a blocking manner. If the RPCRequest returns within the specified time, the RPC object accesses the area block III in SHARE_MEMORY by calling the AttachShm interface and stores the returned relevant information; if it does not return within the timeout, RPCRequest directly throws an exception, the system records the failure log, and prompts the terminal according to the configuration, indicating that the acquisition process failed, and then decides whether to resend the remote call request or ignore it based on the operation of the client process.
[0130] 2. Authorization module side process
[0131] Step 1: Monitor the access of the client process.
[0132] 1.1 The LISTEN_THREAD class object RecvRequest of the authorization module first applies for a TCP listening listenSocket, binds the receiving port (11000) through the bind interface, and calls the listen interface to wait for the connection request of the client process;
[0133] 1.2 LISTEN_THREAD initializes the thread pool object TheadPoolObject, calls the constructor TheadPool interface, sets the number of threads to 1024, and sets the thread trigger mode to immediate trigger;
[0134] 1.3 listenSocket calls the select interface in a loop to poll the connection request of the client process. When select returns 0, it sleeps for 10us. When the select return value is > 0, it calls the acceptConnection interface to obtain the client process link clientSocket1. At this time, it calls the CreateThread interface of the TheadPoolObject object, extracts a thread Thread1 from the thread pool, and passes the previous clientSocket1 as a parameter to Thread1.
[0135] Step 2: Select and reply to the authorized node.
[0136] 2.1 In the newly extracted Thread1 in the authorization module, clientSocket1 calls the poll interface to receive the client process TCP request message. When poll>0, the receiveBytes interface is called to obtain the link request message, and the BYTE data in the message is converted into data of the REQUIRE_INFO structure through the DECODE interface, and the process identifier (identifier) is obtained from the data. Taking the identifier as alarm_server as an example, all data records with the identifier of alarm_server in the shared memory SHARE_MEMORY area block A are obtained. By calling the AttachShm interface, the node IP (ipAdrress) field and port (port) field of all data records are obtained, and they are arranged in descending order through sort, that is, they are arranged from small to large according to the number of data records. The name of the ipAdrress with the least statistics is recorded and recorded as minNode;
[0137] 2.2 Thread1's class object ThreadOpt packages the above minNode, identifier and port information into a REPLY_PACKET data structure, converts all REPLY_PACKET into normalized string data through lossless memory copy, and converts all strings (CHAR) into binary (BYTE) data through the ENCODE interface. Then, clientSocket1 is used to call the sendBytes interface to reply to the client process that established the TCP link.
[0138] 3. Business process side process
[0139] Step 1: Listen to and process requests from client processes.
[0140] 1.1 The class object ProcService of SERVICE_THREAD of the business process first applies for a remote call socket RPCSocket based on the TCP protocol, binds the receiving port through the bind interface (each business process has a fixed access port, see configuration for details), and calls the listen interface to wait for the connection request of the client process;
[0141] 1.2 RPCSocket calls the select interface in a loop to poll the client process's connection request. When select returns 0, it waits for a certain period of time and sleeps for 10us. When the select return value is > 0, it calls the acceptConnection interface to obtain the client process connection serverSocketA.
[0142] 1.3 serverSocketA calls the poll interface to receive the client process TCP request message. When poll>0, it calls the receiveBytes interface to obtain the RPC link request message, and converts the BYTE data in the message into data of the REQUIRE_INFO structure through the DECODE interface, and obtains the process identifier (identifier) from the data. Taking the identifier as alarm_server as an example, it calls the GetShmByMutilKey interface to obtain the data in the shared memory SHARE_MEMORY area block 1 with the identifier of alarm_server, dev and operation consistent with REQUIRE_INFO, and packs them into the PROC_INFO structure, and converts them all into normalized string data. It converts all CHAR into BYTE data through the ENCODE interface, and directly calls the reply interface through serverSocketA to return;
[0143] 1.4 If poll<0, serverSocketA directly calls the closesocket interface to close the socket and record the failure log.
[0144] The present invention deploys authorization processes, business processes and client processes developed in C++ language. Each process cooperates with each other through the above-mentioned processing process to complete the process authorization and access control of the rail transit integrated monitoring system. While solving the cross-operating system platform byte order, the business processing efficiency can meet the millisecond-level requirements of the integrated monitoring system. In the authorization process, the external communication thread and the cluster sharing thread use character format normalization for the transmission message, and through binary conversion, transmit the message through TCP protocol and UDP protocol respectively, so that data can interact in real time between different processes between different nodes, greatly reducing the time spent on message transmission and message parsing, and improving the system's comprehensive performance and overall efficiency.
[0145] The present invention also provides a rail transit integrated monitoring system process authorization and access control system, comprising: a business node, a client node, and an authorization node, wherein the business node is any node running a business process of the integrated monitoring system, the client node is any node running a client process, and the authorization node is any node deployed with a process authorization module, wherein the process authorization module is used to authorize the business process and perform access control on the client process;
[0146] The business process includes a basic thread, a communication thread, a service thread and a keep-alive thread; the process authorization module is an authorization process, including a registration thread, a heartbeat thread, a synchronization thread and a listening thread; the client process includes a query thread and an access thread;
[0147] When the business process is started, its basic thread reads the monitoring object information from the configuration file and writes the information into the business shared memory. Its communication thread copies the data in the business shared memory, normalizes the character format and converts it into binary, and then makes an authorization request to the process authorization module through unicast. The registration thread of the process authorization module decides whether to authorize the business process according to the authorization policy and load balancing, and writes the authorization result into the authorization shared memory.
[0148] Before accessing the service process, the client process reads the target service process information from the configuration file and writes it into the client shared memory, performs character format normalization and binary conversion, and then sends a query request to the process authorization module through a TCP link; the listening thread of the process authorization module accepts the query request of the client process, retrieves the information of the target service process from the authorized shared memory, performs character format normalization and binary conversion, and then replies the minimum load node information to the client process through a TCP link; the query thread of the client process receives the reply of the process authorization module and updates the service information in the client shared memory;
[0149] The access thread of the client process obtains the main node IP and service port of the target business process from the updated client shared memory according to the reply of the process authorization module, performs character format normalization and binary conversion, and then sends a service request to the business process through a remote procedure call RPC connection; the service thread of the business process listens to the RPC request of the client process, executes the corresponding business logic after receiving the request, and returns the processing result to the client process through the RPC connection;
[0150] During the entire authorization and access control process, the keep-alive thread of the business process maintains connection with the process authorization module through heartbeat communication. At the same time, the synchronization thread of the process authorization module synchronizes information between authorization nodes through multicast to ensure the real-time and consistency of authorization information.
[0151] The present invention also provides a computer device, comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the programs are executed by the processors, the steps of the process authorization and access control method of the rail transit integrated monitoring system as described above are implemented.
[0152] The present invention also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the process authorization and access control method for the rail transit integrated monitoring system as described above are implemented.
[0153] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, devices (systems), computer equipment or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0154] The present invention is described with reference to a flowchart of a method according to an embodiment of the present invention. It should be understood that each process in the flowchart and a combination of processes in the flowchart can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the flowchart. Figure 1 A device that specifies functions in a process or multiple processes.
[0155] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A function specified in a process or multiple processes.
[0156] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 The steps of a specified function in a process or multiple processes.
Claims
1. A rail transit integrated monitoring system process authorization and access control method, characterized in that: The method comprises: Step 1: Deploy a process authorization module on any node in the rail transit integrated monitoring system to authorize business processes and control access to customer processes. The node where the process authorization module is deployed is called an authorization node. Step 2: When a business process on any node is started, its basic thread reads the monitoring object information from the configuration file and writes the information into the business shared memory. Its communication thread obtains the data in the business shared memory, normalizes the character format and converts it into binary, and then makes an authorization request to the process authorization module through unicast. The registration thread of the process authorization module decides whether to authorize the business process based on the authorization policy and load balancing, and writes the authorization result into the authorization shared memory. Step 3: Before accessing the service process, the query thread of the client process on any node reads the target service process information from the configuration file and writes it into the client shared memory, performs character format normalization and binary conversion, and then sends a query request to the process authorization module through the TCP link; the listening thread of the process authorization module accepts the query request of the client process, retrieves the information of the target service process from the authorized shared memory, performs character format normalization and binary conversion, and then replies the minimum load node information to the client process through the TCP link; the query thread of the client process receives the reply of the process authorization module and updates the service information in the client shared memory; Step 4: The access thread of the client process obtains the main node IP and service port of the target business process from the updated client shared memory according to the reply of the process authorization module, performs character format normalization and binary conversion, and then sends a service request to the business process through the remote procedure call RPC connection; the service thread of the business process listens to the RPC request of the client process, executes the corresponding business logic after receiving the request, and returns the processing result to the client process through the RPC connection; Step 5: During the entire authorization and access control process, the keep-alive thread of the business process maintains connection with the process authorization module through heartbeat communication. At the same time, the synchronization thread of the process authorization module synchronizes information between authorization nodes through multicast to ensure the real-time and consistency of authorization information.
2. The method according to claim 1, characterized in that: The basic thread of the business process reads the monitoring object information from the configuration file and writes the information to the business shared memory as follows: The basic thread of the business process reads the target field related information from the configuration file through the instance method of the class, obtains the current monitoring object information and the belonging node information, the current monitoring object information includes one or more of the process identifier, line information, station information, professional description, equipment information, equipment type, operation authority, operation and maintenance information, static attributes and dynamic attributes, the belonging node information includes one or more of the node name, node IP, timeout time, and writes this information into the process data structure; The process information in the process data structure is written into area block 1 in the business shared memory in a read-write state through the shared memory operation interface.
3. The method according to claim 1, characterized in that The communication thread of the business process copies the data in the business shared memory, normalizes the character format and converts it into binary, and then makes an authorization request to the process authorization module in unicast mode. The method is as follows: The communication thread of the business process periodically accesses the area block 1 in the business shared memory in a read-only manner, obtains the information in the process data structure, and maps the process data to the private data memory of this thread through the memory copy function. Through the lossless memory copy method, all the original structure data is converted into normalized string data, and all the strings are converted into binary data through the C++ language encoding conversion interface; Then, the configuration file is read to obtain the pre-configured process authorization related information of the current node, and the sending interface is called to send UDP unicast to all nodes where the process authorization modules in the system are located to apply for process authorization. After that, within the specified timeout period, the receiving interface is called in a blocking manner to wait for a reply. If a reply message is received from the process authorization module within the timeout period, the authorization is successful, and the relevant information about the authorization node in the reply message is written into the reply data structure. Then, the reply data in the reply data structure is written into the area block 2 in the business shared memory in a read-write state through the shared memory operation interface; If no information is received within the time limit, the receiving interface throws an exception, the system records a failure log, and prompts that the registration failed.
4. The method according to claim 1, characterized in that: The registration thread of the process authorization module decides whether to authorize the business process based on the authorization policy and load balancing. The method is as follows: The registration thread of the authorization module first applies for several socket communication objects, binds each socket to a receiving port, and calls the receiving interface in a non-blocking polling manner to receive the authorization request of the business process; If there is a socket receiving interface with a non-zero return value, the message in the receiving interface is obtained, and the binary data in the message is converted into a process data structure through the C++ language decoding and conversion interface, and the process identifier and node IP are obtained from the data structure, and the current process identifier and node IP information are queried in the authorized shared area block A. If obtained, the access time is updated; if not obtained, the load balancing is used to determine which authorization node will reply to the authorization request. The load balancing judgment method is as follows: obtain the authorization node field of all data records, and arrange them in descending order according to the number of data records, and store the counted authorization node names in the authorization node list; perform a delayed comparison between the authorization nodes in the authorization node list and the current authorization node in turn until the current node is found, and call the sending interface to send a reply message to the port that received this message in UDP unicast mode; After replying to the business process, a new sub-area is added to the area block A of the authorized shared memory to store the process data structure corresponding to the process identifier and node IP, and the current time and current authorized node name just obtained are written to the current data record.
5. The method according to claim 1, characterized in that The query thread of the client node reads the target business process information from the configuration file and writes it into the client shared memory. After character format normalization and binary conversion, it sends a query request to the process authorization module through a TCP link. The method is as follows: The class object of the query thread of the client process reads the relevant information of the relevant fields from the configuration file, obtains the information of the required target process, builds the request data structure, and writes it into the area block I of the client shared memory of the client process; Read the process authorization field related information from the configuration file through the class object, obtain the IP information and port information of the nodes where all process authorization modules are located, and store them in the private memory authorization node list; The query thread creates a TCP socket, obtains the node IP and port from the authorized node list, calls the connection interface in a blocking manner, and establishes a TCP link to the node where the process authorization module is located; Access the area block I in the client shared memory through the class object, obtain the request data structure information, and map the request data to the private data memory of this thread through the memory copy function. Convert all the original structure data into normalized string data through lossless memory copy, and convert all the strings into binary data through the C++ language encoding conversion interface. Then use the TCP socket to send the request to the authorized node that establishes the TCP link. Receive the response of the process authorization module by polling the TCP socket, and decode the received binary data into the process data structure through the C++ language decoding and conversion interface, search and update the timestamp of the corresponding process information in the shared memory, and add a new process information sub-area and store the data if it is not found.
6. The method according to claim 1, characterized in that The listening thread of the process authorization module accepts the query request of the client process, retrieves the information of the target business process from the authorized shared memory, normalizes the character format and converts it into binary, and then replies the minimum load node information to the client process through the TCP link. The method is as follows: The class object of the listening thread of the process authorization module creates a TCP listening socket, binds the port and starts listening, and initializes the thread pool object, setting the number of threads and the triggering method; The listening socket polls the connection request of the client process. When there is no new request, the listening thread sleeps for a short time. When there is a new request, the connection is accepted and a thread is drawn from the thread pool to handle the connection; The newly extracted thread receives the TCP request message from the client process and parses it into a request data structure. It searches for relevant data in the authorized shared memory according to the process identifier in the request, obtains the node IP and port, and sorts them in descending order. It obtains the IP address with the least statistics as the node with the least load. The class object of the newly extracted thread packs the sorted nodes, process identifiers and port information into a reply data structure, converts it into a string format through lossless memory copy, converts the string into binary data through the C++ language encoding conversion interface, and sends a reply to the client process through the TCP link.
7. The method according to claim 1, characterized in that The keep-alive thread of the business process maintains the connection with the process authorization module through heartbeat communication. The method is as follows: The keep-alive thread of the business process is bound to a receiving port, and receives the heartbeat reply message sent by the authorization node through non-blocking polling. If received, it reads the message content, obtains the message sending time and updates the refresh time in the reply data structure; If not received, access the reply data structure in the business shared memory, obtain the message refresh time and compare it with the current time to determine whether it exceeds the predefined timeout. If it exceeds the timeout, delete the reply data in the corresponding area block. If it is less than the timeout, send a heartbeat message to the authorized node through the UDP protocol, including the source IP, source process, sending time, dynamic attributes of the monitoring data object, and operation permissions; The heartbeat thread of the process authorization module is bound to a receiving port, and receives the heartbeat message sent by the business process through non-blocking polling. If it is received, the message content is read and the refresh time of the corresponding process in the authorized shared memory is updated. If it is not received, the refresh time and timeout time of each process identifier in the authorized shared memory are accessed and compared with the current time to determine whether the timeout time is exceeded. If the timeout time is exceeded, the sub-area of the corresponding process information in the authorized shared memory is deleted, and polling is performed in sequence until all processes are traversed.
8. The method according to claim 1, characterized in that The synchronization thread of the process authorization module realizes information synchronization between authorization nodes through multicast. The method is as follows: The multicast class object of the synchronization thread of the process authorization module first reads the multicast field related information from the configuration file, including the multicast address and multicast port; then creates a multicast socket, binds the multicast port, and actively adds the multicast address to the multicast group to complete the multicast subscription; The multicast class object reads the process data structure from the authorized shared memory area block A, stores it in the process list, and then polls in sequence. Through the memory copy function, the process information of each process identifier in the authorized shared memory area block A is mapped to the process list in the private data memory of this thread. Through the lossless memory copy method, all the data in the process list is converted into normalized string data, and all the strings are converted into binary data through the C++ language encoding conversion interface. Then, IGMP protocol messages are sent to all authorized nodes for multicast distribution. Receive multicast messages through multicast sockets. If received, get the message, convert the binary data in the message into process data structure through C++ language decoding conversion interface, and then store it in the process list in sequence through lossless memory copy; The multicast class object takes a process identifier from the process list, loops through each process identifier from the authorized shared memory area block A for comparison, and if a match is found, continues. If no match is found during the traversal, a new sub-area is added to the authorized shared memory area block A, and all process information of the processes in the process list is stored in the current sub-area, and then continues to process the next process identifier in the process list.
9. A rail transit integrated monitoring system process authorization and access control system, characterized in that: include: Business nodes, customer nodes, and authorization nodes. The business node is any node that runs a business process of the integrated monitoring system. The customer node is any node that runs a customer process. The authorization node is any node that has a process authorization module deployed. The process authorization module is used to authorize business processes and perform access control on customer processes. The business process includes a basic thread, a communication thread, a service thread and a keep-alive thread; the process authorization module is an authorization process, including a registration thread, a heartbeat thread, a synchronization thread and a listening thread; the client process includes a query thread and an access thread; When the business process is started, its basic thread reads the monitoring object information from the configuration file and writes the information into the business shared memory, and its communication thread copies the data in the business shared memory, normalizes the character format and converts it into binary, and then makes an authorization request to the process authorization module in a unicast manner; The registration thread of the process authorization module decides whether to authorize the business process based on the authorization policy and load balancing, and writes the authorization result into the authorization shared memory; Before accessing the service process, the client process reads the target service process information from the configuration file and writes it into the client shared memory, performs character format normalization and binary conversion, and then sends a query request to the process authorization module through a TCP link; The listening thread of the process authorization module receives the query request of the client process, retrieves the information of the target business process from the authorized shared memory, normalizes the character format and converts it into binary, and then replies the minimum load node information to the client process through the TCP link; the query thread of the client process receives the reply of the process authorization module and updates the service information in the client shared memory; The access thread of the client process obtains the main node IP and service port of the target business process from the updated client shared memory according to the reply of the process authorization module, performs character format normalization and binary conversion, and then sends a service request to the business process through a remote procedure call RPC connection; the service thread of the business process listens to the RPC request of the client process, executes the corresponding business logic after receiving the request, and returns the processing result to the client process through the RPC connection; During the entire authorization and access control process, the keep-alive thread of the business process maintains connection with the process authorization module through heartbeat communication. At the same time, the synchronization thread of the process authorization module synchronizes information between authorization nodes through multicast to ensure the real-time and consistency of authorization information.
10. A computer device, characterized in that: include: one or more processors; Memory; And one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the programs are executed by the processors, the steps of the rail transit integrated monitoring system process authorization and access control method as described in any one of claims 1-8 are implemented.
Citation Information
Patent Citations
Serial data bus communication system
CA1151743A
Data access control method and device, storage medium and database system
CN112487478A
