|
28 | 28 | #include <NdbSleep.h>
|
29 | 29 | #include <NdbOut.hpp>
|
30 | 30 | #include <NdbTick.h>
|
31 |
| - |
| 31 | +#include <ProcessInfo.hpp> |
| 32 | +#include <OwnProcessInfo.hpp> |
32 | 33 |
|
33 | 34 | #include <signaldata/NodeFailRep.hpp>
|
34 | 35 | #include <signaldata/NFCompleteRep.hpp>
|
35 | 36 | #include <signaldata/ApiRegSignalData.hpp>
|
36 | 37 | #include <signaldata/AlterTable.hpp>
|
37 | 38 | #include <signaldata/SumaImpl.hpp>
|
| 39 | +#include <signaldata/ProcessInfoRep.hpp> |
38 | 40 |
|
39 | 41 | #include <mgmapi.h>
|
40 | 42 | #include <mgmapi_configuration.hpp>
|
@@ -66,6 +68,7 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade):
|
66 | 68 | noOfConnectedDBNodes(0),
|
67 | 69 | minDbVersion(0),
|
68 | 70 | theClusterMgrThread(NULL),
|
| 71 | + m_process_info(NULL), |
69 | 72 | m_cluster_state(CS_waiting_for_clean_cache),
|
70 | 73 | m_hbFrequency(0)
|
71 | 74 | {
|
@@ -94,6 +97,7 @@ ClusterMgr::~ClusterMgr()
|
94 | 97 | }
|
95 | 98 | NdbCondition_Destroy(waitForHBCond);
|
96 | 99 | NdbMutex_Destroy(clusterMgrThreadMutex);
|
| 100 | + ProcessInfo::release(m_process_info); |
97 | 101 | DBUG_VOID_RETURN;
|
98 | 102 | }
|
99 | 103 |
|
@@ -195,6 +199,8 @@ ClusterMgr::configure(Uint32 nodeId,
|
195 | 199 |
|
196 | 200 | theFacade.get_registry()->set_connect_backoff_max_time_in_ms(
|
197 | 201 | start_connect_backoff_max_time);
|
| 202 | + |
| 203 | + m_process_info = ProcessInfo::forNodeId(nodeId); |
198 | 204 | }
|
199 | 205 |
|
200 | 206 | void
|
@@ -587,7 +593,7 @@ ClusterMgr::trp_deliver_signal(const NdbApiSignal* sig,
|
587 | 593 | }
|
588 | 594 |
|
589 | 595 | ClusterMgr::Node::Node()
|
590 |
| - : hbFrequency(0), hbCounter(0) |
| 596 | + : hbFrequency(0), hbCounter(0), processInfoSent(0) |
591 | 597 | {
|
592 | 598 | }
|
593 | 599 |
|
@@ -656,6 +662,39 @@ ClusterMgr::recalcMinDbVersion()
|
656 | 662 | minDbVersion = newMinDbVersion;
|
657 | 663 | }
|
658 | 664 |
|
| 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 | + |
659 | 698 | /******************************************************************************
|
660 | 699 | * API_REGREQ and friends
|
661 | 700 | ******************************************************************************/
|
@@ -833,6 +872,15 @@ ClusterMgr::execAPI_REGCONF(const NdbApiSignal * signal,
|
833 | 872 | }
|
834 | 873 | }
|
835 | 874 |
|
| 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 | + |
836 | 884 | // Distribute signal to all threads/blocks
|
837 | 885 | // TODO only if state changed...
|
838 | 886 | theFacade.for_each(this, signal, ptr);
|
@@ -923,6 +971,7 @@ ClusterMgr::reportConnected(NodeId nodeId)
|
923 | 971 | cm_node.hbMissed = 0;
|
924 | 972 | cm_node.hbCounter = 0;
|
925 | 973 | cm_node.hbFrequency = 0;
|
| 974 | + cm_node.processInfoSent = false; |
926 | 975 |
|
927 | 976 | assert(theNode.is_connected() == false);
|
928 | 977 |
|
@@ -1245,6 +1294,14 @@ ClusterMgr::print_nodes(const char* where, NdbOut& out)
|
1245 | 1294 | out << "<<" << endl;
|
1246 | 1295 | }
|
1247 | 1296 |
|
| 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 | +} |
1248 | 1305 |
|
1249 | 1306 | /******************************************************************************
|
1250 | 1307 | * Arbitrator
|
|
0 commit comments