IBM Books

Group Services Programming Guide and Reference

ha_gs_subscribe subroutine

Purpose

ha_gs_subscribe - Called by a GS client to join a group as a subscriber

Library

GSAPI Thread-Safe Library (libha_gs_r.a)

GSAPI Library (not thread-safe) (libha_gs.a)

Syntax

#include <ha_gs.h>
 
ha_gs_rc_t
    ha_gs_subscribe(
                ha_gs_token_t           *subscriber_token,
        const   ha_gs_proposal_info_t   *proposal_info)
 

Parameters

subscriber_token
A pointer to a token that will be returned by the Group Services subsystem that is used to identify the membership of the GS client in the group as a subscriber. The GS client must pass a copy of the token on all subsequent GSAPI calls that refer to the group. The GSAPI passes a copy of the token to the GS client on all subsequent callbacks that refer to the group.

proposal_info
A pointer to a buffer that contains a proposal information block, which describes the proposed subscribe request.

Description

The ha_gs_subscribe subroutine is used by a GS client to register as a subscriber for a Group Services group. If the named group does not already exist, the HA_GS_UNKNOWN_GROUP error number is returned asynchronously by the delayed error callback routine.

Note that subscribers are known only to the Group Services subsystem. The providers of the group and the other subscribers of the group are unaware of any of the subscribers to the group.

In addition to groups defined by providers, a GS client can subscribe to a number of system-defined groups. These provide status information about nodes and various communications adapters. A listing of these groups appears later in this section. Additional information about these concepts is in the section Host and adapter membership groups.

Information about the subscribe request is supplied through the subscribe request block, which is a type of proposal information block. On the ha_gs_subscribe subroutine, specify the proposal information block as a subscribe request block. For the definition of the proposal information block, see the ha_gs_delayed_error_callback man page.

The subscribe request block has the following definition:

typedef struct {
    ha_gs_subscription_ctrl_t   gs_subscription_control;
    ha_gs_group_name_t          gs_subscription_group;
    ha_gs_subscriber_cb_t       *gs_subscription_callback;
} ha_gs_subscribe_request_t;

The gs_subscription_control field contains one or more flags that indicate the types of information that the subscriber wishes to receive about changes to the subscribed-to group. A GS client may subscribe to changes in the group's state, its membership list, or both.

The flags are not exclusive and may be specified in any combination by OR'ing the individual flags together. The flags that may be specified are:

HA_GS_SUBSCRIBE_STATE
The subscriber wants to receive the group's state value whenever the state value is updated.

HA_GS_SUBSCRIBE_DELTA_JOINS
The subscriber wants to receive the set of providers that are joining the group, whenever a join occurs.

HA_GS_SUBSCRIBE_DELTA_LEAVES
The subscriber wants to receive the set of providers that are leaving the group, whenever a voluntary leave or an involuntary leave (failure leave) occurs.

HA_GS_SUBSCRIBE_DELTAS_ONLY
The subscriber wants to receive both the set of providers that are joining the group, whenever a join occurs, and the set of providers that are leaving the group, whenever a leave occurs.

HA_GS_SUBSCRIBE_MEMBERSHIP
The subscriber wants to receive a full list of providers in the group, whenever a membership change (either join or leave) occurs. If this flag is specified along with either of the delta flags, the delta list and the full membership list are given as two separate lists during membership changes. The delta flags free the subscriber from having to determine the changing members by comparing full membership lists after getting notifications.

If HA_GS_SUBSCRIBE_MEMBERSHIP is not specified, but at least one of the delta flags is specified, the subscriber still receives the full list of providers in the group on the first subscription notification that contains membership data for the group. Subsequent notifications contain only the delta list of joining or leaving providers.

HA_GS_SUBSCRIBE_ALL_MEMBERSHIP
The subscriber wants to receive on all subscription notifications that contain membership information both the full set of providers in the group and the delta list of joining or leaving providers.

HA_GS_SUBSCRIBE_STATE_AND_MEMBERSHIP
The subscriber wants to receive all of the information described by the other flags.

The gs_subscription_group field points to a string that contains the name of the group to which the caller wishes to subscribe.

The gs_subscription_callback field points to the callback routine that is to be called when Group Services has a notification to deliver that contains data that satisfies this subscription request. A pointer to a valid function must be given in the gs_subscription_callback field. If a NULL pointer is given, a synchronous error of HA_GS_BAD_PARAMETER will be returned on the call to ha_gs_subscribe. If the pointer is not NULL but does not point to an executable function, then unpredictable results, such as fatal program failure, may occur during execution of your program.

A process can also subscribe for host or adapter membership information as follows.

These groups are specified for subscription by using the following constants:

If the SP system on which the GS client is running does not have an SP Switch, or it is not currently active on any nodes, a request to subscribe to HA_GS_CSS0_MEMBERSHIP_GROUP or HA_GS_CSS1_MEMBERSHIP_GROUP will result in an asynchronous HA_GS_UNKNOWN_GROUP delayed error.

If the node on which the GS client is running does not have an active SP Switch adapter, then a request to subscribe to HA_GS_CSSRAW_MEMBERSHIP_GROUP will result in an asynchronous HA_GS_UNKNOWN_GROUP delayed error. It is also possible to receive subscription "special" data on notifications for this group. (See Appendix A, Subscription special data.)

If a GS client is running in the Group Services PSSP domain and attempts to subscribe to one of the Group Services HACMP/ES domain system-defined groups, it will result in an asynchronous HA_GS_UNKNOWN_GROUP delayed error.

The availability of information from the adapter membership groups supported within the HACMP/ES Group Services domain depends upon the set of networks defined to HACMP/ES for heartbeating. You can specify any of the above-mentioned groups; however, the GS client will receive an asynchronous HA_GS_UNKNOWN_GROUP delayed error in the following cases:

  1. The requested adapter type is not installed on any of the nodes in this HACMP/ES cluster.
  2. The requested adapter type is installed on one or more of the nodes in this HACMP/ES cluster, but the adapter type is not specified to HACMP/ES for use in heartbeating.
  3. The requested adapter type is installed on one or more of the nodes in this HACMP/ES cluster and the adapter type is specified to HACMP/ES for use in heartbeating, but one of the following two cases exist:
    1. None of the adapters of that type on any nodes within the domain are currently active.
    2. None of the adapters of that type are active on this node.

In any case where the GS client receives an asynchronous delayed error on a subscription request, it may want to wait a period of time and reissue the request, as adapters may have become active in the interim.

For all subscriptions to system-defined groups, all controls and notifications act very much like those for subscriptions to user-defined groups. The subscription control flags in the gs_subscription_control field may be used to control the level of information received by the subscriber for the host or adapter membership group notifications.

Notifications for host or adapter membership look the same as notifications for any other group; each active node or adapter is represented as a provider. The instance number for each node "provider" is a value of 0 and the node number for each node "provider" is its node number. The instance number for each adapter "provider" is its adapter interface number (for example, a value of 2 for en2) and the node number for each adapter "provider" is the node on which it is installed.

Nodes and adapters are ordered from "oldest" to "youngest," The oldest node or adapter (that is, the first node or adapter to join its membership group) is at the head of the list and the youngest is at the end.

Restrictions

The calling process must be a GS client.

Return Values

If the ha_gs_subscribe subroutine is successful, it returns a value of 0 (HA_GS_OK) and the subscriber_token field is set to the token that identifies this subscriber's connection to the group.

Note that subscriber tokens are assigned, invalidated, and reassigned in a manner similar to the way in which file descriptors are assigned, invalidated, and reassigned as files are opened and closed.

Here is an example.

A GS client subscribes to group bar and receives subscriber token 2. When the same client unsubscribes from group bar or becomes unsubscribed because group bar is dissolved, Group Services invalidates subscriber token 2 and makes it available for reassignment. When the next GS client (it could be the same or a different GS client) subscribes to the next group (it could be the same or a different group), Group Services assigns subscriber token 2 to that client.

Error Values

If the ha_gs_subscribe subroutine is unsuccessful, it returns an error number and the contents of the subscriber_token field are undefined. If the error is detected immediately, an error is returned synchronously. If the error is detected after the call has been accepted, an error is returned asynchronously.

The GSAPI error numbers are defined in the ha_gs.h header file. For more information on GSAPI errors, see GSAPI errors (err_gsapi).

Synchronous Errors

The following errors may be returned synchronously by the ha_gs_subscribe subroutine:

HA_GS_BAD_PARAMETER
The subscription control flags contain invalid values; or the group name is not specified or is zero length.

HA_GS_NAME_TOO_LONG
The group name specified is too long.

HA_GS_NO_INIT
The GS client has not yet successfully initialized itself with Group Services by calling ha_gs_init().

HA_GS_NO_MEMORY
The GS library is unable to allocate memory. The GS client should re-try the request.

HA_GS_NOT_OK
The connection to the GS daemon has been lost. The GS client needs to reinitialize (via ha_gs_init()).

Asynchronous Errors

The following errors may be returned asynchronously by the ha_gs_subscribe subroutine:

HA_GS_BAD_PARAMETER
The specified parameter was not valid.

HA_GS_UNKNOWN_GROUP
The group that was specified on the call to the ha_gs_subscribe subroutine does not exist.

Files

ha_gs.h

Prerequisite Information

Understanding Group Services.

Related Information

Subroutines: ha_gs_init, ha_gs_unsubscribe


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]