コード例 #1
0
void removeNode(const char* safName)
{
  ClRcT rc;
  ClAmsEntityConfigT entity;

  if (ccbHandle==CL_HANDLE_INVALID_VALUE) initHandles();
  initEntity(&entity,safName,CL_AMS_ENTITY_TYPE_NODE);

  entityStop(entity);

  ClCpmSlotInfoT slotInfo;  
  saNameSet(&slotInfo.nodeName,safName);
  if ((rc = clCpmSlotGet(CL_CPM_NODENAME, &slotInfo))  != CL_OK) checkError("Get node address",rc);
  
  if ((rc = clCpmNodeShutDown(slotInfo.nodeIocAddress))  != CL_OK) checkError("shutdown ASP on node",rc);

  ClAmsNodeStatusT* ns;

  bool done = false;
  do
    {
      ns = clAmsMgmtNodeGetStatus( mgmtHandle ,safName);
      sleep(1);
      if (!ns) done = true;
      else
        {
          if (ns->isClusterMember == CL_AMS_NODE_IS_NOT_CLUSTER_MEMBER) done=true;
          clHeapFree(ns);
        }
    } while (!done);

  if ((rc = clAmsMgmtCCBEntityDelete(ccbHandle,&entity))  != CL_OK) checkError("Delete node",rc);      
  if ((rc = clAmsMgmtCCBCommit(ccbHandle) ) != CL_OK) checkError("Committing deletion of node", rc);
}
ClRcT clCpmShutDown(ClUint32T argc, ClCharT *argv[], ClCharT **retStr)
{
    ClUint32T rc = CL_OK;

    if (!CL_CPM_IS_ACTIVE())
    {
        cpmCliPrint(retStr,
                    "Node shutdown operation can be performed "
                    "only on CPM/G active");
        rc = CL_CPM_RC(CL_ERR_OP_NOT_PERMITTED);
        goto failure;
    }

    if (2 == argc)
    {
        ClIocNodeAddressT nodeAddress = 0;

        nodeAddress = (ClIocNodeAddressT) cpmCliStrToInt(argv[1]);
        if (nodeAddress <= 0) 
        {
            cpmCliPrint(retStr, "Invalid node address [%s]", argv[1]);
            rc = CL_CPM_RC(CL_ERR_INVALID_PARAMETER);
            goto failure;
        }

        rc = clCpmNodeShutDown(nodeAddress);
        if (CL_OK != rc)
        {
            cpmCliPrint(retStr,
                        "Failed to shutdown the node, error [%#x]",
                        rc);
            goto failure;
        }
    }
    else
    {
        rc = CL_CPM_RC(CL_ERR_INVALID_PARAMETER);
        cpmCliPrint(retStr,
                    "Usage : nodeShutdown <node address>\n"
                    "\tnode address[in decimal] - IOC address "
                    "of the node");
        goto failure;
    }

    return CL_OK;

 failure:
    return rc;
}