#include "controller_mysql.h"
#include "dfg.h"
#include "logging.h"
#include "stats.h"
#include "stdlib.h"
#include "local_files.h"
#include "controller_dfg.h"
#include <mysql.h>
#include <stdbool.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
Go to the source code of this file.
|
int | db_register_msu_type (int msu_type_id, char *name) |
|
int | db_register_statistic (int stat_id, char *name) |
|
int | db_register_thread_stats (int thread_id, int runtime_id) |
|
static int | split_exec_cmd (char *cmd) |
|
static int | db_clear () |
|
int | db_init (int clear) |
| Initialize the MySQL client library, and connect to the server Also init tables for running system. More...
|
|
int | db_terminate () |
| Destroy the MySQL client environment. More...
|
|
int | db_register_runtime (int runtime_id) |
| Register a runtime in the DB. More...
|
|
int | db_register_thread (int thread_id, int runtime_id) |
| Register a runtime's thread in the DB. More...
|
|
int | db_register_msu (int msu_id, int msu_type_id, int thread_id, int runtime_id) |
| Register an MSU in the DB. More...
|
|
int | db_register_msu_timeseries (int msu_id) |
| Register timseries for an MSU in the DB. More...
|
|
int | db_register_thread_timeseries (int thread_id, int runtime_id) |
|
int | db_register_msu_stats (int msu_id, int msu_type_id, int thread_id, int runtime_id) |
|
int | db_check_and_register (const char *check_query, const char *insert_query, const char *element, int element_id) |
| Register an element in the DB. More...
|
|
static int | get_ts_query (char query[1024], enum stat_id stat_id, int item_id, int runtime_id) |
|
int | db_insert_sample (struct timed_stat *input, struct stat_sample_hdr *input_hdr, int runtime_id) |
| Insert datapoint for a timseries in the DB. More...
|
|
Value:
log(LOG_SQL,
"MYSQL not initialized"); \
return -1; \
}
#define log(level, fmt,...)
Log at a custom level.
Definition at line 38 of file controller_mysql.c.
#define MAX_INIT_CONTENTS_SIZE 8192 |
#define SQL_LOCK pthread_mutex_lock(&lock) |
#define SQL_UNLOCK pthread_mutex_unlock(&lock) |
int db_check_and_register |
( |
const char * |
check_query, |
|
|
const char * |
insert_query, |
|
|
const char * |
element, |
|
|
int |
element_id |
|
) |
| |
Register an element in the DB.
Does nothing if element already exists
- Parameters
-
const | char *check_query: query to check existence of element |
const | char *insert_query: query to insert element |
const | char *element: element's type |
int | element_id |
- Returns
- : 0 on success
Definition at line 385 of file controller_mysql.c.
Initialize the MySQL client library, and connect to the server Also init tables for running system.
- Parameters
-
- Returns
- : 0 on success
Definition at line 116 of file controller_mysql.c.
Insert datapoint for a timseries in the DB.
- Parameters
-
input | pointer to timed_stat object |
input_hdr | header of stat sample |
- Returns
- : 0 on success
Definition at line 455 of file controller_mysql.c.
int db_register_msu |
( |
int |
msu_id, |
|
|
int |
msu_type_id, |
|
|
int |
thread_id, |
|
|
int |
runtime_id |
|
) |
| |
Register an MSU in the DB.
Does nothing if MSU already exists
- Parameters
-
struct | dfg_msu *msu |
int | thread_id |
int | runtime_id |
- Returns
- : 0 on success
Definition at line 266 of file controller_mysql.c.
int db_register_msu_stats |
( |
int |
msu_id, |
|
|
int |
msu_type_id, |
|
|
int |
thread_id, |
|
|
int |
runtime_id |
|
) |
| |
int db_register_msu_timeseries |
( |
int |
msu_id | ) |
|
Register timseries for an MSU in the DB.
Does nothing if timeserie already exists
- Returns
- : 0 on success
Definition at line 292 of file controller_mysql.c.
int db_register_msu_type |
( |
int |
msu_type_id, |
|
|
char * |
name |
|
) |
| |
int db_register_runtime |
( |
int |
runtime_id | ) |
|
Register a runtime in the DB.
Does nothing if runtime id already exists
- Parameters
-
int | runtime_id: the runtime ID |
- Returns
- : 0 on success
Definition at line 218 of file controller_mysql.c.
int db_register_statistic |
( |
int |
stat_id, |
|
|
char * |
name |
|
) |
| |
int db_register_thread |
( |
int |
thread_id, |
|
|
int |
runtime_id |
|
) |
| |
Register a runtime's thread in the DB.
Does nothing if thread already exists
- Parameters
-
int | thread_id |
int | runtime_id |
- Returns
- : 0 on success
Definition at line 241 of file controller_mysql.c.
int db_register_thread_stats |
( |
int |
thread_id, |
|
|
int |
runtime_id |
|
) |
| |
int db_register_thread_timeseries |
( |
int |
thread_id, |
|
|
int |
runtime_id |
|
) |
| |
Destroy the MySQL client environment.
- Parameters
-
- Returns
- : 0 on success
Definition at line 176 of file controller_mysql.c.
static int get_ts_query |
( |
char |
query[1024], |
|
|
enum stat_id |
stat_id, |
|
|
int |
item_id, |
|
|
int |
runtime_id |
|
) |
| |
|
static |
static int split_exec_cmd |
( |
char * |
cmd | ) |
|
|
static |
bool mysql_initialized = false |