summaryrefslogtreecommitdiff
path: root/ndb/src/mgmapi/mgmapi.cpp
diff options
context:
space:
mode:
authorunknown <monty@mishka.local>2004-12-22 13:54:39 +0200
committerunknown <monty@mishka.local>2004-12-22 13:54:39 +0200
commitbb2d3eaa30a3881927142c985fb637aca06d9823 (patch)
tree8e5f08b17957f896c2d4e931e60b57d99c260ed6 /ndb/src/mgmapi/mgmapi.cpp
parent52d080f09979deb2063a8010feee3b925a3d7938 (diff)
parent5c79810a6d3ca19254c310f1519664729367b647 (diff)
downloadmariadb-git-bb2d3eaa30a3881927142c985fb637aca06d9823.tar.gz
Merge with 4.1
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union Build-tools/Do-compile: Auto merged VC++Files/sql/mysqld.dsp: Auto merged client/Makefile.am: Auto merged client/mysql.cc: Auto merged BitKeeper/deleted/.del-acinclude.m4~f4ab416bac5003: Auto merged client/mysqltest.c: Auto merged include/my_base.h: Auto merged innobase/dict/dict0dict.c: Auto merged innobase/dict/dict0load.c: Auto merged innobase/include/dict0dict.h: Auto merged innobase/include/row0mysql.h: Auto merged innobase/os/os0file.c: Auto merged innobase/srv/srv0srv.c: Auto merged libmysql/libmysql.c: Auto merged myisam/mi_check.c: Auto merged myisam/mi_rnext_same.c: Auto merged myisam/mi_write.c: Auto merged myisam/sort.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/ctype_ujis.result: Auto merged mysql-test/r/gis-rtree.result: Auto merged mysql-test/r/group_by.result: Auto merged mysql-test/r/merge.result: Auto merged mysql-test/r/metadata.result: Auto merged mysql-test/r/ndb_alter_table.result: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/insert_update.result: Auto merged mysql-test/r/timezone2.result: Auto merged mysql-test/r/type_enum.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/ctype_ucs.test: Auto merged mysql-test/t/merge.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/system_mysql_db_fix.test: Auto merged mysql-test/t/variables.test: Auto merged ndb/include/ndbapi/NdbConnection.hpp: Auto merged ndb/include/ndbapi/NdbDictionary.hpp: Auto merged ndb/src/common/util/version.c: Auto merged ndb/src/kernel/blocks/dbacc/DbaccInit.cpp: Auto merged ndb/src/kernel/blocks/dbacc/Makefile.am: Auto merged ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Auto merged ndb/src/kernel/blocks/dblqh/DblqhInit.cpp: Auto merged ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Auto merged ndb/src/kernel/blocks/dbtux/Dbtux.hpp: Auto merged ndb/src/ndbapi/NdbBlob.cpp: Auto merged ndb/src/ndbapi/NdbConnection.cpp: Auto merged ndb/src/ndbapi/NdbDictionary.cpp: Auto merged ndb/src/ndbapi/NdbDictionaryImpl.cpp: Auto merged ndb/src/ndbapi/NdbDictionaryImpl.hpp: Auto merged ndb/src/ndbapi/NdbOperationExec.cpp: Auto merged ndb/src/ndbapi/NdbScanOperation.cpp: Auto merged ndb/test/ndbapi/Makefile.am: Auto merged scripts/make_win_src_distribution.sh: Auto merged scripts/mysql_install_db.sh: Auto merged sql/field.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/ha_ndbcluster.h: Auto merged sql/handler.cc: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_geofunc.cc: Auto merged sql/item_row.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_strfunc.h: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysqld.cc: Auto merged sql/net_serv.cc: Auto merged sql/password.c: Auto merged sql/protocol.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_derived.cc: Auto merged sql/sql_do.cc: Auto merged sql/sql_handler.cc: Auto merged sql/sql_help.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_repl.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_union.cc: Auto merged sql/examples/ha_archive.cc: Auto merged sql/strfunc.cc: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged sql/tztime.h: Auto merged sql/udf_example.cc: Auto merged sql/unireg.cc: Auto merged Makefile.am: Simple merge client/mysqldump.c: Simple merge configure.in: Simple merge libmysqld/lib_sql.cc: Automatic merge mysql-test/r/func_str.result: Automatic merge mysql-test/r/grant.result: simple merge mysql-test/r/multi_update.result: automatc merge mysql-test/r/ps.result: automatic merge mysql-test/r/ps_2myisam.result: Automatic merge mysql-test/r/ps_3innodb.result: Automatic merge mysql-test/r/ps_4heap.result: Automatic merge mysql-test/r/ps_5merge.result: Automatic merge mysql-test/r/ps_6bdb.result: Automatic merge mysql-test/r/ps_7ndb.result: Automatic merge mysql-test/r/show_check.result: Automatic merge mysql-test/r/subselect.result: Automatic merge mysql-test/t/grant.test: Automatic merge mysql-test/t/multi_update.test: Automatic merge mysql-test/t/ps.test: Automatic merge mysql-test/t/show_check.test: Automatic merge ndb/docs/wl2077.txt: merge ndb/src/mgmsrv/main.cpp: merge scripts/mysql_fix_privilege_tables.sh: merge sql/item.cc: Merge (difficult) sql/item.h: simple merge sql/item_cmpfunc.h: Automatic merge sql/item_subselect.cc: Simple merge sql/item_subselect.h: Automatic merge sql/mysql_priv.h: Simple merge sql/slave.h: Automatic merge sql/sql_base.cc: Removed code that was backported to 4.1 sql/sql_class.h: Merge (some code moved to sql_insert.cc) sql/sql_db.cc: simple merge sql/sql_insert.cc: Merge (difficult as logic had changed both in 4.1 and 5.0) Some coded moved here from sql_class.h sql/sql_parse.cc: Merge (difficult) sql/sql_prepare.cc: Simple merge sql/sql_select.cc: Automatic merge sql/sql_table.cc: Simple merge sql/sql_update.cc: Difficult merge because of different logic for multi-updates sql/sql_yacc.yy: Simple merge tests/client_test.c: Simple merge
Diffstat (limited to 'ndb/src/mgmapi/mgmapi.cpp')
-rw-r--r--ndb/src/mgmapi/mgmapi.cpp106
1 files changed, 86 insertions, 20 deletions
diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp
index e22ceffe773..5a95c6e9ac1 100644
--- a/ndb/src/mgmapi/mgmapi.cpp
+++ b/ndb/src/mgmapi/mgmapi.cpp
@@ -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;
@@ -1053,15 +1102,18 @@ ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle, int nodeId,
"set cluster loglevel", &args);
CHECK_REPLY(reply, -1);
+ DBUG_ENTER("ndb_mgm_set_loglevel_clusterlog");
+ DBUG_PRINT("enter",("node=%d, category=%d, level=%d", nodeId, cat, level));
+
BaseString result;
reply->get("result", result);
if(strcmp(result.c_str(), "Ok") != 0) {
SET_ERROR(handle, EINVAL, result.c_str());
delete reply;
- return -1;
+ DBUG_RETURN(-1);
}
delete reply;
- return 0;
+ DBUG_RETURN(0);
}
extern "C"
@@ -1117,7 +1169,7 @@ ndb_mgm_listen_event(NdbMgmHandle handle, int filter[])
int port= ndb_mgm_get_connected_port(handle);
SocketClient s(hostname, port);
const NDB_SOCKET_TYPE sockfd = s.connect();
- if (sockfd < 0) {
+ if (sockfd == NDB_INVALID_SOCKET) {
setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__,
"Unable to connect to");
return -1;
@@ -1493,7 +1545,8 @@ ndb_mgm_start(NdbMgmHandle handle, int no_of_nodes, const int * node_list)
*****************************************************************************/
extern "C"
int
-ndb_mgm_start_backup(NdbMgmHandle handle, unsigned int* _backup_id,
+ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed,
+ unsigned int* _backup_id,
struct ndb_mgm_reply* /*reply*/)
{
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_start_backup");
@@ -1507,8 +1560,17 @@ ndb_mgm_start_backup(NdbMgmHandle handle, unsigned int* _backup_id,
CHECK_CONNECTED(handle, -1);
Properties args;
+ args.put("completed", wait_completed);
const Properties *reply;
- reply = ndb_mgm_call(handle, start_backup_reply, "start backup", &args);
+ { // start backup can take some time, set timeout high
+ Uint64 old_timeout= handle->read_timeout;
+ if (wait_completed == 2)
+ handle->read_timeout= 30*60*1000; // 30 minutes
+ else if (wait_completed == 1)
+ handle->read_timeout= 5*60*1000; // 5 minutes
+ reply = ndb_mgm_call(handle, start_backup_reply, "start backup", &args);
+ handle->read_timeout= old_timeout;
+ }
CHECK_REPLY(reply, -1);
BaseString result;
@@ -1690,6 +1752,9 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype)
{
CHECK_HANDLE(handle, 0);
CHECK_CONNECTED(handle, 0);
+ union { long l; char c[sizeof(long)]; } endian_check;
+
+ endian_check.l = 1;
int nodeid= handle->cfg._ownNodeId;
@@ -1700,6 +1765,7 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype)
args.put("user", "mysqld");
args.put("password", "mysqld");
args.put("public key", "a public key");
+ args.put("endian", (endian_check.c[sizeof(long)-1])?"big":"little");
const ParserRow<ParserDummy> reply[]= {
MGM_CMD("get nodeid reply", NULL, ""),