Removed return of illegal pointer, changed signatures to...

Removed return of illegal pointer, changed signatures to ndb_mgm_get_clusterlog_severity_filter and ndb_mgm_get_clusterlog_loglevel
parent 7d86df6a
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
#ifndef MGMAPI_H #ifndef MGMAPI_H
#define MGMAPI_H #define MGMAPI_H
#include "mgmapi_config_parameters.h"
#include "ndb_logevent.h"
#define MGM_LOGLEVELS CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1
/** /**
* @mainpage MySQL Cluster Management API * @mainpage MySQL Cluster Management API
* *
...@@ -838,6 +843,30 @@ extern "C" { ...@@ -838,6 +843,30 @@ extern "C" {
enum ndb_mgm_event_severity severity, enum ndb_mgm_event_severity severity,
int enable, int enable,
struct ndb_mgm_reply* reply); struct ndb_mgm_reply* reply);
/**
* Get clusterlog severity filter
*
* @param handle NDB management handle
*
* @param loglevel A vector of seven (NDB_MGM_EVENT_SEVERITY_ALL)
* elements of struct ndb_mgm_severity,
* where each element contains
* 1 if a severity indicator is enabled and 0 if not.
* A severity level is stored at position
* ndb_mgm_clusterlog_level;
* for example the "error" level is stored in position
* [NDB_MGM_EVENT_SEVERITY_ERROR].
* The first element [NDB_MGM_EVENT_SEVERITY_ON] in
* the vector signals whether the cluster log
* is disabled or enabled.
* @param severity_size The size of the vector (NDB_MGM_EVENT_SEVERITY_ALL)
* @return Number of returned severities or -1 on error
*/
int ndb_mgm_get_clusterlog_severity_filter(NdbMgmHandle handle,
struct ndb_mgm_severity* severity,
unsigned int severity_size);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/** /**
* Get clusterlog severity filter * Get clusterlog severity filter
* *
...@@ -855,7 +884,8 @@ extern "C" { ...@@ -855,7 +884,8 @@ extern "C" {
* whether the cluster log * whether the cluster log
* is disabled or enabled. * is disabled or enabled.
*/ */
const unsigned int *ndb_mgm_get_clusterlog_severity_filter(NdbMgmHandle handle); const unsigned int *ndb_mgm_get_clusterlog_severity_filter_old(NdbMgmHandle handle);
#endif
/** /**
* Set log category and levels for the cluster log * Set log category and levels for the cluster log
...@@ -872,6 +902,23 @@ extern "C" { ...@@ -872,6 +902,23 @@ extern "C" {
enum ndb_mgm_event_category category, enum ndb_mgm_event_category category,
int level, int level,
struct ndb_mgm_reply* reply); struct ndb_mgm_reply* reply);
/**
* get log category and levels
*
* @param handle NDB management handle.
* @param loglevel A vector of twelve (MGM_LOGLEVELS) elements
* of struct ndb_mgm_loglevel,
* where each element contains
* loglevel of corresponding category
* @param loglevel_size The size of the vector (MGM_LOGLEVELS)
* @return Number of returned loglevels or -1 on error
*/
int ndb_mgm_get_clusterlog_loglevel(NdbMgmHandle handle,
struct ndb_mgm_loglevel* loglevel,
unsigned int loglevel_size);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/** /**
* get log category and levels * get log category and levels
* *
...@@ -880,7 +927,9 @@ extern "C" { ...@@ -880,7 +927,9 @@ extern "C" {
* where each element contains * where each element contains
* loglevel of corresponding category * loglevel of corresponding category
*/ */
const unsigned int *ndb_mgm_get_clusterlog_loglevel(NdbMgmHandle handle); const unsigned int *ndb_mgm_get_clusterlog_loglevel_old(NdbMgmHandle handle);
#endif
/** @} *********************************************************************/ /** @} *********************************************************************/
/** /**
...@@ -1153,10 +1202,14 @@ extern "C" { ...@@ -1153,10 +1202,14 @@ extern "C" {
int e, struct ndb_mgm_reply* r) int e, struct ndb_mgm_reply* r)
{ return ndb_mgm_set_clusterlog_severity_filter(h,(ndb_mgm_event_severity)s, { return ndb_mgm_set_clusterlog_severity_filter(h,(ndb_mgm_event_severity)s,
e,r); } e,r); }
struct ndb_mgm_severity {
enum ndb_mgm_event_severity category;
unsigned int value;
};
inline inline
const unsigned int *ndb_mgm_get_logfilter(NdbMgmHandle h) const unsigned int * ndb_mgm_get_logfilter(NdbMgmHandle h)
{ return ndb_mgm_get_clusterlog_severity_filter(h); } { return ndb_mgm_get_clusterlog_severity_filter_old(h); }
inline inline
int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle h, int n, int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle h, int n,
...@@ -1164,9 +1217,14 @@ extern "C" { ...@@ -1164,9 +1217,14 @@ extern "C" {
int l, struct ndb_mgm_reply* r) int l, struct ndb_mgm_reply* r)
{ return ndb_mgm_set_clusterlog_loglevel(h,n,c,l,r); } { return ndb_mgm_set_clusterlog_loglevel(h,n,c,l,r); }
struct ndb_mgm_loglevel {
enum ndb_mgm_event_category category;
unsigned int value;
};
inline inline
const unsigned int *ndb_mgm_get_loglevel_clusterlog(NdbMgmHandle h) const unsigned int * ndb_mgm_get_loglevel_clusterlog(NdbMgmHandle h)
{ return ndb_mgm_get_clusterlog_loglevel(h); } { return ndb_mgm_get_clusterlog_loglevel_old(h); }
#endif #endif
......
/* Copyright (C) 2003 MySQL AB /* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -1257,12 +1257,43 @@ ndb_mgm_get_event_severity_string(enum ndb_mgm_event_severity severity) ...@@ -1257,12 +1257,43 @@ ndb_mgm_get_event_severity_string(enum ndb_mgm_event_severity severity)
return 0; return 0;
} }
extern "C"
int
ndb_mgm_get_clusterlog_severity_filter(NdbMgmHandle handle,
struct ndb_mgm_severity* severity,
unsigned int severity_size)
{
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_clusterlog_severity_filter");
const ParserRow<ParserDummy> getinfo_reply[] = {
MGM_CMD("clusterlog", NULL, ""),
MGM_ARG(clusterlog_severity_names[0], Int, Mandatory, ""),
MGM_ARG(clusterlog_severity_names[1], Int, Mandatory, ""),
MGM_ARG(clusterlog_severity_names[2], Int, Mandatory, ""),
MGM_ARG(clusterlog_severity_names[3], Int, Mandatory, ""),
MGM_ARG(clusterlog_severity_names[4], Int, Mandatory, ""),
MGM_ARG(clusterlog_severity_names[5], Int, Mandatory, ""),
MGM_ARG(clusterlog_severity_names[6], Int, Mandatory, ""),
};
CHECK_HANDLE(handle, NULL);
CHECK_CONNECTED(handle, NULL);
Properties args;
const Properties *reply;
reply = ndb_mgm_call(handle, getinfo_reply, "get info clusterlog", &args);
CHECK_REPLY(reply, NULL);
for(unsigned int i=0; i < severity_size; i++) {
reply->get(clusterlog_severity_names[severity[i].category], &severity[i].value);
}
return severity_size;
}
extern "C" extern "C"
const unsigned int * const unsigned int *
ndb_mgm_get_clusterlog_severity_filter(NdbMgmHandle handle) ndb_mgm_get_clusterlog_severity_filter_old(NdbMgmHandle handle)
{ {
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_clusterlog_severity_filter"); SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_clusterlog_severity_filter");
unsigned int enabled[(int)NDB_MGM_EVENT_SEVERITY_ALL]= static unsigned int enabled[(int)NDB_MGM_EVENT_SEVERITY_ALL]=
{0,0,0,0,0,0,0}; {0,0,0,0,0,0,0};
const ParserRow<ParserDummy> getinfo_reply[] = { const ParserRow<ParserDummy> getinfo_reply[] = {
MGM_CMD("clusterlog", NULL, ""), MGM_CMD("clusterlog", NULL, ""),
...@@ -1377,9 +1408,46 @@ ndb_mgm_get_event_category_string(enum ndb_mgm_event_category status) ...@@ -1377,9 +1408,46 @@ ndb_mgm_get_event_category_string(enum ndb_mgm_event_category status)
static const char *clusterlog_names[]= static const char *clusterlog_names[]=
{ "startup", "shutdown", "statistics", "checkpoint", "noderestart", "connection", "info", "warning", "error", "congestion", "debug", "backup" }; { "startup", "shutdown", "statistics", "checkpoint", "noderestart", "connection", "info", "warning", "error", "congestion", "debug", "backup" };
extern "C"
int
ndb_mgm_get_clusterlog_loglevel(NdbMgmHandle handle,
struct ndb_mgm_loglevel* loglevel,
unsigned int loglevel_size)
{
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_clusterlog_loglevel");
int loglevel_count = loglevel_size;
const ParserRow<ParserDummy> getloglevel_reply[] = {
MGM_CMD("get cluster loglevel", NULL, ""),
MGM_ARG(clusterlog_names[0], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[1], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[2], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[3], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[4], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[5], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[6], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[7], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[8], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[9], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[10], Int, Mandatory, ""),
MGM_ARG(clusterlog_names[11], Int, Mandatory, ""),
};
CHECK_HANDLE(handle, NULL);
CHECK_CONNECTED(handle, NULL);
Properties args;
const Properties *reply;
reply = ndb_mgm_call(handle, getloglevel_reply, "get cluster loglevel", &args);
CHECK_REPLY(reply, NULL);
for(int i=0; i < loglevel_count; i++) {
reply->get(clusterlog_names[loglevel[i].category], &loglevel[i].value);
}
return loglevel_count;
}
extern "C" extern "C"
const unsigned int * const unsigned int *
ndb_mgm_get_clusterlog_loglevel(NdbMgmHandle handle) ndb_mgm_get_clusterlog_loglevel_old(NdbMgmHandle handle)
{ {
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_clusterlog_loglevel"); SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_clusterlog_loglevel");
int loglevel_count = CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1 ; int loglevel_count = CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1 ;
......
...@@ -1632,7 +1632,15 @@ CommandInterpreter::executeClusterLog(char* parameters) ...@@ -1632,7 +1632,15 @@ CommandInterpreter::executeClusterLog(char* parameters)
char * item = strtok_r(tmpString, " ", &tmpPtr); char * item = strtok_r(tmpString, " ", &tmpPtr);
int enable; int enable;
const unsigned int *enabled= ndb_mgm_get_logfilter(m_mgmsrv); ndb_mgm_severity enabled[NDB_MGM_EVENT_SEVERITY_ALL] =
{{NDB_MGM_EVENT_SEVERITY_ON,0},
{NDB_MGM_EVENT_SEVERITY_DEBUG,0},
{NDB_MGM_EVENT_SEVERITY_INFO,0},
{NDB_MGM_EVENT_SEVERITY_WARNING,0},
{NDB_MGM_EVENT_SEVERITY_ERROR,0},
{NDB_MGM_EVENT_SEVERITY_CRITICAL,0},
{NDB_MGM_EVENT_SEVERITY_ALERT,0}};
ndb_mgm_get_clusterlog_severity_filter(m_mgmsrv, &enabled[0], NDB_MGM_EVENT_SEVERITY_ALL);
if(enabled == NULL) { if(enabled == NULL) {
ndbout << "Couldn't get status" << endl; ndbout << "Couldn't get status" << endl;
printError(); printError();
...@@ -1645,25 +1653,25 @@ CommandInterpreter::executeClusterLog(char* parameters) ...@@ -1645,25 +1653,25 @@ CommandInterpreter::executeClusterLog(char* parameters)
********************/ ********************/
if (strcasecmp(item, "INFO") == 0) { if (strcasecmp(item, "INFO") == 0) {
DBUG_PRINT("info",("INFO")); DBUG_PRINT("info",("INFO"));
if(enabled[0] == 0) if(enabled[0].value == 0)
{ {
ndbout << "Cluster logging is disabled." << endl; ndbout << "Cluster logging is disabled." << endl;
m_error = 0; m_error = 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#if 0 #if 0
for(i = 0; i<7;i++) for(i = 0; i<DB_MGM_EVENT_SEVERITY_ALL;i++)
printf("enabled[%d] = %d\n", i, enabled[i]); printf("enabled[%d] = %d\n", i, enabled[i].value);
#endif #endif
ndbout << "Severities enabled: "; ndbout << "Severities enabled: ";
for(i = 1; i < (int)NDB_MGM_EVENT_SEVERITY_ALL; i++) { for(i = 1; i < (int)NDB_MGM_EVENT_SEVERITY_ALL; i++) {
const char *str= ndb_mgm_get_event_severity_string((ndb_mgm_event_severity)i); const char *str= ndb_mgm_get_event_severity_string(enabled[i].category);
if (str == 0) if (str == 0)
{ {
DBUG_ASSERT(false); DBUG_ASSERT(false);
continue; continue;
} }
if(enabled[i]) if(enabled[i].value)
ndbout << BaseString(str).ndb_toupper() << " "; ndbout << BaseString(str).ndb_toupper() << " ";
} }
ndbout << endl; ndbout << endl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment