Skip to content

Commit a147b8b

Browse files
committed
wl#9819 patch #9: Send ProcessInfoRep from ClusterMgr
1 parent abd4382 commit a147b8b

File tree

4 files changed

+78
-14
lines changed

4 files changed

+78
-14
lines changed

storage/ndb/include/kernel/ProcessInfo.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ProcessInfo {
5050
void setNodeId(Uint16);
5151
const char * getConnectionName() const { return connection_name; };
5252
const char * getProcessName() const { return process_name; };
53-
const char * getHostAddress() const;
53+
const char * getHostAddress() const { return host_address; };
5454
int getPid() const;
5555
int getAngelPid() const { return angel_process_id; };
5656
int getPort() const { return application_port; };
@@ -67,9 +67,9 @@ class ProcessInfo {
6767
STATIC_CONST( AddressStringLength = 48 ); // Long enough for IPv6
6868
STATIC_CONST( AddressStringLengthInWords = 12);
6969

70-
// /* Interface for ClusterManager to create signal */
71-
// void buildProcessInfoReport(ProcessInfoRep *);
72-
//
70+
/* Interface for ClusterManager to create signal */
71+
void buildProcessInfoReport(ProcessInfoRep *);
72+
7373

7474
private: /* Data Members */
7575
char connection_name[ConnectionNameLength];
@@ -86,9 +86,4 @@ inline bool ProcessInfo::isValid() const {
8686
return process_id;
8787
}
8888

89-
inline const char * ProcessInfo::getHostAddress() const {
90-
return host_address[0] ? host_address : 0;
91-
}
92-
93-
9489
#endif

storage/ndb/include/ndb_version.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,12 @@ ndbd_multi_tc_instance_takeover(Uint32 x)
895895
*/
896896
#define NDBD_SUPPORT_PARALLEL_SYNCH NDB_MAKE_VERSION(7,4,3)
897897

898+
/**
899+
* Support for wl#9819 ndbinfo.processes
900+
* FIXME adjust this when actually merging
901+
*/
902+
#define NDBD_PROCESSINFO_VERSION NDB_MAKE_VERSION(7,5,5)
903+
898904
#define NDBD_ISOLATE_ORD_72 NDB_MAKE_VERSION(7,2,19)
899905
#define NDBD_ISOLATE_ORD_73 NDB_MAKE_VERSION(7,3,8)
900906
#define NDBD_ISOLATE_ORD_74 NDB_MAKE_VERSION(7,4,3)

storage/ndb/src/ndbapi/ClusterMgr.cpp

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
#include <NdbSleep.h>
2929
#include <NdbOut.hpp>
3030
#include <NdbTick.h>
31-
31+
#include <ProcessInfo.hpp>
32+
#include <OwnProcessInfo.hpp>
3233

3334
#include <signaldata/NodeFailRep.hpp>
3435
#include <signaldata/NFCompleteRep.hpp>
3536
#include <signaldata/ApiRegSignalData.hpp>
3637
#include <signaldata/AlterTable.hpp>
3738
#include <signaldata/SumaImpl.hpp>
39+
#include <signaldata/ProcessInfoRep.hpp>
3840

3941
#include <mgmapi.h>
4042
#include <mgmapi_configuration.hpp>
@@ -66,6 +68,7 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade):
6668
noOfConnectedDBNodes(0),
6769
minDbVersion(0),
6870
theClusterMgrThread(NULL),
71+
m_process_info(NULL),
6972
m_cluster_state(CS_waiting_for_clean_cache),
7073
m_hbFrequency(0)
7174
{
@@ -94,6 +97,7 @@ ClusterMgr::~ClusterMgr()
9497
}
9598
NdbCondition_Destroy(waitForHBCond);
9699
NdbMutex_Destroy(clusterMgrThreadMutex);
100+
ProcessInfo::release(m_process_info);
97101
DBUG_VOID_RETURN;
98102
}
99103

@@ -195,6 +199,8 @@ ClusterMgr::configure(Uint32 nodeId,
195199

196200
theFacade.get_registry()->set_connect_backoff_max_time_in_ms(
197201
start_connect_backoff_max_time);
202+
203+
m_process_info = ProcessInfo::forNodeId(nodeId);
198204
}
199205

200206
void
@@ -587,7 +593,7 @@ ClusterMgr::trp_deliver_signal(const NdbApiSignal* sig,
587593
}
588594

589595
ClusterMgr::Node::Node()
590-
: hbFrequency(0), hbCounter(0)
596+
: hbFrequency(0), hbCounter(0), processInfoSent(0)
591597
{
592598
}
593599

@@ -656,6 +662,39 @@ ClusterMgr::recalcMinDbVersion()
656662
minDbVersion = newMinDbVersion;
657663
}
658664

665+
/******************************************************************************
666+
* Send PROCESSINFO_REP
667+
******************************************************************************/
668+
void
669+
ClusterMgr::sendProcessInfoReport(NodeId nodeId)
670+
{
671+
LinearSectionPtr ptr[3];
672+
LinearSectionPtr & nameSection = ptr[ProcessInfoRep::ConnNameSectionNum];
673+
LinearSectionPtr & addrSection = ptr[ProcessInfoRep::HostAddrSectionNum];
674+
BlockReference ownRef = numberToRef(API_CLUSTERMGR, theFacade.ownId());
675+
NdbApiSignal signal(ownRef);
676+
int nsections = 1;
677+
signal.theVerId_signalNumber = GSN_PROCESSINFO_REP;
678+
signal.theReceiversBlockNumber = QMGR;
679+
signal.theTrace = 0;
680+
signal.theLength = ProcessInfoRep::SignalLength;
681+
682+
ProcessInfoRep * report = CAST_PTR(ProcessInfoRep, signal.getDataPtrSend());
683+
m_process_info->buildProcessInfoReport(report);
684+
nameSection.p = (Uint32 *) m_process_info->getConnectionName();
685+
nameSection.sz = ProcessInfo::ConnectionNameLengthInWords;
686+
const char * hostAddress = m_process_info->getHostAddress();
687+
if(hostAddress[0])
688+
{
689+
// report->flags = ProcessInfoRep::HostAddressFlag;
690+
nsections = 2;
691+
addrSection.p = (Uint32 *) hostAddress;
692+
addrSection.sz = ProcessInfo::AddressStringLengthInWords;
693+
}
694+
raw_sendSignal(&signal, nodeId, ptr, nsections);
695+
}
696+
697+
659698
/******************************************************************************
660699
* API_REGREQ and friends
661700
******************************************************************************/
@@ -833,6 +872,15 @@ ClusterMgr::execAPI_REGCONF(const NdbApiSignal * signal,
833872
}
834873
}
835874

875+
/* Send ProcessInfo Report to a newly connected DB node */
876+
if ( cm_node.m_info.m_type == NodeInfo::DB &&
877+
cm_node.m_info.m_version >= NDBD_PROCESSINFO_VERSION &&
878+
(! cm_node.processInfoSent) )
879+
{
880+
sendProcessInfoReport(nodeId);
881+
cm_node.processInfoSent = true;
882+
}
883+
836884
// Distribute signal to all threads/blocks
837885
// TODO only if state changed...
838886
theFacade.for_each(this, signal, ptr);
@@ -923,6 +971,7 @@ ClusterMgr::reportConnected(NodeId nodeId)
923971
cm_node.hbMissed = 0;
924972
cm_node.hbCounter = 0;
925973
cm_node.hbFrequency = 0;
974+
cm_node.processInfoSent = false;
926975

927976
assert(theNode.is_connected() == false);
928977

@@ -1245,6 +1294,14 @@ ClusterMgr::print_nodes(const char* where, NdbOut& out)
12451294
out << "<<" << endl;
12461295
}
12471296

1297+
void
1298+
ClusterMgr::setProcessInfo(const char * connection_name,
1299+
const char * address_string, int port)
1300+
{
1301+
m_process_info->setConnectionName(connection_name);
1302+
m_process_info->setHostAddress(address_string);
1303+
m_process_info->setPort(port);
1304+
}
12481305

12491306
/******************************************************************************
12501307
* Arbitrator

storage/ndb/src/ndbapi/ClusterMgr.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -30,7 +30,6 @@
3030

3131
extern "C" void* runClusterMgr_C(void * me);
3232

33-
3433
/**
3534
@class ClusterMgr
3635
This class runs a heartbeat protocol between nodes, to detect if remote
@@ -58,7 +57,10 @@ class ClusterMgr : public trp_client
5857

5958
void reportConnected(NodeId nodeId);
6059
void reportDisconnected(NodeId nodeId);
61-
60+
void setProcessInfo(const char * connection_name,
61+
const char * application_address,
62+
int application_port);
63+
void sendProcessInfoReport(NodeId nodeId);
6264
void doStop();
6365
void startThread();
6466

@@ -129,6 +131,8 @@ class ClusterMgr : public trp_client
129131
Uint32 hbFrequency; // Heartbeat frequence
130132
Uint32 hbCounter; // # milliseconds passed since last hb sent
131133
Uint32 hbMissed; // # missed heartbeats
134+
135+
bool processInfoSent; // ProcessInfo Report has been sent to node
132136
};
133137

134138
const trp_node & getNodeInfo(NodeId) const;
@@ -141,6 +145,7 @@ class ClusterMgr : public trp_client
141145
*/
142146
int m_auto_reconnect;
143147
Uint32 m_connect_count;
148+
144149
private:
145150
Uint32 m_max_api_reg_req_interval;
146151
Uint32 noOfAliveNodes;
@@ -151,6 +156,7 @@ class ClusterMgr : public trp_client
151156
NdbThread* theClusterMgrThread;
152157

153158
NdbCondition* waitForHBCond;
159+
class ProcessInfo * m_process_info;
154160

155161
enum Cluster_state m_cluster_state;
156162
/**

0 commit comments

Comments
 (0)