|
|||||||||||
|
[patch 4/8] mgm for win32
From: <stewart(at)flamingspork.com>
Date: Wed Sep 19 2007 - 03:46:45 EDT ooo bzr diff -r1 -pa/:b/ ndb/src/mgm* |di -m '\S+\.[hc]c?(pp)?(\.in)?' --- a/ndb/src/mgmapi/LocalConfig.cpp 2007-08-29 07:25:53 +0000 +++ b/ndb/src/mgmapi/LocalConfig.cpp 2007-09-06 13:30:50 +0000- snprintf(tempString2, sizeof(tempString2),"%s:%s", buf, NDB_PORT); + BaseString::snprintf(tempString2, sizeof(tempString2),"%s:%s", buf, NDB_PORT);
buf= tempString2;
BaseString tmp(buf);
tmp.split(split, ":");
if(!(split[0].trim() == "nodes")){
const int noOfNodes = atoi(split[1].c_str());
{
SET_ERROR(handle, NDB_MGM_OUT_OF_MEMORY,
"Allocating ndb_mgm_cluster_state");
- return NULL;
+ DBUG_RETURN(NULL); }
state->no_of_nodes= noOfNodes;
free(state);
SET_ERROR(handle, NDB_MGM_ILLEGAL_SERVER_REPLY,
"Probably disconnected");
- return NULL;
+ DBUG_RETURN(NULL);
}
tmp.assign(buf);
@@ -858,12 +860,12 @@ if(i+1 != noOfNodes){
free(state);
SET_ERROR(handle, NDB_MGM_ILLEGAL_NODE_STATUS, "Node count mismatch");
- return NULL;
+ DBUG_RETURN(NULL); } qsort(state->node_states, state->no_of_nodes, sizeof(state->node_states[0]),
cmp_state);
extern "C"
handle->socket = tmp;
if(reply == NULL) {
CHECK_REPLY(reply, -1);
+#ifdef NDB_WIN32 +#include #include <Properties.hpp> #include <socket_io.h> @@ -80,7 +84,7 @@ return;
if ( *h )
my_free((char*)* h,MYF(MY_ALLOW_ZERO_PTR));
+#ifdef NDB_WIN32 + struct _timeb start_time; + _ftime(&start_time); +#else
struct timeval start_time;
/* header */
if ( strcmp("
+#endif
if (elapsed_ms >= timeout_in_milliseconds)
{
--- a/ndb/src/mgmclient/CommandInterpreter.cpp 2007-08-29 07:25:53 +0000
+++ b/ndb/src/mgmclient/CommandInterpreter.cpp 2007-09-16 12:55:19 +0000
@@ -14,6 +14,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include
//#define HAVE_GLOBAL_REPLICATION
-#include + +#include @@ -42,6 +42,7 @@ static Ndb_mgmclient* com;
+#ifndef NDB_WIN32
}
NDB_STD_OPTS_VARS;
prompt= 0;
+#ifndef NDB_WIN32
signal(SIGPIPE, handler);
com = new Ndb_mgmclient(opt_connect_str,1);
int ret= 0;
@@ -460,10 +459,8 @@
// read config locally
_config= readConfig();
if (_config == 0) {
- if (config_filename != NULL)
- ndbout << "Invalid configuration file: " << config_filename << endl;
- else
- ndbout << "Invalid configuration file" << endl;
+ ndbout_c("Invalid configuration file: %s\n",
+ config_filename?config_filename:"} @@ -519,7 +516,7 @@
if ((m_node_id_mutex = NdbMutex_Create()) == 0)
{
require(false);
@@ -2890,7 +2887,7 @@
"localhost:%u",getPort());
+#if 0 && !defined(MYSQL_YACC)&& !defined(_WINSOCKAPI_) +// ^... sql_yacc.cc includes this file, and defines GROUP which is a typedef in winsock2.h +#include #include <ndb_global.h> #include <ndb_opts.h> +#ifdef NDB_WIN32 +#define NDB_SVC svc +#include #include "EventLogger.hpp" #include <Config.hpp> @@ -45,6 +58,7 @@ #undef DEBUG #define DEBUG(x) ndbout << x << endl;
+typedef BaseString bstring;
@@ -103,7 +117,15 @@ +static const char * opt_install_svc_name, *opt_remove_svc_name; +static int opt_install_svc, opt_remove_svc; +static int opt_svc; + +#ifdef NDB_WIN32 +#define W32 1 +#else +#define W32 0 +#endif struct MgmGlobals { MgmGlobals(); ~MgmGlobals(); @@ -153,9 +175,12 @@ { "print-full-config", 'P', "Print full config and exit",
(gptr*) &g_print_full_config, (gptr*) &g_print_full_config, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
- { "daemon", 'd', "Run ndb_mgmd in daemon mode (default)",
- (gptr*) &opt_daemon, (gptr*) &opt_daemon, 0,
- GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
+ { "daemon", 'd', "Run ndb_mgmd in daemon mode (default)"
+#ifdef NDB_WIN32
+ "\n\t[WINDOWS: option not available]"
+#endif
+ ,(gptr*) &opt_daemon, (gptr*) &opt_daemon, 0,
+ GET_BOOL, NO_ARG, !W32, 0, 0, 0, 0, 0 },
{ "interactive", OPT_INTERACTIVE,
"Run interactive. Not supported but provided for testing purposes",
(gptr*) &opt_interactive, (gptr*) &opt_interactive, 0,
{ "nodaemon", OPT_NO_DAEMON,
- "Don't run as daemon, but don't read from stdin", - (gptr*) &opt_non_interactive, (gptr*) &opt_non_interactive, 0, + "Don't run as daemon, but don't read from stdin" +#ifdef NDB_WIN32 + "\n\t[WINDOWS: will only run as --nodaemon]" +#endif + ,(gptr*) &opt_non_interactive, (gptr*) &opt_non_interactive, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "mycnf", 256, "Read cluster config from my.cnf", (gptr*) &opt_mycnf, (gptr*) &opt_mycnf, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, +#ifdef NDB_WIN32 + { "install", 'i', "install [windows service name]", + (gptr*) &opt_install_svc, (gptr*) &opt_install_svc_name, 0, + GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0 }, + { "remove", 'r', "remove [windows service name]", + (gptr*) &opt_remove_svc, (gptr*) &opt_remove_svc_name, 0, + GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0 }, + { "service", 's', "internal use. must be passed to the service", + (gptr*) &opt_svc, (gptr*) &opt_svc, 0,+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, +#endif { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -189,12 +228,59 @@
my_print_variables(my_long_options);
+#ifdef NDB_WIN32 +#define NDB_SVC +#include
load_defaults("my",load_default_groups,&argc,&argv);
if ((ho_error=handle_options(&argc, &argv, my_long_options,
ndb_std_get_one_option)))
exit(ho_error);
- -start:
+ if (opt_interactive ||
+ opt_non_interactive ||
+ g_print_full_config) {
+ opt_daemon= 0;
+ }
+#ifdef NDB_WIN32
+#define CHECKFIRST(IR) if(strcmp(argv_[1],"-"#IR))return ndbout_c("-"#IR" must be first")
+ if(opt_install_svc)
+ { CHECKFIRST(i);
+ int havename=(opt_install_svc_name!=0);
+ return install(argv_[0],opt_install_svc_name,argc_-1-havename,argv_+1+havename);
+ }
+ if(opt_remove_svc)
+ { CHECKFIRST(r);
+ return remove(argv_[0],opt_remove_svc_name);
+ }
+ if(opt_svc)
+ {
+ ndbout_svc=&evtlog;
+ useeventlog=1;
+ return svc.Init(argv_[0],start);
+ }
+#endif
+ return start(0);
+}
+int restofmain(void*);
+int error_end();
+int the_end();
+int start(void*)
+{
glob= new MgmGlobals;
/**
global_mgmt_server_check = 1;
if (opt_mycnf == 0 && opt_config_filename == 0)
{
+ struct stat buf;
+ if (stat("config.ini", &buf) != -1)
opt_config_filename = "config.ini";
}
+
+ if (!opt_config_filename && !opt_connect_str)
+ {
+ ndbout_c("config file required");
+ return 0;
+ }
glob->socketServer = new SocketServer();
glob->mgmObject = new MgmtSrvr(glob->socketServer, opt_config_filename, opt_connect_str);
if (g_print_full_config)
if (glob->mgmObject->init())
my_setwd(NdbConfig_get_path(0), MYF(0));
glob->localNodeId= glob->mgmObject->getOwnNodeId();
if (glob->localNodeId == 0) {
} glob->port= glob->mgmObject->getPort();
if (glob->port == 0)
glob->interface_name = 0;
"(perhaps a ndb_mgmd is already running),\n"
"and if you are executing on the correct computer",
(glob->interface_name ? glob->interface_name : "*"), glob->port);
- goto error_end;
+ return error_end();
}
free(glob->interface_name);
glob->interface_name = 0;
- goto error_end; + return error_end(); } if(!glob->mgmObject->check_start()){
ndbout_c("Unable to check start management server.");
ndbout_c("Probably caused by illegal initial configuration file.");
- goto error_end;
+ return error_end(); }
@@ -371,14 +493,19 @@ // We disconnect from the ConfigRetreiver mgmd when we delete glob below glob->socketServer->stopSessions(true); g_eventLogger.info("Shutdown complete"); - the_end: delete glob;
+ ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
+ return 1;
+}
+int the_end()
+{ delete glob;
if(g_RestartServer)
ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
return 0;
+}
+int error_end()
+{ delete glob;
ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
return 1;
-- Stewart Smith -- MySQL Code Commits Mailing List For list archives: http://lists.mysql.com/commits To unsubscribe: http://lists.mysql.com/commits?unsub=lists@pantek.comReceived on Wed Sep 19 04:11:55 2007 This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 09:32:55 EDT |
||||||||||
|
|||||||||||