Services.cpp 45.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* 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 */

mysqldev@mysql.com's avatar
mysqldev@mysql.com committed
17
#include <ndb_global.h>
18 19 20 21 22 23 24 25
#include <ctype.h>

#include <uucode.h>
#include <socket_io.h>
#include <ndb_version.h>
#include <mgmapi.h>
#include <EventLogger.hpp>
#include <signaldata/SetLogLevelOrd.hpp>
joreland@mysql.com's avatar
joreland@mysql.com committed
26
#include <LogLevel.hpp>
27 28
#include <BaseString.hpp>

29 30
#include <ConfigValues.hpp>
#include <mgmapi_configuration.hpp>
joreland@mysql.com's avatar
joreland@mysql.com committed
31
#include <Vector.hpp>
32
#include "Services.hpp"
33
#include "../mgmapi/ndb_logevent.hpp"
34

35
#include <base64.h>
36
#include <ndberror.h>
37

38
extern bool g_StopServer;
39
extern bool g_RestartServer;
tomas@poseidon.ndb.mysql.com's avatar
ndb:  
tomas@poseidon.ndb.mysql.com committed
40
extern EventLogger g_eventLogger;
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
static const unsigned int MAX_READ_TIMEOUT = 1000 ;
static const unsigned int MAX_WRITE_TIMEOUT = 100 ;

/**
   const char * name;
   const char * realName;
   const Type type;
   const ArgType argType;
   const ArgRequired argRequired;
   const ArgMinMax argMinMax;
   const int minVal;
   const int maxVal;
   void (T::* function)(const class Properties & args);
   const char * description;
*/

#define MGM_CMD(name, fun, desc) \
 { name, \
   0, \
   ParserRow<MgmApiSession>::Cmd, \
   ParserRow<MgmApiSession>::String, \
   ParserRow<MgmApiSession>::Optional, \
   ParserRow<MgmApiSession>::IgnoreMinMax, \
   0, 0, \
   fun, \
   desc, 0 }

#define MGM_ARG(name, type, opt, desc) \
 { name, \
   0, \
   ParserRow<MgmApiSession>::Arg, \
   ParserRow<MgmApiSession>::type, \
   ParserRow<MgmApiSession>::opt, \
   ParserRow<MgmApiSession>::IgnoreMinMax, \
   0, 0, \
   0, \
  desc, 0 }

#define MGM_ARG2(name, type, opt, min, max, desc) \
 { name, \
   0, \
   ParserRow<MgmApiSession>::Arg, \
   ParserRow<MgmApiSession>::type, \
   ParserRow<MgmApiSession>::opt, \
   ParserRow<MgmApiSession>::IgnoreMinMax, \
   min, max, \
   0, \
  desc, 0 }

#define MGM_END() \
 { 0, \
   0, \
   ParserRow<MgmApiSession>::Arg, \
   ParserRow<MgmApiSession>::Int, \
   ParserRow<MgmApiSession>::Optional, \
   ParserRow<MgmApiSession>::IgnoreMinMax, \
   0, 0, \
   0, \
   0, 0 }

#define MGM_CMD_ALIAS(name, realName, fun) \
 { name, \
   realName, \
   ParserRow<MgmApiSession>::CmdAlias, \
   ParserRow<MgmApiSession>::Int, \
   ParserRow<MgmApiSession>::Optional, \
   ParserRow<MgmApiSession>::IgnoreMinMax, \
   0, 0, \
   0, \
   0, 0 }

#define MGM_ARG_ALIAS(name, realName, fun) \
 { name, \
   realName, \
   ParserRow<MgmApiSession>::ArgAlias, \
   ParserRow<MgmApiSession>::Int, \
   ParserRow<MgmApiSession>::Optional, \
   ParserRow<MgmApiSession>::IgnoreMinMax, \
   0, 0, \
   0, \
   0, 0 }

const
ParserRow<MgmApiSession> commands[] = {
  MGM_CMD("get statport", &MgmApiSession::getStatPort, ""),
  
  MGM_CMD("get config", &MgmApiSession::getConfig, ""),
    MGM_ARG("version", Int, Mandatory, "Configuration version number"),
    MGM_ARG("node", Int, Optional, "Node ID"),

tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
132 133 134
  MGM_CMD("get nodeid", &MgmApiSession::get_nodeid, ""),
    MGM_ARG("version", Int, Mandatory, "Configuration version number"),
    MGM_ARG("nodetype", Int, Mandatory, "Node type"),
135
    MGM_ARG("transporter", String, Optional, "Transporter type"),
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
136 137 138 139
    MGM_ARG("nodeid", Int, Optional, "Node ID"),
    MGM_ARG("user", String, Mandatory, "Password"),
    MGM_ARG("password", String, Mandatory, "Password"),
    MGM_ARG("public key", String, Mandatory, "Public key"),
140
    MGM_ARG("endian", String, Optional, "Endianness"),
tomas@poseidon.ndb.mysql.com's avatar
ndb:  
tomas@poseidon.ndb.mysql.com committed
141
    MGM_ARG("name", String, Optional, "Name of connection"),
142
    MGM_ARG("timeout", Int, Optional, "Timeout in seconds"),
143
    MGM_ARG("log_event", Int, Optional, "Log failure in cluster log"),
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
144

145
  MGM_CMD("get version", &MgmApiSession::getVersion, ""),
joreland@mysql.com's avatar
joreland@mysql.com committed
146
  
147 148 149 150
  MGM_CMD("get status", &MgmApiSession::getStatus, ""),

  MGM_CMD("get info clusterlog", &MgmApiSession::getInfoClusterLog, ""),

151 152 153 154 155 156 157
  MGM_CMD("restart node", &MgmApiSession::restart_v1, ""),
    MGM_ARG("node", String, Mandatory, "Nodes to restart"),
    MGM_ARG("initialstart", Int, Optional, "Initial start"),
    MGM_ARG("nostart", Int, Optional, "No start"),
    MGM_ARG("abort", Int, Optional, "Abort"),

  MGM_CMD("restart node v2", &MgmApiSession::restart_v2, ""),
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
    MGM_ARG("node", String, Mandatory, "Nodes to restart"),
    MGM_ARG("initialstart", Int, Optional, "Initial start"),
    MGM_ARG("nostart", Int, Optional, "No start"),
    MGM_ARG("abort", Int, Optional, "Abort"),

  MGM_CMD("restart all", &MgmApiSession::restartAll, ""),
    MGM_ARG("initialstart", Int, Optional, "Initial start"),
    MGM_ARG("nostart", Int, Optional, "No start"),
    MGM_ARG("abort", Int, Optional, "Abort"),

  MGM_CMD("insert error", &MgmApiSession::insertError, ""),
    MGM_ARG("node", Int, Mandatory, "Node to receive error"),
    MGM_ARG("error", Int, Mandatory, "Errorcode to insert"),

  MGM_CMD("set trace", &MgmApiSession::setTrace, ""),
    MGM_ARG("node", Int, Mandatory, "Node"),
    MGM_ARG("trace", Int, Mandatory, "Trace number"),

  MGM_CMD("log signals", &MgmApiSession::logSignals, ""),
    MGM_ARG("node", Int, Mandatory, "Node"),
    MGM_ARG("blocks", String, Mandatory, "Blocks (space separated)"),
    MGM_ARG("in", Int, Mandatory, "Log input signals"),
    MGM_ARG("out", Int, Mandatory, "Log output signals"),

  MGM_CMD("start signallog", &MgmApiSession::startSignalLog, ""),
    MGM_ARG("node", Int, Mandatory, "Node"),

  MGM_CMD("stop signallog", &MgmApiSession::stopSignalLog, ""),
    MGM_ARG("node", Int, Mandatory, "Node"),

  MGM_CMD("dump state", &MgmApiSession::dumpState, ""),
    MGM_ARG("node", Int, Mandatory ,"Node"),
    MGM_ARG("args", String, Mandatory, "Args(space separated int's)"),

  MGM_CMD("start backup", &MgmApiSession::startBackup, ""),
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
193
    MGM_ARG("completed", Int, Optional ,"Wait until completed"),
194 195 196 197

  MGM_CMD("abort backup", &MgmApiSession::abortBackup, ""),
    MGM_ARG("id", Int, Mandatory, "Backup id"),

198
  MGM_CMD("stop", &MgmApiSession::stop_v1, ""),
199 200 201
    MGM_ARG("node", String, Mandatory, "Node"),
    MGM_ARG("abort", Int, Mandatory, "Node"),

202
  MGM_CMD("stop v2", &MgmApiSession::stop_v2, ""),
203 204 205 206 207
    MGM_ARG("node", String, Mandatory, "Node"),
    MGM_ARG("abort", Int, Mandatory, "Node"),

  MGM_CMD("stop all", &MgmApiSession::stopAll, ""),
    MGM_ARG("abort", Int, Mandatory, "Node"),
208
    MGM_ARG("stop", String, Optional, "MGM/DB or both"),
209

210 211 212 213 214 215 216 217 218 219 220 221 222
  MGM_CMD("enter single user", &MgmApiSession::enterSingleUser, ""),
    MGM_ARG("nodeId", Int, Mandatory, "Node"),
  
  MGM_CMD("exit single user", &MgmApiSession::exitSingleUser, ""),
  

  MGM_CMD("start", &MgmApiSession::start, ""),
    MGM_ARG("node", Int, Mandatory, "Node"),

  MGM_CMD("start all", &MgmApiSession::startAll, ""),

  MGM_CMD("bye", &MgmApiSession::bye, ""),

223 224
  MGM_CMD("end session", &MgmApiSession::endSession, ""),

225 226
  MGM_CMD("set loglevel", &MgmApiSession::setLogLevel, ""),
    MGM_ARG("node", Int, Mandatory, "Node"),
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
227
    MGM_ARG("category", Int, Mandatory, "Event category"),
228 229 230 231
    MGM_ARG("level", Int, Mandatory, "Log level (0-15)"),

  MGM_CMD("set cluster loglevel", &MgmApiSession::setClusterLogLevel, ""),
    MGM_ARG("node", Int, Mandatory, "Node"),
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
232
    MGM_ARG("category", Int, Mandatory, "Event category"),
233 234 235 236
    MGM_ARG("level", Int, Mandatory, "Log level (0-15)"),

  MGM_CMD("set logfilter", &MgmApiSession::setLogFilter, ""),
    MGM_ARG("level", Int, Mandatory, "Severety level"),
237
    MGM_ARG("enable", Int, Mandatory, "1=disable, 0=enable, -1=toggle"),
238

239 240 241 242
  MGM_CMD("set parameter", &MgmApiSession::setParameter, ""),
    MGM_ARG("node", String, Mandatory, "Node"),
    MGM_ARG("parameter", String, Mandatory, "Parameter"),
    MGM_ARG("value", String, Mandatory, "Value"),
joreland@mysql.com's avatar
joreland@mysql.com committed
243

244 245 246 247 248 249 250
  MGM_CMD("set connection parameter",
	  &MgmApiSession::setConnectionParameter, ""),
    MGM_ARG("node1", String, Mandatory, "Node1 ID"),
    MGM_ARG("node2", String, Mandatory, "Node2 ID"),
    MGM_ARG("param", String, Mandatory, "Parameter"),
    MGM_ARG("value", String, Mandatory, "Value"),

251 252 253 254 255 256
  MGM_CMD("get connection parameter",
	  &MgmApiSession::getConnectionParameter, ""),
    MGM_ARG("node1", String, Mandatory, "Node1 ID"),
    MGM_ARG("node2", String, Mandatory, "Node2 ID"),
    MGM_ARG("param", String, Mandatory, "Parameter"),

joreland@mysql.com's avatar
joreland@mysql.com committed
257 258
  MGM_CMD("listen event", &MgmApiSession::listen_event, ""),
    MGM_ARG("node", Int, Optional, "Node"),  
259
    MGM_ARG("parsable", Int, Optional, "Parsable"),  
joreland@mysql.com's avatar
joreland@mysql.com committed
260 261
    MGM_ARG("filter", String, Mandatory, "Event category"),

262 263
  MGM_CMD("purge stale sessions", &MgmApiSession::purge_stale_sessions, ""),

264 265
  MGM_CMD("check connection", &MgmApiSession::check_connection, ""),

266 267
  MGM_CMD("transporter connect", &MgmApiSession::transporter_connect, ""),

268 269
  MGM_CMD("get mgmd nodeid", &MgmApiSession::get_mgmd_nodeid, ""),

270 271 272 273
  MGM_CMD("report event", &MgmApiSession::report_event, ""),
    MGM_ARG("length", Int, Mandatory, "Length"),
    MGM_ARG("data", String, Mandatory, "Data"),

274 275 276
  MGM_END()
};

277 278 279 280 281 282 283 284 285
struct PurgeStruct
{
  NodeBitmask free_nodes;/* free nodes as reported
			  * by ndbd in apiRegReqConf
			  */
  BaseString *str;
  NDB_TICKS tick;
};

286
MgmApiSession::MgmApiSession(class MgmtSrvr & mgm, NDB_SOCKET_TYPE sock)
287 288 289
  : SocketServer::Session(sock), m_mgmsrv(mgm)
{
  DBUG_ENTER("MgmApiSession::MgmApiSession");
290 291 292
  m_input = new SocketInputStream(sock);
  m_output = new SocketOutputStream(sock);
  m_parser = new Parser_t(commands, *m_input, true, true, true);
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
293
  m_allocated_resources= new MgmtSrvr::Allocated_resources(m_mgmsrv);
294
  m_stopSelf= 0;
295
  DBUG_VOID_RETURN;
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
296 297 298 299
}

MgmApiSession::~MgmApiSession()
{
300
  DBUG_ENTER("MgmApiSession::~MgmApiSession");
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
301 302 303 304 305 306 307 308
  if (m_input)
    delete m_input;
  if (m_output)
    delete m_output;
  if (m_parser)
    delete m_parser;
  if (m_allocated_resources)
    delete m_allocated_resources;
309 310 311 312 313
  if(m_socket != NDB_INVALID_SOCKET)
  {
    NDB_CLOSE_SOCKET(m_socket);
    m_socket= NDB_INVALID_SOCKET;
  }
314 315 316 317
  if(m_stopSelf < 0)
    g_RestartServer= true;
  if(m_stopSelf)
    g_StopServer= true;
318
  DBUG_VOID_RETURN;
319 320 321
}

void
322 323 324 325
MgmApiSession::runSession()
{
  DBUG_ENTER("MgmApiSession::runSession");

326 327 328 329 330 331 332 333 334 335 336 337 338
  Parser_t::Context ctx;
  while(!m_stop) {
    m_parser->run(ctx, *this);

    if(ctx.m_currentToken == 0)
      break;

    switch(ctx.m_status) {
    case Parser_t::UnknownCommand:
#ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT
      /* Backwards compatibility for old NDBs that still use
       * the old "GET CONFIG" command.
       */
joreland@mysql.com's avatar
joreland@mysql.com committed
339 340
	  size_t i;
      for(i=0; i<strlen(ctx.m_currentToken); i++)
341 342 343 344 345 346 347 348 349 350 351 352
	ctx.m_currentToken[i] = toupper(ctx.m_currentToken[i]);

      if(strncmp("GET CONFIG ", 
		 ctx.m_currentToken,
		 strlen("GET CONFIG ")) == 0)
	getConfig_old(ctx);
#endif /* MGM_GET_CONFIG_BACKWARDS_COMPAT */
      break;
    default:
      break;
    }
  }
353
  if(m_socket != NDB_INVALID_SOCKET)
354
  {
joreland@mysql.com's avatar
joreland@mysql.com committed
355
    NDB_CLOSE_SOCKET(m_socket);
356 357 358 359
    m_socket= NDB_INVALID_SOCKET;
  }

  DBUG_VOID_RETURN;
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
}

#ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT
void
MgmApiSession::getConfig_old(Parser_t::Context &ctx) {
  Properties args;

  Uint32 version, node;

  if(sscanf(ctx.m_currentToken, "GET CONFIG %d %d",
	    (int *)&version, (int *)&node) != 2) {
    m_output->println("Expected 2 arguments for GET CONFIG");
    return;
  }

  /* Put arguments in properties object so we can call the real function */  
  args.put("version", version);
  args.put("node", node);
  getConfig_common(ctx, args, true);
}
#endif /* MGM_GET_CONFIG_BACKWARDS_COMPAT */

void
MgmApiSession::getConfig(Parser_t::Context &ctx, 
			 const class Properties &args) {
  getConfig_common(ctx, args);
}

388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
static Properties *
backward(const char * base, const Properties* reply){
  Properties * ret = new Properties();
  Properties::Iterator it(reply);
  for(const char * name = it.first(); name != 0; name=it.next()){
    PropertiesType type;
    reply->getTypeOf(name, &type);
    switch(type){
    case PropertiesType_Uint32:{
      Uint32 val;
      reply->get(name, &val);
      ret->put(name, val);
    }
      break;
    case PropertiesType_char:
      {
	const char * val;
	reply->get(name, &val);
	ret->put(name, val);
	if(!strcmp(name, "Type") && !strcmp(val, "DB")){
	  ret->put("NoOfDiskBufferPages", (unsigned)0);
	  ret->put("NoOfDiskFiles", (unsigned)0);
	  ret->put("NoOfDiskClusters", (unsigned)0);
	  ret->put("NoOfFreeDiskClusters", (unsigned)0);
	  ret->put("NoOfDiskClustersPerDiskFile", (unsigned)0);
	  ret->put("NoOfConcurrentCheckpointsDuringRestart", (unsigned)1);
	  ret->put("NoOfConcurrentCheckpointsAfterRestart", (unsigned)1);
	  ret->put("NoOfConcurrentProcessesHandleTakeover", (unsigned)1);
	}
      }
      break;
    case PropertiesType_Properties:
      {
	const Properties * recurse;
	reply->get(name, &recurse);
	Properties * val = backward(name, recurse);
	ret->put(name, val);
      }
      break;
    case PropertiesType_Uint64:
      break;
    }
  }
  return ret;
}

tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
434 435 436 437 438 439
void
MgmApiSession::get_nodeid(Parser_t::Context &,
			  const class Properties &args)
{
  const char *cmd= "get nodeid reply";
  Uint32 version, nodeid= 0, nodetype= 0xff;
440
  Uint32 timeout= 20;  // default seconds timeout
441
  const char * transporter;
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
442 443 444
  const char * user;
  const char * password;
  const char * public_key;
445
  const char * endian= NULL;
tomas@poseidon.ndb.mysql.com's avatar
ndb:  
tomas@poseidon.ndb.mysql.com committed
446
  const char * name= NULL;
447 448
  Uint32 log_event= 1;
  bool log_event_version;
449
  union { long l; char c[sizeof(long)]; } endian_check;
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
450 451 452

  args.get("version", &version);
  args.get("nodetype", &nodetype);
453
  args.get("transporter", &transporter);
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
454 455 456 457
  args.get("nodeid", &nodeid);
  args.get("user", &user);
  args.get("password", &password);
  args.get("public key", &public_key);
458
  args.get("endian", &endian);
tomas@poseidon.ndb.mysql.com's avatar
ndb:  
tomas@poseidon.ndb.mysql.com committed
459
  args.get("name", &name);
460
  args.get("timeout", &timeout);
461 462
  /* for backwards compatability keep track if client uses new protocol */
  log_event_version= args.get("log_event", &log_event);
463 464 465 466 467

  endian_check.l = 1;
  if(endian 
     && strcmp(endian,(endian_check.c[sizeof(long)-1])?"big":"little")!=0) {
    m_output->println(cmd);
468
    m_output->println("result: Node does not have the same endianness as the management server.");
469 470 471 472
    m_output->println("");
    return;
  }

tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
  bool compatible;
  switch (nodetype) {
  case NODE_TYPE_MGM:
  case NODE_TYPE_API:
    compatible = ndbCompatible_mgmt_api(NDB_VERSION, version);
    break;
  case NODE_TYPE_DB:
    compatible = ndbCompatible_mgmt_ndb(NDB_VERSION, version);
    break;
  default:
    m_output->println(cmd);
    m_output->println("result: unknown nodetype %d", nodetype);
    m_output->println("");
    return;
  }
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
488

489
  struct sockaddr_in addr;
490
  SOCKET_SIZE_TYPE addrlen= sizeof(addr);
491
  int r = getpeername(m_socket, (struct sockaddr*)&addr, &addrlen);
joreland@mysql.com's avatar
joreland@mysql.com committed
492
  if (r != 0 ) {
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
493
    m_output->println(cmd);
494
    m_output->println("result: getpeername(%d) failed, err= %d", m_socket, r);
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
495 496 497 498 499
    m_output->println("");
    return;
  }

  NodeId tmp= nodeid;
joreland@mysql.com's avatar
joreland@mysql.com committed
500
  if(tmp == 0 || !m_allocated_resources->is_reserved(tmp)){
501
    BaseString error_string;
502
    int error_code;
503
    NDB_TICKS tick= 0;
504
    /* only report error on second attempt as not to clog the cluster log */
505
    while (!m_mgmsrv.alloc_node_id(&tmp, (enum ndb_mgm_node_type)nodetype, 
506
                                   (struct sockaddr*)&addr, &addrlen, error_code, error_string,
507
                                   tick == 0 ? 0 : log_event))
508
    {
509 510
      /* NDB_MGM_ALLOCID_CONFIG_MISMATCH is a non retriable error */
      if (tick == 0 && error_code != NDB_MGM_ALLOCID_CONFIG_MISMATCH)
511 512 513 514 515 516 517 518 519 520 521
      {
        // attempt to free any timed out reservations
        tick= NdbTick_CurrentMillisecond();
        struct PurgeStruct ps;
        m_mgmsrv.get_connected_nodes(ps.free_nodes);
        // invert connected_nodes to get free nodes
        ps.free_nodes.bitXORC(NodeBitmask());
        ps.str= 0;
        ps.tick= tick;
        m_mgmsrv.get_socket_server()->
          foreachSession(stop_session_if_timed_out,&ps);
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
522
	m_mgmsrv.get_socket_server()->checkSessions();
523
        error_string = "";
524 525
        continue;
      }
526 527
      const char *alias;
      const char *str;
528 529
      alias= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)
						nodetype, &str);
joreland@mysql.com's avatar
joreland@mysql.com committed
530
      m_output->println(cmd);
531
      m_output->println("result: %s", error_string.c_str());
532 533 534
      /* only use error_code protocol if client knows about it */
      if (log_event_version)
        m_output->println("error_code: %d", error_code);
joreland@mysql.com's avatar
joreland@mysql.com committed
535 536 537 538
      m_output->println("");
      return;
    }
  }    
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
539 540 541 542 543 544 545 546 547 548
  
#if 0
  if (!compatible){
    m_output->println(cmd);
    m_output->println("result: incompatible version mgmt 0x%x and node 0x%x",
		      NDB_VERSION, version);
    m_output->println("");
    return;
  }
#endif
joreland@mysql.com's avatar
joreland@mysql.com committed
549
  
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
550
  m_output->println(cmd);
joreland@mysql.com's avatar
joreland@mysql.com committed
551
  m_output->println("nodeid: %u", tmp);
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
552 553
  m_output->println("result: Ok");
  m_output->println("");
554
  m_allocated_resources->reserve_node(tmp, timeout*1000);
joreland@mysql.com's avatar
joreland@mysql.com committed
555
  
tomas@poseidon.ndb.mysql.com's avatar
ndb:  
tomas@poseidon.ndb.mysql.com committed
556 557 558
  if (name)
    g_eventLogger.info("Node %d: %s", tmp, name);

tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
559 560 561
  return;
}

562 563 564 565 566 567 568 569 570 571 572
void
MgmApiSession::getConfig_common(Parser_t::Context &,
				const class Properties &args,
				bool compat) {
  Uint32 version, node = 0;

  args.get("version", &version);
  args.get("node", &node);

  const Config *conf = m_mgmsrv.getConfig();
  if(conf == NULL) {
573
    m_output->println("get config reply");
574 575 576 577 578
    m_output->println("result: Could not fetch configuration");
    m_output->println("");
    return;
  }

579 580 581 582
  if(version > 0 && version < makeVersion(3, 5, 0) && compat){
    Properties *reply = backward("", conf->m_oldConfig);
    reply->put("Version", version);
    reply->put("LocalNodeId", node);
583

584 585 586
    backward("", reply);
    //reply->print();
    
587 588 589 590 591
    const Uint32 size = reply->getPackedSize();
    Uint32 *buffer = new Uint32[size/4+1];
    
    reply->pack(buffer);
    delete reply;
592
    
593 594
    const int uurows = (size + 44)/45;
    char * uubuf = new char[uurows * 62+5];
595
      
596 597
    const int uusz = uuencode_mem(uubuf, (char *)buffer, size);
    delete[] buffer;
598
      
599
    m_output->println("GET CONFIG %d %d %d %d %d",
600 601
		      0, version, node, size, uusz);
    
602
    m_output->println("begin 664 Ndb_cfg.bin");
603
      
604 605 606 607 608
    /* XXX Need to write directly to the socket, because the uubuf is not
     * NUL-terminated. This could/should probably be done in a nicer way.
     */
    write_socket(m_socket, MAX_WRITE_TIMEOUT, uubuf, uusz);
    delete[] uubuf;
609
      
610 611
    m_output->println("end");
    m_output->println("");
612 613
    return;
  }
614

615 616 617
  if(compat){
    m_output->println("GET CONFIG %d %d %d %d %d",1, version, 0, 0, 0);
    return;
618
  }
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645

  if(node != 0){
    bool compatible;
    switch (m_mgmsrv.getNodeType(node)) {
    case NDB_MGM_NODE_TYPE_NDB:
      compatible = ndbCompatible_mgmt_ndb(NDB_VERSION, version);
      break;
    case NDB_MGM_NODE_TYPE_API:
    case NDB_MGM_NODE_TYPE_MGM:
      compatible = ndbCompatible_mgmt_api(NDB_VERSION, version);
      break;
    default:
      m_output->println("get config");
      m_output->println("result: unrecognignized node type");
      m_output->println("");
      return;
    }
    
    if (!compatible){
      m_output->println("get config");
      m_output->println("result: incompatible version mgmt 0x%x and node 0x%x",
			NDB_VERSION, version);
      m_output->println("");
      return;
    }
  }  
  
646
  NdbMutex_Lock(m_mgmsrv.m_configMutex);
647 648 649 650 651
  const ConfigValues * cfg = &conf->m_configValues->m_config;
  const Uint32 size = cfg->getPackedSize();
  
  UtilBuffer src;
  cfg->pack(src);
652
  NdbMutex_Unlock(m_mgmsrv.m_configMutex);
653
  
654 655
  char *tmp_str = (char *) malloc(base64_needed_encoded_length(src.length()));
  int res = base64_encode(src.get_data(), src.length(), tmp_str);
656 657 658
  
  m_output->println("get config reply");
  m_output->println("result: Ok");
659
  m_output->println("Content-Length: %d", strlen(tmp_str));
660 661 662
  m_output->println("Content-Type: ndbconfig/octet-stream");
  m_output->println("Content-Transfer-Encoding: base64");
  m_output->println("");
663
  m_output->println(tmp_str);
664

665
  free(tmp_str);
666
  return;
667 668 669 670 671 672 673
}

void
MgmApiSession::getStatPort(Parser_t::Context &, 
			   const class Properties &) {

  m_output->println("get statport reply");
joreland@mysql.com's avatar
joreland@mysql.com committed
674
  m_output->println("tcpport: %d", 0);
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689
  m_output->println("");
}

void
MgmApiSession::insertError(Parser<MgmApiSession>::Context &,
			   Properties const &args) {
  Uint32 node = 0, error = 0;

  args.get("node", &node);
  args.get("error", &error);

  int result = m_mgmsrv.insertError(node, error);

  m_output->println("insert error reply");
  if(result != 0)
690
    m_output->println("result: %s", get_error_text(result));
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
  else
    m_output->println("result: Ok");
  m_output->println("");
}

void
MgmApiSession::setTrace(Parser<MgmApiSession>::Context &,
			Properties const &args) {
  Uint32 node = 0, trace = 0;

  args.get("node", &node);
  args.get("trace", &trace);

  int result = m_mgmsrv.setTraceNo(node, trace);

  m_output->println("set trace reply");
  if(result != 0)
708
    m_output->println("result: %s", get_error_text(result));
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726
  else
    m_output->println("result: Ok");
  m_output->println("");
}

void
MgmApiSession::getVersion(Parser<MgmApiSession>::Context &,
			  Properties const &) {
  m_output->println("version");
  m_output->println("id: %d", NDB_VERSION);
  m_output->println("major: %d", getMajor(NDB_VERSION));
  m_output->println("minor: %d", getMinor(NDB_VERSION));
  m_output->println("string: %s", NDB_VERSION_STRING);
  m_output->println("");
}

void
MgmApiSession::startBackup(Parser<MgmApiSession>::Context &,
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
727 728
			   Properties const &args) {
  DBUG_ENTER("MgmApiSession::startBackup");
729
  unsigned backupId;
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
730
  Uint32 completed= 2;
731 732
  int result;

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
733
  args.get("completed", &completed);
734

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
735
  result = m_mgmsrv.startBackup(backupId, completed);
736 737 738

  m_output->println("start backup reply");
  if(result != 0)
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
739
  {
740
    m_output->println("result: %s", get_error_text(result));
741 742 743
  }
  else{
    m_output->println("result: Ok");
744 745
    if (completed)
      m_output->println("id: %d", backupId);
746 747
  }
  m_output->println("");
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
748
  DBUG_VOID_RETURN;
749 750 751 752 753 754 755 756 757 758 759 760 761
}

void
MgmApiSession::abortBackup(Parser<MgmApiSession>::Context &,
			   Properties const &args) {
  Uint32 id = 0;

  args.get("id", &id);

  int result = m_mgmsrv.abortBackup(id);

  m_output->println("abort backup reply");
  if(result != 0)
762
    m_output->println("result: %s", get_error_text(result));
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781
  else
    m_output->println("result: Ok");
  m_output->println("");
}

/*****************************************************************************/

void
MgmApiSession::dumpState(Parser<MgmApiSession>::Context &,
			 Properties const &args) {
  Uint32 node;
  BaseString args_str;

  args.get("node", &node);
  args.get("args", args_str);

  int result = m_mgmsrv.dumpState(node, args_str.c_str());
  m_output->println("dump state reply");
  if(result != 0)
782
    m_output->println("result: %s", get_error_text(result));
783 784 785 786 787 788 789 790
  else
    m_output->println("result: Ok");
  m_output->println("");
}


void
MgmApiSession::bye(Parser<MgmApiSession>::Context &,
791
                   Properties const &) {
792 793 794
  m_stop = true;
}

795 796 797 798 799 800 801 802 803 804 805
void
MgmApiSession::endSession(Parser<MgmApiSession>::Context &,
                          Properties const &) {
  if(m_allocated_resources)
    delete m_allocated_resources;

  m_allocated_resources= new MgmtSrvr::Allocated_resources(m_mgmsrv);

  m_output->println("end session reply");
}

806 807 808
void
MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
				  Properties const &args) {
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
809 810
  const char *reply= "set cluster loglevel reply";
  Uint32 node, level, cat;
811
  BaseString errorString;
812 813
  SetLogLevelOrd logLevel;
  int result;
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
814
  DBUG_ENTER("MgmApiSession::setClusterLogLevel");
815
  args.get("node", &node);
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
816
  args.get("category", &cat);
817 818
  args.get("level", &level);

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
819 820
  DBUG_PRINT("enter",("node=%d, category=%d, level=%d", node, cat, level));

821 822
  /* XXX should use constants for this value */
  if(level > 15) {
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
823 824
    m_output->println(reply);
    m_output->println("result: Invalid loglevel %d", level);
825
    m_output->println("");
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
826
    DBUG_VOID_RETURN;
827 828
  }

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
829 830 831
  LogLevel::EventCategory category= 
    (LogLevel::EventCategory)(cat-(int)CFG_MIN_LOGLEVEL);

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
832
  m_mgmsrv.m_event_listner.lock();
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
833 834 835 836 837
  if (m_mgmsrv.m_event_listner[0].m_logLevel.setLogLevel(category,level))
  {
    m_output->println(reply);
    m_output->println("result: Invalid category %d", category);
    m_output->println("");
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
838
    m_mgmsrv.m_event_listner.unlock();
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
839
    DBUG_VOID_RETURN;
840
  }
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
841
  m_mgmsrv.m_event_listner.unlock();
842

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
843
  {
844 845
    LogLevel tmp;
    m_mgmsrv.m_event_listner.update_max_log_level(tmp);
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
846
  }
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
847 848

  m_output->println(reply);
joreland@mysql.com's avatar
joreland@mysql.com committed
849
  m_output->println("result: Ok");
850
  m_output->println("");
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
851
  DBUG_VOID_RETURN;
852 853 854 855 856
}

void
MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &,
			   Properties const &args) {
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
857
  Uint32 node = 0, level = 0, cat;
858
  BaseString errorString;
859 860 861 862
  SetLogLevelOrd logLevel;
  int result;
  logLevel.clear();
  args.get("node", &node);
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
863
  args.get("category", &cat);
864 865 866 867
  args.get("level", &level);

  /* XXX should use constants for this value */
  if(level > 15) {
868 869 870 871
    m_output->println("set loglevel reply");
    m_output->println("result: Invalid loglevel", errorString.c_str());
    m_output->println("");
    return;
872 873
  }

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
874 875 876 877 878 879 880 881 882
  LogLevel::EventCategory category= 
    (LogLevel::EventCategory)(cat-(int)CFG_MIN_LOGLEVEL);

  {
    LogLevel ll;
    ll.setLogLevel(category,level);
    m_mgmsrv.m_event_listner.update_max_log_level(ll);
  }

883
  m_output->println("set loglevel reply");
joreland@mysql.com's avatar
joreland@mysql.com committed
884
  m_output->println("result: Ok");
885 886 887 888 889 890 891 892 893 894 895 896 897 898
  m_output->println("");
}

void
MgmApiSession::stopSignalLog(Parser<MgmApiSession>::Context &,
			     Properties const &args) {
  Uint32 node;

  args.get("node", &node);

  int result = m_mgmsrv.stopSignalTracing(node);

  m_output->println("stop signallog");
  if(result != 0)
899
    m_output->println("result: %s", get_error_text(result));
900 901 902 903 904 905
  else
    m_output->println("result: Ok");
  m_output->println("");
}

void
906
MgmApiSession::restart_v1(Parser<MgmApiSession>::Context &,
907
		       Properties const &args) {
908 909 910 911 912 913 914 915 916 917 918
  restart(args,1);
}

void
MgmApiSession::restart_v2(Parser<MgmApiSession>::Context &,
		       Properties const &args) {
  restart(args,2);
}

void
MgmApiSession::restart(Properties const &args, int version) {
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938
  Uint32
    nostart = 0,
    initialstart = 0,
    abort = 0;
  char *nodes_str;
  Vector<NodeId> nodes;
    
  args.get("initialstart", &initialstart);
  args.get("nostart", &nostart);
  args.get("abort", &abort);
  args.get("node", (const char **)&nodes_str);

  char *p, *last;
  for((p = strtok_r(nodes_str, " ", &last));
      p;
      (p = strtok_r(NULL, " ", &last))) {
    nodes.push_back(atoi(p));
  }

  int restarted = 0;
939 940 941 942
  int result= m_mgmsrv.restartNodes(nodes,
                                    &restarted,
                                    nostart != 0,
                                    initialstart != 0,
943 944
                                    abort != 0,
                                    &m_stopSelf);
945 946 947
  
  m_output->println("restart reply");
  if(result != 0){
948
    m_output->println("result: %d-%s", result, get_error_text(result));
949 950 951
  } else
    m_output->println("result: Ok");
  m_output->println("restarted: %d", restarted);
952 953
  if(version>1)
    m_output->println("disconnect: %d", (m_stopSelf)?1:0);
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969
  m_output->println("");
}

void
MgmApiSession::restartAll(Parser<MgmApiSession>::Context &, 
			  Properties const &args)
{
  Uint32 nostart = 0;
  Uint32 initialstart = 0;
  Uint32 abort = 0;
  
  args.get("initialstart", &initialstart);
  args.get("abort", &abort);
  args.get("nostart", &nostart);
  
  int count = 0;
970
  int result = m_mgmsrv.restartDB(nostart, initialstart, abort, &count);
971 972 973

  m_output->println("restart reply");
  if(result != 0)
974
    m_output->println("result: %s", get_error_text(result));
975 976 977 978 979 980 981 982 983 984 985
  else
    m_output->println("result: Ok");
  m_output->println("restarted: %d", count);
  m_output->println("");
}

static void
printNodeStatus(OutputStream *output,
		MgmtSrvr &mgmsrv,
		enum ndb_mgm_node_type type) {
  NodeId nodeId = 0;
stewart@willster.(none)'s avatar
stewart@willster.(none) committed
986
  mgmsrv.updateStatus();
987 988
  while(mgmsrv.getNextNodeId(&nodeId, type)) {
    enum ndb_mgm_node_status status;
989 990 991 992 993
    Uint32 startPhase = 0, 
      version = 0, 
      dynamicId = 0, 
      nodeGroup = 0,
      connectCount = 0;
994
    bool system;
995 996 997 998
    const char *address= NULL;
    mgmsrv.status(nodeId, &status, &version, &startPhase,
		  &system, &dynamicId, &nodeGroup, &connectCount,
		  &address);
999 1000 1001 1002 1003 1004 1005 1006 1007 1008
    output->println("node.%d.type: %s",
		      nodeId,
		      ndb_mgm_get_node_type_string(type));
    output->println("node.%d.status: %s",
		      nodeId,
		      ndb_mgm_get_node_status_string(status));
    output->println("node.%d.version: %d", nodeId, version);
    output->println("node.%d.startphase: %d", nodeId, startPhase);
    output->println("node.%d.dynamic_id: %d", nodeId, dynamicId);
    output->println("node.%d.node_group: %d", nodeId, nodeGroup);
1009
    output->println("node.%d.connect_count: %d", nodeId, connectCount);
jonas@perch.ndb.mysql.com's avatar
ndb -  
jonas@perch.ndb.mysql.com committed
1010
    output->println("node.%d.address: %s", nodeId, address ? address : "");
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063
  }

}

void
MgmApiSession::getStatus(Parser<MgmApiSession>::Context &,
			 Properties const &) {
  int noOfNodes = 0;

  NodeId nodeId = 0;
  while(m_mgmsrv.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)){
    noOfNodes++;
  }
  nodeId = 0;
  while(m_mgmsrv.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_API)){
    noOfNodes++;
  }
  nodeId = 0;
  while(m_mgmsrv.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_MGM)){
    noOfNodes++;
  }
  
  m_output->println("node status");
  m_output->println("nodes: %d", noOfNodes);
  printNodeStatus(m_output, m_mgmsrv, NDB_MGM_NODE_TYPE_NDB);
  printNodeStatus(m_output, m_mgmsrv, NDB_MGM_NODE_TYPE_MGM);
  printNodeStatus(m_output, m_mgmsrv, NDB_MGM_NODE_TYPE_API);

  nodeId = 0;

  m_output->println("");
}

void
MgmApiSession::getInfoClusterLog(Parser<MgmApiSession>::Context &,
		    Properties const &) {
  const char* names[] = { "enabled",
			  "debug",
			  "info",
			  "warning",
			  "error",
			  "critical",
			  "alert" };
  
  m_output->println("clusterlog");
  for(int i = 0; i < 7; i++) {
    m_output->println("%s: %d",
		      names[i], m_mgmsrv.isEventLogFilterEnabled(i));
  }
  m_output->println("");
}

void
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
MgmApiSession::stop_v1(Parser<MgmApiSession>::Context &,
                       Properties const &args) {
  stop(args,1);
}

void
MgmApiSession::stop_v2(Parser<MgmApiSession>::Context &,
                       Properties const &args) {
  stop(args,2);
}

void
MgmApiSession::stop(Properties const &args, int version) {
1077 1078 1079 1080 1081 1082
  Uint32 abort;
  char *nodes_str;
  Vector<NodeId> nodes;

  args.get("node", (const char **)&nodes_str);
  if(nodes_str == NULL)
1083 1084 1085 1086
  {
    m_output->println("stop reply");
    m_output->println("result: empty node list");
    m_output->println("");
1087
    return;
1088
  }
1089 1090 1091 1092 1093 1094 1095 1096 1097
  args.get("abort", &abort);

  char *p, *last;
  for((p = strtok_r(nodes_str, " ", &last));
      p;
      (p = strtok_r(NULL, " ", &last))) {
    nodes.push_back(atoi(p));
  }

1098 1099 1100
  int stopped= 0;
  int result= 0;
  if (nodes.size())
1101
    result= m_mgmsrv.stopNodes(nodes, &stopped, abort != 0, &m_stopSelf);
1102

1103 1104
  m_output->println("stop reply");
  if(result != 0)
1105
    m_output->println("result: %s", get_error_text(result));
1106 1107 1108
  else
    m_output->println("result: Ok");
  m_output->println("stopped: %d", stopped);
1109 1110
  if(version>1)
    m_output->println("disconnect: %d", (m_stopSelf)?1:0);
1111 1112 1113 1114 1115
  m_output->println("");
}

void
MgmApiSession::stopAll(Parser<MgmApiSession>::Context &,
1116
                       Properties const &args) {
1117
  int stopped[2] = {0,0};
1118 1119 1120
  Uint32 abort;
  args.get("abort", &abort);

1121 1122 1123 1124 1125 1126 1127 1128 1129
  BaseString stop;
  const char* tostop= "db";
  int ver=1;
  if (args.get("stop", stop))
  {
    tostop= stop.c_str();
    ver= 2;
  }

1130 1131 1132
  int result= 0;
  if(strstr(tostop,"db"))
    result= m_mgmsrv.shutdownDB(&stopped[0], abort != 0);
1133
  if(!result && strstr(tostop,"mgm"))
1134
    result= m_mgmsrv.shutdownMGM(&stopped[1], abort!=0, &m_stopSelf);
1135 1136 1137

  m_output->println("stop reply");
  if(result != 0)
1138
    m_output->println("result: %s", get_error_text(result));
1139 1140
  else
    m_output->println("result: Ok");
1141 1142 1143
  m_output->println("stopped: %d", stopped[0]+stopped[1]);
  if(ver >1)
    m_output->println("disconnect: %d", (m_stopSelf)?1:0);
1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155
  m_output->println("");
}

void
MgmApiSession::enterSingleUser(Parser<MgmApiSession>::Context &,
			  Properties const &args) {
  int stopped = 0;
  Uint32 nodeId = 0;
  args.get("nodeId", &nodeId);
  int result = m_mgmsrv.enterSingleUser(&stopped, nodeId);
  m_output->println("enter single user reply");
  if(result != 0) {
1156
    m_output->println("result: %s", get_error_text(result));
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170
  }
  else {
    m_output->println("result: Ok");
  }
  m_output->println("");
}

void
MgmApiSession::exitSingleUser(Parser<MgmApiSession>::Context &,
			      Properties const &args) {
  int stopped = 0;
  int result = m_mgmsrv.exitSingleUser(&stopped, false);
  m_output->println("exit single user reply");
  if(result != 0)
1171
    m_output->println("result: %s", get_error_text(result));
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
  else
    m_output->println("result: Ok");
  m_output->println("");
}


void
MgmApiSession::startSignalLog(Parser<MgmApiSession>::Context &,
			      Properties const &args) {
  Uint32 node;

  args.get("node", &node);

  int result = m_mgmsrv.startSignalTracing(node);

  m_output->println("start signallog reply");
  if(result != 0)
1189
    m_output->println("result: %s", get_error_text(result));
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207
  else
    m_output->println("result: Ok");
  m_output->println("");
}

void
MgmApiSession::logSignals(Parser<MgmApiSession>::Context &,
			   Properties const &args) {
  Uint32 node = 0, in = 0, out = 0;
  //  BaseString blocks;
  BaseString blockList;
  char * blockName;
  args.get("node", &node);
  args.get("in", &in);
  args.get("out", &out);
  args.get("blocks", blockList);
  // fast fix - pekka
  char buf[200];
1208
  BaseString::snprintf(buf, 200, "%s", blockList.c_str());
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233
  Vector<BaseString> blocks;  

  blockName=strtok(buf,"|");
  while( blockName != NULL)
    {
      blocks.push_back(blockName);
      blockName=strtok(NULL,"|");
    }
  

  if(in > 1 || out > 1)
    return; /* Invalid arguments */
  
  const MgmtSrvr::LogMode modes[] = {
    MgmtSrvr::Off,
    MgmtSrvr::Out,
    MgmtSrvr::In,
    MgmtSrvr::InOut,
  };
  MgmtSrvr::LogMode mode = modes[in<<1 | out];

  int result = m_mgmsrv.setSignalLoggingMode(node, mode, blocks);

  m_output->println("log signals reply");
  if(result != 0)
1234
    m_output->println("result: %s", get_error_text(result));
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250
  else
    m_output->println("result: Ok");
  m_output->println("");
}

void
MgmApiSession::start(Parser<MgmApiSession>::Context &,
		     Properties const &args) {
  Uint32 node;

  args.get("node", &node);
  
  int result = m_mgmsrv.start(node);

  m_output->println("start reply");
  if(result != 0)
1251
    m_output->println("result: %s", get_error_text(result));
1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275
  else
    m_output->println("result: Ok");
  m_output->println("");
}

void
MgmApiSession::startAll(Parser<MgmApiSession>::Context &,
			Properties const &) {
  NodeId node = 0;
  int started = 0;

  while(m_mgmsrv.getNextNodeId(&node, NDB_MGM_NODE_TYPE_NDB))
    if(m_mgmsrv.start(node) == 0)
      started++;

  m_output->println("start reply");
  m_output->println("result: Ok");
  m_output->println("started: %d", started);
  m_output->println("");
}

void
MgmApiSession::setLogFilter(Parser_t::Context &ctx,
			    const class Properties &args) {
1276
  Uint32 severity;
1277
  Uint32 enable;
1278

1279
  args.get("level", &severity);
1280
  args.get("enable", &enable);
1281

1282
  int result = m_mgmsrv.setEventLogFilter(severity, enable);
1283 1284 1285 1286 1287 1288

  m_output->println("set logfilter reply");
  m_output->println("result: %d", result);
  m_output->println("");
}

joreland@mysql.com's avatar
joreland@mysql.com committed
1289
static NdbOut&
joreland@mysql.com's avatar
joreland@mysql.com committed
1290 1291 1292
operator<<(NdbOut& out, const LogLevel & ll)
{
  out << "[LogLevel: ";
1293
  for(size_t i = 0; i<LogLevel::LOGLEVEL_CATEGORIES; i++)
joreland@mysql.com's avatar
joreland@mysql.com committed
1294 1295
    out << ll.getLogLevel((LogLevel::EventCategory)i) << " ";
  out << "]";
pekka@mysql.com's avatar
pekka@mysql.com committed
1296
  return out;
joreland@mysql.com's avatar
joreland@mysql.com committed
1297 1298 1299
}

void
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1300
Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId){
joreland@mysql.com's avatar
joreland@mysql.com committed
1301
  
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1302 1303 1304
  Uint32 threshold;
  LogLevel::EventCategory cat;
  Logger::LoggerLevel severity;
1305
  EventLoggerBase::EventTextFunction textF;
1306
  int i, n;
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1307 1308
  DBUG_ENTER("Ndb_mgmd_event_service::log");
  DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId));
1309

1310
  if (EventLoggerBase::event_lookup(eventType,cat,threshold,severity,textF))
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1311
    DBUG_VOID_RETURN;
joreland@mysql.com's avatar
joreland@mysql.com committed
1312 1313

  char m_text[256];
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328
  EventLogger::getText(m_text, sizeof(m_text),
		       textF, theData, nodeId);

  BaseString str("log event reply\n");
  str.appfmt("type=%d\n", eventType);
  str.appfmt("time=%d\n", 0);
  str.appfmt("source_nodeid=%d\n", nodeId);
  for (i= 0; ndb_logevent_body[i].token; i++)
  {
    if ( ndb_logevent_body[i].type != eventType)
      continue;
    int val= theData[ndb_logevent_body[i].index];
    if (ndb_logevent_body[i].index_fn)
      val= (*(ndb_logevent_body[i].index_fn))(val);
    str.appfmt("%s=%d\n",ndb_logevent_body[i].token, val);
1329 1330 1331 1332 1333 1334
    if(strcmp(ndb_logevent_body[i].token,"error") == 0)
    {
      int m_text_len= strlen(m_text);
      snprintf(m_text+m_text_len, 4 , " - ");
      ndb_error_string(theData[3], m_text+(m_text_len+3), sizeof(m_text)-m_text_len-3);
    }
1335
  }
joreland@mysql.com's avatar
joreland@mysql.com committed
1336

1337
  Vector<NDB_SOCKET_TYPE> copy;
joreland@mysql.com's avatar
joreland@mysql.com committed
1338
  m_clients.lock();
1339 1340 1341 1342
  for(i = m_clients.size() - 1; i >= 0; i--)
  {
    if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat))
    {
1343
      NDB_SOCKET_TYPE fd= m_clients[i].m_socket;
tomas@poseidon.ndb.mysql.com's avatar
Merge  
tomas@poseidon.ndb.mysql.com committed
1344
      if(fd != NDB_INVALID_SOCKET)
1345 1346 1347
      {
	int r;
	if (m_clients[i].m_parsable)
tomas@poseidon.ndb.mysql.com's avatar
Merge  
tomas@poseidon.ndb.mysql.com committed
1348
	  r= println_socket(fd,
1349 1350
			    MAX_WRITE_TIMEOUT, str.c_str());
	else
tomas@poseidon.ndb.mysql.com's avatar
Merge  
tomas@poseidon.ndb.mysql.com committed
1351
	  r= println_socket(fd,
1352 1353
			    MAX_WRITE_TIMEOUT, m_text);
	if (r == -1) {
tomas@poseidon.ndb.mysql.com's avatar
Merge  
tomas@poseidon.ndb.mysql.com committed
1354
	  copy.push_back(fd);
1355 1356
	  m_clients.erase(i, false);
	}
joreland@mysql.com's avatar
joreland@mysql.com committed
1357
      }
1358 1359
    }
  }
joreland@mysql.com's avatar
joreland@mysql.com committed
1360
  m_clients.unlock();
1361
  
1362 1363 1364 1365
  if ((n= (int)copy.size()))
  {
    for(i= 0; i < n; i++)
      NDB_CLOSE_SOCKET(copy[i]);
joreland@mysql.com's avatar
joreland@mysql.com committed
1366 1367 1368

    LogLevel tmp; tmp.clear();
    m_clients.lock();
1369
    for(i= m_clients.size() - 1; i >= 0; i--)
joreland@mysql.com's avatar
joreland@mysql.com committed
1370 1371
      tmp.set_max(m_clients[i].m_logLevel);
    m_clients.unlock();
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1372
    update_log_level(tmp);
joreland@mysql.com's avatar
joreland@mysql.com committed
1373
  }
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1374
  DBUG_VOID_RETURN;
joreland@mysql.com's avatar
joreland@mysql.com committed
1375 1376 1377
}

void
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1378 1379
Ndb_mgmd_event_service::update_max_log_level(const LogLevel &log_level)
{
1380 1381 1382 1383 1384
  LogLevel tmp = log_level;
  m_clients.lock();
  for(int i = m_clients.size() - 1; i >= 0; i--)
    tmp.set_max(m_clients[i].m_logLevel);
  m_clients.unlock();
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1385 1386 1387 1388 1389 1390
  update_log_level(tmp);
}

void
Ndb_mgmd_event_service::update_log_level(const LogLevel &tmp)
{
1391 1392 1393 1394 1395 1396
  m_logLevel = tmp;
  EventSubscribeReq req;
  req = tmp;
  // send update to all nodes
  req.blockRef = 0;
  m_mgmsrv->m_log_level_requests.push_back(req);
1397 1398 1399
}

void
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437
Ndb_mgmd_event_service::check_listeners()
{
  int i, n= 0;
  DBUG_ENTER("Ndb_mgmd_event_service::check_listeners");
  m_clients.lock();
  for(i= m_clients.size() - 1; i >= 0; i--)
  {
    int fd= m_clients[i].m_socket;
    DBUG_PRINT("info",("%d %d",i,fd));
    char buf[1];
    buf[0]=0;
    if (fd != NDB_INVALID_SOCKET &&
	println_socket(fd,MAX_WRITE_TIMEOUT,"<PING>") == -1)
    {
      NDB_CLOSE_SOCKET(fd);
      m_clients.erase(i, false);
      n=1;
    }
  }
  if (n)
  {
    LogLevel tmp; tmp.clear();
    for(i= m_clients.size() - 1; i >= 0; i--)
      tmp.set_max(m_clients[i].m_logLevel);
    update_log_level(tmp);
  }
  m_clients.unlock();
  DBUG_VOID_RETURN;
}

void
Ndb_mgmd_event_service::add_listener(const Event_listener& client)
{
  DBUG_ENTER("Ndb_mgmd_event_service::add_listener");
  DBUG_PRINT("enter",("client.m_socket: %d", client.m_socket));

  check_listeners();

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1438 1439
  m_clients.push_back(client);
  update_max_log_level(client.m_logLevel);
1440 1441

  DBUG_VOID_RETURN;
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1442 1443
}

1444
void
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1445
Ndb_mgmd_event_service::stop_sessions(){
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1446
  m_clients.lock();
joreland@mysql.com's avatar
joreland@mysql.com committed
1447
  for(int i = m_clients.size() - 1; i >= 0; i--){
joreland@mysql.com's avatar
joreland@mysql.com committed
1448
    if(m_clients[i].m_socket != NDB_INVALID_SOCKET){
joreland@mysql.com's avatar
joreland@mysql.com committed
1449 1450 1451
      NDB_CLOSE_SOCKET(m_clients[i].m_socket);
      m_clients.erase(i);
    }
1452
  }
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1453
  m_clients.unlock();
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468
}

void
MgmApiSession::setParameter(Parser_t::Context &,
			    Properties const &args) {
  BaseString node, param, value;
  args.get("node", node);
  args.get("parameter", param);
  args.get("value", value);
  
  BaseString result;
  int ret = m_mgmsrv.setDbParameter(atoi(node.c_str()), 
				    atoi(param.c_str()),
				    value.c_str(),
				    result);
1469
  
1470 1471 1472 1473
  m_output->println("set parameter reply");
  m_output->println("message: %s", result.c_str());
  m_output->println("result: %d", ret);
  m_output->println("");
1474
}
1475

1476 1477
void
MgmApiSession::setConnectionParameter(Parser_t::Context &ctx,
1478
				      Properties const &args) {
1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497
  BaseString node1, node2, param, value;
  args.get("node1", node1);
  args.get("node2", node2);
  args.get("param", param);
  args.get("value", value);
  
  BaseString result;
  int ret = m_mgmsrv.setConnectionDbParameter(atoi(node1.c_str()),
					      atoi(node2.c_str()),
					      atoi(param.c_str()),
					      atoi(value.c_str()),
					      result);
  
  m_output->println("set connection parameter reply");
  m_output->println("message: %s", result.c_str());
  m_output->println("result: %s", (ret>0)?"Ok":"Failed");
  m_output->println("");
}

1498 1499 1500 1501
void
MgmApiSession::getConnectionParameter(Parser_t::Context &ctx,
				      Properties const &args) {
  BaseString node1, node2, param;
1502
  int value = 0;
1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514

  args.get("node1", node1);
  args.get("node2", node2);
  args.get("param", param);
  
  BaseString result;
  int ret = m_mgmsrv.getConnectionDbParameter(atoi(node1.c_str()),
					      atoi(node2.c_str()),
					      atoi(param.c_str()),
					      &value,
					      result);
  
1515
  m_output->println("get connection parameter reply");
1516
  m_output->println("value: %d", value);
1517
  m_output->println("result: %s", (ret>0)?"Ok":result.c_str());
1518 1519
  m_output->println("");
}
1520

joreland@mysql.com's avatar
joreland@mysql.com committed
1521 1522 1523
void
MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx,
			    Properties const & args) {
1524
  Uint32 parsable= 0;
joreland@mysql.com's avatar
joreland@mysql.com committed
1525 1526 1527
  BaseString node, param, value;
  args.get("node", node);
  args.get("filter", param);
1528
  args.get("parsable", &parsable);
joreland@mysql.com's avatar
joreland@mysql.com committed
1529 1530 1531 1532

  int result = 0;
  BaseString msg;

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1533
  Ndb_mgmd_event_service::Event_listener le;
1534
  le.m_parsable = parsable;
joreland@mysql.com's avatar
joreland@mysql.com committed
1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550
  le.m_socket = m_socket;

  Vector<BaseString> list;
  param.trim();
  param.split(list, " ,");
  for(size_t i = 0; i<list.size(); i++){
    Vector<BaseString> spec;
    list[i].trim();
    list[i].split(spec, "=:");
    if(spec.size() != 2){
      msg.appfmt("Invalid filter specification: >%s< >%s< %d", 
		 param.c_str(), list[i].c_str(), spec.size());
      result = -1;
      goto done;
    }

1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562
    spec[0].trim().ndb_toupper();
    int category = ndb_mgm_match_event_category(spec[0].c_str());
    if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){
      category = atoi(spec[0].c_str());
      if(category < NDB_MGM_MIN_EVENT_CATEGORY ||
	 category > NDB_MGM_MAX_EVENT_CATEGORY){
	msg.appfmt("Unknown category: >%s<", spec[0].c_str());
	result = -1;
	goto done;
      }
    }
    
joreland@mysql.com's avatar
joreland@mysql.com committed
1563 1564 1565 1566 1567 1568
    int level = atoi(spec[1].c_str());
    if(level < 0 || level > 15){
      msg.appfmt("Invalid level: >%s<", spec[1].c_str());
      result = -1;
      goto done;
    }
1569
    category -= CFG_MIN_LOGLEVEL;
1570
    le.m_logLevel.setLogLevel((LogLevel::EventCategory)category, level);
joreland@mysql.com's avatar
joreland@mysql.com committed
1571 1572 1573 1574 1575 1576 1577 1578
  }
  
  if(list.size() == 0){
    msg.appfmt("Empty filter specification");
    result = -1;
    goto done;
  }
  
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1579
  m_mgmsrv.m_event_listner.add_listener(le);
joreland@mysql.com's avatar
joreland@mysql.com committed
1580 1581
  
  m_stop = true;
joreland@mysql.com's avatar
joreland@mysql.com committed
1582
  m_socket = NDB_INVALID_SOCKET;
joreland@mysql.com's avatar
joreland@mysql.com committed
1583 1584 1585 1586 1587 1588

done:
  m_output->println("listen event");
  m_output->println("result: %d", result);
  if(result != 0)
    m_output->println("msg: %s", msg.c_str());
joreland@mysql.com's avatar
joreland@mysql.com committed
1589
  m_output->println("");
joreland@mysql.com's avatar
joreland@mysql.com committed
1590 1591
}

1592 1593 1594 1595 1596 1597 1598
void
MgmApiSession::stop_session_if_not_connected(SocketServer::Session *_s, void *data)
{
  MgmApiSession *s= (MgmApiSession *)_s;
  struct PurgeStruct &ps= *(struct PurgeStruct *)data;
  if (s->m_allocated_resources->is_reserved(ps.free_nodes))
  {
1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612
    if (ps.str)
      ps.str->appfmt(" %d", s->m_allocated_resources->get_nodeid());
    s->stopSession();
  }
}

void
MgmApiSession::stop_session_if_timed_out(SocketServer::Session *_s, void *data)
{
  MgmApiSession *s= (MgmApiSession *)_s;
  struct PurgeStruct &ps= *(struct PurgeStruct *)data;
  if (s->m_allocated_resources->is_reserved(ps.free_nodes) &&
      s->m_allocated_resources->is_timed_out(ps.tick))
  {
1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628
    s->stopSession();
  }
}

void
MgmApiSession::purge_stale_sessions(Parser_t::Context &ctx,
				    const class Properties &args)
{
  struct PurgeStruct ps;
  BaseString str;
  ps.str = &str;

  m_mgmsrv.get_connected_nodes(ps.free_nodes);
  ps.free_nodes.bitXORC(NodeBitmask()); // invert connected_nodes to get free nodes

  m_mgmsrv.get_socket_server()->foreachSession(stop_session_if_not_connected,&ps);
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1629
  m_mgmsrv.get_socket_server()->checkSessions();
1630 1631 1632 1633 1634 1635 1636 1637

  m_output->println("purge stale sessions reply");
  if (str.length() > 0)
    m_output->println("purged:%s",str.c_str());
  m_output->println("result: Ok");
  m_output->println("");
}

1638 1639 1640 1641 1642 1643 1644 1645 1646
void
MgmApiSession::check_connection(Parser_t::Context &ctx,
				const class Properties &args)
{
  m_output->println("check connection reply");
  m_output->println("result: Ok");
  m_output->println("");
}

1647 1648
void
MgmApiSession::transporter_connect(Parser_t::Context &ctx,
1649 1650 1651
				   Properties const &args)
{
  m_mgmsrv.transporter_connect(m_socket);
1652 1653 1654

  m_stop= true;
  m_stopped= true; // force a stop (no closing socket)
1655
  m_socket= NDB_INVALID_SOCKET;   // so nobody closes it
1656 1657
}

1658 1659
void
MgmApiSession::get_mgmd_nodeid(Parser_t::Context &ctx,
1660 1661
			       Properties const &args)
{
1662 1663 1664 1665 1666
  m_output->println("get mgmd nodeid reply");
  m_output->println("nodeid:%u",m_mgmsrv.getOwnNodeId());  
  m_output->println("");
}

1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691
void
MgmApiSession::report_event(Parser_t::Context &ctx,
			    Properties const &args)
{
  Uint32 length;
  const char *data_string;
  Uint32 data[25];

  args.get("length", &length);
  args.get("data", &data_string);

  BaseString tmp(data_string);
  Vector<BaseString> item;
  tmp.split(item, " ");
  for (int i = 0; i < length ; i++)
  {
    sscanf(item[i].c_str(), "%u", data+i);
  }

  m_mgmsrv.eventReport(data);
  m_output->println("report event reply");
  m_output->println("result: ok");
  m_output->println("");
}

1692 1693
template class MutexVector<int>;
template class Vector<ParserRow<MgmApiSession> const*>;