Facilitating event notification through use of an inverse mapping structure for subset determination

One embodiment of the present invention provides a system that performs event notification in a distributed computing system. During operation, the system receives an event that was generated at a node in the distributed computing system, wherein the event includes a set of name/value pairs associated with the event. Next, the system compares the event against a set of client event registrations to determine a set of clients to be notified of the event, wherein each client event registration identifies a client and a target set of name/value pairs, wherein the client is to be notified of the event if the target set of name/value pairs matches a subset of the set of name/value pairs associated with the event. Finally, the system sends a notification of the event to the set of clients to be notified of the event.

BACKGROUND

1. Field of the Invention

The present invention relates to the design of distributed computing systems. More specifically, the present invention relates to a method and an apparatus that uses an inverse mapping structure for subset determination to facilitate event notification in a distributed computing system.

2. Related Art

Distributed computing systems presently make it possible to develop distributed applications that can harness the computational power of multiple computing nodes in performing a computational task. This can greatly increase the speed with which the computational task can be performed. However, it is often hard to coordinate computational activities between application components running on different computing nodes within the distributed computing system.

In order to operate properly, distributed applications must somehow keep track of the state of application components in order to coordinate interactions between the application components. This can involve periodically exchanging “heartbeat” messages or other information between application components to keep track of which application components are functioning properly.

Some distributed operating systems presently keep track of this type of information for purposes of coordinating interactions between operating system components running on different computing nodes. However, these distributed operating systems only use this information in performing specific operating system functions. They do not make the information available to distributed applications or other clients.

Hence, in many situations, a distributed application has to keep track of this information on its own. Note that the additional work involved in keeping track of this information is largely wasted because the distributed operating system already keeps track of the information. Moreover, the task of keeping track of this information generates additional network traffic, which can impede communications between nodes in the distributed computing system.

Hence, what is needed is a method and an apparatus that enables a distributed application to be notified of events that occur on different computing nodes within a distributed computing system without requiring the distributed application to perform the event monitoring operations.

One problem in performing event notification is to rapidly determine which clients are to be notified of an incoming event. The naive approach is to compare the incoming event against each of the client registrations, wherein a given client registration identifies specific events that an associated client has registered to be notified of. Note that this may require an incoming event to be compared against every client registration in the system, which can potentially be very slow.

Hence what is needed is a method and an apparatus for rapidly determine which clients are to be notified of a specific incoming event.

SUMMARY

One embodiment of the present invention provides a system that performs event notification in a distributed computing system. During operation, the system receives an event that was generated at a node in the distributed computing system, wherein the event includes a set of name/value pairs associated with the event. Next, the system compares the event against a set of client event registrations to determine a set of clients to be notified of the event, wherein each client event registration identifies a client and a target set of name/value pairs, wherein the client is to be notified of the event if the target set of name/value pairs matches a subset of the set of name/value pairs associated with the event. Finally, the system sends a notification of the event to the set of clients to be notified of the event.

In a variation on this embodiment, comparing the event against the set of client event registrations involves performing a subset determination operation to identify which client event registrations match a subset of the set of name/value pairs associated with the event.

In a further variation, for each name/value pair associated with the incoming event, performing the subset determination operation involves looking up an entry in a hash table for the name/value pair. This entry identifies which client event registrations contain matching name/value pairs. The system also increments a counter for each client event registration that contains a matching name/value pair. If the counter for a given client event registration equals the number of name/value pairs in the client event registration, the system adds the associated client to the set of clients to be notified of the event. Note that the counters are reset after each incoming event is processed.

In a variation on this embodiment, prior to receiving the event, the system initializes the hash table. This is accomplished by looking up a hash table entry for each name/value pair in each client event registration, which may involve creating hash table entries for the name/value pairs, if necessary. It also involves updating the hash table entry to point to a counter for the associated client event registration. In this way, a subsequent hash table lookup for an event can increment counters for client event registrations that contain matching name/value pairs.

In a variation on this embodiment, comparing the event against the set of client event registrations additionally involves comparing a class and a subclass associated with the event against a class and a subclass associated with each client event registration.

In a variation on this embodiment, clients can include applications or application components running within the distributed computing system. They can also include applications or application components running outside of the distributed computing system.

In a variation on this embodiment, the events can include cluster membership events, such as a node joining the cluster or a node leaving the cluster. The events can also include events related to applications, such as a state change for an application (or an application component), or a state change for a group of related applications. Note that a state change for an application (or application component) can include: the application entering an on-line state; the application entering an off-line state; the application entering a degraded state, wherein the application is not functioning efficiently; and the application entering a faulted state, wherein the application is not functioning. The events can also include state changes related to monitoring applications or other system components, such as “monitoring started” and “monitoring stopped.”

DETAILED DESCRIPTION

Distributed Computing System

FIG. 1illustrates a distributed computing system100in accordance with an embodiment of the present invention. As is illustrated inFIG. 1, distributed computing system100includes a number of clients121–123coupled to a highly available server101through a network120. Network120can generally include any type of wire or wireless communication channel capable of coupling together computing nodes. This includes, but is not limited to, a local area network, a wide area network, or a combination of networks. In one embodiment of the present invention, network120includes the Internet. Clients121–122can generally include any node on a network including computational capability and including a mechanism for communicating across the network.

Highly available server101can generally include any collection of computational nodes including a mechanism for servicing requests from a client for computational and/or data storage resources. Moreover, highly available server101is configured so that it can continue to operate even if a node within highly available server101fails. This can be accomplished using a failover model, wherein if an instance of an application fails, a new instance is automatically started, possibly on a different node within the distributed computing system.

In the embodiment illustrated inFIG. 1, highly available server101includes a number of computing nodes106–109coupled together through a cluster network102. Computing nodes106–109can generally include any type of computer system, including, but not limited to, a computer system based on a microprocessor, a mainframe computer, a digital signal processor, a portable computing device, a personal organizer, a device controller, and a computational engine within an appliance. Cluster network102can generally include any type of wire or wireless communication channel capable of coupling together computing nodes. This includes, but is not limited to, a local area network, a wide area network, or a combination of networks.

Computing nodes106–109host a number of application components110–117, which communicate with each other to service requests from clients121–123. Note that application components can include any type of application (or portion of an application) that can execute on computing nodes106–109. During operation, resources within computing nodes106–109provide a distributed event notification mechanism that can be used by application components110–117to coordinate interactions between application components110–117. This distributed event notification mechanism is described in more detail below with reference toFIGS. 2–5.

Note that although the present invention is described in the context of a highly available server101, including multiple computing nodes106–109, the present invention is not meant to be limited to such a system. In general, the present invention can be applied to any type of computing system with multiple computing nodes and is not meant to be limited to the specific highly available server101illustrated inFIG. 1.

Computing Node

FIG. 2illustrates a computing node106in accordance with an embodiment of the present invention. Computing node106contains a node operating system (OS)206, which can generally include any type of operating system for a computer system. Cluster operating system (OS)204runs on top of node OS206, and coordinates interactions between computing nodes106–109.

In one embodiment of the present invention, cluster OS204supports failover operations to provide high availability for applications running on computing nodes106–109. In this embodiment, cluster OS204ensures that state information for an application is propagated to persistent storage. In this way, if the application fails, a new instance of the application can be automatically started by retrieving the state information from persistent storage. Note that the new instance of the application can be started on either the same computing node or a different computing node. Moreover, the failover operation generally takes place without significantly interrupting ongoing operations associated with the application.

Cluster OS provides an event application programming interface (API) that can be used by application components110–111to receive event notifications. More specifically, event API202enables application components: to register to be notified of events; to post events; and to and to receive notifications for events as is described below with reference toFIGS. 3–5.

Event Forwarding Components

FIG. 3illustrates components involved in the event forwarding process in accordance with an embodiment of the present invention. As is illustrated inFIG. 3, computing nodes106–109in the highly available server101contain inter-node event forwarders (IEFs)302–305, respectively. Each of these IEFs302–305receives events generated locally on computing nodes106–109and automatically communicates the events to all of the other IEFs as is illustrated by the dashed lines inFIG. 3.

Computing node107also contains a highly available event forwarder (HA-EF)306, which is responsible for forwarding specific events to clients that desire to be notified of the specific events. HA-EF306does this by receiving an event from IEF303on computing node107and then looking up the event in a cluster database307to determine which clients desire to be notified of the event. HA-EF306then forwards the event to any clients, such as client308, that desire to be notified of the event.

Note that client308can be located within computing nodes106–109. For example, an application component110on computing node106can be notified of a change in state of an application component115on computing node107. Client308can alternatively be located at a remote client. For example, an application on client121can be notified of state changes to a group of related application components110,115and112running on computing nodes,106,107and109, respectively.

Note that HA-EF306is “highly available.” This means that if HA-EF306fails, a new instance of HA-EF306is automatically restarted, possibly on a different computing node. Note that HA-EF306can be restarted using client registration information stored within cluster database307. In one embodiment of the present invention, when a new instance of HA-EF306is restarted, the new instance asks for a snapshot of the event information from all of the other nodes.

Also note that cluster database307is a fault-tolerant distributed database that is stored in non-volatile storage associated with computing nodes106–109. In this way, the event registration information will not be lost if one of the computing nodes106–109fails.

Registration Process

FIG. 4is a flow chart illustrating the registration process for event notification in accordance with an embodiment of the present invention. The process starts when a client, such as client308inFIG. 3, sends a registration request to HA-EF306(step402). This can involve sending the registration request to an IP address associated with HA-EF306. (Note that this IP address can be a “highly-available” IP address that stays the same regardless of which cluster node HA-EF306is running on.) This registration request includes a callback address for client308. For example, the callback address can include an Internet Protocol (IP) address and associated port number for client308. The registration request also includes a list of events that the client is interested in being notified of.

Events in the list can include any type of events that can be detected within computing nodes106–109. For example, the events can include cluster membership events, such as a node joining the cluster or a node leaving the cluster. The events can also involve applications. For example, the events can include: a state change for an application (or an application component) running within the distributed computing system, or a state change for a group of related applications running within the distributed computing system.

Note that a state change for an application (or application component) can include: the application entering an on-line state; the application entering an off-line state; the application entering a degraded state, wherein the application is not functioning efficiently; and the application entering a faulted state, wherein the application is not functioning. The events can also include state changes related to monitoring applications or other system components, such as “monitoring started” and “monitoring stopped.” Also note that the present invention is not limited to the types of events listed above. In general, any other type of event associated with a computing node, such as timer expiring or an interrupt occurring, can give rise to a notification.

Upon receiving the registration request, HA-EF306records the callback address of client308and the list of events in cluster database307(step404). HA-EF306then responds “success” to client308and the registration process is complete (step406). After registering for an event, client308can simply disconnect and does not need to maintain any connections to the cluster. When an event of interest subsequently arrives, HA-EF306initiates a connection to client308to deliver the event. Thus, client308does not need to do any maintenance, except for maintaining an open listening socket.

Event Forwarding Process

FIG. 5is a flow chart illustrating the process of forwarding an event in accordance with an embodiment of the present invention. This process starts when an event is generated at one of computing nodes106–109, for example computing node106(step502). This event generation may involve an application component (or operating system component) posting the event through an event API on one of the computing nodes. In one embodiment of the present invention, events can be generated through the SOLARIS™ sysevent mechanism. (SOLARIS is a registered trademark of SUN Microsystems, Inc. of Santa Clara, Calif.)

Next, a local IEF302on computing node106receives the event and forwards the event to the other IEFs303–305located on the other computing nodes107–109(step504). In one embodiment of the present invention, the event is added to the sysevent queue in the delivered nodes, which allows the event to be treated as if it was generated locally (except that it is not again forwarded to other nodes).

Next, HA-EF306receives the event and looks up an associated list of clients in cluster database307. This lookup can involve any type of lookup structure that can efficiently lookup a set of interested clients for a specific event. HA-EF306then forwards the event to all of the clients in the list (step506). This completes the event notification process.

Note that the event notification process facilitates the development of distributed applications because it allows application components running on different computing nodes to be informed of state changes in related application components without having to exchange heartbeat messages or other status information between the application components.

Also note that in many applications, it is important to guarantee a total ordering of events. Hence if events are missed, it is advantageous for subsequent events to indicate the total state of the system, so that clients are not left with an incorrect view of the event ordering.

Data Structure for the Event Lookup Process

In one embodiment of the present invention, the event lookup process described in step506above involves an inverse mapping operation that attempts to match an incoming event with a set of client event registrations. More specifically, each incoming event specifies a class and a sub-class for the event and a set of name/value pairs associated with the event. The lookup process matches the incoming event with client event registrations that contain the same class and subclass and a subset of the name/value pairs associated with the event.

For example, a given incoming event may be associated with class=“cluster,” subclass=“resource group state” and a number of name/value pairs: {resource group name=“foo”}; {node=“node1”}; and {state=“online”}. This incoming event will match any client event registration with the same class and subclass and that contains a matching subset of the name/value pairs in the incoming event. (Note that it is possible for a client event registration to specify no name/value pairs, in which case any event with the same class and sub-class will match the client event registration.)

FIG. 6illustrates various data structures that facilitate the inverse mapping operation in accordance with an embodiment of the present invention. These data structures include a hash table602, which contains entries associated with a specific class, a specific subclass and a specific name/value pair.

Each hash table entry (604,606and608) points to linked list of pointers which point to corresponding event data structures. For example, entry604in hash table602is associated with a linked list containing pointers610,611and612, which point to event1data structures616, event2data structure617and event3data structure618, respectively. Entry606in hash table602similarly points to a linked list containing pointers613and614, which point to event2data structure617and event3data structure618, respectively. Finally, entry608in hash table602points to a linked list containing a single pointer615, which points to event3data structure618.

Event data structures616–618represent specific client event registrations. For example, inFIG. 6, a client associated with client data structure621is registered to be notified of event1and event2, which are associated with event1data structure616and event2data structure617, respectively. Event1data structure616and event2data structure617contain back pointers652and655, which point to client data structure621, and client data structure621points to a list containing event1data structure616and event2data structure617.

Similarly, a client associated with client data structure622is registered to be notified of event3, wherein event3is associated with event3data structure618. To keep track of these associations, event3data structure618contains a back pointer658, which points to client data structure622, and client data structure622points to a list containing event3data structure618. Note that client data structures621and622are part of a list of clients620.

Each event is associated with a number of properties. In particular, event1is associated with class1, subclass1and name/value pair1(nv1). To keep track of this association, entry604in hash table602is associated with a pointer612, which references counter650within event1data structure616. This allows a subsequent lookup into entry604to increment counter650. Event1data structure616also contains a total651, which specifies the number of name/value pairs associated with the event. In this case, total651is set to “one” because event1data structure616is only associated with a single name/value pair.

Whenever counter650is incremented, the resulting value is compared against total651. If the resulting value matches total651, the associated client is placed in notification list630, so that the associated client will subsequently be notified of the event.

FIG. 6also includes a visited list640, which keeps track of the counters that have been incremented for an incoming event. This allows the counters to be reset after the incoming event is processed.

Process of Initializing Event Lookup Data Structures

FIG. 7presents a flow chart illustrating the process of initializing the lookup structure involved in the event lookup process in accordance with an embodiment of the present invention. The system starts by cycling through the client event registrations. Upon accessing a specific client event registration (step702) the system creates a client data structure (such as client data structure621inFIG. 6) if one does not already exist (step704). The system also creates an event data structure for each client event registration, such as event1data structure616inFIG. 6, if one does not already exist (step706).

Next, for each name/value pair specified in the client event registration, the system creates a hash key. For example, inFIG. 6, the hash key for entry606in hash table602is created from class1, subclass1and name/value pair1. The system uses this hash key to perform a lookup in hash table602. Note that this lookup may involve creating a hash table entry for the hash key if an entry does not exist. Next, the system adds a pointer from the hash table entry to the event data structure so that subsequent lookups using the same hash key can increment a counter in the event data structure (step708).

Note that the client event registrations may be received over time as they are generated at the client computer systems during systems operation. In this case, each additional client event registrations is used to incrementally update the lookup structure.

Note that subsequent lookup operations involving the above-described data structures do not require any time-consuming string comparison operations; only fast hash table lookups and pointer lookups are required.

Operations Involved in the Event Lookup Process

FIG. 8presents a flow chart illustrating the event lookup process in accordance with an embodiment of the present invention. Upon receiving an event (step802), the system processes a name/value pair for the event (step804). This involves generating a hash key for the name/value pair and the associated class and subclass (step806). The system uses this hash key to perform a hash lookup to locate a corresponding hash table entry (step808).

Next, the system follows an event pointer in the hash table entry to locate an event data structure (step810), and then increments a counter in the event data structure (step812). The system also places a reference to the counter in visited list640, so that the counter can be reset after the event is processed. If a value in the counter equals the total number of name/value pairs associated with the event data structure, the system adds the associated client to notification list630so that the client will be notified of the event (step814). Steps810,812and814are repeated for each event pointer in the hash table entry.

Next, if there are more name/value pair associated with the event, the system returns to step804to process the next name/value pair for the event. Otherwise, the system resets all of the counters in visited list640(step818). The system also sends event notifications to all clients in visited list640and resets visited list640. At this point, the system is ready to process the next event.

Example Lookup

For the exemplary set of client event registrations illustrated inFIG. 6, suppose an incoming event has the following properties, class1, subclass1, name1=value1and name2=value2. Since there are two name/value pairs (name1=value1and name2=value2) for this event, there are two possible hash keys (class1:subclass1:name1=value1) and (class1:subclass1:name2=value2). (InFIG. 6, note that “NV1” represents name1=value1, “NV2” represents name2=value2, and “NV3” represents name3=value3.)

The system first performs a lookup based on the first hash key which returns entry604from hash table602. Entry604points to events616–618. Next, the system increments counters for events616–618so that they contain the number one. Event1, which is associated with event1data structure616, only requires one match, so the associated client is placed on notification list630. Event2and event3, which are associated with event2data structures617and event3data structure618, respectively, require more than one match, so clients for event2and event3are not placed on notification list630yet.

Next, the system performs a second lookup based on the second hash key. This second lookup returns entry606from hash table602, which points to event2data structures617and event3data structure618. The system then increments counters653and656for event2data structure617and event3data structure618so that they contain the number two. Event2only requires two matches, so the associated client is placed on notification list630. However, event3requires three matches, so the associated client for event3is not put into notification list630.

At this point, the lookup is complete, and the system sends notifications to the clients in notification list630and then clears notification list630. The system refers to visited list640to clear all of the counters that have been incremented.