mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/jonas/src/mysql-4.1-push
This commit is contained in:
5
mysql-test/r/ndb_config.result
Normal file
5
mysql-test/r/ndb_config.result
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
ndbd,1,localhost ndbd,2,localhost ndb_mgmd,3, mysqld,4, mysqld,5, mysqld,6, mysqld,7,
|
||||||
|
1,localhost,41943040,12582912 2,localhost,41943040,12582912
|
||||||
|
1 localhost 41943040 12582912
|
||||||
|
2 localhost 41943040 12582912
|
||||||
|
1 2
|
4
mysql-test/t/ndb_config.test
Normal file
4
mysql-test/t/ndb_config.test
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host 2> /dev/null
|
||||||
|
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null
|
||||||
|
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults -r \\n -f " " --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null
|
||||||
|
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --type=ndbd --host=localhost 2> /dev/null
|
@ -49,6 +49,7 @@
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <ndb_types.h>
|
#include <ndb_types.h>
|
||||||
#include "mgmapi_config_parameters.h"
|
#include "mgmapi_config_parameters.h"
|
||||||
|
|
||||||
@ -351,6 +352,12 @@ extern "C" {
|
|||||||
int ndb_mgm_get_latest_error_line(const NdbMgmHandle handle);
|
int ndb_mgm_get_latest_error_line(const NdbMgmHandle handle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set error stream
|
||||||
|
*/
|
||||||
|
void ndb_mgm_set_error_stream(NdbMgmHandle, FILE *);
|
||||||
|
|
||||||
|
|
||||||
/** @} *********************************************************************/
|
/** @} *********************************************************************/
|
||||||
/**
|
/**
|
||||||
* @name Functions: Create/Destroy Management Server Handles
|
* @name Functions: Create/Destroy Management Server Handles
|
||||||
|
@ -50,8 +50,11 @@
|
|||||||
|
|
||||||
#define CFG_DB_FILESYSTEM_PATH 125
|
#define CFG_DB_FILESYSTEM_PATH 125
|
||||||
#define CFG_DB_NO_REDOLOG_FILES 126
|
#define CFG_DB_NO_REDOLOG_FILES 126
|
||||||
#define CFG_DB_DISC_BANDWIDTH 127
|
|
||||||
#define CFG_DB_SR_DISC_BANDWITH 128
|
#define CFG_DB_LCP_DISC_PAGES_TUP 127
|
||||||
|
#define CFG_DB_LCP_DISC_PAGES_TUP_SR 128
|
||||||
|
#define CFG_DB_LCP_DISC_PAGES_ACC 137
|
||||||
|
#define CFG_DB_LCP_DISC_PAGES_ACC_SR 138
|
||||||
|
|
||||||
#define CFG_DB_TRANSACTION_CHECK_INTERVAL 129
|
#define CFG_DB_TRANSACTION_CHECK_INTERVAL 129
|
||||||
#define CFG_DB_TRANSACTION_INACTIVE_TIMEOUT 130
|
#define CFG_DB_TRANSACTION_INACTIVE_TIMEOUT 130
|
||||||
|
@ -722,10 +722,12 @@ void Dbacc::execREAD_CONFIG_REQ(Signal* signal)
|
|||||||
ndbrestart1Lab(signal);
|
ndbrestart1Lab(signal);
|
||||||
|
|
||||||
clblPagesPerTick = 50;
|
clblPagesPerTick = 50;
|
||||||
//ndb_mgm_get_int_parameter(p, CFG_DB_, &clblPagesPerTick);
|
ndb_mgm_get_int_parameter(p, CFG_DB_LCP_DISC_PAGES_ACC_SR,
|
||||||
|
&clblPagesPerTick);
|
||||||
|
|
||||||
clblPagesPerTickAfterSr = 50;
|
clblPagesPerTickAfterSr = 50;
|
||||||
//ndb_mgm_get_int_parameter(p, CFG_DB_, &clblPagesPerTickAfterSr);
|
ndb_mgm_get_int_parameter(p, CFG_DB_LCP_DISC_PAGES_ACC,
|
||||||
|
&clblPagesPerTickAfterSr);
|
||||||
|
|
||||||
tdata0 = 0;
|
tdata0 = 0;
|
||||||
initialiseRecordsLab(signal, ref, senderData);
|
initialiseRecordsLab(signal, ref, senderData);
|
||||||
|
@ -663,10 +663,12 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal)
|
|||||||
initialiseRecordsLab(signal, 0, ref, senderData);
|
initialiseRecordsLab(signal, 0, ref, senderData);
|
||||||
|
|
||||||
clblPagesPerTick = 50;
|
clblPagesPerTick = 50;
|
||||||
//ndb_mgm_get_int_parameter(p, CFG_DB_, &clblPagesPerTick);
|
ndb_mgm_get_int_parameter(p, CFG_DB_LCP_DISC_PAGES_TUP_SR,
|
||||||
|
&clblPagesPerTick);
|
||||||
|
|
||||||
clblPagesPerTickAfterSr = 50;
|
clblPagesPerTickAfterSr = 50;
|
||||||
//ndb_mgm_get_int_parameter(p, CFG_DB_, &clblPagesPerTickAfterSr);
|
ndb_mgm_get_int_parameter(p, CFG_DB_LCP_DISC_PAGES_TUP,
|
||||||
|
&clblPagesPerTickAfterSr);
|
||||||
|
|
||||||
}//Dbtup::execSIZEALT_REP()
|
}//Dbtup::execSIZEALT_REP()
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ struct ndb_mgm_handle {
|
|||||||
#ifdef MGMAPI_LOG
|
#ifdef MGMAPI_LOG
|
||||||
FILE* logfile;
|
FILE* logfile;
|
||||||
#endif
|
#endif
|
||||||
|
FILE *errstream;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SET_ERROR(h, e, s) setError(h, e, __LINE__, s)
|
#define SET_ERROR(h, e, s) setError(h, e, __LINE__, s)
|
||||||
@ -153,6 +154,7 @@ ndb_mgm_create_handle()
|
|||||||
h->read_timeout = 50000;
|
h->read_timeout = 50000;
|
||||||
h->write_timeout = 100;
|
h->write_timeout = 100;
|
||||||
h->cfg_i = 0;
|
h->cfg_i = 0;
|
||||||
|
h->errstream = stdout;
|
||||||
|
|
||||||
strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE);
|
strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE);
|
||||||
|
|
||||||
@ -213,6 +215,13 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
void
|
||||||
|
ndb_mgm_set_error_stream(NdbMgmHandle handle, FILE * file)
|
||||||
|
{
|
||||||
|
handle->errstream = file;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Error handling
|
* Error handling
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -382,8 +391,8 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries,
|
|||||||
break;
|
break;
|
||||||
if (verbose > 0) {
|
if (verbose > 0) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
ndbout_c("Unable to connect with connect string: %s",
|
fprintf(handle->errstream, "Unable to connect with connect string: %s\n",
|
||||||
cfg.makeConnectString(buf,sizeof(buf)));
|
cfg.makeConnectString(buf,sizeof(buf)));
|
||||||
verbose= -1;
|
verbose= -1;
|
||||||
}
|
}
|
||||||
if (no_retries == 0) {
|
if (no_retries == 0) {
|
||||||
@ -392,32 +401,35 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries,
|
|||||||
"Unable to connect with connect string: %s",
|
"Unable to connect with connect string: %s",
|
||||||
cfg.makeConnectString(buf,sizeof(buf)));
|
cfg.makeConnectString(buf,sizeof(buf)));
|
||||||
if (verbose == -2)
|
if (verbose == -2)
|
||||||
ndbout << ", failed." << endl;
|
fprintf(handle->errstream, ", failed.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (verbose == -1) {
|
if (verbose == -1) {
|
||||||
ndbout << "Retrying every " << retry_delay_in_seconds << " seconds";
|
fprintf(handle->errstream, "Retrying every %d seconds",
|
||||||
|
retry_delay_in_seconds);
|
||||||
if (no_retries > 0)
|
if (no_retries > 0)
|
||||||
ndbout << ". Attempts left:";
|
fprintf(handle->errstream, ". Attempts left:");
|
||||||
else
|
else
|
||||||
ndbout << ", until connected.";;
|
fprintf(handle->errstream, ", until connected.");
|
||||||
ndbout << flush;
|
fflush(handle->errstream);
|
||||||
verbose= -2;
|
verbose= -2;
|
||||||
}
|
}
|
||||||
if (no_retries > 0) {
|
if (no_retries > 0) {
|
||||||
if (verbose == -2) {
|
if (verbose == -2) {
|
||||||
ndbout << " " << no_retries;
|
fprintf(handle->errstream, " %d", no_retries);
|
||||||
ndbout << flush;
|
fflush(handle->errstream);
|
||||||
}
|
}
|
||||||
no_retries--;
|
no_retries--;
|
||||||
}
|
}
|
||||||
NdbSleep_SecSleep(retry_delay_in_seconds);
|
NdbSleep_SecSleep(retry_delay_in_seconds);
|
||||||
}
|
}
|
||||||
if (verbose == -2)
|
if (verbose == -2)
|
||||||
ndbout << endl;
|
{
|
||||||
|
fprintf(handle->errstream, "\n");
|
||||||
|
fflush(handle->errstream);
|
||||||
|
}
|
||||||
handle->cfg_i = i;
|
handle->cfg_i = i;
|
||||||
|
|
||||||
handle->socket = sockfd;
|
handle->socket = sockfd;
|
||||||
handle->connected = 1;
|
handle->connected = 1;
|
||||||
|
|
||||||
@ -469,7 +481,9 @@ ndb_mgm_match_node_type(const char * type)
|
|||||||
for(int i = 0; i<no_of_type_values; i++)
|
for(int i = 0; i<no_of_type_values; i++)
|
||||||
if(strcmp(type, type_values[i].str) == 0)
|
if(strcmp(type, type_values[i].str) == 0)
|
||||||
return type_values[i].value;
|
return type_values[i].value;
|
||||||
|
else if(strcmp(type, type_values[i].alias) == 0)
|
||||||
|
return type_values[i].value;
|
||||||
|
|
||||||
return NDB_MGM_NODE_TYPE_UNKNOWN;
|
return NDB_MGM_NODE_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1664,28 +1678,28 @@ ndb_mgm_get_configuration(NdbMgmHandle handle, unsigned int version) {
|
|||||||
do {
|
do {
|
||||||
const char * buf;
|
const char * buf;
|
||||||
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
||||||
ndbout_c("ERROR Message: %s\n", buf);
|
fprintf(handle->errstream, "ERROR Message: %s\n\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = "<Unspecified>";
|
buf = "<Unspecified>";
|
||||||
if(!prop->get("Content-Type", &buf) ||
|
if(!prop->get("Content-Type", &buf) ||
|
||||||
strcmp(buf, "ndbconfig/octet-stream") != 0){
|
strcmp(buf, "ndbconfig/octet-stream") != 0){
|
||||||
ndbout_c("Unhandled response type: %s", buf);
|
fprintf(handle->errstream, "Unhandled response type: %s\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = "<Unspecified>";
|
buf = "<Unspecified>";
|
||||||
if(!prop->get("Content-Transfer-Encoding", &buf)
|
if(!prop->get("Content-Transfer-Encoding", &buf)
|
||||||
|| strcmp(buf, "base64") != 0){
|
|| strcmp(buf, "base64") != 0){
|
||||||
ndbout_c("Unhandled encoding: %s", buf);
|
fprintf(handle->errstream, "Unhandled encoding: %s\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = "<Content-Length Unspecified>";
|
buf = "<Content-Length Unspecified>";
|
||||||
Uint32 len = 0;
|
Uint32 len = 0;
|
||||||
if(!prop->get("Content-Length", &len)){
|
if(!prop->get("Content-Length", &len)){
|
||||||
ndbout_c("Invalid response: %s\n", buf);
|
fprintf(handle->errstream, "Invalid response: %s\n\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1710,14 +1724,14 @@ ndb_mgm_get_configuration(NdbMgmHandle handle, unsigned int version) {
|
|||||||
const int res = base64_decode(buf64, len-1, tmp);
|
const int res = base64_decode(buf64, len-1, tmp);
|
||||||
delete[] buf64;
|
delete[] buf64;
|
||||||
if(res != 0){
|
if(res != 0){
|
||||||
ndbout_c("Failed to decode buffer");
|
fprintf(handle->errstream, "Failed to decode buffer\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigValuesFactory cvf;
|
ConfigValuesFactory cvf;
|
||||||
const int res2 = cvf.unpack(tmp);
|
const int res2 = cvf.unpack(tmp);
|
||||||
if(!res2){
|
if(!res2){
|
||||||
ndbout_c("Failed to unpack buffer");
|
fprintf(handle->errstream, "Failed to unpack buffer\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1821,7 +1835,7 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype)
|
|||||||
}
|
}
|
||||||
Uint32 _nodeid;
|
Uint32 _nodeid;
|
||||||
if(!prop->get("nodeid", &_nodeid) != 0){
|
if(!prop->get("nodeid", &_nodeid) != 0){
|
||||||
ndbout_c("ERROR Message: <nodeid Unspecified>\n");
|
fprintf(handle->errstream, "ERROR Message: <nodeid Unspecified>\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nodeid= _nodeid;
|
nodeid= _nodeid;
|
||||||
@ -1897,7 +1911,7 @@ ndb_mgm_set_int_parameter(NdbMgmHandle handle,
|
|||||||
do {
|
do {
|
||||||
const char * buf;
|
const char * buf;
|
||||||
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
||||||
ndbout_c("ERROR Message: %s\n", buf);
|
fprintf(handle->errstream, "ERROR Message: %s\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res= 0;
|
res= 0;
|
||||||
@ -1940,7 +1954,7 @@ ndb_mgm_set_int64_parameter(NdbMgmHandle handle,
|
|||||||
do {
|
do {
|
||||||
const char * buf;
|
const char * buf;
|
||||||
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
||||||
ndbout_c("ERROR Message: %s\n", buf);
|
fprintf(handle->errstream, "ERROR Message: %s\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res= 0;
|
res= 0;
|
||||||
@ -1983,7 +1997,7 @@ ndb_mgm_set_string_parameter(NdbMgmHandle handle,
|
|||||||
do {
|
do {
|
||||||
const char * buf;
|
const char * buf;
|
||||||
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
||||||
ndbout_c("ERROR Message: %s\n", buf);
|
fprintf(handle->errstream, "ERROR Message: %s\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res= 0;
|
res= 0;
|
||||||
@ -2020,7 +2034,7 @@ ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **purged){
|
|||||||
do {
|
do {
|
||||||
const char * buf;
|
const char * buf;
|
||||||
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
|
||||||
ndbout_c("ERROR Message: %s\n", buf);
|
fprintf(handle->errstream, "ERROR Message: %s\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (purged) {
|
if (purged) {
|
||||||
|
@ -915,7 +915,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
|
|||||||
STR_VALUE(MAX_INT_RNIL) },
|
STR_VALUE(MAX_INT_RNIL) },
|
||||||
|
|
||||||
{
|
{
|
||||||
KEY_INTERNAL,
|
CFG_DB_LCP_DISC_PAGES_TUP_SR,
|
||||||
"NoOfDiskPagesToDiskDuringRestartTUP",
|
"NoOfDiskPagesToDiskDuringRestartTUP",
|
||||||
DB_TOKEN,
|
DB_TOKEN,
|
||||||
"?",
|
"?",
|
||||||
@ -927,7 +927,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
|
|||||||
STR_VALUE(MAX_INT_RNIL) },
|
STR_VALUE(MAX_INT_RNIL) },
|
||||||
|
|
||||||
{
|
{
|
||||||
KEY_INTERNAL,
|
CFG_DB_LCP_DISC_PAGES_TUP,
|
||||||
"NoOfDiskPagesToDiskAfterRestartTUP",
|
"NoOfDiskPagesToDiskAfterRestartTUP",
|
||||||
DB_TOKEN,
|
DB_TOKEN,
|
||||||
"?",
|
"?",
|
||||||
@ -939,7 +939,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
|
|||||||
STR_VALUE(MAX_INT_RNIL) },
|
STR_VALUE(MAX_INT_RNIL) },
|
||||||
|
|
||||||
{
|
{
|
||||||
KEY_INTERNAL,
|
CFG_DB_LCP_DISC_PAGES_ACC_SR,
|
||||||
"NoOfDiskPagesToDiskDuringRestartACC",
|
"NoOfDiskPagesToDiskDuringRestartACC",
|
||||||
DB_TOKEN,
|
DB_TOKEN,
|
||||||
"?",
|
"?",
|
||||||
@ -951,7 +951,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
|
|||||||
STR_VALUE(MAX_INT_RNIL) },
|
STR_VALUE(MAX_INT_RNIL) },
|
||||||
|
|
||||||
{
|
{
|
||||||
KEY_INTERNAL,
|
CFG_DB_LCP_DISC_PAGES_ACC,
|
||||||
"NoOfDiskPagesToDiskAfterRestartACC",
|
"NoOfDiskPagesToDiskAfterRestartACC",
|
||||||
DB_TOKEN,
|
DB_TOKEN,
|
||||||
"?",
|
"?",
|
||||||
|
@ -127,14 +127,14 @@ private:
|
|||||||
Properties m_info;
|
Properties m_info;
|
||||||
Properties m_systemDefaults;
|
Properties m_systemDefaults;
|
||||||
|
|
||||||
static const ParamInfo m_ParamInfo[];
|
|
||||||
static const int m_NoOfParams;
|
|
||||||
|
|
||||||
static const AliasPair m_sectionNameAliases[];
|
static const AliasPair m_sectionNameAliases[];
|
||||||
static const char* m_sectionNames[];
|
static const char* m_sectionNames[];
|
||||||
static const int m_noOfSectionNames;
|
static const int m_noOfSectionNames;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static const ParamInfo m_ParamInfo[];
|
||||||
|
static const int m_NoOfParams;
|
||||||
|
|
||||||
static const SectionRule m_SectionRules[];
|
static const SectionRule m_SectionRules[];
|
||||||
static const ConfigRule m_ConfigRules[];
|
static const ConfigRule m_ConfigRules[];
|
||||||
static const int m_NoOfRules;
|
static const int m_NoOfRules;
|
||||||
|
@ -9,7 +9,7 @@ ndbtools_PROGRAMS = \
|
|||||||
ndb_show_tables \
|
ndb_show_tables \
|
||||||
ndb_select_all \
|
ndb_select_all \
|
||||||
ndb_select_count \
|
ndb_select_count \
|
||||||
ndb_restore
|
ndb_restore ndb_config
|
||||||
|
|
||||||
tools_common_sources = ../test/src/NDBT_ReturnCodes.cpp \
|
tools_common_sources = ../test/src/NDBT_ReturnCodes.cpp \
|
||||||
../test/src/NDBT_Table.cpp \
|
../test/src/NDBT_Table.cpp \
|
||||||
@ -32,6 +32,16 @@ ndb_restore_SOURCES = restore/restore_main.cpp \
|
|||||||
restore/consumer_printer.cpp \
|
restore/consumer_printer.cpp \
|
||||||
restore/Restore.cpp
|
restore/Restore.cpp
|
||||||
|
|
||||||
|
ndb_config_SOURCES = config.cpp \
|
||||||
|
../src/mgmsrv/Config.cpp \
|
||||||
|
../src/mgmsrv/ConfigInfo.cpp \
|
||||||
|
../src/mgmsrv/InitConfigFileParser.cpp
|
||||||
|
ndb_config_CXXFLAGS = -I$(top_srcdir)/ndb/src/mgmapi \
|
||||||
|
-I$(top_srcdir)/ndb/src/mgmsrv \
|
||||||
|
-I$(top_srcdir)/ndb/include/mgmcommon \
|
||||||
|
-DMYSQLCLUSTERDIR="\"\""
|
||||||
|
|
||||||
|
|
||||||
include $(top_srcdir)/ndb/config/common.mk.am
|
include $(top_srcdir)/ndb/config/common.mk.am
|
||||||
include $(top_srcdir)/ndb/config/type_ndbapitools.mk.am
|
include $(top_srcdir)/ndb/config/type_ndbapitools.mk.am
|
||||||
|
|
||||||
@ -45,6 +55,7 @@ ndb_show_tables_LDFLAGS = @ndb_bin_am_ldflags@
|
|||||||
ndb_select_all_LDFLAGS = @ndb_bin_am_ldflags@
|
ndb_select_all_LDFLAGS = @ndb_bin_am_ldflags@
|
||||||
ndb_select_count_LDFLAGS = @ndb_bin_am_ldflags@
|
ndb_select_count_LDFLAGS = @ndb_bin_am_ldflags@
|
||||||
ndb_restore_LDFLAGS = @ndb_bin_am_ldflags@
|
ndb_restore_LDFLAGS = @ndb_bin_am_ldflags@
|
||||||
|
ndb_config_LDFLAGS = @ndb_bin_am_ldflags@
|
||||||
|
|
||||||
# Don't update the files from bitkeeper
|
# Don't update the files from bitkeeper
|
||||||
%::SCCS/s.%
|
%::SCCS/s.%
|
||||||
|
407
ndb/tools/config.cpp
Normal file
407
ndb/tools/config.cpp
Normal file
@ -0,0 +1,407 @@
|
|||||||
|
/* 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 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ndb_config --nodes --query=nodeid --type=ndbd --host=local1
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ndb_global.h>
|
||||||
|
#include <my_sys.h>
|
||||||
|
#include <my_getopt.h>
|
||||||
|
#include <mysql_version.h>
|
||||||
|
|
||||||
|
#include <NdbOut.hpp>
|
||||||
|
#include <mgmapi.h>
|
||||||
|
#include <mgmapi_configuration.hpp>
|
||||||
|
#include <ConfigInfo.hpp>
|
||||||
|
|
||||||
|
static int g_verbose = 0;
|
||||||
|
static int try_reconnect = 3;
|
||||||
|
|
||||||
|
static int g_nodes = 1;
|
||||||
|
static const char * g_connectstring = 0;
|
||||||
|
static const char * g_query = 0;
|
||||||
|
|
||||||
|
static int g_nodeid = 0;
|
||||||
|
static const char * g_type = 0;
|
||||||
|
static const char * g_host = 0;
|
||||||
|
static const char * g_field_delimiter=",";
|
||||||
|
static const char * g_row_delimiter=" ";
|
||||||
|
|
||||||
|
int g_print_full_config, opt_ndb_shm;
|
||||||
|
|
||||||
|
typedef ndb_mgm_configuration_iterator Iter;
|
||||||
|
|
||||||
|
static void ndb_std_print_version()
|
||||||
|
{
|
||||||
|
printf("MySQL distrib %s, for %s (%s)\n",
|
||||||
|
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct my_option my_long_options[] =
|
||||||
|
{
|
||||||
|
{ "usage", '?', "Display this help and exit.",
|
||||||
|
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ "help", '?', "Display this help and exit.",
|
||||||
|
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ "version", 'V', "Output version information and exit.", 0, 0, 0,
|
||||||
|
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ "ndb-connectstring", 256,
|
||||||
|
"Set connect string for connecting to ndb_mgmd. "
|
||||||
|
"Syntax: \"[nodeid=<id>;][host=]<hostname>[:<port>]\". "
|
||||||
|
"Overides specifying entries in NDB_CONNECTSTRING and Ndb.cfg",
|
||||||
|
(gptr*) &g_connectstring, (gptr*) &g_connectstring,
|
||||||
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ "nodes", 256, "Print nodes",
|
||||||
|
(gptr*) &g_nodes, (gptr*) &g_nodes,
|
||||||
|
0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||||
|
{ "query", 'q', "Query option(s)",
|
||||||
|
(gptr*) &g_query, (gptr*) &g_query,
|
||||||
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
{ "host", 257, "Host",
|
||||||
|
(gptr*) &g_host, (gptr*) &g_host,
|
||||||
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
{ "type", 258, "Type of node/connection",
|
||||||
|
(gptr*) &g_type, (gptr*) &g_type,
|
||||||
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
{ "id", 258, "Nodeid",
|
||||||
|
(gptr*) &g_nodeid, (gptr*) &g_nodeid,
|
||||||
|
0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
{ "nodeid", 258, "Nodeid",
|
||||||
|
(gptr*) &g_nodeid, (gptr*) &g_nodeid,
|
||||||
|
0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
{ "fields", 'f', "Field separator",
|
||||||
|
(gptr*) &g_field_delimiter, (gptr*) &g_field_delimiter,
|
||||||
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
{ "rows", 'r', "Row separator",
|
||||||
|
(gptr*) &g_row_delimiter, (gptr*) &g_row_delimiter,
|
||||||
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void usage()
|
||||||
|
{
|
||||||
|
char desc[] =
|
||||||
|
"This program will retreive config options for a ndb cluster\n";
|
||||||
|
ndb_std_print_version();
|
||||||
|
my_print_help(my_long_options);
|
||||||
|
my_print_variables(my_long_options);
|
||||||
|
}
|
||||||
|
static my_bool
|
||||||
|
ndb_std_get_one_option(int optid,
|
||||||
|
const struct my_option *opt __attribute__((unused)),
|
||||||
|
char *argument)
|
||||||
|
{
|
||||||
|
switch (optid) {
|
||||||
|
case 'V':
|
||||||
|
ndb_std_print_version();
|
||||||
|
exit(0);
|
||||||
|
case '?':
|
||||||
|
usage();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match/Apply framework
|
||||||
|
*/
|
||||||
|
struct Match
|
||||||
|
{
|
||||||
|
int m_key;
|
||||||
|
BaseString m_value;
|
||||||
|
virtual int eval(NdbMgmHandle, const Iter&);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Apply
|
||||||
|
{
|
||||||
|
Apply() {}
|
||||||
|
Apply(int val) { m_key = val;}
|
||||||
|
int m_key;
|
||||||
|
virtual int apply(NdbMgmHandle, const Iter&);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NodeTypeApply : public Apply
|
||||||
|
{
|
||||||
|
virtual int apply(NdbMgmHandle, const Iter&);
|
||||||
|
};
|
||||||
|
|
||||||
|
static int parse_query(Vector<Apply*>&, int &argc, char**& argv);
|
||||||
|
static int parse_where(Vector<Match*>&, int &argc, char**& argv);
|
||||||
|
static int eval(NdbMgmHandle, const Iter&, const Vector<Match*>&);
|
||||||
|
static int apply(NdbMgmHandle, const Iter&, const Vector<Apply*>&);
|
||||||
|
int
|
||||||
|
main(int argc, char** argv){
|
||||||
|
NDB_INIT(argv[0]);
|
||||||
|
const char *load_default_groups[]= { "mysql_cluster",0 };
|
||||||
|
load_defaults("my",load_default_groups,&argc,&argv);
|
||||||
|
int ho_error;
|
||||||
|
if ((ho_error=handle_options(&argc, &argv, my_long_options,
|
||||||
|
ndb_std_get_one_option)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
NdbMgmHandle mgm = ndb_mgm_create_handle();
|
||||||
|
if(mgm == NULL) {
|
||||||
|
fprintf(stderr, "Cannot create handle to management server.\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ndb_mgm_set_error_stream(mgm, stderr);
|
||||||
|
|
||||||
|
if (ndb_mgm_set_connectstring(mgm, g_connectstring))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "* %5d: %s\n",
|
||||||
|
ndb_mgm_get_latest_error(mgm),
|
||||||
|
ndb_mgm_get_latest_error_msg(mgm));
|
||||||
|
fprintf(stderr,
|
||||||
|
"* %s", ndb_mgm_get_latest_error_desc(mgm));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ndb_mgm_connect(mgm, try_reconnect-1, 5, 1))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Connect failed");
|
||||||
|
fprintf(stderr, " code: %d, msg: %s\n",
|
||||||
|
ndb_mgm_get_latest_error(mgm),
|
||||||
|
ndb_mgm_get_latest_error_msg(mgm));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
else if(g_verbose)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Connected to %s:%d\n",
|
||||||
|
ndb_mgm_get_connected_host(mgm),
|
||||||
|
ndb_mgm_get_connected_port(mgm));
|
||||||
|
}
|
||||||
|
|
||||||
|
ndb_mgm_configuration * conf = ndb_mgm_get_configuration(mgm, 0);
|
||||||
|
if(conf == 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Could not get configuration");
|
||||||
|
fprintf(stderr, "code: %d, msg: %s\n",
|
||||||
|
ndb_mgm_get_latest_error(mgm),
|
||||||
|
ndb_mgm_get_latest_error_msg(mgm));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
else if(g_verbose)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Fetched configuration\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Apply*> select_list;
|
||||||
|
Vector<Match*> where_clause;
|
||||||
|
|
||||||
|
if(strcmp(g_row_delimiter, "\\n") == 0)
|
||||||
|
g_row_delimiter = "\n";
|
||||||
|
if(strcmp(g_field_delimiter, "\\n") == 0)
|
||||||
|
g_field_delimiter = "\n";
|
||||||
|
|
||||||
|
if(parse_query(select_list, argc, argv))
|
||||||
|
{
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parse_where(where_clause, argc, argv))
|
||||||
|
{
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iter iter(* conf, CFG_SECTION_NODE);
|
||||||
|
bool prev= false;
|
||||||
|
iter.first();
|
||||||
|
for(iter.first(); iter.valid(); iter.next())
|
||||||
|
{
|
||||||
|
if(eval(mgm, iter, where_clause))
|
||||||
|
{
|
||||||
|
if(prev)
|
||||||
|
printf("%s", g_row_delimiter);
|
||||||
|
prev= true;
|
||||||
|
apply(mgm, iter, select_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int
|
||||||
|
parse_query(Vector<Apply*>& select, int &argc, char**& argv)
|
||||||
|
{
|
||||||
|
if(g_query)
|
||||||
|
{
|
||||||
|
BaseString q(g_query);
|
||||||
|
Vector<BaseString> list;
|
||||||
|
q.split(list, ",");
|
||||||
|
for(unsigned i = 0; i<list.size(); i++)
|
||||||
|
{
|
||||||
|
const char * str= list[i].c_str();
|
||||||
|
if(strcasecmp(str, "id") == 0 || strcasecmp(str, "nodeid") == 0)
|
||||||
|
select.push_back(new Apply(CFG_NODE_ID));
|
||||||
|
else if(strncasecmp(str, "host", 4) == 0)
|
||||||
|
select.push_back(new Apply(CFG_NODE_HOST));
|
||||||
|
else if(strcasecmp(str, "type") == 0)
|
||||||
|
select.push_back(new NodeTypeApply());
|
||||||
|
else if(g_nodes)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for(int p = 0; p<ConfigInfo::m_NoOfParams; p++)
|
||||||
|
{
|
||||||
|
if(0)ndbout_c("%s %s",
|
||||||
|
ConfigInfo::m_ParamInfo[p]._section,
|
||||||
|
ConfigInfo::m_ParamInfo[p]._fname);
|
||||||
|
if(strcmp(ConfigInfo::m_ParamInfo[p]._section, "DB") == 0 ||
|
||||||
|
strcmp(ConfigInfo::m_ParamInfo[p]._section, "API") == 0 ||
|
||||||
|
strcmp(ConfigInfo::m_ParamInfo[p]._section, "MGM") == 0)
|
||||||
|
{
|
||||||
|
if(strcasecmp(ConfigInfo::m_ParamInfo[p]._fname, str) == 0)
|
||||||
|
{
|
||||||
|
select.push_back(new Apply(ConfigInfo::m_ParamInfo[p]._paramId));
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!found)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unknown query option: %s\n", str);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unknown query option: %s\n", str);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int
|
||||||
|
parse_where(Vector<Match*>& where, int &argc, char**& argv)
|
||||||
|
{
|
||||||
|
Match m;
|
||||||
|
if(g_host)
|
||||||
|
{
|
||||||
|
m.m_key = CFG_NODE_HOST;
|
||||||
|
m.m_value.assfmt("%s", g_host);
|
||||||
|
where.push_back(new Match(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(g_type)
|
||||||
|
{
|
||||||
|
m.m_key = CFG_TYPE_OF_SECTION;
|
||||||
|
m.m_value.assfmt("%d", ndb_mgm_match_node_type(g_type));
|
||||||
|
where.push_back(new Match(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(g_nodeid)
|
||||||
|
{
|
||||||
|
m.m_key = CFG_NODE_ID;
|
||||||
|
m.m_value.assfmt("%d", g_nodeid);
|
||||||
|
where.push_back(new Match(m));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template Vector<Apply*>;
|
||||||
|
template Vector<Match*>;
|
||||||
|
|
||||||
|
static
|
||||||
|
int
|
||||||
|
eval(NdbMgmHandle mgm, const Iter& iter, const Vector<Match*>& where)
|
||||||
|
{
|
||||||
|
for(unsigned i = 0; i<where.size(); i++)
|
||||||
|
{
|
||||||
|
if(where[i]->eval(mgm, iter) == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int
|
||||||
|
apply(NdbMgmHandle mgm, const Iter& iter, const Vector<Apply*>& list)
|
||||||
|
{
|
||||||
|
for(unsigned i = 0; i<list.size(); i++)
|
||||||
|
{
|
||||||
|
list[i]->apply(mgm, iter);
|
||||||
|
if(i + 1 != list.size())
|
||||||
|
printf("%s", g_field_delimiter);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Match::eval(NdbMgmHandle h, const Iter& iter)
|
||||||
|
{
|
||||||
|
Uint32 val32;
|
||||||
|
Uint64 val64;
|
||||||
|
const char* valc;
|
||||||
|
if (iter.get(m_key, &val32) == 0)
|
||||||
|
{
|
||||||
|
if(atoi(m_value.c_str()) != val32)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(iter.get(m_key, &val64) == 0)
|
||||||
|
{
|
||||||
|
if(atoll(m_value.c_str()) != val64)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(iter.get(m_key, &valc) == 0)
|
||||||
|
{
|
||||||
|
if(strcmp(m_value.c_str(), valc) != 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Apply::apply(NdbMgmHandle h, const Iter& iter)
|
||||||
|
{
|
||||||
|
Uint32 val32;
|
||||||
|
Uint64 val64;
|
||||||
|
const char* valc;
|
||||||
|
if (iter.get(m_key, &val32) == 0)
|
||||||
|
{
|
||||||
|
printf("%u", val32);
|
||||||
|
}
|
||||||
|
else if(iter.get(m_key, &val64) == 0)
|
||||||
|
{
|
||||||
|
printf("%llu", val64);
|
||||||
|
}
|
||||||
|
else if(iter.get(m_key, &valc) == 0)
|
||||||
|
{
|
||||||
|
printf("%s", valc);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
NodeTypeApply::apply(NdbMgmHandle h, const Iter& iter)
|
||||||
|
{
|
||||||
|
Uint32 val32;
|
||||||
|
if (iter.get(CFG_TYPE_OF_SECTION, &val32) == 0)
|
||||||
|
{
|
||||||
|
printf("%s", ndb_mgm_get_node_type_alias_string((ndb_mgm_node_type)val32, 0));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user