IBM Books

Group Services Programming Guide and Reference

ha_gs_init subroutine

Purpose

ha_gs_init - Called by a process to register with the Group Services Application Programming Interface (GSAPI)

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_init(
                ha_gs_descriptor_t          *ha_gs_descriptor,
        const   ha_gs_socket_ctrl_t         socket_options,
        const   ha_gs_responsiveness_t      *responsiveness_control,
        const   char                        *deactivate_script,
                ha_gs_responsiveness_cb_t   *responsiveness_callback,
                ha_gs_delayed_error_cb_t    *delayed_error_callback,
                ha_gs_query_cb_t            *query_callback)
 

Parameters

ha_gs_descriptor
A pointer to a buffer in which the Group Services subsystem will return the file descriptor that the process will use to communicate with the Group Services Application Programming Interface (GSAPI).

The process itself must not read or write directly on this file descriptor.

socket_options
This flag must be set to either HA_GS_SOCKET_NO_SIGNAL or HA_GS_SOCKET_NO_SIGNAL|HA_GS_ENABLE_ADAPTER_INFO. Refer to for recommended methods of dealing with incoming messages.

HA_GS_SOCKET_NO_SIGNAL
No signals will be generated when messages arrive. Refer to for recommended methods of dealing with incoming messages.

HA_GS_ENABLE_ADAPTER_INFO
A newly added socket control option to support the adapter information. This option must be used in addition to the existing options.

responsiveness_control
A pointer to a buffer that contains a responsiveness control structure. The responsiveness control structure specifies the method, if any, that will be used to perform responsiveness checks for this process.

deactivate_script
The path name to a "deactivate script" to be called during an expel protocol. This field is optional. For more information on deactivate scripts, see the ha_gs_expel man page.

responsiveness_callback
A pointer to a callback routine that will be called when the GSAPI delivers a responsiveness notification to the GS client. For information on the responsiveness callback routine, see the ha_gs_responsiveness_callback man page.

delayed_error_callback
A pointer to a callback routine that will be called when the GSAPI needs to deliver a delayed error number for a request that is discovered asynchronously to be invalid. A delayed error number can be delivered in response to any protocol or subscription request.

query_callback
This field is reserved for IBM use.

Description

The ha_gs_init subroutine is used by a process to register itself with the Group Services Application Programming Interface (GSAPI). The subroutine allows the GSAPI to initialize itself as necessary and establishes a connection between the GSAPI and the GS client. This subroutine returns synchronously.

Only processes that meet one of the following conditions are allowed to initialize themselves with the GSAPI:

  1. Effective user ID (EUID) is root.
  2. Effective group ID (EGID) is an AIX group called hagsuser.
  3. Effective user ID is a supplementary user to hagsuser group.

Refer to PSSP: Administration Guide, SA22-7348 for information about setting up the Group Services subsystem to enable support for use of hagsuser.

As described in Group Services domains, a GS client must indicate the Group Services domain to which it wants to attach by setting the following environment variables prior to invoking ha_gs_init. This domain may be the Group Services PSSP domain. It may also be a Group Services HACMP/ES domain if HACMP/ES is installed, or it may be the RSCT domain.

The HA_DOMAIN_NAME environment variable must be set and exported in a GS client's environment to the name of the domain in which the GS client and the Group Services daemon are running. On a node, this is the domain to which the node belongs. On the control workstation, there is a Group Services daemon for each domain, and the setting of HA_DOMAIN_NAME identifies the domain and the particular Group Services daemon to which the GS client will connect.

Note:
On the RS/6000 SP, the HA_SYSPAR_NAME environment variable is still supported. However, the HA_DOMAIN_NAME environment variable is more versatile because it can be used to refer to a domain either on an RS/6000 SP or on an HACMP/ES cluster. On an RS/6000 SP, a domain is a system partition. On an HACMP/ES cluster, a domain is the entire cluster.

The responsiveness control structure has the following definition:

typedef struct
{
    ha_gs_responsiveness_type_t     gs_responsiveness_type;
    unsigned int                    gs_responsiveness_interval;
    ha_gs_time_limit_t              gs_responsiveness_response_time_limit;
    void                            *gs_counter_location;
    unsigned int                    gs_counter_length;
} ha_gs_responsiveness_t;             /* responsiveness attributes */

The responsiveness control structure is used to specify whether the process wants the GSAPI to check it periodically for responsiveness and, if so, the protocol to be used. It should be noted that the GSAPI will always be able to detect the actual exit (intentional or otherwise) of all GS clients. However, this check allows the GSAPI to determine if the GS client is able to respond in a reasonable fashion. It also allows the GS client to perform any periodic validity checks on its own operation or environment that might be needed.

If the GS client fails a responsiveness check and it is joined to any groups as a provider, the other providers in the groups receive an announcement that a provider has failed its responsiveness protocol.

The responsiveness protocol is run only when the GS client is idle. If the GS client is involved in group actions (for example, running protocols) and it is responding as expected, the GSAPI does not perform the responsiveness protocol.

The gs_responsiveness_type field contains the type of responsiveness protocol that is to be performed for this GS client. It may take one of the following values:

HA_GS_NO_RESPONSIVENESS
The GSAPI should not perform a responsiveness protocol for this GS client. The remaining fields in the structure are ignored.

HA_GS_PING_RESPONSIVENESS
The GSAPI should "ping" the GS client periodically, by delivering a notification to the GS client and expecting a response. The notification will call the responsiveness callback routine specified on input by the GS client.

HA_GS_COUNTER_RESPONSIVENESS
The GSAPI should periodically check an arithmetic counter specified by a multi-threaded GS client. If the counter is changing, the GS client is assumed to be responsive. If the counter does not change, the GSAPI will call the responsiveness callback routine specified by the GS client before assuming that the GS client is nonresponsive.

The gs_responsiveness_interval field contains the number of seconds that the GSAPI should wait between invocations of the specified responsiveness protocol.

The gs_responsiveness_response_time_limit field contains the number of seconds that the GSAPI should wait for a return from the responsiveness callback routine. If the routine fails to return, the GSAPI assumes that the GS client has become nonresponsive.

The gs_counter_location field points to the counter that the GSAPI should monitor for the HA_GS_COUNTER_RESPONSIVENESS protocol. The counter must reside in the GS client's address space. If the HA_GS_PING_RESPONSIVENESS protocol is specified, this field is ignored.

The gs_counter_length field contains the length in bytes, of the counter to be monitored. It may be a value of 2, 4, or 8. If the HA_GS_PING_RESPONSIVENESS protocol is specified, this field is ignored.

Security

The effective user ID of the calling process must be root, the effective user ID must be a supplementary user ID to an AIX group called hagsuser, or the effective group ID must be an AIX group called hagsuser.

Return Values

If the ha_gs_init subroutine is successful, it returns a value of 0 (HA_GS_OK), and the ha_gs_descriptor field contains the file descriptor of the GSAPI socket.

Error Values

If the ha_gs_init subroutine is unsuccessful, it returns an error number synchronously. The contents of the ha_gs_descriptor field are undefined.

If the calling process fails to connect the Group Services subsystem because of insufficient authority, the ha_gs_init subroutine may be successful, but ha_gs_dispatch returns an error synchronously.

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_init subroutine:

HA_GS_BAD_PARAMETER
A null delayed error callback value was given; or invalid responsiveness control information was given; or an invalid socket control flag was given (it must be HA_GS_SOCKET_NO_SIGNAL or HA_GS_SOCKET_NO_SIGNAL|HA_GS_ENABLE_ADAPTER_INFO).

HA_GS_EXISTS
This GS client has already successfully invoked ha_gs_init().

HA_GS_NO_MEMORY
The GS library is unable to allocate memory. The GS client should retry 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()).

HA_GS_NOT_SUPPORTED
The GS client was compiled against a newer version of the GS library than is currently installed on this node.

HA_GS_CONNECT_FAILED
The GS daemon on this node is not running; or this GS client does not have appropriate authority to connect the GS daemon.

HA_GS_SOCK_CREATE_FAILED
Internal error. Retry request.

HA_GS_SOCK_INIT_FAILED
Internal error. Retry request.

Asynchronous Errors

None.

Files

ha_gs.h

Prerequisite Information

Understanding Group Services.

Related Information

Structures in the ha_gs.h header file: ha_gs_responsiveness_t type definition

Subroutines: ha_gs_init, ha_gs_join, ha_gs_send_message, ha_gs_leave, ha_gs_expel, ha_gs_subscribe, ha_gs_change_attributes, ha_gs_change_state_value, ha_gs_goodbye, ha_gs_get_adapter_info, ha_gs_get_node_number.


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