Commit 90b102da authored by unknown's avatar unknown
Browse files

BUG#11595 ndb_mgm shows from IP for second mgmd

BUG#12037 ndb_mgmd IP address do not show in other ndb_mgmd processes

Extend ApiVersionConf to include address.


ndb/include/kernel/signaldata/ApiVersion.hpp:
  Extend ApiVersionConf to include inet_addr. the address used for communication to this node.
ndb/src/kernel/blocks/qmgr/QmgrMain.cpp:
  include connect address in ApiVersionConf
ndb/src/mgmsrv/MgmtSrvr.cpp:
  ::status() now also returns char* address of the node.
  For API or MGM, this is in ApiVersionConf.
  For NDB, this is the standard get_connect_address.
  
  When sending ApiVersionReq, try to send to a STARTED node (as these have
  properly joined the cluster and know the connect addresses).
  
  If versionNode is called for getOwnNodeId()==nodeId, try to get the address
  via ApiVersionConf. If that fails, look it up in the configuration.
ndb/src/mgmsrv/MgmtSrvr.hpp:
  Add char **address to prototypes.
ndb/src/mgmsrv/Services.cpp:
  Get the connect address from mgmsrv.status()
parent 8c963d39
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -49,12 +49,11 @@ class ApiVersionConf {
   */
  friend class MgmtSrv;  
public:
  STATIC_CONST( SignalLength = 3 );
  STATIC_CONST( SignalLength = 4 );
  Uint32 senderRef; 
  Uint32 nodeId; //api node id
  Uint32 version; // Version of API node

  
  Uint32 inet_addr;
};

#endif
+2 −0
Original line number Diff line number Diff line
@@ -2012,6 +2012,8 @@ Qmgr::execAPI_VERSION_REQ(Signal * signal) {
  else
    conf->version =  0;
  conf->nodeId = nodeId;
  struct in_addr in= globalTransporterRegistry.get_connect_address(nodeId);
  conf->inet_addr= in.s_addr;

  sendSignal(senderRef, 
	     GSN_API_VERSION_CONF,
+43 −7
Original line number Diff line number Diff line
@@ -690,30 +690,46 @@ MgmtSrvr::start(int nodeId)
 *****************************************************************************/

int 
MgmtSrvr::versionNode(int nodeId, Uint32 &version)
MgmtSrvr::versionNode(int nodeId, Uint32 &version, const char **address)
{
  version= 0;
  if (getOwnNodeId() == nodeId)
  {
    sendVersionReq(nodeId, version, address);
    version= NDB_VERSION;
    if(!*address)
    {
      ndb_mgm_configuration_iterator
	iter(*_config->m_configValues, CFG_SECTION_NODE);
      unsigned tmp= 0;
      for(iter.first();iter.valid();iter.next())
      {
	if(iter.get(CFG_NODE_ID, &tmp)) require(false);
	if((unsigned)nodeId!=tmp)
	  continue;
	if(iter.get(CFG_NODE_HOST, address)) require(false);
	break;
      }
    }
  }
  else if (getNodeType(nodeId) == NDB_MGM_NODE_TYPE_NDB)
  {
    ClusterMgr::Node node= theFacade->theClusterMgr->getNodeInfo(nodeId);
    if(node.connected)
      version= node.m_info.m_version;
    *address= get_connect_address(nodeId);
  }
  else if (getNodeType(nodeId) == NDB_MGM_NODE_TYPE_API ||
	   getNodeType(nodeId) == NDB_MGM_NODE_TYPE_MGM)
  {
    return sendVersionReq(nodeId, version);
    return sendVersionReq(nodeId, version, address);
  }

  return 0;
}

int 
MgmtSrvr::sendVersionReq(int v_nodeId, Uint32 &version)
MgmtSrvr::sendVersionReq(int v_nodeId, Uint32 &version, const char **address)
{
  SignalSender ss(theFacade);
  ss.lock();
@@ -734,8 +750,21 @@ MgmtSrvr::sendVersionReq(int v_nodeId, Uint32 &version)
    {
      bool next;
      nodeId = 0;

      while((next = getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) == true &&
	    okToSendTo(nodeId, true) != 0);

      const ClusterMgr::Node &node=
	theFacade->theClusterMgr->getNodeInfo(nodeId);
      if(next && node.m_state.startLevel != NodeState::SL_STARTED)
      {
	NodeId tmp=nodeId;
	while((next = getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) == true &&
	      okToSendTo(nodeId, true) != 0);
	if(!next)
	  nodeId= tmp;
      }

      if(!next) return NO_CONTACT_WITH_DB_NODES;

      if (ss.sendSignal(nodeId, &ssig) != SEND_OK) {
@@ -753,6 +782,9 @@ MgmtSrvr::sendVersionReq(int v_nodeId, Uint32 &version)
	CAST_CONSTPTR(ApiVersionConf, signal->getDataPtr());
      assert(conf->nodeId == v_nodeId);
      version = conf->version;
      struct in_addr in;
      in.s_addr= conf->inet_addr;
      *address= inet_ntoa(in);
      return 0;
    }
    case GSN_NF_COMPLETEREP:{
@@ -1060,8 +1092,9 @@ int MgmtSrvr::restart(bool nostart, bool initialStart,
      Uint32 startPhase = 0, version = 0, dynamicId = 0, nodeGroup = 0;
      Uint32 connectCount = 0;
      bool system;
      const char *address;
      status(nodeId, &s, &version, &startPhase, 
	     &system, &dynamicId, &nodeGroup, &connectCount);
	     &system, &dynamicId, &nodeGroup, &connectCount, &address);
      NdbSleep_MilliSleep(100);  
      waitTime = (maxTime - NdbTick_CurrentMillisecond());
    }
@@ -1137,11 +1170,14 @@ MgmtSrvr::status(int nodeId,
		 bool * _system,
		 Uint32 * dynamic,
		 Uint32 * nodegroup,
		 Uint32 * connectCount)
		 Uint32 * connectCount,
		 const char **address)
{
  if (getNodeType(nodeId) == NDB_MGM_NODE_TYPE_API ||
      getNodeType(nodeId) == NDB_MGM_NODE_TYPE_MGM) {
    versionNode(nodeId, *version);
    versionNode(nodeId, *version, address);
  } else {
    *address= get_connect_address(nodeId);
  }

  const ClusterMgr::Node node = 
+4 −3
Original line number Diff line number Diff line
@@ -208,7 +208,8 @@ public:
	     bool * systemShutdown,
	     Uint32 * dynamicId,
	     Uint32 * nodeGroup,
	     Uint32 * connectCount);
	     Uint32 * connectCount,
	     const char **address);
  
  // All the functions below may return any of this error codes:
  // NO_CONTACT_WITH_PROCESS, PROCESS_NOT_CONFIGURED, WRONG_PROCESS_TYPE,
@@ -255,7 +256,7 @@ public:
   *   @param   processId: Id of the DB process to stop
   *   @return  0 if succeeded, otherwise: as stated above, plus:
   */
  int versionNode(int nodeId, Uint32 &version);
  int versionNode(int nodeId, Uint32 &version, const char **address);

  /**
   *   Maintenance on the system
@@ -611,7 +612,7 @@ private:

  class TransporterFacade * theFacade;

  int  sendVersionReq( int processId, Uint32 &version);
  int  sendVersionReq( int processId, Uint32 &version, const char **address);
  int translateStopRef(Uint32 errCode);
  
  bool _isStopThread;
+5 −3
Original line number Diff line number Diff line
@@ -903,8 +903,10 @@ printNodeStatus(OutputStream *output,
      nodeGroup = 0,
      connectCount = 0;
    bool system;
    const char *address= NULL;
    mgmsrv.status(nodeId, &status, &version, &startPhase,
		  &system, &dynamicId, &nodeGroup, &connectCount);
		  &system, &dynamicId, &nodeGroup, &connectCount,
		  &address);
    output->println("node.%d.type: %s",
		      nodeId,
		      ndb_mgm_get_node_type_string(type));
@@ -916,7 +918,7 @@ printNodeStatus(OutputStream *output,
    output->println("node.%d.dynamic_id: %d", nodeId, dynamicId);
    output->println("node.%d.node_group: %d", nodeId, nodeGroup);
    output->println("node.%d.connect_count: %d", nodeId, connectCount);
    output->println("node.%d.address: %s", nodeId, mgmsrv.get_connect_address(nodeId));
    output->println("node.%d.address: %s", nodeId, address);
  }

}