Merge branch 'blr' into develop

Conflicts:
	client/maxadmin.c
	server/core/CMakeLists.txt
	server/core/dcb.c
	server/core/gateway.c
	server/core/poll.c
	server/core/test/CMakeLists.txt
	server/core/test/makefile
	server/include/poll.h
	server/modules/routing/debugcmd.c
This commit is contained in:
Mark Riddoch
2014-11-19 12:00:55 +00:00
84 changed files with 2452 additions and 549 deletions

View File

@ -29,10 +29,13 @@
* 21/06/13 Mark Riddoch Initial implementation
* 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
*
* @endverbatim
*/
#define DEFAULT_NBPOLLS 3 /**< Default number of non block polls before we block */
#define DEFAULT_POLLSLEEP 1000 /**< Default poll wait time (milliseconds) */
/**
* Maximum length for configuration parameter value.
*/
@ -92,11 +95,15 @@ typedef struct {
int n_threads; /**< Number of polling threads */
char *version_string; /**< The version string of embedded database library */
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);

View File

@ -98,12 +98,28 @@ typedef struct gw_protocol {
int (*session)(struct dcb *, void *);
} GWPROTOCOL;
/**
* The event queue structure used in the polling loop to maintain a queue
* of events that need to be processed for the DCB.
*
* next The next DCB in the event queue
* prev The previous DCB in the event queue
* pending_events The events that are pending processing
* processing_events The evets currently being processed
* processing Flag to indicate the processing status of the DCB
* eventqlock Spinlock to protect this structure
* inserted Insertion time for logging purposes
* started Time that the processign started
*/
typedef struct {
struct dcb *next;
struct dcb *prev;
uint32_t pending_events;
uint32_t processing_events;
int processing;
SPINLOCK eventqlock;
unsigned long inserted;
unsigned long started;
} DCBEVENTQ;
/**

View File

@ -18,6 +18,7 @@
* Copyright MariaDB Corporation Ab 2014
*/
#include <time.h>
#include <dcb.h>
/**
* @file housekeeper.h A mechanism to have task run periodically
@ -31,6 +32,11 @@
* @endverbatim
*/
typedef enum {
HK_REPEATED = 1,
HK_ONESHOT
} HKTASK_TYPE;
/**
* The housekeeper task list
*/
@ -40,12 +46,22 @@ typedef struct hktask {
void *data; /*< Data to pass the task */
int frequency; /*< How often to call the tasks (seconds) */
time_t nextdue; /*< When the task should be next run */
HKTASK_TYPE
type; /*< The task type */
struct hktask
*next; /*< Next task in the list */
} HKTASK;
/**
* The global housekeeper heartbeat value. This value is increamente
* every 100ms and may be used for crude timing etc.
*/
extern unsigned long hkheartbeat;
extern void hkinit();
extern int hktask_add(char *name, void (*task)(void *), void *data, int frequency);
extern int hktask_oneshot(char *name, void (*task)(void *), void *data, int when);
extern int hktask_remove(char *name);
extern void hkshutdown();
extern void hkshow_tasks(DCB *pdcb);
#endif

65
server/include/memlog.h Normal file
View File

@ -0,0 +1,65 @@
#ifndef _MEMLOG_H
#define _MEMLOG_H
/*
* This file is distributed as part of MariaDB 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 Ab 2014
*/
/**
* @file memlog.h The memory logging mechanism
*
* @verbatim
* Revision History
*
* Date Who Description
* 26/09/14 Mark Riddoch Initial implementation
*
* @endverbatim
*/
#include <spinlock.h>
typedef enum { ML_INT, ML_LONG, ML_LONGLONG, ML_STRING } MEMLOGTYPE;
typedef struct memlog {
char *name;
SPINLOCK lock;
void *values;
int offset;
int size;
MEMLOGTYPE type;
unsigned int flags;
unsigned int iflags;
struct memlog *next;
} MEMLOG;
/*
* MEMLOG flag bits
*/
#define MLNOAUTOFLUSH 0x0001
/*
* MEMLOG internal flags
*/
#define MLWRAPPED 0x0001
extern MEMLOG *memlog_create(char *, MEMLOGTYPE, int);
extern void memlog_destroy(MEMLOG *);
extern void memlog_set(MEMLOG *, unsigned int);
extern void memlog_log(MEMLOG *, void *);
extern void memlog_flush_all();
extern void memlog_flush(MEMLOG *);
#endif

View File

@ -32,6 +32,8 @@
* 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
* @endverbatim
*/
@ -58,6 +60,7 @@ typedef struct modules {
extern void *load_module(const char *module, const char *type);
extern void unload_module(const char *module);
extern void unload_all_modules();
extern void printModules();
extern void dprintAllModules(DCB *);
char* get_maxscale_home(void);

View File

@ -32,7 +32,6 @@
* @endverbatim
*/
#define MAX_EVENTS 1000
#define EPOLL_TIMEOUT 1000 /**< The epoll timeout in milliseconds */
extern void poll_init();
extern int poll_add_dcb(DCB *);
@ -40,8 +39,11 @@ extern int poll_remove_dcb(DCB *);
extern void poll_waitevents(void *);
extern void poll_shutdown();
extern GWBITMASK *poll_bitmask();
extern void poll_set_maxwait(unsigned int);
extern void poll_set_nonblocking_polls(unsigned int);
extern void dprintPollStats(DCB *);
extern void dShowThreads(DCB *dcb);
void poll_add_epollin_event_to_dcb(DCB* dcb, GWBUF* buf);
extern void dShowEventQ(DCB *dcb);
extern void dShowEventStats(DCB *dcb);
#endif