diff options
author | unknown <mskold/marty@mysql.com/linux.site> | 2006-11-30 13:30:59 +0100 |
---|---|---|
committer | unknown <mskold/marty@mysql.com/linux.site> | 2006-11-30 13:30:59 +0100 |
commit | 9253140b8d7dc129e290f18d21afd8c974a2f50a (patch) | |
tree | 4d5d9ad91c1d48d2a04fc529001bc900e6fd464a /storage/ndb | |
parent | 56b3bc3227cad25ecedb40f32cc9732c6b57e7f4 (diff) | |
download | mariadb-git-9253140b8d7dc129e290f18d21afd8c974a2f50a.tar.gz |
Removed return of illegal pointer, changed signatures to ndb_mgm_get_clusterlog_severity_filter and ndb_mgm_get_clusterlog_loglevel
Diffstat (limited to 'storage/ndb')
-rw-r--r-- | storage/ndb/include/mgmapi/mgmapi.h | 72 | ||||
-rw-r--r-- | storage/ndb/src/mgmapi/mgmapi.cpp | 76 | ||||
-rw-r--r-- | storage/ndb/src/mgmclient/CommandInterpreter.cpp | 20 |
3 files changed, 151 insertions, 17 deletions
diff --git a/storage/ndb/include/mgmapi/mgmapi.h b/storage/ndb/include/mgmapi/mgmapi.h index b6b87ebaaa9..70dda4d3b66 100644 --- a/storage/ndb/include/mgmapi/mgmapi.h +++ b/storage/ndb/include/mgmapi/mgmapi.h @@ -17,6 +17,11 @@ #ifndef 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 * @@ -843,6 +848,30 @@ extern "C" { * * @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 + * + * @param handle NDB management handle + * * @return A vector of seven elements, * where each element contains * 1 if a severity indicator is enabled and 0 if not. @@ -855,7 +884,8 @@ extern "C" { * whether the cluster log * 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 @@ -872,6 +902,23 @@ extern "C" { enum ndb_mgm_event_category category, int level, 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 * @@ -880,7 +927,9 @@ extern "C" { * where each element contains * 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" { int e, struct ndb_mgm_reply* r) { return ndb_mgm_set_clusterlog_severity_filter(h,(ndb_mgm_event_severity)s, e,r); } - + struct ndb_mgm_severity { + enum ndb_mgm_event_severity category; + unsigned int value; + }; + inline - const unsigned int *ndb_mgm_get_logfilter(NdbMgmHandle h) - { return ndb_mgm_get_clusterlog_severity_filter(h); } + const unsigned int * ndb_mgm_get_logfilter(NdbMgmHandle h) + { return ndb_mgm_get_clusterlog_severity_filter_old(h); } inline int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle h, int n, @@ -1164,9 +1217,14 @@ extern "C" { int l, struct ndb_mgm_reply* 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 - const unsigned int *ndb_mgm_get_loglevel_clusterlog(NdbMgmHandle h) - { return ndb_mgm_get_clusterlog_loglevel(h); } + const unsigned int * ndb_mgm_get_loglevel_clusterlog(NdbMgmHandle h) + { return ndb_mgm_get_clusterlog_loglevel_old(h); } #endif diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp index 7c5fafd2286..9bac1ed43f3 100644 --- a/storage/ndb/src/mgmapi/mgmapi.cpp +++ b/storage/ndb/src/mgmapi/mgmapi.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB + /* Copyright (C) 2003 MySQL AB 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 @@ -1258,11 +1258,42 @@ ndb_mgm_get_event_severity_string(enum ndb_mgm_event_severity severity) } 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" 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"); - 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}; const ParserRow<ParserDummy> getinfo_reply[] = { MGM_CMD("clusterlog", NULL, ""), @@ -1378,8 +1409,45 @@ static const char *clusterlog_names[]= { "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" 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"); int loglevel_count = CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1 ; diff --git a/storage/ndb/src/mgmclient/CommandInterpreter.cpp b/storage/ndb/src/mgmclient/CommandInterpreter.cpp index 8bff874a97a..5ac4d1adf64 100644 --- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp @@ -1632,7 +1632,15 @@ CommandInterpreter::executeClusterLog(char* parameters) char * item = strtok_r(tmpString, " ", &tmpPtr); 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) { ndbout << "Couldn't get status" << endl; printError(); @@ -1645,25 +1653,25 @@ CommandInterpreter::executeClusterLog(char* parameters) ********************/ if (strcasecmp(item, "INFO") == 0) { DBUG_PRINT("info",("INFO")); - if(enabled[0] == 0) + if(enabled[0].value == 0) { ndbout << "Cluster logging is disabled." << endl; m_error = 0; DBUG_VOID_RETURN; } #if 0 - for(i = 0; i<7;i++) - printf("enabled[%d] = %d\n", i, enabled[i]); + for(i = 0; i<DB_MGM_EVENT_SEVERITY_ALL;i++) + printf("enabled[%d] = %d\n", i, enabled[i].value); #endif ndbout << "Severities enabled: "; 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) { DBUG_ASSERT(false); continue; } - if(enabled[i]) + if(enabled[i].value) ndbout << BaseString(str).ndb_toupper() << " "; } ndbout << endl; |