Ejemplo n.º 1
0
void
ClusterMgr::execDISCONNECT_REP(const NdbApiSignal* sig,
                               const LinearSectionPtr ptr[])
{
  const DisconnectRep * rep = CAST_CONSTPTR(DisconnectRep, sig->getDataPtr());
  Uint32 nodeId = rep->nodeId;

  assert(nodeId > 0 && nodeId < MAX_NODES);
  Node & cm_node = theNodes[nodeId];
  trp_node & theNode = cm_node;

  bool node_failrep = theNode.m_node_fail_rep;
  set_node_dead(theNode);
  theNode.set_connected(false);

  noOfConnectedNodes--;
  if (noOfConnectedNodes == 0)
  {
    if (!global_flag_skip_invalidate_cache &&
        theFacade.m_globalDictCache)
    {
      theFacade.m_globalDictCache->lock();
      theFacade.m_globalDictCache->invalidate_all();
      theFacade.m_globalDictCache->unlock();
      m_connect_count ++;
      m_cluster_state = CS_waiting_for_clean_cache;
    }

    if (m_auto_reconnect == 0)
    {
      theStop = 2;
    }
  }

  if (node_failrep == false)
  {
    /**
     * Inform API
     */
    NdbApiSignal signal(numberToRef(API_CLUSTERMGR, getOwnNodeId()));
    signal.theVerId_signalNumber = GSN_NODE_FAILREP;
    signal.theReceiversBlockNumber = API_CLUSTERMGR;
    signal.theTrace  = 0;
    signal.theLength = NodeFailRep::SignalLengthLong;

    NodeFailRep * rep = CAST_PTR(NodeFailRep, signal.getDataPtrSend());
    rep->failNo = 0;
    rep->masterNodeId = 0;
    rep->noOfNodes = 1;
    NodeBitmask::clear(rep->theAllNodes);
    NodeBitmask::set(rep->theAllNodes, nodeId);
    execNODE_FAILREP(&signal, 0);
  }
}
Ejemplo n.º 2
0
/**
 * We're holding the trp_client lock while performing poll from
 * ClusterMgr. So we always execute all the execSIGNAL-methods in
 * ClusterMgr with protection other methods that use the trp_client
 * lock (reportDisconnect, reportConnect, is_cluster_completely_unavailable,
 * ArbitMgr (sendSignalToQmgr)).
 */
void
ClusterMgr::trp_deliver_signal(const NdbApiSignal* sig,
                               const LinearSectionPtr ptr[3])
{
    const Uint32 gsn = sig->theVerId_signalNumber;
    const Uint32 * theData = sig->getDataPtr();

    switch (gsn) {
    case GSN_API_REGREQ:
        execAPI_REGREQ(theData);
        break;

    case GSN_API_REGCONF:
        execAPI_REGCONF(sig, ptr);
        break;

    case GSN_API_REGREF:
        execAPI_REGREF(theData);
        break;

    case GSN_NODE_FAILREP:
        execNODE_FAILREP(sig, ptr);
        break;

    case GSN_NF_COMPLETEREP:
        execNF_COMPLETEREP(sig, ptr);
        break;
    case GSN_ARBIT_STARTREQ:
        if (theArbitMgr != NULL)
            theArbitMgr->doStart(theData);
        break;

    case GSN_ARBIT_CHOOSEREQ:
        if (theArbitMgr != NULL)
            theArbitMgr->doChoose(theData);
        break;

    case GSN_ARBIT_STOPORD:
        if(theArbitMgr != NULL)
            theArbitMgr->doStop(theData);
        break;

    case GSN_ALTER_TABLE_REP:
    {
        if (theFacade.m_globalDictCache == NULL)
            break;
        const AlterTableRep* rep = (const AlterTableRep*)theData;
        theFacade.m_globalDictCache->lock();
        theFacade.m_globalDictCache->
        alter_table_rep((const char*)ptr[0].p,
                        rep->tableId,
                        rep->tableVersion,
                        rep->changeType == AlterTableRep::CT_ALTERED);
        theFacade.m_globalDictCache->unlock();
        break;
    }
    case GSN_SUB_GCP_COMPLETE_REP:
    {
        /**
         * Report
         */
        theFacade.for_each(this, sig, ptr);

        /**
         * Reply
         */
        {
            BlockReference ownRef = numberToRef(API_CLUSTERMGR, theFacade.ownId());
            NdbApiSignal tSignal(* sig);
            Uint32* send= tSignal.getDataPtrSend();
            memcpy(send, theData, tSignal.getLength() << 2);
            CAST_PTR(SubGcpCompleteAck, send)->rep.senderRef = ownRef;
            Uint32 ref= sig->theSendersBlockRef;
            Uint32 aNodeId= refToNode(ref);
            tSignal.theReceiversBlockNumber= refToBlock(ref);
            tSignal.theVerId_signalNumber= GSN_SUB_GCP_COMPLETE_ACK;
            tSignal.theSendersBlockRef = API_CLUSTERMGR;
            safe_noflush_sendSignal(&tSignal, aNodeId);
        }
        break;
    }
    case GSN_TAKE_OVERTCCONF:
    {
        /**
         * Report
         */
        theFacade.for_each(this, sig, ptr);
        return;
    }
    case GSN_CONNECT_REP:
    {
        execCONNECT_REP(sig, ptr);
        return;
    }
    case GSN_DISCONNECT_REP:
    {
        execDISCONNECT_REP(sig, ptr);
        return;
    }
    case GSN_CLOSE_COMREQ:
    {
        theFacade.perform_close_clnt(this);
        return;
    }
    case GSN_EXPAND_CLNT:
    {
        theFacade.expand_clnt();
        return;
    }
    default:
        break;

    }
    return;
}