[BACK]Return to srm_clients.h CVS log [TXT][DIR] Up to [Development] / failsafe / FailSafe / cluster_services / include

File: [Development] / failsafe / FailSafe / cluster_services / include / srm_clients.h (download)

Revision 1.1, Thu Aug 31 19:16:32 2000 UTC (17 years, 1 month ago) by vasa
Branch: MAIN
CVS Tags: HEAD

Initial checkin

/*
 * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it would be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * 
 * Further, this software is distributed without any warranty that it is
 * free of the rightful claim of any third person regarding infringement
 * or the like.  Any license provided herein, whether implied or
 * otherwise, applies only to this software file.  Patent licenses, if
 * any, provided herein do not apply to combinations of this program with
 * other software, or any other product whatsoever.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
 * 
 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
 * Mountain View, CA 94043, or:
 * 
 * http://www.sgi.com 
 * 
 * For further information regarding this notice, see: 
 * 
 * http://oss.sgi.com/projects/GenInfo/NoticeExplan
 */
/* 
 * srm_clients.h
 *
 * This header file contains all data structures used by srm_client
 * thread.
 */

/*
 * The srm_client thread maintains a list (sc_clients_list) of 
 * information specific to each client (sc_client_t). The elements in 
 * the list are accessed by srm_main thread also.
 */

#ifndef SRM_CLIENTS_H
#define SRM_CLIENTS_H
#ident "$Id: srm_clients.h,v 1.1 2000/08/31 19:16:32 vasa Exp $"

/* For comments, see srm.h */
typedef uint32_t	sc_clnt_flags_t;
#define SCF_MUSTPULSE		SRF_MUSTPULSE	
#define SCF_SUPERUSER		SRF_SUPERUSER
#define SCF_RESSTATE		SRF_RESSTATE  
#define SCF_RESERROR		SRF_RESERROR
#define SCF_RESFLAGS		SRF_RESFLAGS
#define SCF_RESGRPSTATE		SRF_RESGRPSTATE
#define SCF_RESSTATE_GRP	SRF_RESSTATE_GRP
#define SCF_RESERROR_GRP	SRF_RESERROR_GRP

typedef enum {
    SCS_NEW		= 1,	/* This is a new client, yet to register */
    SCS_REGISTERING	= 2,	/* Registered message needs to be preped */
    SCS_REGISTERING2	= 3,	/* Registered message has been enqueued */
    SCS_REGISTERED	= 4,	/* Registered message has been sent. 
				 * In all of the above three states, the
				 * registered message could be either 
				 * registration succeeded or registration
				 * failed */
    SCS_DEREGISTERING	= 5,	/* Need to prep deregistered message */
    SCS_DEREGISTERING2	= 6,	/* Deregistered message has been enqueued */
    SCS_DEREGISTERED	= 7,	/* SRM views this client as dead */
    SCS_BADCONNECTION	= 8	/* Connection with this client has broken
				 * down. This client will be deregistered
				 * after, all requests have been satisfied,
				 * do not wait for replies to be sent. */
} sc_clnt_state_t;

typedef enum {
    SCR_REGISTER	= SMCCMD_REGISTER,
    SCR_UNREG		= SMCCMD_UNREG,
    SCR_ALLOCATE	= SMCCMD_ALLOCATE,
    SCR_RELEASE		= SMCCMD_RELEASE,
    SCR_PROBE		= SMCCMD_PROBE,
    SCR_BIND		= SMCCMD_BIND,
    SCR_UNBIND		= SMCCMD_UNBIND,
    SCR_MODIFYBIND	= SMCCMD_MODIFYBIND,
    SCR_BINDINFO	= SMCCMD_BINDINFO,
    SCR_DISCOVER	= SMCCMD_DISCOVER,
    SCR_MODIFYMON	= SMCCMD_MODIFYMON,
    SCR_DUMP		= SMCCMD_DUMP,
    SCR_RESINFO		= SMCCMD_RESINFO,
    SCR_RESSTAT		= SMCCMD_RESSTAT
} sc_clnt_req_type_t;

/* Information returned for each binding - SCR_BINDINFO request */
typedef struct sc_per_binding_resp_s {
    srm_res_req_status_t	status;		/* status for the binding */
    sr_bind_states_t		bind_state;	/* State of binding */ 
    uint32_t			res_cnt;	/* Number of resources in the
						 * binding */
} sc_per_binding_resp_t;

/* Information returned for each resource - SCR_RESINFO request */
typedef struct sc_per_resource_resp_s {
    srm_res_req_status_t	status;		/* status for the resource */
    ci_nodeid_t			res_owner;	/* Resource owner */
    sr_res_states_t		res_state;	/* Resource state */
    sr_res_err_t		res_error;	/* Resource error status */
    uint32_t			res_flags;	/* Resource flags */
} sc_per_resource_resp_t;

/* Information returned for each resource - SCR_RESSTATS request.
 * See srm.h for information on statistics returned */
typedef struct sc_per_resstat_resp_s {
    srm_res_req_status_t	rs_status;	/* resource operation status */
    uint32_t			rs_generation_no;
    uint32_t			rs_num_monfailures;
    uint32_t			rs_cumm_num_monfailures;
    uint32_t			rs_cumm_num_monitors;
    uint32_t			rs_max_monitortime;
    uint32_t			rs_min_monitortime;
    uint32_t			rs_recent_monitortime;
    uint32_t			rs_threshold_monitortime;
    uint32_t			rs_histo_monitortime[5];
} sc_per_resstat_resp_t;

/* Information returned for each resource - POLL request */
typedef struct sc_per_res_pollresp_s {
    srm_infotype_t	sp_infotype;	/* Type of information */
    uint32_t		sp_infovalue;	/* Information value - It can be 
					 * sr_res_states_t, sr_res_err_t,
					 * sr_bind_states_t or 
					 * resource flags */
    ci_nodeid_t		sp_resowner;	/* Resource owner - used when 
					 * information type is SIT_RESSTATE 
					 * and value is SRS_ALLOCATED */
    uint32_t		sp_groupid;	/* Application that owns the 
					 * resource. */
} sc_per_res_pollresp_t;


/* Structure to store reply to SCR_BINDINFO request. This structure
 * should be similar to srm_bindinfo_t. See srm.h */
typedef struct sc_bindinfo_s {
    srm_res_t			bi_binding;	/* binding name and type */
    srm_res_req_status_t	bi_status;	/* bindinfo status for the 
						 * binding */
    sr_bind_states_t		bi_state;	/* State of binding */
    uint32_t			bi_numres;	/* Number of resources */
    srm_list_t			*bi_reslist;	/* List of resources */
} sc_bindinfo_t;

typedef struct sc_per_node_probe_resp_s {
    ci_nodeid_t			nodeid;		/* Node id */
    srm_probestatus_t		alloc_status;	/* Probe status 
						 * of the resource at the 
						 * node */
} sc_per_node_probe_resp_t;

typedef struct sc_probe_resp_s {
    uint32_t			node_cnt;	/* No. of nodes probe responses
						 * are expected from */
    sc_per_node_probe_resp_t	*resp_array;	/* Array of probe responses */
} sc_probe_resp_t;
   
typedef struct sc_clnt_res_s {
    sr_rte_t			*rtep;		/* Resource id */
    srm_res_req_status_t	status;		/* Status of the request   */
    sc_probe_resp_t		probe_resp;	/* List of sc_probe_resp_t */
} sc_clnt_res_t;

typedef struct sc_clnt_res_grp_s {
    char 		*type;		/* Type of the resources in this grp */
    uint32_t		undone_cnt;	/* Resource count to be done */
    srm_list_t		*res_list;	/* Each element is of type
					 * sc_clnt_res_t. Each resource in the
					 * a list (a group) must be of the
					 * same type. */
} sc_clnt_res_grp_t;

typedef struct sc_clnt_s sc_clnt_t;

typedef struct sc_clnt_req_s {
    sc_clnt_req_type_t		type;		/* Type of client request */
    srm_list_t			*res_grp_list;	/* List of resource groups in 
						 * the request. Each element 
						 * is sc_clnt_res_grp_t */
    sc_clnt_t			*clnt;		/* Pointer to the client that
						 * made this request */
    uint32_t			hdl;		/* Handle generated by the 
						 * library to identify this 
						 * request */
    srm_flags_t			flags;		/* Request flags forced rel 
						 * etc */
    uint32_t			priority;	/* Priority of the request */
    uint32_t			grp_id;		/* The group the application 
						 * made this request belongs 
					  	 * too */
    uint32_t			node_cnt;	/* Number of nodes on which this
						 * request has to be executed, 
					 	 * relevant only for PROBE */
    uint32_t			res_cnt;	/* Number of resources in 
						 * this req */
    uint32_t			undone_cnt;	/* # of resource groups in 
						 * the request which have not 
						 * completed */
    uint32_t			todo_cnt;	/* # of resource groups in 
						 * the request for which a
						 * task has not been 
						 * scheduled */
    ci_err_t			status;		/* Status of the overall 
						 * request */
    srm_res_req_status_t	bind_status;	/* bind/unbind request */
    sr_binding_t		*bindtep;	/* Pointer to the bind table 
						 * entry in case of a
						 * bind request */
    char			*discover_type; /* String describing the 
						 * resource type this discover 
						 * request is for. */
    union {
	srm_list_t	*resstat_list;	/* List of srm_resstat_t returned as
					 * a result of a resstat operation.
					 * One resstat structure is returned
					 * for each resource */
	srm_list_t	*resinfo_list;	/* List of srm_resinfo_t returned as 
					 * a result of a resinfo operation. 
					 * One resinfo structure is returned
					 * for each resource */
	srm_list_t	*bind_list;	/* List of srm_bindinfo_t returned as a 
					 * result of a bindinfo operation. One 
					 * srm_bindinfo_t is returned for 
					 * each binding */
	srm_list_t	*discover_list;	/* List of resources resturned as a
					 * result of a discover operation */
    }			result_list;
    int			dumplevel;		/* Dump level for dump req 
						 * only */
} sc_clnt_req_t;

#define SC_GRPID_INVALID ((uint32_t) (-1))

#define SC_CHECK_ALIVE	100		/* If the check_alive reaches this
					 * number, we send a kill signal to
					 * check if client is alive */
struct sc_clnt_s {
    ipcserv_hdl_t	ipchdl;		/* IPC connection handle */
    uint32_t		check_alive;	/* Counter used to check if client
					 * is alive */
    sc_clnt_state_t	state;		/* State of the client, reg/dereg */
    ci_err_t		registration_error;
					/* Errors encountered in the process
					 * of client registration. Example:
					 * Registration request from a 
					 * library with incompatible version
					 * number. The connection is 
					 * terminated when registration is
					 * complete or when failed message
					 * is sent to the client */
    sc_clnt_flags_t 	flags;		/* Client flags */
    srm_list_t		*req_list;	/* List of sc_clnt_req_t 
					 * (unfinished client requests) */
    srm_list_t		*alloc_list;	/* List of global resource table
					   entries for all resources
					   allocated by the client */
    srm_list_t		*reqmsg_list;	/* List of unprocessed request
					 * messages */
    srm_list_t		*respmsg_list;	/* List of response messages to
					 * be sent */
};

/* srmd server connection file location */
#define SRM_IPC_CONNFILE_PREFIX		CI_HACOMM_DIR "/" CI_SRM_PREFIX

#endif /* SRM_CLIENTS_H */