NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | EXAMPLES | FILES | ATTRIBUTES | SEE ALSO
cc [flags…]-I /usr/cluster/include file -L /usr/cluster/lib -l scha #include <scha.h>scha_err_t scha_cluster_open(scha_cluster_t *handle);
The scha_cluster_open(3HA), scha_cluster_get(3HA), and scha_cluster_close(3HA) functions are used together to get to information about a cluster.
scha_cluster_open(3HA) initializes cluster access and returns an access handle to be used by scha_cluster_get(3HA). The handle argument is the address of a variable to hold the value returned from the function call.
scha_cluster_get(3HA) accesses cluster information as indicated by the tag argument. The handle is a value returned from a prior call to scha_cluster_open(3HA). The tag should be a string value defined by a macro in the <scha_tags.h> header file. The arguments that follow the tag depend on the value of tag.
An additional argument following the tag might be needed to indicate a cluster node from which the information is to be retrieved. The last argument in the argument list is to be of a type suitable to hold the information indicated by tag. This is the out argument for the cluster information. No value is returned for the out parameter if the function fails. Memory that is allocated to hold information returned by scha_cluster_get(3HA) remains intact until scha_cluster_close(3HA) is called on the handle used for the scha_cluster_get(3HA).
scha_cluster_close(3HA) takes a handle argument returned from a previous call to scha_cluster_get(3HA). It invalidates the handle and frees memory allocated to return values to scha_cluster_get(3HA) calls that were made with the handle. Note that memory, if needed to return a value, is allocated for each get call. Space allocated to return a value in one call will not be overwritten and reused by subsequent calls.
The macros defined in <scha_tags.h> that may be used as tag values follow. The type of the output argument and any additional arguments are indicated. Structure and enum types are described in scha_calls(3HA).
The output argument type is char**.
It returns the name of cluster node where the function executed.
The output argument type is char**. An additional argument is of type uint_t. The additional argument is a numeric cluster node identifier.
It returns the name of the node indicated by the numeric identifier.
The output argument type is scha_str_array_t**.
It returns the names of all nodes in the cluster.
The output argument type is scha_uint_array_t**.
It returns numeric node identifiers of all the nodes in the cluster.
The output argument type is uint_t*.
It returns the numeric node identifier for the node where the command is executed.
The output argument type is uint_t*. An additional argument is of type char *. The macro requires an additional argument that is a name of a cluster node.
It returns the numeric node identifier of the node indicated by the name.
The output argument type is char**.
It returns the hostname by which the node that the command is run on as addressed on the cluster interconnect.
The output argument type is char**. An additional argument is of type char *. The macro requires an additional unflagged argument that is the name of a cluster node.
It returns the hostname by which the named node is addressed on the cluster interconnect.
The output argument type is scha_str_array_t**.
It returns the hostnames for all cluster nodes by which the nodes are addressed on the cluster interconnect.
The output argument type is scha_node_state_t*.
It returns SCHA_NODE_UP or SCHA_NODE_DOWN, depending on the state of the node where the command is executed.
The output argument type is scha_node_state_t*. An additional argument is type char*. The macro requires an additional unflagged argument that is the name of a cluster node.
It returns SCHA_NODE_UP or SCHA_NODE_DOWN, depending on the state of the named node.
The output argument type is int*.
It returns the number of the syslog(3C) facility that is used for the cluster log.
The output argument type is scha_str_array_t**.
It returns the names of all the resource groups that are being managed on the cluster.
The output argument is type scha_str_array_t**.
It returns the names of all the resource types that are registered on the cluster.
The output argument is type char**.
It returns the name of the cluster.
The scha_cluster_open() function returns the following:
The function succeeded.
The function failed.
Function succeeded.
See scha_calls(3HA) for a description of other error codes.
The following example uses the scha_cluster_get(3HA) function to get the names of all cluster nodes and find out whether the node is up or down.
#include <scha.h> #include <stdio.h> #include <stdlib.h> main() { scha_err_t err; scha_node_state_t node_state; scha_str_array_t *all_nodenames; scha_cluster_t handle; int ix; const char *str; err = scha_cluster_open(&handle); if (err != SCHA_ERR_NOERR) { fprintf(stderr, "FAILED: scha_cluster_open()0); exit(err); } err = scha_cluster_get(handle, SCHA_ALL_NODENAMES, &all_nodenames); if (err != SCHA_ERR_NOERR) { fprintf(stderr, "FAILED: scha_cluster_get()0); exit(err); } for (ix = 0; ix < all_nodenames->array_cnt; ix++) { err = scha_cluster_get(handle, SCHA_NODESTATE_NODE, all_nodenames->str_array[ix], &node_state); if (err != SCHA_ERR_NOERR) { fprintf(stderr, "FAILED: scha_cluster_get()" "SCHA_NODESTATE_NODE0); exit(err); } switch (node_state) { case SCHA_NODE_UP: str = "UP"; break; case SCHA_NODE_DOWN: str = "DOWN"; break; } printf("State of node: %s value: %s\n", all_nodenames->str_array[ix], str); } }
See for descriptions of the following attributes:
ATTRIBUTE TYPE |
ATTRIBUTE VALUE |
---|---|
Availability |
SUNWscdev |
Interface Stability |
Evolving |
scha_cluster_get(1HA), scha_calls(3HA), scha_cluster_getlogfacility(3HA), scha_cluster_getnodename(3HA), scha_strerror(3HA), attributes(5)
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | EXAMPLES | FILES | ATTRIBUTES | SEE ALSO