ClRcT clLogClntStreamEntryGet(ClLogClntEoDataT *pClntEoEntry, SaNameT *pStreamName, SaNameT *pNodeName, ClStringT *pShmName, ClUint32T shmSize, ClCntNodeHandleT *phStreamNode, ClBoolT *pAddedEntry) { ClRcT rc = CL_OK; ClLogStreamKeyT *pStreamKey = NULL; CL_LOG_DEBUG_TRACE(("Enter")); *pAddedEntry = CL_FALSE; rc = clLogClntEoEntryGet(&pClntEoEntry); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogClntEoEntryGet(): rc[0x %x]", rc)); return rc; } rc = clLogStreamKeyCreate(pStreamName, pNodeName, pClntEoEntry->maxStreams, &pStreamKey); if( CL_OK != rc ) { return rc; } rc = clCntNodeFind(pClntEoEntry->hClntStreamTable, (ClCntKeyHandleT) pStreamKey, phStreamNode); if( CL_ERR_NOT_EXIST == CL_GET_ERROR_CODE(rc) ) { rc = clLogClntStreamEntryAdd(pClntEoEntry->hClntStreamTable, pStreamKey, pShmName, shmSize, phStreamNode); if( CL_OK != rc ) { clLogStreamKeyDestroy(pStreamKey); } else { *pAddedEntry = CL_TRUE; } return rc; } clLogStreamKeyDestroy(pStreamKey); CL_LOG_DEBUG_TRACE(("Exit")); return rc; }
static ClRcT clLogMasterStreamTableRecreate(ClLogSvrCommonEoDataT *pCommonEoEntry, ClBufferHandleT hFileEntryBuf, ClLogFileDataT *pFileData) { ClRcT rc = CL_OK; ClLogStreamKeyT streamKey = {{0}}; ClLogStreamKeyT *pStreamKey = NULL; ClLogMasterStreamDataT *pStreamData = NULL; ClCntNodeHandleT hStreamNode = CL_HANDLE_INVALID_VALUE; ClUint32T bitNum = 0; ClLogMasterEoDataT *pMasterEoEntry = NULL; CL_LOG_DEBUG_TRACE(("Enter")); rc = clLogMasterEoEntryGet(&pMasterEoEntry, &pCommonEoEntry); if( CL_OK != rc ) { return rc; } rc = clXdrUnmarshallSaNameT(hFileEntryBuf, &(streamKey.streamName)); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallSaNameT(): rc[0x %x]", rc)); return rc; } rc = clXdrUnmarshallSaNameT(hFileEntryBuf, &(streamKey.streamScopeNode)); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallSaNameT(): rc[0x %x]", rc)); return rc; } rc = clLogStreamKeyCreate(&streamKey.streamName, &streamKey.streamScopeNode, pCommonEoEntry->maxStreams, &pStreamKey); if( CL_OK != rc ) { return rc; } pStreamData = (ClLogMasterStreamDataT*) clHeapCalloc(1, sizeof(ClLogMasterStreamDataT)); if( NULL == pStreamData ) { CL_LOG_DEBUG_ERROR(("clHeapCalloc()")); clLogStreamKeyDestroy(pStreamKey); return rc; } rc = clXdrUnmarshallClUint64T(hFileEntryBuf, &(pStreamData->streamMcastAddr)); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallClUint64T(): rc[0x %x]", rc)); clHeapFree(pStreamData); clLogStreamKeyDestroy(pStreamKey); return rc; } rc = clXdrUnmarshallClUint16T(hFileEntryBuf, &(pStreamData->streamId)); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallClUint16T(): rc[0x %x]", rc)); clHeapFree(pStreamData); clLogStreamKeyDestroy(pStreamKey); return rc; } rc = clCntNodeAddAndNodeGet(pFileData->hStreamTable, (ClCntKeyHandleT) pStreamKey, (ClCntDataHandleT) pStreamData, NULL, &hStreamNode); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntNodeAdd(): rc[0x %x]", rc)); clHeapFree(pStreamData); clLogStreamKeyDestroy(pStreamKey); return rc; } /* Find out the partiuclar stream is still valid */ if( strncmp(gStreamScopeGlobal, (const ClCharT *)pStreamKey->streamScopeNode.value, pStreamKey->streamScopeNode.length) && CL_FALSE == clLogMasterStreamIsValid(&pStreamKey->streamScopeNode)) { /* * marking this as invalid by assigining CL_IOC_RESERVED_ADDRESS * so that streamMcastAddr will not be allocated & bit will not be set * numActive streams count also will be valid */ pStreamData->streamMcastAddr = CL_IOC_RESERVED_ADDRESS; clLogNotice(CL_LOG_AREA_FILE_OWNER, CL_LOG_CTX_FO_INIT, "Invalidating the stream [%.*s:%.*s]", pStreamKey->streamScopeNode.length, pStreamKey->streamScopeNode.value, pStreamKey->streamName.length, pStreamKey->streamName.value); } if( CL_IOC_RESERVED_ADDRESS != pStreamData->streamMcastAddr ) { bitNum = pStreamData->streamMcastAddr - pMasterEoEntry->startMcastAddr; CL_LOG_DEBUG_TRACE(("bitNUm: %d pStreamData->streamMcastAddr : %lld \n", bitNum, pStreamData->streamMcastAddr)); rc = clBitmapBitSet(pMasterEoEntry->hAllocedAddrMap, bitNum); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clBitmapBitClear()")); CL_LOG_CLEANUP(clCntNodeDelete(pFileData->hStreamTable, hStreamNode), CL_OK); } pFileData->nActiveStreams++; clLogInfo(CL_LOG_AREA_MASTER, CL_LOG_CTX_CKPT_READ, "Active stream [%.*s:%.*s] has been added", pStreamKey->streamScopeNode.length, pStreamKey->streamScopeNode.value, pStreamKey->streamName.length, pStreamKey->streamName.value); } CL_LOG_DEBUG_TRACE(("Exit")); return CL_OK; }
static ClRcT clLogSvrStreamEntryUnpackNAdd(ClLogSvrEoDataT *pSvrEoEntry, ClLogSvrCommonEoDataT *pSvrCommonEoEntry, ClBufferHandleT msg, ClUint32T dsId) { ClRcT rc = CL_OK; SaNameT streamName = {0}; SaNameT streamScopeNode = {0}; ClUint32T compTableSize = 0; ClCntNodeHandleT hSvrStreamNode = CL_HANDLE_INVALID_VALUE; ClLogStreamKeyT *pStreamKey = NULL; ClStringT shmName = {0}; ClStringT fileName = {0}; ClStringT fileLocation = {0}; CL_LOG_DEBUG_TRACE(("Enter")); rc = clLogSvrStreamTableGet(pSvrEoEntry); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogSvrStreamTableCreate(): rc[0x %x]\n", rc)); return rc; } rc = clXdrUnmarshallSaNameT(msg, &streamName); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrUnmarshallSaNameT(): rc[0x %x]\n", rc)); return rc; } CL_LOG_DEBUG_VERBOSE(("streamName: %*s", streamName.length, streamName.value)); rc = clXdrUnmarshallSaNameT(msg, &streamScopeNode); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrUnmarshallSaNameT(): rc[0x %x]\n", rc)); return rc; } CL_LOG_DEBUG_VERBOSE(("streamScopeNode: %*s", streamScopeNode.length, streamScopeNode.value)); rc = clXdrUnmarshallClStringT(msg, &fileName); if(CL_OK != rc) { CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClStringT(): rc[%#x]\n", rc)); return rc; } rc = clXdrUnmarshallClStringT(msg, &fileLocation); if(CL_OK != rc) { CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClStringT(): rc[%#x]\n", rc)); return rc; } rc = clXdrUnmarshallClUint32T(msg, &compTableSize); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClUint32T(): rc[0x %x]\n", rc)); return rc; } CL_LOG_DEBUG_VERBOSE(("compSize : %u", compTableSize)); rc = clLogStreamKeyCreate(&streamName, &streamScopeNode, pSvrCommonEoEntry->maxStreams, &pStreamKey); if( CL_OK != rc ) { return rc; } rc = clLogShmNameCreate(&streamName,&streamScopeNode,&shmName); if( CL_OK != rc ) { return rc; } clLogInfo("LOG","CRT","Recreating log stream [%*s] shared memory [%*s] located at [%*s] from persistent checkpoint",streamName.length,streamName.value,shmName.length,shmName.pValue,streamScopeNode.length, streamScopeNode.value); rc = clLogSvrStreamEntryAdd(pSvrEoEntry, pSvrCommonEoEntry, pStreamKey, &shmName, &hSvrStreamNode); clHeapFree(shmName.pValue); shmName.pValue=NULL; shmName.length=0; if (CL_ERR_DUPLICATE == CL_GET_ERROR_CODE(rc)) /* But if it is a duplicate stream should we do the items below? (if so we need to load hSvrStreamNode...) */ { return rc; } if( CL_OK != rc ) { clLogStreamKeyDestroy(pStreamKey); return rc; } rc = clLogSvrCompEntryRecreate(pSvrCommonEoEntry, pSvrEoEntry,hSvrStreamNode, msg, compTableSize); if(( CL_OK != rc )&&(CL_ERR_DUPLICATE != CL_GET_ERROR_CODE(rc))) { CL_LOG_CLEANUP(clCntNodeDelete(pSvrEoEntry->hSvrStreamTable, hSvrStreamNode), CL_OK); return rc; } rc = clLogSvrShmOpenNFlusherCreate(pSvrEoEntry, &streamName, &streamScopeNode, &fileName, &fileLocation, hSvrStreamNode, dsId); if (( CL_OK != rc )&&(CL_ERR_DUPLICATE != CL_GET_ERROR_CODE(rc))) { CL_LOG_DEBUG_ERROR(("clLogSvrShmOpenAndFlusherCreate(): rc[0x %x]\n", rc)); CL_LOG_CLEANUP(clCntNodeDelete(pSvrEoEntry->hSvrStreamTable, hSvrStreamNode), CL_OK); } CL_LOG_DEBUG_TRACE(("Exit")); return rc; }
ClRcT clLogSOStreamEntryUnpackNAdd(ClLogSvrCommonEoDataT *pCommonEoData, ClBufferHandleT msg) { ClRcT rc = CL_OK; ClUint32T size = 0; ClUint32T count = 0; SaNameT streamName = {0}; SaNameT streamScopeNode = {0}; ClLogStreamOwnerDataIDLT soData = {0}; ClLogStreamKeyT *pStreamKey = NULL; ClCntHandleT hStreamTable = CL_HANDLE_INVALID_VALUE; ClLogStreamOwnerDataT *pStreamOwnerData = NULL; ClCntNodeHandleT hStreamOwnerNode = CL_HANDLE_INVALID_VALUE; ClLogStreamScopeT streamScope; ClLogSOEoDataT *pSoEoEntry = NULL; CL_LOG_DEBUG_TRACE(("Enter")); memset(&streamScope,0,sizeof(ClLogStreamScopeT)); rc = clXdrUnmarshallSaNameT(msg, &streamName); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallSaNameT(): rc[0x %x]", rc)); return rc; } CL_LOG_DEBUG_TRACE(("streamName: %*s", streamName.length, streamName.value)); rc = clXdrUnmarshallSaNameT(msg, &streamScopeNode); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallSaNameT(): rc[0x %x]", rc)); return rc; } CL_LOG_DEBUG_TRACE(("streamScopeNode: %*s", streamScopeNode.length, streamScopeNode.value)); rc = clLogStreamScopeGet(&streamScopeNode, &streamScope); if( CL_OK != rc ) { return rc; } CL_LOG_DEBUG_TRACE(("streamScope: %d \n", streamScope)); rc = VDECL_VER(clXdrUnmarshallClLogStreamOwnerDataIDLT, 4, 0, 0)(msg, &soData); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrMarshallSaNameT(): rc[0x %x]", rc)); return rc; } rc = clLogStreamOwnerStreamTableGet(&pSoEoEntry, streamScope); if( CL_OK != rc ) { clHeapFree(soData.streamAttr.fileName.pValue); clHeapFree(soData.streamAttr.fileLocation.pValue); return rc; } rc = clLogSOLock(pSoEoEntry, streamScope); if( CL_OK != rc ) { clHeapFree(soData.streamAttr.fileName.pValue); clHeapFree(soData.streamAttr.fileLocation.pValue); return rc; } rc = clLogStreamKeyCreate(&streamName, &streamScopeNode, pCommonEoData->maxStreams, &pStreamKey); if( CL_OK != rc ) { clHeapFree(soData.streamAttr.fileName.pValue); clHeapFree(soData.streamAttr.fileLocation.pValue); CL_LOG_CLEANUP(clLogSOUnlock(pSoEoEntry, streamScope), CL_OK); return rc; } hStreamTable = (CL_LOG_STREAM_GLOBAL == streamScope) ? pSoEoEntry->hGStreamOwnerTable : pSoEoEntry->hLStreamOwnerTable ; rc = clLogStreamOwnerEntryAdd(hStreamTable, streamScope, pStreamKey, &hStreamOwnerNode); if( CL_OK != rc ) { clHeapFree(pStreamKey); clHeapFree(soData.streamAttr.fileName.pValue); clHeapFree(soData.streamAttr.fileLocation.pValue); CL_LOG_CLEANUP(clLogSOUnlock(pSoEoEntry, streamScope), CL_OK); return rc; } rc = clCntNodeUserDataGet(hStreamTable, hStreamOwnerNode, (ClCntDataHandleT *) &pStreamOwnerData); if( CL_OK != rc ) { CL_LOG_CLEANUP(clCntNodeDelete(hStreamTable, hStreamOwnerNode), CL_OK); clHeapFree(soData.streamAttr.fileName.pValue); clHeapFree(soData.streamAttr.fileLocation.pValue); CL_LOG_CLEANUP(clLogSOUnlock(pSoEoEntry, streamScope), CL_OK); return rc; } pStreamOwnerData->nodeStatus = CL_LOG_NODE_STATUS_INIT; pStreamOwnerData->streamId = soData.streamId; pStreamOwnerData->streamMcastAddr = soData.streamMcastAddr; pStreamOwnerData->dsId = soData.dsId; pStreamOwnerData->isNewStream = soData.isNewStream; pStreamOwnerData->openCnt = soData.openCnt; pStreamOwnerData->ackerCnt = soData.ackerCnt; pStreamOwnerData->nonAckerCnt = soData.nonAckerCnt; clLogStreamAttributesCopy(&soData.streamAttr, &pStreamOwnerData->streamAttr, CL_TRUE); CL_LOG_DEBUG_TRACE(("streamId : %hu", soData.streamId)); CL_LOG_DEBUG_TRACE(("streamMcastAddr: %llu", soData.streamMcastAddr)); rc = clLogStreamOwnerFilterInfoUnpack(msg, pStreamOwnerData); if( CL_OK != rc ) { CL_LOG_CLEANUP(clCntNodeDelete(hStreamTable, hStreamOwnerNode), CL_OK); clHeapFree(soData.streamAttr.fileName.pValue); clHeapFree(soData.streamAttr.fileLocation.pValue); CL_LOG_CLEANUP(clLogSOUnlock(pSoEoEntry, streamScope), CL_OK); return rc; } clHeapFree(soData.streamAttr.fileName.pValue); clHeapFree(soData.streamAttr.fileLocation.pValue); rc = clXdrUnmarshallClUint32T(msg, &size); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClUint32T(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clCntNodeDelete(hStreamTable, hStreamOwnerNode), CL_OK); CL_LOG_CLEANUP(clLogSOUnlock(pSoEoEntry, streamScope), CL_OK); return rc; } CL_LOG_DEBUG_VERBOSE(("compSize : %u", size)); for(count = 0; count < size; count++) { rc = clLogCompEntryUnpackNAdd(msg, pStreamOwnerData); if( CL_OK != rc ) { if(CL_GET_ERROR_CODE(rc) == CL_ERR_DUPLICATE) { rc = CL_OK; } else { CL_LOG_CLEANUP(clCntNodeDelete(hStreamTable, hStreamOwnerNode), CL_OK); CL_LOG_CLEANUP(clLogSOUnlock(pSoEoEntry, streamScope), CL_OK); return rc; } } } CL_LOG_CLEANUP(clLogSOUnlock(pSoEoEntry, streamScope), CL_OK); CL_LOG_DEBUG_TRACE(("Exit")); return rc; }