コード例 #1
0
ファイル: NdbRestarter.cpp プロジェクト: 0x00xw/mysql-2
int NdbRestarter::restartAll(bool initial,
			     bool nostart,
			     bool abort){
  
  if (!isConnected())
    return -1;

  if (ndb_mgm_restart2(handle, 0, NULL, initial, 1, abort) == -1) {
    MGMERR(handle);
    g_err  << "Could not restart(stop) all nodes " << endl;
    // return -1; Continue anyway - Magnus
  }
  
  if (waitClusterNoStart(60) != 0){
    g_err << "Cluster didnt enter STATUS_NOT_STARTED within 60s" << endl;
    return -1;
  }
  
  if(nostart){
    g_debug << "restartAll: nostart == true" << endl;
    return 0;
  }

  if (ndb_mgm_start(handle, 0, NULL) == -1) {
    MGMERR(handle);
    g_err  << "Could not restart(start) all nodes " << endl;
    return -1;
  }
  
  return 0;
}
コード例 #2
0
int
NdbRestarter::rollingRestart(Uint32 flags)
{
  if (getStatus() != 0)
    return -1;
  
  NdbNodeBitmask ng_mask;
  NdbNodeBitmask restart_nodes;
  Vector<int> nodes;
  for(unsigned i = 0; i < ndbNodes.size(); i++)
  { 
    if (ng_mask.get(ndbNodes[i].node_group) == false)
    {
      ng_mask.set(ndbNodes[i].node_group);
      nodes.push_back(ndbNodes[i].node_id);
      restart_nodes.set(ndbNodes[i].node_id);
    }
  }

loop:  
  if (ndb_mgm_restart2(handle, nodes.size(), nodes.getBase(),
                       (flags & NRRF_INITIAL) != 0, 
                       (flags & NRRF_NOSTART) != 0,
                       (flags & NRRF_ABORT) != 0 || true) <= 0)
  {
    return -1;
  }
  
  if (waitNodesNoStart(nodes.getBase(), nodes.size()))
    return -1;

  if (startNodes(nodes.getBase(), nodes.size()))
    return -1;

  if (waitClusterStarted())
    return -1;

  nodes.clear();
  for (Uint32 i = 0; i<ndbNodes.size(); i++)
  {
    if (restart_nodes.get(ndbNodes[i].node_id) == false)
    {
      nodes.push_back(ndbNodes[i].node_id);
      restart_nodes.set(ndbNodes[i].node_id);
    }
  }
  if (nodes.size())
    goto loop;
  
  return 0;
}
コード例 #3
0
ファイル: NdbRestarter.cpp プロジェクト: 0x00xw/mysql-2
int
NdbRestarter::restartOneDbNode(int _nodeId,
			       bool inital,
			       bool nostart,
			       bool abort){
  if (!isConnected())
    return -1;

  int ret = 0;
  
  if ((ret = ndb_mgm_restart2(handle, 1, &_nodeId,
			      inital, nostart, abort)) <= 0) {
    /**
     * ndb_mgm_restart2 returned error, one reason could
     * be that the node have not stopped fast enough!
     * Check status of the node to see if it's on the 
     * way down. If that's the case ignore the error
     */ 

    if (getStatus() != 0)
      return -1;

    g_info << "ndb_mgm_restart2 returned with error, checking node state" << endl;

    for(size_t i = 0; i < ndbNodes.size(); i++){
      if(ndbNodes[i].node_id == _nodeId){
	g_info <<_nodeId<<": status="<<ndbNodes[i].node_status<<endl;
	/* Node found check state */
	switch(ndbNodes[i].node_status){
	case NDB_MGM_NODE_STATUS_RESTARTING:
	case NDB_MGM_NODE_STATUS_SHUTTING_DOWN:
	  return 0;
	default:
	  break;
	}
      }
    }
    
    MGMERR(handle);
    g_err  << "Could not stop node with id = "<< _nodeId << endl;
    return -1;
  }

  return 0;
}