Back to home page

Enduro/X

 
 

    


0001 /**
0002  *
0003  * @file tpadmsv.h
0004  */
0005 /* -----------------------------------------------------------------------------
0006  * Enduro/X Middleware Platform for Distributed Transaction Processing
0007  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0008  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0009  * This software is released under one of the following licenses:
0010  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0011  * See LICENSE file for full text.
0012  * -----------------------------------------------------------------------------
0013  * AGPL license:
0014  *
0015  * This program is free software; you can redistribute it and/or modify it under
0016  * the terms of the GNU Affero General Public License, version 3 as published
0017  * by the Free Software Foundation;
0018  *
0019  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0020  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0021  * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0022  * for more details.
0023  *
0024  * You should have received a copy of the GNU Affero General Public License along 
0025  * with this program; if not, write to the Free Software Foundation, Inc.,
0026  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0027  *
0028  * -----------------------------------------------------------------------------
0029  * A commercial use license is available from Mavimax, Ltd
0030  * contact@mavimax.com
0031  * -----------------------------------------------------------------------------
0032  */
0033 
0034 #ifndef TPADMSV_H
0035 #define TPADMSV_H
0036 
0037 #ifdef  __cplusplus
0038 extern "C" {
0039 #endif
0040 
0041 /*---------------------------Includes-----------------------------------*/
0042 /*---------------------------Externs------------------------------------*/
0043 extern char ndrx_G_svcnm2[];
0044 /*---------------------------Macros-------------------------------------*/
0045 
0046 /** minimum error free size to install in buffer                */
0047 #define TPADM_ERROR_MINSZ           MAX_TP_ERROR_LEN+128
0048 
0049 
0050 /** client data size                                            */
0051 #define TPADM_CLIENT_DATASZ         (sizeof(ndrx_adm_client_t)*2)
0052 
0053 /** minimum free buffer size for processing responses / paging  */
0054 #define TPADM_DEFAULT_BUFFER_MINSZ      4096
0055 /** Number of seconds to live */
0056 #define TPADM_DEFAULT_VALIDITY          30      
0057 /** houskeep of the cursors */
0058 #define TPADM_DEFAULT_SCANTIME          15
0059 /** Max number of open cursors same time */
0060 #define TPADM_DEFAULT_CURSORS_MAX       100
0061 
0062 #define TPADM_EL(X,Y)                   EXOFFSET(X, Y), #Y
0063 /*---------------------------Enums--------------------------------------*/
0064 /*---------------------------Typedefs-----------------------------------*/
0065 
0066 /**
0067  * Admin server configuration
0068  */
0069 typedef struct
0070 {
0071     int buffer_minsz;
0072     int validity;
0073     int scantime;
0074     int cursors_max;
0075 } ndrx_adm_conf_t;
0076 
0077 /**
0078  * C structure fields to UBF fields which are loaded to caller
0079  */
0080 typedef struct
0081 {
0082     BFLDID fid;         /**< UBF Field ID                                   */
0083     int c_offset;       /**< C offset                                       */
0084     char *name;         /**< Field name                                     */
0085 } ndrx_adm_elmap_t;
0086 
0087 /**
0088  * Admin cursors open
0089  */
0090 struct ndrx_adm_cursors
0091 {
0092     char cursorid[MAXTIDENT+1]; /**< Cached cursor id                       */
0093     int curspos;                /**< Current cursor position                */
0094     ndrx_growlist_t list;       /**< List of the cursor items               */
0095     
0096     ndrx_stopwatch_t w;         /**< Stopwatch when the cursor was open     */
0097     ndrx_adm_elmap_t *map;      /**< Field map for response                 */
0098     EX_hash_handle hh;          /**< makes this structure hashable          */
0099 };
0100 
0101 /**
0102  * Cursors type
0103  */
0104 typedef struct ndrx_adm_cursors ndrx_adm_cursors_t;
0105 
0106 /**
0107  * Map classes to operations
0108  */
0109 typedef struct
0110 {
0111     char *clazz;                               /**< Class name                  */
0112     char clazzshort[3];                        /**< Short class name            */
0113     /** Get cursor   */
0114     int (*p_get)(char *clazz, ndrx_adm_cursors_t *cursnew, long flags);
0115     ndrx_adm_elmap_t    *fields_map;           /**< field mappings              */
0116 } ndrx_adm_class_map_t;
0117 
0118 /*---------------------------Globals------------------------------------*/
0119 extern NDRX_API ndrx_adm_class_map_t ndrx_G_class_map[];
0120 extern NDRX_API ndrx_adm_elmap_t ndrx_G_client_map[];
0121 extern NDRX_API ndrx_adm_elmap_t ndrx_G_domain_map[];
0122 extern NDRX_API ndrx_adm_elmap_t ndrx_G_machine_map[];
0123 extern NDRX_API ndrx_adm_elmap_t ndrx_G_queue_map[];
0124 extern NDRX_API ndrx_adm_elmap_t ndrx_G_server_map[];
0125 extern NDRX_API ndrx_adm_elmap_t ndrx_G_service_map[];
0126 extern NDRX_API ndrx_adm_elmap_t ndrx_G_svcgrp_map[];
0127 extern NDRX_API ndrx_adm_elmap_t ndrx_G_brcon_map[];
0128 /*---------------------------Statics------------------------------------*/
0129 
0130 extern ndrx_adm_conf_t ndrx_G_adm_config;   /**< admin server config    */
0131 
0132 /*---------------------------Prototypes---------------------------------*/
0133 extern long ndrx_adm_error_get(UBFH *p_ub);
0134 extern int ndrx_adm_error_set(UBFH *p_ub, long error_code, 
0135         long fldid, const char *fmt, ...);
0136 
0137 /* Class types: */
0138 extern NDRX_API int ndrx_adm_client_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags);
0139 extern NDRX_API int ndrx_adm_domain_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags);
0140 extern NDRX_API int ndrx_adm_machine_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags);
0141 extern NDRX_API int ndrx_adm_queue_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags);
0142 extern NDRX_API int ndrx_adm_server_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags);
0143 extern NDRX_API int ndrx_adm_service_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags);
0144 extern NDRX_API int ndrx_adm_svcgrp_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags);
0145 extern NDRX_API int ndrx_adm_brcon_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags);
0146 
0147 extern NDRX_API int ndrx_adm_list_call(int (*p_rsp_process)(command_reply_t *reply, size_t reply_len),
0148         int req_cmd, int resp_cmd, char *dst_qstr);
0149 
0150 extern NDRX_API ndrx_adm_cursors_t* ndrx_adm_curs_get(char *cursid);
0151 
0152 extern NDRX_API ndrx_adm_cursors_t* ndrx_adm_curs_new(UBFH *p_ub, ndrx_adm_class_map_t *map,
0153         ndrx_adm_cursors_t *data);
0154 
0155 extern NDRX_API int ndrx_adm_curs_housekeep(void);
0156 extern NDRX_API void ndrx_adm_curs_close(ndrx_adm_cursors_t *curs);
0157 extern NDRX_API int ndrx_adm_curs_fetch(UBFH *p_ub, ndrx_adm_cursors_t *curs,
0158         long *ret_occurs, long *ret_more);
0159 
0160 extern NDRX_API ndrx_adm_class_map_t *ndrx_adm_class_map_get(char *clazz);
0161 
0162 #ifdef  __cplusplus
0163 }
0164 #endif
0165 
0166 #endif  /* TPADMSV_H */
0167 
0168 /* vim: set ts=4 sw=4 et smartindent: */