Commit 189f1938 authored by unknown's avatar unknown
Browse files

Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.1

into gw.mysql.r18.ru:/usr/home/ram/work/4.1.b6993

parents 51e8c4ad 96d6a116
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ public:
  /** The log levels. NOTE: Could not use the name LogLevel since 
   * it caused conflicts with another class.
   */
  enum LoggerLevel {LL_OFF, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR,
  enum LoggerLevel {LL_ON, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR,
		    LL_CRITICAL, LL_ALERT, LL_ALL};
  
  /**
+12 −2
Original line number Diff line number Diff line
@@ -244,7 +244,9 @@ extern "C" {
   *   Log severities (used to filter the cluster log)
   */
  enum ndb_mgm_clusterlog_level {
    NDB_MGM_CLUSTERLOG_OFF = 0,             /*< Cluster log off*/
    NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1,
    /* must range from 0 and up, indexes into an array */
    NDB_MGM_CLUSTERLOG_ON    = 0,           /*< Cluster log on*/
    NDB_MGM_CLUSTERLOG_DEBUG = 1,           /*< Used in NDB Cluster
					     *< developement
					     */
@@ -264,7 +266,8 @@ extern "C" {
					     *< corrected immediately,
					     *< such as a corrupted system
					     */
    NDB_MGM_CLUSTERLOG_ALL = 7              /*< All severities on*/
    /* must be next number, works as bound in loop */
    NDB_MGM_CLUSTERLOG_ALL = 7              /*< All severities */
  };

  /**
@@ -580,11 +583,13 @@ extern "C" {
   *
   * @param   handle        NDB management handle.
   * @param   level         A cluster log level to filter.
   * @param   enable        set 1=enable 0=disable
   * @param   reply         Reply message.
   * @return                -1 on error.
   */
  int ndb_mgm_filter_clusterlog(NdbMgmHandle handle,
				enum ndb_mgm_clusterlog_level level,
				int enable,
				struct ndb_mgm_reply* reply);

  /**
@@ -620,6 +625,11 @@ extern "C" {
				      int level,
				      struct ndb_mgm_reply* reply);

  ndb_mgm_clusterlog_level
  ndb_mgm_match_clusterlog_level(const char * name);
  const char * 
  ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level);

  /**
   * Set log category and levels for the Node
   *
+6 −4
Original line number Diff line number Diff line
@@ -48,10 +48,10 @@ public:
  bool empty() const;

  /** @brief Convert to uppercase */
  void ndb_toupper();
  BaseString& ndb_toupper();

  /** @brief Convert to lowercase */
  void ndb_tolower();
  BaseString& ndb_tolower();

  /** @brief Assigns from a char * */
  BaseString& assign(const char* s);
@@ -206,16 +206,18 @@ BaseString::empty() const
  return m_len == 0;
}

inline void
inline BaseString&
BaseString::ndb_toupper() {
  for(unsigned i = 0; i < length(); i++)
    m_chr[i] = toupper(m_chr[i]);
  return *this;
}

inline void
inline BaseString&
BaseString::ndb_tolower() {
  for(unsigned i = 0; i < length(); i++)
    m_chr[i] = tolower(m_chr[i]);
  return *this;
}

inline bool
+13 −4
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
//
// PUBLIC
//
const char* Logger::LoggerLevelNames[] = { "OFF     ", 
const char* Logger::LoggerLevelNames[] = { "ON      ", 
					   "DEBUG   ",
					   "INFO    ",
					   "WARNING ",
@@ -46,7 +46,9 @@ Logger::Logger() :
  m_pSyslogHandler(NULL)
{
  m_pHandlerList = new LogHandlerList();
  m_logLevels[LL_INFO] = true;
  disable(LL_ALL);
  enable(LL_ON);
  enable(LL_INFO);
}

Logger::~Logger()
@@ -227,6 +229,13 @@ Logger::removeAllHandlers()
bool
Logger::isEnable(LoggerLevel logLevel) const
{
  if (logLevel == LL_ALL)
  {
    for (unsigned i = 1; i < MAX_LOG_LEVELS; i++)
      if (!m_logLevels[i])
	return false;
    return true;
  }
  return m_logLevels[logLevel];
}

@@ -235,7 +244,7 @@ Logger::enable(LoggerLevel logLevel)
{
  if (logLevel == LL_ALL)
  {
    for (unsigned i = 1; i < MAX_LOG_LEVELS; i++)
    for (unsigned i = 0; i < MAX_LOG_LEVELS; i++)
    {
      m_logLevels[i] = true;
    }
@@ -337,7 +346,7 @@ Logger::debug(const char* pMsg, ...) const
void 
Logger::log(LoggerLevel logLevel, const char* pMsg, va_list ap) const
{
  if (m_logLevels[LL_OFF] == false && m_logLevels[logLevel])
  if (m_logLevels[LL_ON] && m_logLevels[logLevel])
  {
    LogHandler* pHandler = NULL;
    while ( (pHandler = m_pHandlerList->next()) != NULL)
+64 −15
Original line number Diff line number Diff line
@@ -914,21 +914,67 @@ ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes, const int *node_list)
  return ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0);
}

static const char *clusterlog_level_names[]=
  { "enabled", "debug", "info", "warning", "error", "critical", "alert" };

struct ndb_mgm_clusterlog_levels 
{
  const char* name;
  enum ndb_mgm_clusterlog_level level;
} clusterlog_levels[] = {
  { clusterlog_level_names[0], NDB_MGM_CLUSTERLOG_ON },
  { clusterlog_level_names[1], NDB_MGM_CLUSTERLOG_DEBUG },
  { clusterlog_level_names[2], NDB_MGM_CLUSTERLOG_INFO },
  { clusterlog_level_names[3], NDB_MGM_CLUSTERLOG_WARNING },
  { clusterlog_level_names[4], NDB_MGM_CLUSTERLOG_ERROR },
  { clusterlog_level_names[5], NDB_MGM_CLUSTERLOG_CRITICAL },
  { clusterlog_level_names[6], NDB_MGM_CLUSTERLOG_ALERT },
  { "all",                     NDB_MGM_CLUSTERLOG_ALL },
  { 0,                         NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL },
};

extern "C"
ndb_mgm_clusterlog_level
ndb_mgm_match_clusterlog_level(const char * name)
{
  if(name == 0)
    return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL;
  
  for(int i = 0; clusterlog_levels[i].name !=0 ; i++)
    if(strcasecmp(name, clusterlog_levels[i].name) == 0)
      return clusterlog_levels[i].level;

  return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL;
}

extern "C"
const char * 
ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level)
{
  int i= (int)level;
  if (i >= 0 && i < (int)NDB_MGM_CLUSTERLOG_ALL)
    return clusterlog_level_names[i];
  for(i = (int)NDB_MGM_CLUSTERLOG_ALL; clusterlog_levels[i].name != 0; i++)
    if(clusterlog_levels[i].level == level)
      return clusterlog_levels[i].name;
  return 0;
}

extern "C"
unsigned int *
ndb_mgm_get_logfilter(NdbMgmHandle handle) 
{
  SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_logfilter");
  static Uint32 enabled[7] = {0,0,0,0,0,0,0};
  static Uint32 enabled[(int)NDB_MGM_CLUSTERLOG_ALL] = {0,0,0,0,0,0,0};
  const ParserRow<ParserDummy> getinfo_reply[] = {
    MGM_CMD("clusterlog", NULL, ""),
    MGM_ARG("enabled", Int, Mandatory, ""),
    MGM_ARG("debug", Int, Mandatory, ""),
    MGM_ARG("info", Int, Mandatory, ""),
    MGM_ARG("warning", Int, Mandatory, ""),
    MGM_ARG("error", Int, Mandatory, ""),
    MGM_ARG("critical", Int, Mandatory, ""),
    MGM_ARG("alert", Int, Mandatory, ""),
    MGM_ARG(clusterlog_level_names[0], Int, Mandatory, ""),
    MGM_ARG(clusterlog_level_names[1], Int, Mandatory, ""),
    MGM_ARG(clusterlog_level_names[2], Int, Mandatory, ""),
    MGM_ARG(clusterlog_level_names[3], Int, Mandatory, ""),
    MGM_ARG(clusterlog_level_names[4], Int, Mandatory, ""),
    MGM_ARG(clusterlog_level_names[5], Int, Mandatory, ""),
    MGM_ARG(clusterlog_level_names[6], Int, Mandatory, ""),
  };
  CHECK_HANDLE(handle, NULL);
  CHECK_CONNECTED(handle, NULL);
@@ -938,10 +984,8 @@ ndb_mgm_get_logfilter(NdbMgmHandle handle)
  reply = ndb_mgm_call(handle, getinfo_reply, "get info clusterlog", &args);
  CHECK_REPLY(reply, NULL);
  
  const char *names[] = { "enabled", "debug", "info", "warning", "error",
			  "critical", "alert" };
  for(int i=0; i < 7; i++) {
    reply->get(names[i], &enabled[i]);
  for(int i=0; i < (int)NDB_MGM_CLUSTERLOG_ALL; i++) {
    reply->get(clusterlog_level_names[i], &enabled[i]);
  }
  return enabled;
}
@@ -950,6 +994,7 @@ extern "C"
int 
ndb_mgm_filter_clusterlog(NdbMgmHandle handle, 
			  enum ndb_mgm_clusterlog_level level,
			  int enable,
			  struct ndb_mgm_reply* /*reply*/) 
{
  SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_filter_clusterlog");
@@ -964,6 +1009,7 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle,

  Properties args;
  args.put("level", level);
  args.put("enable", enable);
  
  const Properties *reply;
  reply = ndb_mgm_call(handle, filter_reply, "set logfilter", &args);
@@ -971,11 +1017,14 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle,

  BaseString result;
  reply->get("result", result);
  if(strcmp(result.c_str(), "1") == 0) {

  if (strcmp(result.c_str(), "1") == 0)
    retval = 1;
  else if (strcmp(result.c_str(), "0") == 0)
    retval = 0;
  } else {
  else
  {
    SET_ERROR(handle, EINVAL, result.c_str());
    retval = -1;
  }
  delete reply;
  return retval;
Loading