Skip to content

Commit abd4382

Browse files
committed
wl#9819 patch #8: Handle ProcessInfoRep signal and ndbinfo.processes scan in Qmgr
1 parent 0838250 commit abd4382

File tree

4 files changed

+101
-4
lines changed

4 files changed

+101
-4
lines changed

storage/ndb/src/common/util/ProcessInfo.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "NdbHost.h"
2121
#include "ProcessInfo.hpp"
2222
#include "OwnProcessInfo.hpp"
23-
// #include "signaldata/ProcessInfoRep.hpp"
23+
#include "signaldata/ProcessInfoRep.hpp"
2424
#include "EventLogger.hpp"
2525
#include "ndb_net.h"
2626
#include "ndb_socket.h"
@@ -162,7 +162,6 @@ void ProcessInfo::setNodeId(Uint16 nodeId) {
162162
node_id = nodeId;
163163
}
164164

165-
#ifdef FOR_LATER
166165
void ProcessInfo::initializeFromProcessInfoRep(ProcessInfoRep * signal) {
167166
g_eventLogger->info("Received ProcessInfoRep. "
168167
"Node: %d, Port: %d, Name: %s, Pid: %d",
@@ -188,4 +187,3 @@ void ProcessInfo::buildProcessInfoReport(ProcessInfoRep *signal) {
188187
signal->node_id, signal->application_port,
189188
signal->process_name, signal->process_id);
190189
}
191-
#endif

storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ class Qmgr : public SimulatedBlock {
372372
// Ndbinfo signal
373373
void execDBINFO_SCANREQ(Signal *signal);
374374

375+
// ProcessInfo Report signal
376+
void execPROCESSINFO_REP(Signal *signal);
377+
375378
// NDBCNTR informing us our node is fully started
376379
void execNODE_STARTED_REP(Signal *signal);
377380

storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ Qmgr::Qmgr(Block_context& ctx)
215215
addRecSignal(GSN_ALLOC_NODEID_CONF, &Qmgr::execALLOC_NODEID_CONF);
216216
addRecSignal(GSN_ALLOC_NODEID_REF, &Qmgr::execALLOC_NODEID_REF);
217217
addRecSignal(GSN_ENABLE_COMCONF, &Qmgr::execENABLE_COMCONF);
218-
218+
addRecSignal(GSN_PROCESSINFO_REP, &Qmgr::execPROCESSINFO_REP);
219+
219220
// Arbitration signals
220221
addRecSignal(GSN_ARBIT_PREPREQ, &Qmgr::execARBIT_PREPREQ);
221222
addRecSignal(GSN_ARBIT_PREPCONF, &Qmgr::execARBIT_PREPCONF);

storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <signaldata/DihRestart.hpp>
4444
#include <signaldata/DumpStateOrd.hpp>
4545
#include <signaldata/IsolateOrd.hpp>
46+
#include <signaldata/ProcessInfoRep.hpp>
4647
#include <ndb_version.h>
4748
#include <OwnProcessInfo.hpp>
4849
#include <NodeInfo.hpp>
@@ -3653,6 +3654,8 @@ Qmgr::api_failed(Signal* signal, Uint32 nodeId)
36533654
closeCom->requestType = CloseComReqConf::RT_API_FAILURE;
36543655
closeCom->failNo = 0;
36553656
closeCom->noOfNodes = 1;
3657+
ProcessInfo * processInfo = getProcessInfo(nodeId);
3658+
if(processInfo) processInfo->invalidate();
36563659
NodeBitmask::clear(closeCom->theNodes);
36573660
NodeBitmask::set(closeCom->theNodes, failedNodePtr.i);
36583661
sendSignal(TRPMAN_REF, GSN_CLOSE_COMREQ, signal,
@@ -7594,13 +7597,105 @@ Qmgr::execDBINFO_SCANREQ(Signal *signal)
75947597
ndbinfo_send_row(signal, req, row, rl);
75957598
break;
75967599
}
7600+
case Ndbinfo::PROCESSES_TABLEID:
7601+
{
7602+
jam();
7603+
for(int i = 1 ; i <= max_api_node_id ; i++)
7604+
{
7605+
NodeInfo nodeInfo = getNodeInfo(i);
7606+
if(nodeInfo.m_connected)
7607+
{
7608+
char version_buffer[NDB_VERSION_STRING_BUF_SZ];
7609+
ndbGetVersionString(nodeInfo.m_version, nodeInfo.m_mysql_version,
7610+
0, version_buffer, NDB_VERSION_STRING_BUF_SZ);
7611+
7612+
ProcessInfo *processInfo = getProcessInfo(i);
7613+
if(processInfo && processInfo->isValid())
7614+
{
7615+
Ndbinfo::Row row(signal, req);
7616+
row.write_uint32(getOwnNodeId()); // reporting_node_id
7617+
row.write_uint32(i); // node_id
7618+
row.write_uint32(nodeInfo.getType()); // node_type
7619+
row.write_string(processInfo->getHostAddress()); // host_addr
7620+
row.write_string(version_buffer); // node_version
7621+
row.write_uint32(processInfo->getPid()); // process_id
7622+
row.write_uint32(processInfo->getAngelPid()); // angel_process_id
7623+
row.write_string(processInfo->getProcessName()); // process_name
7624+
row.write_string(processInfo->getConnectionName()); // conn_name
7625+
row.write_uint32(processInfo->getPort()); // application_port
7626+
ndbinfo_send_row(signal, req, row, rl);
7627+
}
7628+
else if(nodeInfo.m_type != NodeInfo::DB)
7629+
{
7630+
/* MGM/API node is < version 7.5.5 or has not sent ProcessInfoRep */
7631+
7632+
struct in_addr addr= globalTransporterRegistry.get_connect_address(i);
7633+
char address_buffer[16];
7634+
Ndb_inet_ntop(AF_INET, & addr, address_buffer, 16);
7635+
7636+
Ndbinfo::Row row(signal, req);
7637+
row.write_uint32(getOwnNodeId()); // reporting_node_id
7638+
row.write_uint32(i); // node_id
7639+
row.write_uint32(nodeInfo.getType()); // node_type
7640+
row.write_string(address_buffer); // host_addr
7641+
row.write_string(version_buffer); // node_version
7642+
row.write_uint32(0); // process_id
7643+
row.write_uint32(0); // angel_process_id
7644+
row.write_string(""); // process_name
7645+
row.write_string(""); // conn_name
7646+
row.write_uint32(0); // application_port
7647+
ndbinfo_send_row(signal, req, row, rl);
7648+
}
7649+
}
7650+
}
7651+
break;
7652+
}
75977653
default:
75987654
break;
75997655
}
76007656
ndbinfo_send_scan_conf(signal, req, rl);
76017657
}
76027658

76037659

7660+
void
7661+
Qmgr::execPROCESSINFO_REP(Signal *signal)
7662+
{
7663+
jamEntry();
7664+
ProcessInfoRep * report = (ProcessInfoRep *) signal->theData;
7665+
SectionHandle handle(this, signal);
7666+
SegmentedSectionPtr connNamePtr, hostAddrPtr;
7667+
7668+
ProcessInfo * processInfo = getProcessInfo(report->node_id);
7669+
if(processInfo)
7670+
{
7671+
/* Set everything except the connection name and host address */
7672+
processInfo->initializeFromProcessInfoRep(report);
7673+
7674+
/* Set the connection name */
7675+
handle.getSection(connNamePtr, ProcessInfoRep::ConnNameSectionNum);
7676+
processInfo->setConnectionName(connNamePtr.p->theData);
7677+
7678+
/* Set the host address */
7679+
if(handle.getSection(hostAddrPtr, ProcessInfoRep::HostAddrSectionNum))
7680+
{
7681+
processInfo->setHostAddress(hostAddrPtr.p->theData);
7682+
}
7683+
else
7684+
{
7685+
/* Use the address from the transporter registry.
7686+
As implemented below we use setHostAddress() with struct in_addr
7687+
to set an IPv4 address. An alternate more abstract version
7688+
of ProcessInfo::setHostAddress() is also available, which
7689+
takes a struct sockaddr * and length.
7690+
*/
7691+
struct in_addr addr=
7692+
globalTransporterRegistry.get_connect_address(report->node_id);
7693+
processInfo->setHostAddress(& addr);
7694+
}
7695+
}
7696+
releaseSections(handle);
7697+
}
7698+
76047699
void
76057700
Qmgr::execISOLATE_ORD(Signal* signal)
76067701
{

0 commit comments

Comments
 (0)