ndb - bug#24544

  fix so backup message is printed even in case of "ndb_mgm -e"
parent 60b19639
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
bool bool
printBACKUP_REQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 bno){ printBACKUP_REQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 bno){
BackupReq* sig = (BackupReq*)theData; BackupReq* sig = (BackupReq*)theData;
fprintf(output, " senderData: %d DataLength: %d\n", fprintf(output, " senderData: %d DataLength: %d flags: %d\n",
sig->senderData, sig->senderData,
sig->backupDataLen); sig->backupDataLen,
sig->flags);
return true; return true;
} }
......
...@@ -119,7 +119,7 @@ class CommandInterpreter { ...@@ -119,7 +119,7 @@ class CommandInterpreter {
int executeStatus(int processId, const char* parameters, bool all); int executeStatus(int processId, const char* parameters, bool all);
int executeEventReporting(int processId, const char* parameters, bool all); int executeEventReporting(int processId, const char* parameters, bool all);
int executeDumpState(int processId, const char* parameters, bool all); int executeDumpState(int processId, const char* parameters, bool all);
int executeStartBackup(char * parameters); int executeStartBackup(char * parameters, bool interactive);
int executeAbortBackup(char * parameters); int executeAbortBackup(char * parameters);
int executeStop(Vector<BaseString> &command_list, unsigned command_pos, int executeStop(Vector<BaseString> &command_list, unsigned command_pos,
int *node_ids, int no_of_nodes); int *node_ids, int no_of_nodes);
...@@ -991,7 +991,7 @@ CommandInterpreter::execute_impl(const char *_line, bool interactive) ...@@ -991,7 +991,7 @@ CommandInterpreter::execute_impl(const char *_line, bool interactive)
else if(strcasecmp(firstToken, "START") == 0 && else if(strcasecmp(firstToken, "START") == 0 &&
allAfterFirstToken != NULL && allAfterFirstToken != NULL &&
strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){
m_error= executeStartBackup(allAfterFirstToken); m_error= executeStartBackup(allAfterFirstToken, interactive);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if(strcasecmp(firstToken, "ABORT") == 0 && else if(strcasecmp(firstToken, "ABORT") == 0 &&
...@@ -2442,24 +2442,17 @@ CommandInterpreter::executeEventReporting(int processId, ...@@ -2442,24 +2442,17 @@ CommandInterpreter::executeEventReporting(int processId,
return retval; return retval;
} }
/***************************************************************************** /*****************************************************************************
* Backup * Backup
*****************************************************************************/ *****************************************************************************/
int int
CommandInterpreter::executeStartBackup(char* parameters) CommandInterpreter::executeStartBackup(char* parameters, bool interactive)
{ {
struct ndb_mgm_reply reply; struct ndb_mgm_reply reply;
unsigned int backupId; unsigned int backupId;
#if 0 int fd = -1;
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
int fd = ndb_mgm_listen_event(m_mgmsrv, filter);
if (fd < 0)
{
ndbout << "Initializing start of backup failed" << endl;
printError();
return fd;
}
#endif
Vector<BaseString> args; Vector<BaseString> args;
{ {
BaseString(parameters).split(args); BaseString(parameters).split(args);
...@@ -2472,25 +2465,21 @@ CommandInterpreter::executeStartBackup(char* parameters) ...@@ -2472,25 +2465,21 @@ CommandInterpreter::executeStartBackup(char* parameters)
int sz= args.size(); int sz= args.size();
int result; int result;
if (sz == 2 && int flags = 2;
args[1] == "NOWAIT") if (sz == 2 && args[1] == "NOWAIT")
{ {
flags = 0;
result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply); result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply);
} }
else if (sz == 1 || else if (sz == 1 || (sz == 3 && args[1] == "WAIT" && args[2] == "COMPLETED"))
(sz == 3 &&
args[1] == "WAIT" &&
args[2] == "COMPLETED"))
{ {
flags = 2;
ndbout_c("Waiting for completed, this may take several minutes"); ndbout_c("Waiting for completed, this may take several minutes");
result = ndb_mgm_start_backup(m_mgmsrv, 2, &backupId, &reply);
} }
else if (sz == 3 && else if (sz == 3 && args[1] == "WAIT" && args[2] == "STARTED")
args[1] == "WAIT" &&
args[2] == "STARTED")
{ {
ndbout_c("Waiting for started, this may take several minutes"); ndbout_c("Waiting for started, this may take several minutes");
result = ndb_mgm_start_backup(m_mgmsrv, 1, &backupId, &reply); flags = 1;
} }
else else
{ {
...@@ -2498,45 +2487,63 @@ CommandInterpreter::executeStartBackup(char* parameters) ...@@ -2498,45 +2487,63 @@ CommandInterpreter::executeStartBackup(char* parameters)
return -1; return -1;
} }
/**
* If interactive...event listner is already running
*/
if (flags == 2 && !interactive)
{
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0, 0 };
fd = ndb_mgm_listen_event(m_mgmsrv, filter);
if (fd < 0)
{
ndbout << "Initializing start of backup failed" << endl;
printError();
return fd;
}
}
result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply);
if (result != 0) { if (result != 0) {
ndbout << "Backup failed" << endl; ndbout << "Backup failed" << endl;
printError(); printError();
#if 0
close(fd); if (fd >= 0)
#endif close(fd);
return result; return result;
} }
#if 0
ndbout_c("Waiting for completed, this may take several minutes"); if (fd >= 0)
char *tmp;
char buf[1024];
{ {
SocketInputStream in(fd); char *tmp;
int count = 0; char buf[1024];
{
SocketInputStream in(fd);
int count = 0;
do {
tmp = in.gets(buf, 1024);
if(tmp)
{
ndbout << tmp;
unsigned int id;
if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){
count++;
}
}
} while(count < 2);
}
SocketInputStream in(fd, 10);
do { do {
tmp = in.gets(buf, 1024); tmp = in.gets(buf, 1024);
if(tmp) if(tmp && tmp[0] != 0)
{ {
ndbout << tmp; ndbout << tmp;
unsigned int id;
if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){
count++;
}
} }
} while(count < 2); } while(tmp && tmp[0] != 0);
close(fd);
} }
SocketInputStream in(fd, 10);
do {
tmp = in.gets(buf, 1024);
if(tmp && tmp[0] != 0)
{
ndbout << tmp;
}
} while(tmp && tmp[0] != 0);
close(fd);
#endif
return 0; return 0;
} }
......
...@@ -131,15 +131,6 @@ SignalSender::getNoOfConnectedNodes() const { ...@@ -131,15 +131,6 @@ SignalSender::getNoOfConnectedNodes() const {
return theFacade->theClusterMgr->getNoOfConnectedNodes(); return theFacade->theClusterMgr->getNoOfConnectedNodes();
} }
SendStatus
SignalSender::sendSignal(Uint16 nodeId, const SimpleSignal * s){
return theFacade->theTransporterRegistry->prepareSend(&s->header,
1, // JBB
&s->theData[0],
nodeId,
&s->ptr[0]);
}
template<class T> template<class T>
SimpleSignal * SimpleSignal *
SignalSender::waitFor(Uint32 timeOutMillis, T & t) SignalSender::waitFor(Uint32 timeOutMillis, T & t)
......
...@@ -1512,3 +1512,28 @@ void PollGuard::unlock_and_signal() ...@@ -1512,3 +1512,28 @@ void PollGuard::unlock_and_signal()
template class Vector<NodeStatusFunction>; template class Vector<NodeStatusFunction>;
template class Vector<TransporterFacade::ThreadData::Object_Execute>; template class Vector<TransporterFacade::ThreadData::Object_Execute>;
#include "SignalSender.hpp"
SendStatus
SignalSender::sendSignal(Uint16 nodeId, const SimpleSignal * s){
#ifdef API_TRACE
if(setSignalLog() && TRACE_GSN(s->header.theVerId_signalNumber)){
SignalHeader tmp = s->header;
tmp.theSendersBlockRef = getOwnRef();
LinearSectionPtr ptr[3];
signalLogger.sendSignal(tmp,
1,
s->theData,
nodeId, ptr, 0);
signalLogger.flushSignalLog();
}
#endif
return theFacade->theTransporterRegistry->prepareSend(&s->header,
1, // JBB
&s->theData[0],
nodeId,
&s->ptr[0]);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment