Notification Service integration added

Notification Service integration added
This commit is contained in:
MassimilianoPinto
2015-03-09 18:06:16 +01:00
13 changed files with 1092 additions and 66 deletions

View File

@ -18,7 +18,7 @@
* Copyright MariaDB Corporation Ab 2013-2014
*/
#include <skygw_utils.h>
#include <openssl/sha.h>
/**
* @file config.h The configuration handling elements
*
@ -30,12 +30,15 @@
* 07/05/14 Massimiliano Pinto Added version_string to global configuration
* 23/05/14 Massimiliano Pinto Added id to global configuration
* 17/10/14 Mark Riddoch Added poll tuning configuration parameters
* 05/03/15 Massimiliano Pinto Added sysname, release, sha1_mac to gateway struct
*
* @endverbatim
*/
#define DEFAULT_NBPOLLS 3 /**< Default number of non block polls before we block */
#define DEFAULT_POLLSLEEP 1000 /**< Default poll wait time (milliseconds) */
#define _SYSNAME_STR_LENGTH 256 /**< sysname len */
#define _RELEASE_STR_LENGTH 256 /**< release len */
/**
* Maximum length for configuration parameter value.
*/
@ -92,22 +95,25 @@ typedef struct config_context {
* The gateway global configuration data
*/
typedef struct {
int n_threads; /**< Number of polling threads */
char *version_string; /**< The version string of embedded database library */
unsigned long id; /**< MaxScale ID */
int n_threads; /**< Number of polling threads */
char *version_string; /**< The version string of embedded database library */
char release_string[_SYSNAME_STR_LENGTH]; /**< The release name string of the system */
char sysname[_SYSNAME_STR_LENGTH]; /**< The release name string of the system */
uint8_t mac_sha1[SHA_DIGEST_LENGTH]; /*< The SHA1 digest of an interface MAC address */
unsigned long id; /**< MaxScale ID */
unsigned int n_nbpoll; /**< Tune number of non-blocking polls */
unsigned int pollsleep; /**< Wait time in blocking polls */
} GATEWAY_CONF;
extern int config_load(char *);
extern int config_reload();
extern int config_threadcount();
extern unsigned int config_nbpolls();
extern unsigned int config_pollsleep();
CONFIG_PARAMETER* config_get_param(CONFIG_PARAMETER* params, const char* name);
config_param_type_t config_get_paramtype(CONFIG_PARAMETER* param);
CONFIG_PARAMETER* config_clone_param(CONFIG_PARAMETER* param);
int config_truth_value(char *str);
extern int config_load(char *);
extern int config_reload();
extern int config_threadcount();
extern unsigned int config_nbpolls();
extern unsigned int config_pollsleep();
CONFIG_PARAMETER* config_get_param(CONFIG_PARAMETER* params, const char* name);
config_param_type_t config_get_paramtype(CONFIG_PARAMETER* param);
CONFIG_PARAMETER* config_clone_param(CONFIG_PARAMETER* param);
extern int config_truth_value(char *);
bool config_set_qualified_param(
CONFIG_PARAMETER* param,
void* val,
@ -131,4 +137,7 @@ bool config_get_valtarget(
CONFIG_PARAMETER* param,
const char* name, /*< if NULL examine current param only */
config_param_type_t ptype);
void config_enable_feedback_task(void);
void config_disable_feedback_task(void);
#endif

View File

@ -29,13 +29,15 @@
* @verbatim
* Revision History
*
* Date Who Description
* 13/06/13 Mark Riddoch Initial implementation
* 08/07/13 Mark Riddoch Addition of monitor modules
* 29/05/14 Mark Riddoch Addition of filter modules
* 01/10/14 Mark Riddoch Addition of call to unload all modules on
* shutdown
* 19/02/15 Mark Riddoch Addition of moduleGetList
* Date Who Description
* 13/06/13 Mark Riddoch Initial implementation
* 08/07/13 Mark Riddoch Addition of monitor modules
* 29/05/14 Mark Riddoch Addition of filter modules
* 01/10/14 Mark Riddoch Addition of call to unload all modules on
* shutdown
* 19/02/15 Mark Riddoch Addition of moduleGetList
* 26/02/15 Massimiliano Pinto Addition of module_feedback_send
*
* @endverbatim
*/
@ -65,7 +67,9 @@ extern void unload_module(const char *module);
extern void unload_all_modules();
extern void printModules();
extern void dprintAllModules(DCB *);
extern char *get_maxscale_home(void);
extern RESULTSET *moduleGetList();
extern char *get_maxscale_home(void);
extern void module_feedback_send(void*);
extern void moduleShowFeedbackReport(DCB *dcb);
#endif

View File

@ -0,0 +1,63 @@
#ifndef _NOTIFICATION_SERVICE_H
#define _NOTIFICATION_SERVICE_H
/*
* This file is distributed as part of the MariaDB Corporation MaxScale. It is free
* software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation,
* version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright MariaDB Corporation Ab 2013-2014
*/
/**
* @file notification.h
*
* The configuration stuct for notification/feedback service
*
* @verbatim
* Revision History
*
* Date Who Description
* 02/03/15 Massimiliano Pinto Initial implementation
*
* @endverbatim
*/
#define _NOTIFICATION_CONNECT_TIMEOUT 30
#define _NOTIFICATION_OPERATION_TIMEOUT 30
#define _NOTIFICATION_SEND_PENDING 0
#define _NOTIFICATION_SEND_OK 1
#define _NOTIFICATION_SEND_ERROR 2
#define _NOTIFICATION_REPORT_ROW_LEN 255
#include <stdint.h>
/**
* The configuration and usage information data for feeback service
*/
typedef struct {
int feedback_enable; /**< Enable/Disable Notification feedback */
char *feedback_url; /**< URL to which the data is sent */
char *feedback_user_info; /**< User info included in the feedback data sent */
int feedback_timeout; /**< An attempt to write/read the data times out and fails after this many seconds */
int feedback_connect_timeout; /**< An attempt to send the data times out and fails after this many seconds */
int feedback_last_action; /**< Holds the feedback last send action status */
char *release_info; /**< Operating system Release name */
char *sysname; /**< Operating system name */
uint8_t *mac_sha1; /**< First available MAC address*/
} FEEDBACK_CONF;
extern char *gw_bin2hex(char *out, const uint8_t *in, unsigned int len);
extern void gw_sha1_str(const uint8_t *in, int in_len, uint8_t *out);
extern FEEDBACK_CONF * config_get_feedback_data();
#endif