Commit 1da0c31b authored by unknown's avatar unknown
Browse files

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

into mysql.com:/home/jonas/src/mysql-4.1-ndb


ndb/src/mgmsrv/main.cpp:
  Auto merged
parents 149b45b8 2468e5ba
Loading
Loading
Loading
Loading
+72 −95
Original line number Diff line number Diff line
@@ -24,6 +24,65 @@
#include <kernel/LogLevel.hpp>
#include <signaldata/EventReport.hpp>

class EventLoggerBase {
public:
  virtual ~EventLoggerBase();

  /**
   * LogLevel settings
   */
  LogLevel m_logLevel;
  
  /**
   * Find a category matching the string
   *
   * @param str string to match.
   * @param cat the event category.
   * @param exactMatch only do exact matching.
   *
   *  @return TRUE if match is found, then cat is modified
   *          FALSE if match is not found
   */
  static bool matchEventCategory(const char * str, 
				 LogLevel::EventCategory * cat,
				 bool exactMatch = false);
  
  /**
   * Returns category name or NULL if not found.
   *
   * @param cat the event category.
   * @return category name.
   */
  static const char * getEventCategoryName(LogLevel::EventCategory cat);

  /**
   * Specifies allowed event categories/log levels.
   */
  struct EventCategoryName {
    LogLevel::EventCategory category;
    const char * name;
  };

  static const EventCategoryName eventCategoryNames[];
  static const Uint32 noOfEventCategoryNames;

  /**
   * This matrix defines which event should be printed when
   *
   * threshold - is in range [0-15]
   * severity  - DEBUG to ALERT (Type of log message)
   */  
  struct EventRepLogLevelMatrix {
    EventReport::EventType        eventType;
    LogLevel::EventCategory   eventCategory;
    Uint32                        threshold;
    Logger::LoggerLevel            severity;
  };

  static const EventRepLogLevelMatrix matrix[];
  static const Uint32 matrixSize;
};

/**
 * The EventLogger is primarily used for logging NDB events 
 * in the Management Server. It inherits all logging functionality of Logger.
@@ -58,7 +117,7 @@
 * @see Logger
 * @version #@ $Id: EventLogger.hpp,v 1.3 2003/09/01 10:15:52 innpeno Exp $
 */
class EventLogger : public Logger
class EventLogger : public EventLoggerBase, public Logger
{
public:
  /**
@@ -70,7 +129,7 @@ public:
  /**
   * Destructor.
   */
  ~EventLogger();
  virtual ~EventLogger();

  /**
   * Opens/creates the eventlog with the specified filename.
@@ -92,16 +151,6 @@ public:
   */
  void close();

  /**
   * Logs the NDB event.
   *
   * @param nodeId the node id of event origin.
   * @param eventType the type of event.
   * @param theData the event data.
   * @deprecated use log(int eventType, const Uint32* theData, NodeId nodeId)
   */
  void log(NodeId nodeId, int eventType, const Uint32* theData);

  /**
   * Logs the NDB event.
   *
@@ -109,16 +158,19 @@ public:
   * @param theData the event data.
   * @param nodeId the node id of event origin.
   */
  void log(int eventType, const Uint32* theData, NodeId nodeId = 0);
  virtual void log(int eventType, const Uint32* theData, NodeId nodeId = 0);

  /**
   * Returns the current log levels. 
   * Enable, disable log levels to filter the events that are sent to the
   * eventlog.
   * Returns the event text for the specified event report type.
   *
   * @return the log level.
   * @param type the event type.
   * @param theData the event data.
   * @param nodeId a node id.
   * @return the event report text.
   */
  LogLevel& getLoglevel();
  static const char* getText(char * dst, size_t dst_len,
			     int type,
			     const Uint32* theData, NodeId nodeId = 0);
  
  /**
   * Returns the log level that is used to filter an event. The event will not
@@ -127,6 +179,7 @@ public:
   * @return the log level filter that is used for all event categories.
   */
  int getFilterLevel() const;

  /**
   * Sets log level filter. The event will be logged if 
   * the event category's log level is <= 'filterLevel'.
@@ -135,92 +188,16 @@ public:
   */
  void setFilterLevel(int filterLevel);

  /**
   * Returns the event text for the specified event report type.
   *
   * @param type the event type.
   * @param theData the event data.
   * @param nodeId a node id.
   * @return the event report text.
   */
  static const char* getText(int type,
			     const Uint32* theData, NodeId nodeId = 0);

  /**
   * Find a category matching the string
   *
   * @param str string to match.
   * @param cat the event category.
   * @param exactMatch only do exact matching.
   *
   *  @return TRUE if match is found, then cat is modified
   *          FALSE if match is not found
   */
  static bool matchEventCategory(const char * str, 
				 LogLevel::EventCategory * cat,
				 bool exactMatch = false);
  
  /**
   * Returns category name or NULL if not found.
   *
   * @param cat the event category.
   * @return category name.
   */
  static const char * getEventCategoryName(LogLevel::EventCategory cat);

  /**
   * Specifies allowed event categories/log levels.
   */
  struct EventCategoryName {
    LogLevel::EventCategory category;
    const char * name;
  };

  static const EventCategoryName eventCategoryNames[];
  static const Uint32 noOfEventCategoryNames;

  /**
   * This matrix defines which event should be printed when
   *
   * threshold - is in range [0-15]
   * severity  - DEBUG to ALERT (Type of log message)
   */  
  struct EventRepLogLevelMatrix {
    EventReport::EventType        eventType;
    LogLevel::EventCategory   eventCategory;
    Uint32                        threshold;
    Logger::LoggerLevel            severity;
  };

  static const EventRepLogLevelMatrix matrix[];

  /**
   * Default log levels for management nodes.
   *
   * threshold - is in range [0-15]
   */
  struct EventLogMatrix {
    LogLevel::EventCategory eventCategory;
    Uint32                  threshold;
  };

  static const EventLogMatrix defEventLogMatrix[];

  
  static const Uint32 matrixSize;
  static const Uint32 defEventLogMatrixSize;

private:
  /** Prohibit */
  EventLogger(const EventLogger&);
  EventLogger operator = (const EventLogger&);
  bool operator == (const EventLogger&);

  LogLevel m_logLevel;
  Uint32 m_filterLevel;

  STATIC_CONST(MAX_TEXT_LENGTH = 256);
  static char m_text[MAX_TEXT_LENGTH];
  char m_text[MAX_TEXT_LENGTH];
};


+20 −4
Original line number Diff line number Diff line
@@ -130,13 +130,20 @@ public:
   */
  Uint32 getLogLevel(EventCategory ec) const;
  
  /**
   * Set this= max(this, ll) per category
   */
  LogLevel& set_max(const LogLevel& ll);
  
  bool operator==(const LogLevel& l) const { 
    return memcmp(this, &l, sizeof(* this)) == 0;
  }
  
private:
  /**
   * The actual data
   */
  Uint32 logLevelData[LOGLEVEL_CATEGORIES];
  
  LogLevel(const LogLevel &);
  Uint8 logLevelData[LOGLEVEL_CATEGORIES];
};

inline
@@ -176,5 +183,14 @@ LogLevel::getLogLevel(EventCategory ec) const{
  return logLevelData[ec];
}

inline
LogLevel & 
LogLevel::set_max(const LogLevel & org){
  for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
    if(logLevelData[i] < org.logLevelData[i])
      logLevelData[i] = org.logLevelData[i];
  }
  return * this;
}

#endif
+11 −3
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
 * RECIVER: SimBlockCMCtrBlck
 */

class EventSubscribeReq {
struct EventSubscribeReq {
  /**
   * Receiver(s)
   */
@@ -38,9 +38,8 @@ class EventSubscribeReq {
   */
  friend class MgmtSrvr;

public:
  STATIC_CONST( SignalLength = 22 );
private:

  /**
   * Note: If you use the same blockRef as you have used earlier, 
   *       you update your ongoing subscription
@@ -55,6 +54,15 @@ private:
  
  Uint32 theCategories[10];
  Uint32 theLevels[10];

  EventSubscribeReq& operator= (const LogLevel& ll){
    noOfEntries = _LOGLEVEL_CATEGORIES;
    for(size_t i = 0; i<noOfEntries; i++){
      theCategories[i] = i;
      theLevels[i] = ll.getLogLevel((LogLevel::EventCategory)i);
    }
    return * this;
  }
};

#endif
+19 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define SET_LOGLEVEL_ORD_HPP

#include <LogLevel.hpp>
#include "EventSubscribeReq.hpp"
#include "SignalData.hpp"

/**
@@ -51,6 +52,24 @@ private:
   * Note level is valid as 0-15
   */
  void setLogLevel(LogLevel::EventCategory ec, int level = 7);

  SetLogLevelOrd& operator= (const LogLevel& ll){
    noOfEntries = _LOGLEVEL_CATEGORIES;
    for(size_t i = 0; i<noOfEntries; i++){
      theCategories[i] = i;
      theLevels[i] = ll.getLogLevel((LogLevel::EventCategory)i);
    }
    return * this;
  }

  SetLogLevelOrd& operator= (const EventSubscribeReq& ll){
    noOfEntries = ll.noOfEntries;
    for(size_t i = 0; i<noOfEntries; i++){
      theCategories[i] = ll.theCategories[i];
      theLevels[i] = ll.theLevels[i];
    }
    return * this;
  }
};

inline
+0 −18
Original line number Diff line number Diff line
@@ -55,24 +55,6 @@
extern "C" {
#endif

  /**
   * Format of statistical information from the NDB Cluster.
   * STATISTIC_LINE is sent on the statistical port from the Management server,
   * each line is timestamped with STATISTIC_DATE.
   */
#define STATISTIC_LINE "date=%s epochsecs=%d nodeid=%u trans=%u commit=%u " \
                        "read=%u insert=%u attrinfo=%u cops=%u abort=%u"
  /**
   * Format of statistical information from the NDB Cluster.
   * STATISTIC_LINE is sent on the statistical port from the Management server,
   * each line is timestamped with STATISTIC_DATE.
   */
#define STATISTIC_DATE "%d-%.2d-%.2d/%.2d:%.2d:%.2d"
  /**
   * Format of statistical information from the NDB Cluster.
   */
#define OP_STATISTIC_LINE "date=%s epochsecs=%d nodeid=%d operations=%u"
	
  /**
   * The NdbMgmHandle.
   */
Loading