Commit e1a12250 authored by unknown's avatar unknown
Browse files

add a new mgmapi ndb_mgm_get_db_parameter_info, which retrieve parameter's name


storage/ndb/include/mgmapi/mgmapi.h:
  add a new function declaration
storage/ndb/src/mgmapi/Makefile.am:
  add a link of a new file ParamInfo.cpp which locate in mgmsrv dir
storage/ndb/src/mgmapi/mgmapi_configuration.cpp:
  add a new mgmapi function ndb_mgm_get_db_parameter_info
storage/ndb/src/mgmsrv/ParamInfo.cpp:
  New BitKeeper file ``storage/ndb/src/mgmsrv/ParamInfo.cpp''
  initialization information of all parameters, this copy from mgmsrv/ConfigInfo.cpp
storage/ndb/src/mgmsrv/ParamInfo.hpp:
  New BitKeeper file ``storage/ndb/src/mgmsrv/ParamInfo.hpp''
parent 3def506b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1133,6 +1133,14 @@ extern "C" {
  int ndb_mgm_check_connection(NdbMgmHandle handle);

  int ndb_mgm_report_event(NdbMgmHandle handle, Uint32 *data, Uint32 length);

  struct ndb_mgm_param_info
  {
    Uint32 m_id;
    const char * m_name;
  };
  int ndb_mgm_get_db_parameter_info(Uint32 paramId, struct ndb_mgm_param_info * info, 
             size_t * size);
#endif

#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
+1 −1
Original line number Diff line number Diff line

noinst_LTLIBRARIES = libmgmapi.la

libmgmapi_la_SOURCES = mgmapi.cpp ndb_logevent.cpp mgmapi_configuration.cpp LocalConfig.cpp ../kernel/error/ndbd_exit_codes.c
libmgmapi_la_SOURCES = mgmapi.cpp ndb_logevent.cpp mgmapi_configuration.cpp LocalConfig.cpp ../kernel/error/ndbd_exit_codes.c ../mgmsrv/ParamInfo.cpp

INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/include/mgmapi

+38 −0
Original line number Diff line number Diff line
#include <ndb_types.h>
#include <mgmapi.h>
#include "mgmapi_configuration.hpp"
#include "../mgmsrv/ParamInfo.hpp"

extern const ParamInfo ParamInfoArray[];
extern const int ParamInfoNum;

ndb_mgm_configuration_iterator::ndb_mgm_configuration_iterator
(const ndb_mgm_configuration & conf, unsigned type_of_section)
@@ -155,3 +159,37 @@ ndb_mgm_find(ndb_mgm_configuration_iterator* iter,
	     int param, unsigned search){
  return iter->find(param, search);
}

/**
 * Retrieve information about parameter
 * @param info : in - pointer to structure allocated by caller
 * @param size : in/out : pointer to int initialized to sizeof(ndb_mgm_param_info)...will be set to bytes set by function on return
*/
extern "C"
int 
ndb_mgm_get_db_parameter_info(Uint32 paramId, struct ndb_mgm_param_info * info, size_t * size) {
  if ( paramId == 0 ) {
      return -1;
  }

  for (int i = 0; i < ParamInfoNum; i++) {
    if (paramId == ParamInfoArray[i]._paramId && strcmp(DB_TOKEN, ParamInfoArray[i]._section) == 0) {
        size_t tmp = 0;
        if (tmp + sizeof(info->m_id) <= *size)
        {
          info->m_id = ParamInfoArray[i]._paramId;
          tmp += sizeof(info->m_id);
        }

        if (tmp + sizeof(info->m_name) <= *size)
        {
          info->m_name = ParamInfoArray[i]._fname;
          tmp += sizeof(info->m_name);
        }

        *size = tmp;
        return 0;
    }
  }
  return -1;
}
+2113 −0

File added.

Preview size limit exceeded, changes collapsed.

+44 −0
Original line number Diff line number Diff line
#ifndef PARAMINFO_H
#define PARAMINFO_H

#define DB_TOKEN "DB"
#define MGM_TOKEN "MGM"
#define API_TOKEN "API"

#ifdef __cplusplus
extern "C"
{
#endif

/**
 * The Configuration parameter type and status
 */

enum ParameterType        { CI_BOOL, CI_INT, CI_INT64, CI_STRING, CI_SECTION };
enum ParameterStatus      { CI_USED,            ///< Active
		     CI_DEPRICATED,      ///< Can be, but shouldn't
		     CI_NOTIMPLEMENTED,  ///< Is ignored.
		     CI_INTERNAL         ///< Not configurable by the user
};

/**
 *   Entry for one configuration parameter
 */
typedef struct m_ParamInfo {
  Uint32         _paramId;
  const char*    _fname;   
  const char*    _section;
  const char*    _description;
  ParameterStatus         _status;
  bool           _updateable;    
  ParameterType           _type;          
  const char*    _default;
  const char*    _min;
  const char*    _max;
}ParamInfo;

#ifdef __cplusplus
}
#endif

#endif