Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of an information obtaining method based on a distributed system according to an embodiment of the present invention, where the present embodiment is applicable to a situation of obtaining information in a distributed system, where the distributed system includes at least one subsystem, and each subsystem includes at least one node, and the method may be executed by an information obtaining apparatus based on a distributed system, where the apparatus may be implemented by software and/or hardware and may be configured in an electronic device, and the electronic device may be configured on a vehicle, such as an unmanned vehicle with control and computing capabilities. As shown in fig. 1, the method includes:
s110, a target subsystem acquires topology messages sent by other subsystems in the distributed system, wherein the target subsystem is a subsystem newly built by the distributed system according to an information acquisition instruction, and the topology messages are used for realizing mutual discovery among the subsystems.
Specifically, when there is a need to acquire a service message in the distributed system, the distributed system may create a target subsystem according to the generated information acquisition instruction, where the target subsystem may be regarded as a null subsystem and includes a node for receiving and sending a message.
After the target subsystem is started, the target subsystem sends topology messages to other subsystems and receives topology messages sent by other subsystems. The topology message may be information for identifying or describing attributes of the subsystems, and may include, for example, names of the subsystems, names of hosts to which the subsystems belong, and the like, so as to implement mutual discovery between the subsystems. In addition, the topology message may be specifically sent in a broadcast or multicast manner, so that all subsystems in the distributed system can receive the topology messages of other subsystems.
And S120, the target subsystem sends a node information acquisition request to any subsystem in other subsystems according to the topology message, so that any subsystem packs the information of all nodes in the distributed system and sends the information to the target subsystem.
After the distributed system is started, each subsystem discovers the other subsystem by a topology discovery mode and acquires the topology network of the distributed system and the information of each subsystem and each node in each subsystem in the topology network, so that each subsystem has a copy of the information of each node in the distributed system. Therefore, by actively sending the node information acquisition request to any subsystem, the information of all nodes in the distributed system can be acquired through any node, so that the problem that the received information is incomplete due to passive reception of the node information sent by each subsystem in the prior art is solved.
In the specific implementation process, each subsystem may have a dedicated communication module for managing information of nodes in each subsystem. Therefore, when any subsystem acquires the node information acquisition request, the node information can be directly packaged through the communication module and transmitted to the target subsystem.
According to the technical scheme of the embodiment, the target subsystem sends the node information acquisition request to any subsystem in other subsystems according to the topology message, and the any subsystem directly packages and sends all information of all nodes according to the request, so that an active information acquisition mode is realized. The problem that information is passively acquired in a mode of establishing unicast channels one by an empty subsystem and a subsystem in the prior art, so that received information is possibly incomplete is solved.
Example two
Fig. 2 is a flowchart of an information obtaining method based on a distributed system according to a second embodiment of the present invention, where on the basis of the second embodiment, optionally, the distributed system includes at least two hosts, and each host includes at least one subsystem; the topology message at least comprises a subsystem name and a host name to which the subsystem belongs; correspondingly, as shown in fig. 2, the method specifically includes:
s210, a target subsystem acquires topology messages sent by other subsystems in the distributed system, wherein the target subsystem is a subsystem newly built by the distributed system according to an information acquisition instruction, and the topology messages are used for realizing mutual discovery among the subsystems.
S220, the target subsystem determines a subsystem set of the other subsystems, which belongs to the same host as the target subsystem, according to the topology messages of the other subsystems.
Because the topology message at least comprises the subsystem name and the host name to which the subsystem belongs, when the target subsystem acquires the topology message of other subsystems, the host name to which the other subsystems belong in the distributed system can be determined according to the host names to which the other subsystems belong, and the subsystem set which belongs to the same host as the target subsystem is determined.
S230, selecting any subsystem from the subsystem set, and sending the node information acquisition request to any subsystem.
The subsystem set comprises all subsystems which are the same as the host to which the target subsystem belongs. Therefore, one subsystem can be arbitrarily selected from the subsystem set, the node information acquisition request is directly sent to the subsystem, and the subsystem can package the information of all the nodes according to the node information acquisition request and send the packaged information to the target subsystem. Therefore, the target subsystem can acquire the information of all the nodes in an active acquisition mode. Because the information of the node is acquired from the subsystems belonging to the same host, the data transmission speed is higher than that of the subsystems among different hosts, and therefore the speed of acquiring the information of the node by the target subsystem is higher.
Optionally, the information of the node at least includes a node name, a node role, a process name to which the node belongs, a host name to which the node belongs, and a subject of the service message.
The node name may be a name identifier of a node, such as a first node, a second node, or the like; the node role can be the embodiment of the specific functions of the node in the distributed system, such as the publisher and/or subscriber of the message. A Process (Process) is a running activity of a program in a computer on some collection of data. In a distributed system, each process may include multiple nodes. The process name to which the node belongs may be the name of the process in which the node participates. The host name may be an identification of a host in the distributed system, such as a computing host or a controlling host. Business messages can be different classifications of message sources (feeds of messages) that are processed. And the service messages can be basic units of communication, each publisher node can publish some service messages to a topic (topic), and subscribers aiming at the topic can receive some service messages under the topic. In this embodiment, the subsystem may package these information of all nodes and send the packaged information to the target subsystem.
Optionally, the target subsystem includes a node to reduce resource occupation and speed up information acquisition in the distributed system.
According to the technical scheme of the embodiment, a subsystem set of the same host as a target subsystem in other subsystems is determined according to topology messages of the other subsystems, any subsystem is selected from the subsystem set, a node information acquisition request is sent to any subsystem, namely the node information acquisition request is directly and actively sent to the subsystem belonging to the same host, and all information of all nodes is directly packaged and sent by the subsystem according to the request. In addition, since data transmission is performed between subsystems in the same host, the scheme of the embodiment obtains information more quickly. Meanwhile, the problem that the received message is possibly incomplete due to the fact that information is passively acquired in the prior art in a mode that unicast channels are established between the empty subsystem and the subsystems one by one is avoided.
EXAMPLE III
Fig. 3 is a schematic structural diagram of an information obtaining apparatus based on a distributed system according to a third embodiment of the present invention, where the distributed system includes at least one subsystem, each subsystem includes at least one node, the apparatus is configured in a target subsystem in the distributed system, and the target subsystem is a subsystem newly built by the distributed system according to an information obtaining instruction, as shown in fig. 3, the apparatus includes:
a topologymessage obtaining module 310, configured to obtain topology messages sent by other subsystems in a distributed system, where the topology messages are used to implement mutual discovery between the subsystems;
an informationrequest sending module 320, configured to send a node information obtaining request to any subsystem of the other subsystems according to the topology message, so that the any subsystem packages information of all nodes in the distributed system and sends the packaged information to the target subsystem.
Optionally, the distributed system includes at least two hosts, and each host includes at least one subsystem; the topology message at least comprises a subsystem name and a host name to which the subsystem belongs;
correspondingly, the informationrequest sending module 320 includes:
the set determining unit is used for determining a subsystem set of the other subsystems, which belongs to the same host as the target subsystem, according to the topology messages of the other subsystems;
and the request sending unit is used for selecting any subsystem from the subsystem set and sending the node information acquisition request to any subsystem.
Optionally, the information of the node at least includes a node name, a node role, a process name to which the node belongs, a host name to which the node belongs, and a subject of the service message.
Optionally, the target subsystem comprises a node.
The information acquisition device based on the distributed system, provided by the embodiment of the invention, can execute the information acquisition method based on the distributed system provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. For details of the technology that are not described in detail in this embodiment, reference may be made to an information acquisition method based on a distributed system according to any embodiment of the present invention.
Example four
Referring to fig. 4, the present embodiment provides anelectronic device 400, which includes: one ormore processors 420; astorage device 410, configured to store one or more programs, where when the one or more programs are executed by the one ormore processors 420, the one ormore processors 420 implement an information obtaining method based on a distributed system according to an embodiment of the present invention, where the distributed system includes at least one subsystem, and each subsystem includes at least one node, and the method includes:
a target subsystem acquires topology messages sent by other subsystems in a distributed system, wherein the target subsystem is a subsystem newly built by the distributed system according to an information acquisition instruction, and the topology messages are used for realizing mutual discovery among the subsystems;
and the target subsystem sends a node information acquisition request to any subsystem in the other subsystems according to the topology message, so that the any subsystem packs the information of all nodes in the distributed system and sends the information to the target subsystem.
Of course, those skilled in the art can understand that theprocessor 420 may also implement the technical solution of the information obtaining method based on the distributed system according to any embodiment of the present invention.
Theelectronic device 400 shown in fig. 4 is only an example and should not bring any limitation to the function and the scope of use of the embodiments of the present invention.
As shown in fig. 4,electronic device 400 is embodied in the form of a general purpose computing device. The components ofelectronic device 400 may include, but are not limited to: one ormore processors 420, amemory device 410, and abus 450 that connects the various system components (including thememory device 410 and the processors 420).
Bus 450 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 400 typically includes a variety of computer system readable media. Such media may be any available media that is accessible byelectronic device 400 and includes both volatile and nonvolatile media, removable and non-removable media.
Thestorage 410 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)411 and/orcache memory 412. Theelectronic device 400 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only,storage system 413 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 4, and commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected tobus 450 by one or more data media interfaces.Storage 410 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 414 having a set (at least one) ofprogram modules 415, which may be stored, for example, instorage 410,such program modules 415 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may comprise an implementation of a network environment. Theprogram modules 415 generally perform the functions and/or methods of any of the embodiments described herein.
Electronic device 400 may also communicate with one or more external devices 460 (e.g., keyboard, pointing device,display 470, etc.), with one or more devices that enable a user to interact withelectronic device 400, and/or with any devices (e.g., network card, modem, etc.) that enableelectronic device 400 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 430. Also, theelectronic device 400 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via thenetwork adapter 440. As shown in FIG. 4, thenetwork adapter 440 communicates with the other modules of theelectronic device 400 via abus 450. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in conjunction withelectronic device 400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Theprocessor 420 executes various functional applications and data processing by executing programs stored in thestorage device 410, for example, implementing an information acquisition method based on a distributed system according to an embodiment of the present invention.
EXAMPLE five
The present embodiment provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform a method for information acquisition based on a distributed system, where the distributed system includes at least one subsystem, and each subsystem includes at least one node, and the method includes:
a target subsystem acquires topology messages sent by other subsystems in a distributed system, wherein the target subsystem is a subsystem newly built by the distributed system according to an information acquisition instruction, and the topology messages are used for realizing mutual discovery among the subsystems;
and the target subsystem sends a node information acquisition request to any subsystem in the other subsystems according to the topology message, so that the any subsystem packs the information of all nodes in the distributed system and sends the information to the target subsystem.
Of course, the storage medium containing the computer-executable instructions provided by the embodiments of the present invention is not limited to the method operations described above, and may also perform related operations in an information acquisition method based on a distributed system provided by any embodiment of the present invention.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.