⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mgmtsrvr.hpp

📁 mysql-5.0.22.tar.gz源码包
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* 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   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#ifndef MgmtSrvr_H#define MgmtSrvr_H#include <kernel_types.h>#include "Config.hpp"#include <NdbCondition.h>#include <mgmapi.h>#include <NdbTCP.h>#include <ConfigRetriever.hpp>#include <Vector.hpp>#include <NodeBitmask.hpp>#include <signaldata/ManagementServer.hpp>#include <ndb_version.h>#include <EventLogger.hpp>#include <signaldata/EventSubscribeReq.hpp>#include <SignalSender.hpp>/** * @desc Block number for Management server. * @todo This should probably be somewhere else. I don't know where atm. */#define MGMSRV 1class ConfigInfoServer;class NdbApiSignal;class Config;class SetLogLevelOrd;class SocketServer;class Ndb_mgmd_event_service : public EventLoggerBase {  friend class MgmtSrvr;public:  struct Event_listener : public EventLoggerBase {    NDB_SOCKET_TYPE m_socket;    Uint32 m_parsable;  };  private:    class MgmtSrvr * m_mgmsrv;  MutexVector<Event_listener> m_clients;public:  Ndb_mgmd_event_service(class MgmtSrvr * m) : m_clients(5) {    m_mgmsrv = m;  }    void add_listener(const Event_listener&);  void check_listeners();  void update_max_log_level(const LogLevel&);  void update_log_level(const LogLevel&);    void log(int eventType, const Uint32* theData, NodeId nodeId);    void stop_sessions();  Event_listener& operator[](unsigned i) { return m_clients[i]; }  const Event_listener& operator[](unsigned i) const { return m_clients[i]; }  void lock() { m_clients.lock(); }  void unlock(){ m_clients.unlock(); }};/** * @class MgmtSrvr * @brief Main class for the management server.  * * It has one interface to be used by a local client.  * With the methods it's possible to send different kind of commands to  * DB processes, as log level, set trace number etc.  * * A MgmtSrvr creates a ConfigInfoServer which serves request on TCP sockets.  * The requests come typical from DB and API processes which want * to fetch its configuration parameters. The MgmtSrvr knows about the * configuration by reading a configuration file. * * The MgmtSrvr class corresponds in some ways to the Ndb class in API.  * It creates a TransporterFacade, receives signals and defines signals * to send and receive. */class MgmtSrvr {  public:  // some compilers need all of this  class Allocated_resources;  friend class Allocated_resources;  class Allocated_resources {  public:    Allocated_resources(class MgmtSrvr &m);    ~Allocated_resources();    // methods to reserve/allocate resources which    // will be freed when running destructor    void reserve_node(NodeId id);    bool is_reserved(NodeId nodeId) { return m_reserved_nodes.get(nodeId); }    bool is_reserved(NodeBitmask mask) { return !mask.bitAND(m_reserved_nodes).isclear(); }    bool isclear() { return m_reserved_nodes.isclear(); }    NodeId get_nodeid() const;  private:    MgmtSrvr &m_mgmsrv;    NodeBitmask m_reserved_nodes;  };  NdbMutex *m_node_id_mutex;  /**   * Start/initate the event log.   */  void startEventLog();  /**   * Stop the event log.   */  void stopEventLog();  /**   * Enable/disable eventlog log levels/severities.   *   * @param serverity the log level/serverity.   * @return true if the severity was enabled.   */  bool setEventLogFilter(int severity, int enable);  /**   * Returns true if the log level/severity is enabled.   *   * @param severity the severity level.   */  bool isEventLogFilterEnabled(int severity);  STATIC_CONST( NO_CONTACT_WITH_PROCESS = 5000 );  STATIC_CONST( PROCESS_NOT_CONFIGURED = 5001 );  STATIC_CONST( WRONG_PROCESS_TYPE = 5002 );  STATIC_CONST( COULD_NOT_ALLOCATE_MEMORY = 5003 );  STATIC_CONST( SEND_OR_RECEIVE_FAILED = 5005 );  STATIC_CONST( INVALID_LEVEL = 5006 );  STATIC_CONST( INVALID_ERROR_NUMBER = 5007 );  STATIC_CONST( INVALID_TRACE_NUMBER = 5008 );  STATIC_CONST( NOT_IMPLEMENTED = 5009 );  STATIC_CONST( INVALID_BLOCK_NAME = 5010 );  STATIC_CONST( CONFIG_PARAM_NOT_EXIST = 5011 );  STATIC_CONST( CONFIG_PARAM_NOT_UPDATEABLE = 5012 );  STATIC_CONST( VALUE_WRONG_FORMAT_INT_EXPECTED = 5013 );  STATIC_CONST( VALUE_TOO_LOW = 5014 );  STATIC_CONST( VALUE_TOO_HIGH = 5015 );  STATIC_CONST( VALUE_WRONG_FORMAT_BOOL_EXPECTED = 5016 );  STATIC_CONST( CONFIG_FILE_OPEN_WRITE_ERROR = 5017 );  STATIC_CONST( CONFIG_FILE_OPEN_READ_ERROR = 5018 );  STATIC_CONST( CONFIG_FILE_WRITE_ERROR = 5019 );  STATIC_CONST( CONFIG_FILE_READ_ERROR = 5020 );  STATIC_CONST( CONFIG_FILE_CLOSE_ERROR = 5021 );  STATIC_CONST( CONFIG_CHANGE_REFUSED_BY_RECEIVER = 5022 );  STATIC_CONST( COULD_NOT_SYNC_CONFIG_CHANGE_AGAINST_PHYSICAL_MEDIUM = 5023 );  STATIC_CONST( CONFIG_FILE_CHECKSUM_ERROR = 5024 );  STATIC_CONST( NOT_POSSIBLE_TO_SEND_CONFIG_UPDATE_TO_PROCESS_TYPE = 5025 );  STATIC_CONST( NODE_SHUTDOWN_IN_PROGESS = 5026 );  STATIC_CONST( SYSTEM_SHUTDOWN_IN_PROGRESS = 5027 );  STATIC_CONST( NODE_SHUTDOWN_WOULD_CAUSE_SYSTEM_CRASH = 5028 );  STATIC_CONST( NO_CONTACT_WITH_DB_NODES = 5030 );  STATIC_CONST( UNSUPPORTED_NODE_SHUTDOWN = 5031 );  STATIC_CONST( NODE_NOT_API_NODE = 5062 );  STATIC_CONST( OPERATION_NOT_ALLOWED_START_STOP = 5063 );  /**   *   This enum specifies the different signal loggig modes possible to set    *   with the setSignalLoggingMode method.   */  enum LogMode {In, Out, InOut, Off};  /* Constructor */  MgmtSrvr(SocketServer *socket_server,	   const char *config_filename,      /* Where to save config */	   const char *connect_string);   int init();  NodeId getOwnNodeId() const {return _ownNodeId;};  /**   *   Read (initial) config file, create TransporterFacade,    *   define signals, create ConfigInfoServer.   *   @return true if succeeded, otherwise false   */  bool check_start(); // may be run before start to check that some things are ok  bool start(BaseString &error_string);  ~MgmtSrvr();  /**   * Get status on a node.   * address may point to a common area (e.g. from inet_addr)   * There is no gaurentee that it is preserved across calls.   * Copy the string if you are not going to use it immediately.   */  int status(int nodeId,	     ndb_mgm_node_status * status,	     Uint32 * version,	     Uint32 * phase,	     bool * systemShutdown,	     Uint32 * dynamicId,	     Uint32 * nodeGroup,	     Uint32 * connectCount,	     const char **address);    // All the functions below may return any of this error codes:  // NO_CONTACT_WITH_PROCESS, PROCESS_NOT_CONFIGURED, WRONG_PROCESS_TYPE,  // COULD_NOT_ALLOCATE_MEMORY, SEND_OR_RECEIVE_FAILED  /**   * Save a configuration to permanent storage   */  int saveConfig(const Config *);  /**   * Save the running configuration   */  int saveConfig() {    return saveConfig(_config);  };  /**   * Read configuration from file, or from another MGM server   */  Config *readConfig();  /**   * Fetch configuration from another MGM server   */  Config *fetchConfig();  /**   *   Stop a node   *    *   @param   processId: Id of the DB process to stop   *   @return  0 if succeeded, otherwise: as stated above, plus:   */  int stopNodes(const Vector<NodeId> &node_ids, int *stopCount, bool abort);  /**   *   Stop the system   */  int stop(int * cnt = 0, bool abort = false);  /**   *   print version info about a node   *    *   @param   processId: Id of the DB process to stop   *   @return  0 if succeeded, otherwise: as stated above, plus:   */  int versionNode(int nodeId, Uint32 &version, const char **address);  /**   *   Maintenance on the system   */  int enterSingleUser(int * cnt = 0, Uint32 singleuserNodeId = 0);  /**   *   Resume from maintenance on the system   */  int exitSingleUser(int * cnt = 0, bool abort = false);  /**   *   Start DB process.   *   @param   processId: Id of the DB process to start   *   @return 0 if succeeded, otherwise: as stated above, plus:   */ int start(int processId);  /**   *   Restart nodes   *   @param processId: Id of the DB process to start   */  int restartNodes(const Vector<NodeId> &node_ids,                   int *stopCount, bool nostart,                   bool initialStart, bool abort);    /**   *   Restart the system   */  int restart(bool nostart, bool initialStart, 	      bool abort = false,	      int * stopCount = 0);    struct BackupEvent {    enum Event {      BackupStarted = 1,      BackupFailedToStart = 2,      BackupCompleted = 3,      BackupAborted = 4    } Event;        NdbNodeBitmask Nodes;    union {      struct {	Uint32 BackupId;      } Started ;      struct {	Uint32 ErrorCode;      } FailedToStart ;      struct {	Uint32 BackupId;	Uint32 NoOfBytes;	Uint32 NoOfRecords;	Uint32 NoOfLogBytes;	Uint32 NoOfLogRecords;	Uint32 startGCP;	Uint32 stopGCP;      } Completed ;      struct {	Uint32 BackupId;	Uint32 Reason;	Uint32 ErrorCode;      } Aborted ;    };  };    /**   * Backup functionallity   */  int startBackup(Uint32& backupId, int waitCompleted= 2);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -