![]() |
|
|||
0001 /** 0002 * @brief Singleton group support 0003 * 0004 * @file singlegrp.h 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #ifndef SINGLEGRP_H_ 0035 #define SINGLEGRP_H_ 0036 0037 #if defined(__cplusplus) 0038 extern "C" { 0039 #endif 0040 0041 /*---------------------------Includes-----------------------------------*/ 0042 #include <ndrx_config.h> 0043 #include <limits.h> 0044 #include <sys/types.h> 0045 #include <nstopwatch.h> 0046 #include <sys/types.h> 0047 #include <exatomic.h> 0048 0049 /*---------------------------Externs------------------------------------*/ 0050 /*---------------------------Macros-------------------------------------*/ 0051 0052 /** 0053 * Flags used for process groups & singleton groups, including internal 0054 * flags: 0055 */ 0056 #define NDRX_SG_IN_USE 0x0001 /**< Given group is used */ 0057 #define NDRX_SG_NO_ORDER 0x0002 /**< Do not use boot order */ 0058 #define NDRX_SG_CHK_PID 0x0004 /**< Check that PID is alive */ 0059 #define NDRX_SG_SRVBOOTCHK 0x0008 /**< Check that servers are booted */ 0060 #define NDRX_SG_VERIFY 0x0010 /**< Shall extra checks be made in locked mode */ 0061 #define NDRX_SG_SINGLETON 0x0020 /**< Singleton group (used for pgs) */ 0062 0063 #define NDRX_SG_RSN_NONE 0 /**< No reason */ 0064 #define NDRX_SG_RSN_EXPIRED 1 /**< Expird by missing refresh */ 0065 #define NDRX_SG_RSN_NOPID 2 /**< PID missing of lock holder */ 0066 #define NDRX_SG_RSN_REFNOFILE 3 /**< Reference file is missing */ 0067 #define NDRX_SG_RSN_REFFFUT 4 /**< Reference file is in future */ 0068 #define NDRX_SG_RSN_NORMAL 5 /**< Normal shutdown */ 0069 #define NDRX_SG_RSN_LOCKE 6 /**< Locking errro (by exsinglesv)*/ 0070 #define NDRX_SG_RSN_CORRUPT 7 /**< Corrupted structures */ 0071 #define NDRX_SG_RSN_NETLOCK 8 /**< Locked by network rsp (other node) */ 0072 #define NDRX_SG_RSN_NETSEQ 9 /**< Network seq ahead of us (>=) */ 0073 #define NDRX_SG_RSN_FSEQ 10 /**< Their seq in file (>=) our lck time */ 0074 0075 #define NDRX_SG_PROCNAMEMAX 16 /**< Max len of the lock process */ 0076 0077 /*---------------------------Enums--------------------------------------*/ 0078 /*---------------------------Typedefs-----------------------------------*/ 0079 0080 /** 0081 * Shared memory entries for singleton group support 0082 */ 0083 typedef struct 0084 { 0085 ndrx_atomic unsigned char is_locked; /**< Is group locked? */ 0086 ndrx_atomic unsigned char is_mmon; /**< Is maintenace mode ON? */ 0087 ndrx_atomic unsigned char is_srv_booted; /**< Is servers booted, when group locked? */ 0088 ndrx_atomic unsigned char is_clt_booted; /**< Is clients boooted, when group locked? */ 0089 ndrx_atomic unsigned short flags; /**< Flags for given entry */ 0090 ndrx_atomic time_t last_refresh; /**< Last lock refresh time */ 0091 ndrx_atomic long sequence; /**< Current ping lock seuqence */ 0092 ndrx_atomic int lockprov_srvid; /**< Lock provder server id */ 0093 ndrx_atomic short lockprov_nodeid; /**< Lock provider E/X cluster node id */ 0094 ndrx_atomic pid_t lockprov_pid; /**< Lock provider pid */ 0095 char volatile lockprov_procname[NDRX_SG_PROCNAMEMAX+1]; /**< Lock provider name */ 0096 char volatile sg_nodes[CONF_NDRX_NODEID_COUNT]; /**< Group nodes (full list us + them) */ 0097 ndrx_atomic int reason; /**< Reason code for unlock */ 0098 0099 } ndrx_sg_shm_t; 0100 0101 /*---------------------------Globals------------------------------------*/ 0102 /*---------------------------Statics------------------------------------*/ 0103 /*---------------------------Prototypes---------------------------------*/ 0104 0105 /** Return the ptr to single group in shared memory */ 0106 extern NDRX_API ndrx_sg_shm_t *ndrx_sg_get(int singlegrp_no); 0107 0108 extern NDRX_API void ndrx_sg_load(ndrx_sg_shm_t * sg, ndrx_sg_shm_t * sg_shm); 0109 0110 /** Is given group locked? */ 0111 extern NDRX_API int ndrx_sg_is_locked(int singlegrp_no, char *reference_file, long flags); 0112 extern NDRX_API int ndrx_sg_is_locked_int(int singlegrp_no, ndrx_sg_shm_t * sg, char *reference_file, long flags); 0113 0114 extern NDRX_API int ndrx_sg_do_lock(int singlegrp_no, short nodeid, int srvid, char *procname, 0115 time_t new_last_refresh, long new_sequence); 0116 extern NDRX_API void ndrx_sg_unlock(ndrx_sg_shm_t * sg, int reason); 0117 0118 /** Return snapshoot of current locking */ 0119 extern NDRX_API void ndrx_sg_get_lock_snapshoot(int *lock_status_out, int *lock_status_out_len, long flags); 0120 0121 /** Reset shared memory block having the singleton gorup infos */ 0122 extern NDRX_API int ndrx_sg_init(void); 0123 extern NDRX_API void ndrx_sg_reset(void); 0124 0125 extern NDRX_API int ndrx_sg_do_refresh(int singlegrp_no, ndrx_sg_shm_t * sg, 0126 short nodeid, int srvid, time_t new_last_refresh, long new_sequence); 0127 0128 extern NDRX_API int ndrx_sg_is_valid(int singlegrp_no); 0129 extern NDRX_API void ndrx_sg_flags_set(int singlegrp_no, unsigned short flags); 0130 extern NDRX_API unsigned short ndrx_sg_flags_get(int singlegrp_no); 0131 extern NDRX_API void ndrx_sg_nodes_set(int singlegrp_no, char *sg_nodes); 0132 0133 extern NDRX_API unsigned char ndrx_sg_bootflag_clt_get(int singlegrp_no); 0134 extern NDRX_API void ndrx_sg_bootflag_clt_set(int singlegrp_no); 0135 extern NDRX_API unsigned char ndrx_sg_bootflag_srv_get(int singlegrp_no); 0136 extern NDRX_API void ndrx_sg_bootflag_srv_set(int singlegrp_no); 0137 extern NDRX_API int ndrx_sg_is_singleton(int singlegrp_no); 0138 0139 #if defined(__cplusplus) 0140 } 0141 #endif 0142 0143 #endif 0144 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |