ClRcT _clCorNodeNameToMoIdGet(ClNameT *nodeName, ClCorNodeDataPtrT *dataNode) { ClRcT rc = CL_OK; ClCntNodeHandleT nodeHandle = 0; ClNameT *tempName = NULL; if(nodeName == NULL) return CL_COR_SET_RC(CL_COR_ERR_NULL_PTR); /* Get the data from the hash table */ CL_DEBUG_PRINT(CL_DEBUG_TRACE,(" Node find for node Name %s", nodeName->value)); /* Do the node find and get the node handle for a particular node name. Now walk all the * node for that particular node handle type. */ rc = clCntNodeFind(nodeNameToMoIdTableHandle, (ClCntKeyHandleT)nodeName, &nodeHandle); if(CL_OK != rc) { CL_DEBUG_PRINT(CL_DEBUG_TRACE,("Failed to get the node Handle for the Node Name %s. rc [0x%x]", nodeName->value, rc)); return rc; } while(nodeHandle != 0) { rc = clCntNodeUserKeyGet(nodeNameToMoIdTableHandle, nodeHandle, (ClCntKeyHandleT *) &tempName); if (rc != CL_OK) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Failed to get the user key from the node handle. rc[0x%x]", rc)); break; } CL_DEBUG_PRINT(CL_DEBUG_TRACE,("Got the Nodename %s", tempName->value)); rc = clCntNodeUserDataGet(nodeNameToMoIdTableHandle, nodeHandle, (ClCntDataHandleT *)dataNode); if(rc != CL_OK) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Failed to get the user data from the node handle. rc [0x%x]", rc)); break; } if((strcmp (nodeName->value, (*dataNode)->nodeName.value)) == 0) { CL_DEBUG_PRINT(CL_DEBUG_TRACE,("Got the MoId for a Node Name %s", (*dataNode)->nodeName.value)); return CL_OK; } rc = clCntNextNodeGet(nodeNameToMoIdTableHandle, nodeHandle, &nodeHandle); if(rc != CL_OK) { CL_DEBUG_PRINT(CL_DEBUG_TRACE,("Failed to get the next node handle. rc[0x%x]", rc)); break; } } if(CL_OK != rc) CL_COR_RETURN_ERROR(CL_DEBUG_TRACE, "Could not get MOId from the node name", rc); return CL_OK; }
ClRcT clCntNodeDelete(ClCntHandleT containerHandle, ClCntNodeHandleT nodeHandle) { CclContainer_t *pContainer = NULL; pContainer = (CclContainer_t *) containerHandle; nullChkRet(pContainer); if(pContainer->validContainer != CONTAINER_ID) { returnCntError(CL_ERR_INVALID_HANDLE, "Passed container handle is invalid"); } if (pContainer->fpFunctionContainerNodeDelete == NULL) { returnCntError(CL_ERR_INVALID_STATE, "Container got corrupted"); } #if HA_ENABLED /* HA-aware container Modifications Start: Hari*/ /* This element is going to be deleted. Let the redundancy peer know it*/ if(pContainer->haEnabled) { ClCntKeyHandleT userKey; if (CL_OK != clCntNodeUserKeyGet(containerHandle, nodeHandle, &userKey)) { errorCode =CL_CNT_RC(CL_ERR_INVALID_STATE); CL_DEBUG_PRINT (CL_DEBUG_TRACE,("\nInvalid state")); return (errorCode); } /* Update the standby component */ errorCode = clCPContainerElemSynch(pContainer->cpsHdl, pContainer->domainId, pContainer->containerId, userKey, 0x0000); /* ELEMENTDEL = 0x00000*/ } #endif /* HA-aware container Modifications End: Hari*/ return (pContainer->fpFunctionContainerNodeDelete (containerHandle, nodeHandle)); }
static ClRcT __clCntWalk(ClCntHandleT containerHandle, ClCntWalkCallbackT fpUserWalkCallback, ClCntArgHandleT userDataArg, ClInt32T dataLength, ClBoolT failSafe) { CclContainer_t *pContainer = NULL; ClCntNodeHandleT containerNode = CL_HANDLE_INVALID_VALUE; ClCntNodeHandleT nextContainerNode = CL_HANDLE_INVALID_VALUE; ClCntDataHandleT userData = CL_HANDLE_INVALID_VALUE; ClCntKeyHandleT userKey = CL_HANDLE_INVALID_VALUE; BaseLinkedListNode_t *pTemp = NULL; ClRcT errorCode = CL_OK; nullChkRet(fpUserWalkCallback); pContainer = (CclContainer_t *) containerHandle; nullChkRet(pContainer); if(pContainer->validContainer != CONTAINER_ID) { returnCntError(CL_ERR_INVALID_HANDLE, "Passed container handle is invalid"); } errorCode = clCntFirstNodeGet (containerHandle, &containerNode); if(errorCode != CL_OK) { if((CL_GET_ERROR_CODE(errorCode)) == CL_ERR_NOT_EXIST) { /* If the container is empty it means we dont have to walk anymore. * Hence return OK. */ return (CL_OK); } return(errorCode); } while (containerNode) { pTemp = (BaseLinkedListNode_t*) containerNode; if(clCntNextNodeGet(containerHandle, containerNode, &nextContainerNode) != CL_OK) { nextContainerNode = 0; } if ((pTemp->pRbeExpression == NULL) || (clRuleExprEvaluate(pTemp->pRbeExpression, (ClUint32T*) userDataArg, dataLength))) { errorCode = clCntNodeUserKeyGet (containerHandle, containerNode, &userKey); errorCode = clCntNodeUserDataGet (containerHandle, containerNode, &userData); errorCode = fpUserWalkCallback(userKey, userData, userDataArg,dataLength); if(!failSafe && (CL_OK != errorCode)) { return (errorCode); } } containerNode = nextContainerNode; } return(CL_OK); }
ClRcT clLogClntStreamWriteWithHeader(ClLogClntEoDataT *pClntEoEntry, ClLogSeverityT severity, ClUint16T serviceId, ClUint16T msgId, const ClCharT *pMsgHeader, va_list args, ClCntNodeHandleT hClntStreamNode) { ClRcT rc = CL_OK; ClLogClntStreamDataT *pClntData = NULL; ClLogStreamHeaderT *pStreamHeader = NULL; ClUint8T *pStreamRecords = NULL; ClUint32T nUnAcked = 0; ClUint32T nDroppedRecords = 0; ClUint8T *pBuffer = NULL; ClUint32T recordSize = 0; CL_LOG_DEBUG_TRACE(("Enter")); CL_LOG_DEBUG_VERBOSE(("Severity: %d ServiceId: %hu MsgId: %hu CompId: %u", severity, serviceId, msgId, pClntEoEntry->compId)); rc = clCntNodeUserDataGet(pClntEoEntry->hClntStreamTable, hClntStreamNode, (ClCntDataHandleT *) &pClntData); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntNodeUserDataGet(): rc[0x %x]", rc)); return rc; } pStreamHeader = pClntData->pStreamHeader; pStreamRecords = pClntData->pStreamRecords; #ifdef NO_SAF ClLogStreamKeyT *pUserKey = NULL; rc = clCntNodeUserKeyGet(pClntEoEntry->hClntStreamTable, hClntStreamNode, (ClCntKeyHandleT *) &pUserKey); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntNodeUserKeyGet(): rc[0x %x]", rc)); return rc; } ClInt32T recSize= pClntData->recSize; #define __UPDATE_RECORD_SIZE do { \ if(recSize < nbytes ) \ recSize = nbytes; \ recSize -= nbytes; \ if(!recSize) \ return CL_OK; \ }while(0) ClUint16T streamId = 10; ClUint64T sequenceNum = pUserKey->sequenceNum; ClUint32T clientId = pClntEoEntry->clientId; ClUint8T* pRecord=clHeapAllocate(recSize); ClTimeT timeStamp = 0; ClUint8T *pRecStart = pRecord; ClUint16T tmp = 1; ClUint8T endian = *(ClUint8T *) &tmp; memset(pRecord, 0, recSize); if( CL_LOG_MSGID_PRINTF_FMT == msgId ) { ClInt32T nbytes = 0; if(recSize < LOG_ASCII_MIN_REC_SIZE ) /* just a minimum record size taking care of the headers*/ { printf("LOG record size has to be minimum [%d] bytes. Got [%d] bytes\n", LOG_ASCII_MIN_REC_SIZE, recSize); return CL_LOG_RC(CL_ERR_INVALID_PARAMETER); } /* * In ASCII logging, we dont need header, so just keeping only the * required fields */ nbytes = snprintf((ClCharT *)pRecord, recSize, LOG_ASCII_HDR_FMT, endian, severity & 0x1f); pRecord += nbytes; __UPDATE_RECORD_SIZE; { ClCharT *pSeverity = (ClCharT *)clLogSeverityStrGet(severity); ClCharT c = 0; ClInt32T hdrLen = 0; ClInt32T len = 0; va_list argsCopy; ClCharT *pFmtStr ; va_copy(argsCopy, args); pFmtStr = va_arg(argsCopy, ClCharT *); if(pMsgHeader && pMsgHeader[0]) { hdrLen = snprintf(&c, 1, "%s.%05lld : %6s) ", pMsgHeader, sequenceNum, pSeverity ? pSeverity : "DEBUG"); if(hdrLen < 0) hdrLen = 0; } len = vsnprintf(&c, 1, pFmtStr, argsCopy); va_end(argsCopy); if(len < 0) len = 0; hdrLen = CL_MIN(hdrLen, recSize - LOG_ASCII_HDR_LEN - LOG_ASCII_DATA_LEN - 1); len = CL_MIN(len, recSize - LOG_ASCII_HDR_LEN - LOG_ASCII_DATA_LEN - hdrLen - 1); nbytes = snprintf((ClCharT*)pRecord, recSize - 1, LOG_ASCII_HDR_LEN_FMT, hdrLen); pRecord += nbytes; __UPDATE_RECORD_SIZE; nbytes = snprintf((ClCharT*)pRecord, recSize - 1, LOG_ASCII_DATA_LEN_DELIMITER_FMT, len); pRecord += nbytes; __UPDATE_RECORD_SIZE; if(pMsgHeader && pMsgHeader[0]) { nbytes = snprintf((ClCharT*)pRecord, recSize - 1, "%s.%05lld : %6s) ", pMsgHeader, sequenceNum, pSeverity ? pSeverity : "DEBUG"); if(nbytes < 0) nbytes = 0; pRecord += nbytes; __UPDATE_RECORD_SIZE; } pFmtStr = va_arg(args, ClCharT *); nbytes = vsnprintf((ClCharT*)pRecord, recSize - 1, pFmtStr, args); if(nbytes < 0) nbytes = 0; } }
static ClRcT clLogSvrStreamInfoPack(ClLogSvrEoDataT *pSvrEoEntry, ClCntNodeHandleT svrStreamNode, ClBufferHandleT msg) { ClRcT rc = CL_OK; ClUint32T size = 0; ClLogStreamKeyT *pStreamKey = NULL; ClLogSvrStreamDataT *pSvrStreamData = NULL; CL_LOG_DEBUG_TRACE(("Enter")); rc = clCntNodeUserDataGet(pSvrEoEntry->hSvrStreamTable, svrStreamNode, (ClCntDataHandleT *)&pSvrStreamData); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntDataForNodeGet(): rc[0x %x]\n", rc)); return rc; } rc = clCntNodeUserKeyGet(pSvrEoEntry->hSvrStreamTable, svrStreamNode, (ClCntKeyHandleT *)&pStreamKey); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntNodeUserKeyGet(): rc[0x %x]\n", rc)); return rc; } rc = clXdrMarshallSaNameT(&(pStreamKey->streamName), msg, 0); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallSaNameT(): rc[0x %x]", rc)); return rc; } rc = clXdrMarshallSaNameT(&(pStreamKey->streamScopeNode), msg, 0); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallSaNameT(): rc[0x %x]", rc)); return rc; } /* * Copy file name and file location keys to reconstruct back the fileowner address */ clXdrMarshallClStringT(&pSvrStreamData->fileName, msg, 0); clXdrMarshallClStringT(&pSvrStreamData->fileLocation, msg, 0); rc = clCntSizeGet(pSvrStreamData->hComponentTable, &size); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntSizeGet(); rc[0x %x]", rc)); return rc; } rc = clXdrMarshallClUint32T(&size, msg, 0); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallClUint32T(): rc[0x %x]", rc)); return rc; } rc = clCntWalk(pSvrStreamData->hComponentTable, clLogSvrCompTablePack, &msg, sizeof(&msg)); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntWalk(): rc[0x %x]", rc)); return rc; } CL_LOG_DEBUG_TRACE(("Exit")); return rc; }
static ClRcT clLogMasterFileEntryPack(ClLogMasterEoDataT *pMasterEoEntry, ClCntNodeHandleT hFileNode, ClCkptSectionIdT *pSecId, ClUint8T **ppBuffer, ClUint32T *pBufferLen) { ClBufferHandleT hFileEntryBuf = CL_HANDLE_INVALID_VALUE; ClLogFileKeyT *pFileKey = NULL; ClLogFileDataT *pFileData = NULL; ClRcT rc = CL_OK; ClVersionT version = { CL_RELEASE_VERSION, CL_MAJOR_VERSION, CL_MINOR_VERSION }; CL_LOG_DEBUG_TRACE(("Enter")); rc = clCntNodeUserKeyGet(pMasterEoEntry->hMasterFileTable, hFileNode, (ClCntKeyHandleT *) &pFileKey); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntNodeUserKeyGet(): rc[0x %x]", rc)); return rc; } rc = clCntNodeUserDataGet(pMasterEoEntry->hMasterFileTable, hFileNode, (ClCntDataHandleT *) &pFileData); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntNodeUserDataGet(): rc[0x %x]", rc)); return rc; } rc = clLogMasterFileEntrySecIdGet(pFileKey, pSecId); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogMasterFileEntrySecIdGet(): rc[0x %x]", rc)); return rc; } rc = clBufferCreate(&hFileEntryBuf); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clBufferCreate(): rc[0x %x]", rc)); clHeapFree(pSecId->id); return rc; } rc = clXdrMarshallClVersionT(&version, hFileEntryBuf, 0); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallClVersionT(): rc[%#x]", rc)); CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK); clHeapFree(pSecId->id); return rc; } rc = clLogMasterFileKeyPack(pFileKey, hFileEntryBuf); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogMasterFileKeyPack(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK); clHeapFree(pSecId->id); return rc; } rc = clLogMasterFileDataPack(pFileData, hFileEntryBuf); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogMasterFileDataPack(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK); clHeapFree(pSecId->id); return rc; } rc = clBufferLengthGet(hFileEntryBuf, pBufferLen); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clBufferLengthGet: rc[0x %x]", rc)); CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK); clHeapFree(pSecId->id); return rc; } /* rc = clBufferFlatten(hFileEntryBuf, ppBuffer); */ *ppBuffer = (ClUint8T*) clHeapCalloc(*pBufferLen, sizeof(ClCharT)); if( NULL == *ppBuffer ) { CL_LOG_DEBUG_ERROR(("clHeapCalloc()")); CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK); clHeapFree(pSecId->id); return rc; } rc = clBufferNBytesRead(hFileEntryBuf, (ClUint8T *) *ppBuffer, pBufferLen); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clBufferFlatten(): rc[0x %x]", rc)); clHeapFree(*ppBuffer); CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK); clHeapFree(pSecId->id); return rc; } CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK); CL_LOG_DEBUG_TRACE(("Exit")); return rc; }
ClRcT clCkptMasterPeerUpdateNoLock(ClIocPortT portId, ClUint32T flag, ClIocNodeAddressT localAddr, ClUint8T credential) { ClRcT rc = CL_OK; CkptPeerInfoT *pPeerInfo = NULL; CkptNodeListInfoT *pPeerInfoDH = NULL; ClCntNodeHandleT nodeHdl = 0; ClCntNodeHandleT tempHdl = 0; ClHandleT *pMasterHandle = NULL; /* * Check whether node/component is coming up or going down. */ if(flag == CL_CKPT_SERVER_UP) { /* * Checkpoint server up scenario. */ clLogDebug(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_ANNOUNCE, "Received welcome message from master, updating the peerlist for [%d]", localAddr); /* Reset the replica list for peer being welcomed without knowing the peer is available or not */ if(localAddr != gCkptSvr->localAddr) { clLogNotice("PEER", "UPDATE", "Resetting the replica list for the peer [%#x] being welcomed", localAddr); clCkptMasterReplicaListUpdateNoLock(localAddr); } /* * Add an entry to the peer list if not existing. * Mark the node as "available" i.e. available for checkpoint * operations like storing replicas etc.. */ rc = clCntDataForKeyGet( gCkptSvr->masterInfo.peerList, (ClPtrT)(ClWordT)localAddr, (ClCntDataHandleT *)&pPeerInfo); if( rc == CL_OK && pPeerInfo != NULL) { CL_ASSERT(pPeerInfo->ckptList != 0); pPeerInfo->credential = credential; pPeerInfo->available = CL_CKPT_NODE_AVAIL; if(localAddr != gCkptSvr->localAddr) { pPeerInfo->replicaCount = 0; } } else { if( CL_OK !=( rc = _ckptMasterPeerListInfoCreate(localAddr, credential,0))) { return rc; } } } else { /* * Node/component down scenario. */ clLogDebug(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Updating the peerAddr [%d] for down notification", localAddr); /* * Find the corresponding entry from the peer list. */ if( CL_OK != (rc = clCntDataForKeyGet(gCkptSvr->masterInfo.peerList, (ClCntKeyHandleT)(ClWordT)localAddr, (ClCntDataHandleT *) &pPeerInfo))) { rc = CL_OK; goto exitOnError; } if( flag != CL_CKPT_COMP_DOWN) { clLogDebug(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Either ckpt server or node down, " "changing active address"); clCntFirstNodeGet(pPeerInfo->mastHdlList,&nodeHdl); tempHdl = 0; while(nodeHdl != 0) { rc = clCntNodeUserKeyGet(pPeerInfo->mastHdlList,nodeHdl, (ClCntKeyHandleT *)&pMasterHandle); if( CL_OK != rc ) { clLogError(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Not able get the data for node handle rc[0x %x]", rc); goto exitOnError; } rc = clCntNextNodeGet(pPeerInfo->mastHdlList, nodeHdl, &tempHdl); /* * Update the active address and inform the clients. */ if( CL_OK != (rc = _clCkpMastertReplicaAddressUpdate(*pMasterHandle, localAddr))) { return rc; } nodeHdl = tempHdl; tempHdl = 0; } } if (flag != CL_CKPT_SVR_DOWN) { /* * Component down/ node down case. * In case of component down close the associated client Hdl. * Incase of node down close all client Hdl. * Delete the ckpt Hdls from the client handle List. */ clLogDebug(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Closing the opened handles from this slot id [%d]...", localAddr); clCntFirstNodeGet(pPeerInfo->ckptList,&nodeHdl); while(nodeHdl != 0) { rc = clCntNodeUserDataGet(pPeerInfo->ckptList,nodeHdl, (ClCntDataHandleT *)&pPeerInfoDH); if( CL_OK != rc ) { clLogError(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Not able get the data for node handle rc[0x %x]", rc); goto exitOnError; } clCntNextNodeGet(pPeerInfo->ckptList,nodeHdl,&tempHdl); if ( (flag == CL_CKPT_COMP_DOWN && pPeerInfoDH->appPortNum == portId) || (flag == CL_CKPT_NODE_DOWN) ) { /* * Close the checkpoint hdl but dont delete the entry from * masterHdl list. */ if(gCkptSvr->masterInfo.masterAddr == gCkptSvr->localAddr) { clLogInfo(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Closing the handle [%#llX]...", pPeerInfoDH->clientHdl); _clCkptMasterCloseNoLock(pPeerInfoDH->clientHdl, localAddr, !CL_CKPT_MASTER_HDL); } } nodeHdl = tempHdl; tempHdl = 0; } } else if (flag == CL_CKPT_SVR_DOWN) { /* * Mark the availability of checkpoint server as UNAVAILABLE. */ if(pPeerInfo->credential == CL_CKPT_CREDENTIAL_POSITIVE) gCkptSvr->masterInfo.availPeerCount--; pPeerInfo->available = CL_CKPT_NODE_UNAVAIL; } if(flag == CL_CKPT_NODE_DOWN || flag == CL_CKPT_SVR_DOWN) { /* * Node down case, delete the entry from master's peer list. */ rc = clCntAllNodesForKeyDelete(gCkptSvr->masterInfo.peerList, (ClPtrT)(ClWordT)localAddr); CKPT_ERR_CHECK(CL_CKPT_SVR,CL_LOG_SEV_ERROR, (" MasterPeerUpdate failed rc[0x %x]\n",rc), rc); } if( flag != CL_CKPT_COMP_DOWN) { /* * Find other nodes to store the replicas of checkpoints for whom * this node was storing the replicas. */ if(gCkptSvr->masterInfo.masterAddr == gCkptSvr->localAddr) { _ckptCheckpointLoadBalancing(); } } } exitOnError: { return rc; } }