ClRcT clCorMoIdNodeNameMapCreate(void)
{

    ClRcT rc;

    /* Create NODE NAME - MOID hash table */
    rc = clCntHashtblCreate(NODE_NAME_TO_MOID_NUM_BUCKETS,
                                                        clCorNodeNameTableNodeNameKeyCompare, 
                                                        clCorNodeNameTableNodeNameHashFn, 
                                                        clCorNodeNameTableNodeNameDeleteCallBack, 
                                                        clCorNodeNameTableNodeNameDestroyCallBack, 
                                                        CL_CNT_NON_UNIQUE_KEY,
                                                        &nodeNameToMoIdTableHandle);

    if(CL_OK != rc)
        CL_COR_RETURN_ERROR(CL_DEBUG_ERROR, "Could not create Hash Table", rc);    

    clCntHashtblCreate(MOID_TO_NODE_NAME_NUM_BUCKETS,
                                                        clCorNodeNameTableMoIdKeyCompare, 
                                                        clCorNodeNameTableMoIdHashFn, 
                                                        clCorNodeNameTableMoIdDeleteCallBack, 
                                                        clCorNodeNameTableMoIdDestroyCallBack, 
                                                        CL_CNT_UNIQUE_KEY,
                                                        &moIdToNodeNameTableHandle);

    if(CL_OK != rc)
        CL_COR_RETURN_ERROR(CL_DEBUG_ERROR, "Could not create Hash Table", rc);    

    return CL_OK;
    
}
static ClRcT
clLogMasterFileDataRecreate(ClLogFileDataT   *pFileData,
                            ClBufferHandleT  hFileEntryBuf)
{
    ClRcT                  rc              = CL_OK;
    ClUint32T              cntSize         = 0;
    ClLogSvrCommonEoDataT  *pCommonEoEntry = NULL;
    ClUint32T              count           = 0;

    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = clLogMasterEoEntryGet(NULL, &pCommonEoEntry);
    if( CL_OK != rc )
    {
        return rc;
    }

    rc = VDECL_VER(clXdrUnmarshallClLogStreamAttrIDLT, 4, 0, 0)(hFileEntryBuf,
            &(pFileData->streamAttr));
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR((
                               "clXdrUnmarshallClLogStreamAttributesT(): rc[0x %x]", rc));
        return rc;
    }

    rc = clXdrUnmarshallClUint32T(hFileEntryBuf, &cntSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClUint32T(): rc[0x %x]", rc));
        return rc;
    }

    rc = clCntHashtblCreate(pCommonEoEntry->maxStreams,
                            clLogStreamKeyCompare, clLogStreamHashFn,
                            clLogMasterStreamEntryDeleteCb,
                            clLogMasterStreamEntryDeleteCb, CL_CNT_UNIQUE_KEY,
                            &(pFileData->hStreamTable));
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clCntHashtbleCreate(): rc[0x %x]\n", rc));
        return rc;
    }

    for(count = 0; count < cntSize; count++)
    {
        rc = clLogMasterStreamTableRecreate(pCommonEoEntry, hFileEntryBuf,
                                            pFileData);
        if( CL_OK != rc )
        {
            /* Just keep on create as much as u can */
        }
    }

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}
ClRcT   _clGmsNameIdDbCreate (ClCntHandleT *dbPtr)
{
    ClRcT   rc = CL_OK;

    if (dbPtr == NULL)
    {
        return CL_ERR_NULL_POINTER;
    }

    /* Create the container */
    rc = clCntHashtblCreate(
            viewDbParams.htbleParams.gmsNumOfBuckets,
            viewDbParams.htbleParams.gmsHashKeyCompareCallback,
            viewDbParams.htbleParams.gmsHashCallback,
            viewDbParams.htbleParams.gmsHashDeleteCallback,
            viewDbParams.htbleParams.gmsHashDestroyCallback,
            CL_CNT_UNIQUE_KEY,
            dbPtr);

    return rc;
}
ClRcT
clLogClntStreamOpen(ClLogHandleT        hLog,
                    SaNameT             *pStreamName,
                    SaNameT             *pNodeName,
                    ClStringT           *pShmName,
                    ClUint32T           shmSize,
                    ClLogStreamHandleT  *phStream,
                    ClUint32T           recSize)
{
    ClRcT                 rc              = CL_OK;
    ClLogClntEoDataT      *pClntEoEntry   = NULL;
    ClBoolT               addedTable      = CL_FALSE;
    ClBoolT               addedEntry      = CL_FALSE;
    ClCntNodeHandleT      hClntStreamNode = CL_HANDLE_INVALID_VALUE;
    ClLogClntStreamDataT  *pUserData      = NULL;

    CL_LOG_DEBUG_TRACE(("Enter"));

    CL_LOG_PARAM_CHK((NULL == pStreamName), CL_LOG_RC(CL_ERR_NULL_POINTER));
    CL_LOG_PARAM_CHK((NULL == pNodeName), CL_LOG_RC(CL_ERR_NULL_POINTER));
    CL_LOG_PARAM_CHK((NULL == pShmName), CL_LOG_RC(CL_ERR_NULL_POINTER));
    CL_LOG_PARAM_CHK((sizeof(ClLogStreamHeaderT) > shmSize),
                      CL_LOG_RC(CL_ERR_INVALID_PARAMETER));
    CL_LOG_PARAM_CHK((NULL == phStream), CL_LOG_RC(CL_ERR_NULL_POINTER));

    rc = clLogClntEoEntryGet(&pClntEoEntry);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clLogClntEoEntryGet(): rc[0x %x]", rc));
        return rc;
    }

    rc = clOsalMutexLock_L(&(pClntEoEntry->clntStreamTblLock));
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clOsalMutexLock(): rc[0x %x]", rc));
        return rc;
    }

    if( CL_HANDLE_INVALID_VALUE == pClntEoEntry->hClntStreamTable )
    {
        rc = clCntHashtblCreate(pClntEoEntry->maxStreams,
                                clLogStreamKeyCompare,
                                clLogStreamHashFn,
                                clLogClntStreamDeleteCb,
                                clLogClntStreamDeleteCb,
                                CL_CNT_UNIQUE_KEY,
                                &(pClntEoEntry->hClntStreamTable));
        if( CL_OK != rc )
        {
            CL_LOG_DEBUG_ERROR(("clCntHashtblCreate(): rc[0x %x]", rc));
            CL_LOG_CLEANUP(
                clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)),CL_OK);
            return rc;
        }
        addedTable = CL_TRUE;
        CL_LOG_DEBUG_VERBOSE(("Created the HashTable"));
    }

    rc = clLogClntStreamEntryGet(pClntEoEntry, pStreamName, pNodeName,
                                 pShmName, shmSize, &hClntStreamNode,
                                 &addedEntry);
    if( CL_OK != rc)
    {
        if( CL_TRUE == addedTable )
        {
            CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK);
        }
        CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)),
                       CL_OK);
        return rc;
    }
    CL_LOG_DEBUG_VERBOSE(("Got the stream entry"));

    rc = clLogHandleStreamHandleCreate(hLog, hClntStreamNode, phStream);
    if( CL_OK != rc)
    {
        if( CL_TRUE == addedEntry )
        {
            CL_LOG_CLEANUP(clCntNodeDelete(pClntEoEntry->hClntStreamTable,
                                           hClntStreamNode), CL_OK);
        }
        if( CL_TRUE == addedTable )
        {
            CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK);
        }
        CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)),
                       CL_OK);
        return rc;
    }
    CL_LOG_DEBUG_VERBOSE(("Created the streamhandle"));

    rc = clCntNodeUserDataGet(pClntEoEntry->hClntStreamTable, hClntStreamNode,
                              (ClCntDataHandleT *) &pUserData);
    if( CL_OK != rc )
    {
        CL_LOG_CLEANUP(clHandleDestroy(pClntEoEntry->hClntHandleDB,
                                             *phStream), CL_OK);
        *phStream = CL_HANDLE_INVALID_VALUE;
        if( CL_TRUE == addedEntry )
        {
            CL_LOG_CLEANUP(clCntNodeDelete(pClntEoEntry->hClntStreamTable,
                                           hClntStreamNode), CL_OK);
        }

        if( CL_TRUE == addedTable )
        {
            CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK);
        }
        CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)),
                       CL_OK);
        return rc;
    }
#ifdef NO_SAF
    pUserData->recSize=recSize;
#endif
    CL_LOG_DEBUG_VERBOSE(("Got stream entry"));
    rc = clBitmapBitSet(pUserData->hStreamBitmap, CL_HDL_IDX(*phStream));
    if( CL_OK != rc )
    {
        CL_LOG_CLEANUP(clHandleDestroy(pClntEoEntry->hClntHandleDB, *phStream),
                       CL_OK);
        *phStream = CL_HANDLE_INVALID_VALUE;
        if( CL_TRUE == addedEntry )
        {
            CL_LOG_CLEANUP(clCntNodeDelete(pClntEoEntry->hClntStreamTable,
                                           hClntStreamNode), CL_OK);
        }

        if( CL_TRUE == addedTable )
        {
            CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK);
        }
        CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)),
                       CL_OK);
        return rc;
    }
    CL_LOG_DEBUG_VERBOSE(("Updated stream bitmap"));

    rc = clLogHandleInitHandleStreamAdd(hLog, *phStream);
    if( CL_OK != rc )
    {
        CL_LOG_CLEANUP(clBitmapBitClear(pUserData->hStreamBitmap, CL_HDL_IDX(*phStream)),
                       CL_OK);
        CL_LOG_CLEANUP(clHandleDestroy(pClntEoEntry->hClntHandleDB, *phStream),
                       CL_OK);
        *phStream = CL_HANDLE_INVALID_VALUE;
        if( CL_TRUE == addedEntry )
        {
            CL_LOG_CLEANUP(clCntNodeDelete(pClntEoEntry->hClntStreamTable,
                                           hClntStreamNode), CL_OK);
        }

        if( CL_TRUE == addedTable )
        {
            CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK);
        }
        CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)),
                       CL_OK);
        return rc;
    }
    CL_LOG_DEBUG_VERBOSE(("Updated init handle"));

    rc = clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock));
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clOsalMutexUnlock(): rc[0x %x]", rc));
        return rc;
    }

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}
/**
 *  Initializes the OM class table.                          
 *
 *  This API initializes the OM class lookup table from the pre-configured<br>
 *    tables: common and application.  It also initializes other tables <br>
 *    and prepares the OM library for usage by other components.
 *
 *  @param pOmCfgData Configuration data for OM
 *
 *  @returns
 *    CL_OK - everything is ok<br>
 *    ==>FIXME:Define(==>FIXME:Define(CL_ERR_INVLD_STATE)<==)<== - wrong initialization state<br>
 *    Runlevel error code - please reference the Runlevel error codes
 *
 */
ClRcT clOmLibInitialize()
{
    ClRcT		rc = CL_OK;
    ClUint32T	classIdx = 0;
    ClUint32T	omCfgDataSz = sizeof(ClOmConfigDataT);
    ClOmClassControlBlockT	*pOmClassEntry = NULL;

    /*
      ClUint32T      cmnOmClassCnt = 0; 
    */
    /*ClUint32T	omClassCnt = 0;
      ClUint32T	skippedClassCnt = 0;*/
    extern ClRcT showMgrModAdd(char *, char *, void (*fp)(char**));
    extern void omShow (char ** );


    CL_FUNC_ENTER();

    /*
     * Check if the OI has its own DB and reload its db
     */
    if(gClOIConfig.oiDBReload)
        return CL_OK;

    /* Get a count of the common classes */


    /* 
       Initialize config data struct and make a 
       copy of the configuration data. 
    */
    memset(&gOmCfgData, 0, omCfgDataSz);
    /* Fill up the gOmCfgData */
    gOmCfgData.maxOmClassBuckets = OM_CLASS_TABLE_MAX_BUCKETS;
    gOmCfgData.minAppOmClassType = OM_APP_MIN_CLASS_TYPE;
    gOmCfgData.maxAppOmClassType = OM_APP_MAX_CLASS_TYPE;
    gOmCfgData.numOfOmClasses = 0;

    /* Create a hash table for storing OM classes */
    rc = clCntHashtblCreate(gOmCfgData.maxOmClassBuckets, omClassKeyCompare, 
                            omClassHashFn, omClassEntryDelCallBack, 
                            omClassEntryDestroyCallBack, CL_CNT_NON_UNIQUE_KEY, &ghOmClassHashTbl);

    if ((rc != CL_OK) || (ghOmClassHashTbl == 0))
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("%s: Failed to create a hash table "
                                       "for OM classes (rc = 0x%x)!!!\n\r", 
                                       __FUNCTION__, rc));
        return (rc);
    }


    /* Consolidate OM class tables into a hash table */
    /* Configure the common OM class table */

    /* Initialize the base class here */


    if ((rc = clOmClassInitialize (&gBaseClassTable, 
                                   gBaseClassTable.eMyClassType, 
                                   gBaseClassTable.maxObjInst,
                                   gBaseClassTable.maxSlots)) != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("%s: Failed to initialize OM with rc = "
                                        "0x%x!\r\n", __FUNCTION__, rc));
        return (rc);
    }




    /* Accumulate the number of classes registered w/ OM */
    /*omClassCnt = classIdx;*/
    pOmClassEntry = NULL;

    /* Configure the application OM class table */
    classIdx = 0;

    if (appOmClassCnt > 0)
    {
        for (; classIdx < appOmClassCnt; classIdx++)
        {
            pOmClassEntry = &(pAppOmClassTbl[classIdx]);
            if (pOmClassEntry->eMyClassType == CL_OM_INVALID_CLASS)
            {
                /* skip invalid class */
                /* 
                   This way invalid classes and missing, i.e. a table
                   size if bigger than the number of classes
                   are allowed in the table.
                */
                /*skippedClassCnt++;*/
                continue;
            }

            if ((rc = clOmClassInitialize (pOmClassEntry, 
                                           pOmClassEntry->eMyClassType, 
                                           pOmClassEntry->maxObjInst,
                                           pOmClassEntry->maxSlots)) != CL_OK)
            {
                CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("%s: Failed to initialize OM with rc = "
                                                "0x%x!\r\n", __FUNCTION__, rc));
                return (rc);
            }
        }
    }
    else
    {
        CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("%s: Not initializing OM Application class "
                                        "table because it does not exist...ignoring.\r\n",
                                        __FUNCTION__));
    }

    /* Get the total number of classes registered w/ OM */
    /*gOmCfgData.numOfOmClasses = omClassCnt + classIdx - skippedClassCnt;*/

    /* Initialize the COR/OM handle translation table */
    if (rc == CL_OK)
    {
        if((rc = omCORTableInit()) != CL_OK)
        {
            CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Failed to setup the COR translation "
                                            "table with rc = 0x%x\r\n", rc));
        }
    }

#ifdef DEBUG
    /* Add OM into the debug agent */
    if (!omClassInitState)
        dbgAddComponent(COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR);
#endif

    omClassInitState = CL_TRUE;
    /* add the om to show manager */ 
    /*@todo: Navdeep (show manager dependency) 
      showMgrModAdd(COMP_PREFIX, COMP_NAME, omShow); 
    */
    CL_FUNC_EXIT();
    return (rc);
}
ClRcT clOmLibInitializeExtended(void)
{
    ClRcT		rc = CL_OK;
    ClUint32T	classIdx = 0;
    ClUint32T	omCfgDataSz = sizeof(ClOmConfigDataT);
    ClOmClassControlBlockT	*pOmClassEntry = NULL;
    ClCharT oiClassFile[CL_MAX_NAME_LENGTH] = {0};
    ClCharT oiRouteFile[CL_MAX_NAME_LENGTH] = {0};
    ClCharT *pOIClassFile = oiClassFile;
    ClCharT *pOIRouteFile = oiRouteFile;
    extern ClRcT showMgrModAdd(char *, char *, void (*fp)(char**));
    extern void omShow (char ** );


    CL_FUNC_ENTER();

    /*
     *First load the OI class configuration. into COR
     */
    if(!gClOIConfig.pOIClassFile)
    {
        clLogError("OI", "CONFIG", "No OI class file is specified to configure the OI classes");
        return CL_OM_SET_RC(CL_ERR_INVALID_PARAMETER);
    }
    if(!gClOIConfig.pOIRouteFile)
    {
        clLogError("OI", "CONFIG", "No OI route file is specified to configure the OI objects");
        return CL_OM_SET_RC(CL_ERR_INVALID_PARAMETER);
    }

    if(gClOIConfig.pOIClassPath)
        snprintf(oiClassFile, sizeof(oiClassFile), "%s/%s", gClOIConfig.pOIClassPath, 
                 gClOIConfig.pOIClassFile);
    else
        pOIClassFile = (ClCharT*)gClOIConfig.pOIClassFile;

    if(gClOIConfig.pOIRoutePath)
        snprintf(oiRouteFile, sizeof(oiRouteFile), "%s/%s", gClOIConfig.pOIRoutePath,
                 gClOIConfig.pOIRouteFile);
    else
        pOIRouteFile = (ClCharT*)gClOIConfig.pOIRouteFile;

    rc = clCorConfigLoad(pOIClassFile, pOIRouteFile);
    if(rc != CL_OK)
    {
        clLogError("OI", "CONFIG", "Loading OI class configuration [%s] to COR returned with error [%#x]",
                   pOIClassFile, rc);
        return rc;
    }

    /* 
       Initialize config data struct and make a 
       copy of the configuration data. 
    */
    memset(&gOmCfgData, 0, omCfgDataSz);
    /* Fill up the gOmCfgData */
    gOmCfgData.maxOmClassBuckets = OM_CLASS_TABLE_MAX_BUCKETS;
    gOmCfgData.minAppOmClassType = OM_APP_MIN_CLASS_TYPE;
    gOmCfgData.maxAppOmClassType = OM_APP_MAX_CLASS_TYPE;
    gOmCfgData.numOfOmClasses = 0;

    /* Create a hash table for storing OM classes */
    rc = clCntHashtblCreate(gOmCfgData.maxOmClassBuckets, omClassKeyCompare, 
                            omClassHashFn, omClassEntryDelCallBack, 
                            omClassEntryDestroyCallBack, CL_CNT_NON_UNIQUE_KEY, &ghOmClassHashTbl);

    rc |= clCntHashtblCreate(gOmCfgData.maxOmClassBuckets, omClassNameKeyCompare, 
                            omClassNameHashFn, omClassEntryDelCallBack, 
                            omClassEntryDestroyCallBack, CL_CNT_NON_UNIQUE_KEY, &ghOmClassNameHashTbl);

    if ((rc != CL_OK) || (ghOmClassHashTbl == 0) 
        || (ghOmClassNameHashTbl == 0))
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("%s: Failed to create a hash table "
                                       "for OM classes (rc = 0x%x)!!!\n\r", __FUNCTION__, rc));
        return (rc);
    }


    /* Consolidate OM class tables into a hash table */
    /* Configure the common OM class table */

    /* Initialize the base class here */


    if ((rc = clOmClassInitialize (&gBaseClassTable, 
                                   gBaseClassTable.eMyClassType, 
                                   gBaseClassTable.maxObjInst,
                                   gBaseClassTable.maxSlots)) != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("%s: Failed to initialize OM with rc = "
                                        "0x%x!\r\n", __FUNCTION__, rc));
        return (rc);
    }


    /* Accumulate the number of classes registered w/ OM */
    /*omClassCnt = classIdx;*/
    pOmClassEntry = NULL;

    /* Configure the application OM class table */
    classIdx = 0;

    if (appOmClassCnt > 0)
    {
        for (; classIdx < appOmClassCnt; classIdx++)
        {
            pOmClassEntry = &(pAppOmClassTbl[classIdx]);
            if (pOmClassEntry->eMyClassType == CL_OM_INVALID_CLASS)
            {
                /* skip invalid class */
                /* 
                   This way invalid classes and missing, i.e. a table
                   size if bigger than the number of classes
                   are allowed in the table.
                */
                /*skippedClassCnt++;*/
                continue;
            }

            if ((rc = clOmClassNameInitialize (pOmClassEntry, 
                                               pOmClassEntry->className,
                                               pOmClassEntry->maxObjInst,
                                               pOmClassEntry->maxSlots)) != CL_OK)
            {
                CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("%s: Failed to initialize OM with rc = "
                                                "0x%x!\r\n", __FUNCTION__, rc));
                return (rc);
            }
        }
    }
    else
    {
        CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("%s: Not initializing OM Application class "
                                        "table because it does not exist...ignoring.\r\n",
                                        __FUNCTION__));
    }

    /* Get the total number of classes registered w/ OM */
    /*gOmCfgData.numOfOmClasses = omClassCnt + classIdx - skippedClassCnt;*/

    /* Initialize the COR/OM handle translation table */
    if (rc == CL_OK)
    {
        if((rc = omCORTableInit()) != CL_OK)
        {
            CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Failed to setup the COR translation "
                                            "table with rc = 0x%x\r\n", rc));
        }
    }

#ifdef DEBUG
    /* Add OM into the debug agent */
    if (!omClassInitState)
        dbgAddComponent(COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR);
#endif

    omClassInitState = CL_TRUE;
    /* add the om to show manager */ 
    /*@todo: Navdeep (show manager dependency) 
      showMgrModAdd(COMP_PREFIX, COMP_NAME, omShow); 
    */
    CL_FUNC_EXIT();
    return (rc);
}
/*  FIXME:
 */
ClRcT   _clGmsDbCreate(
           CL_IN        ClGmsDbT*  const      gmsDb,
           CL_OUT       ClGmsDbT** const      gmsElement)
{
    ClRcT       rc = CL_OK;
    ClUint32T   i = 0;
    ClUint64T   cntIndex = 0;

    if ((gmsDb == NULL) || (gmsElement == NULL))
    {
        return CL_GMS_RC(CL_ERR_NULL_POINTER);
    }

    for(i = 0; i < gmsGlobalInfo.config.noOfGroups; i++)
    {
        if (gmsDb[i].view.isActive == CL_FALSE)
        {
            cntIndex = i;
            break;
        }
    }
    if (i == gmsGlobalInfo.config.noOfGroups)
    {
        return CL_ERR_OUT_OF_RANGE;
    }

    /* Current view database. Holds cluster and groups info */


    rc = clCntHashtblCreate(
                      viewDbParams.htbleParams.gmsNumOfBuckets, 
                      viewDbParams.htbleParams.gmsHashKeyCompareCallback, 
                      viewDbParams.htbleParams.gmsHashCallback,
                      viewDbParams.htbleParams.gmsHashDeleteCallback,
                      viewDbParams.htbleParams.gmsHashDestroyCallback,
                      CL_CNT_UNIQUE_KEY, 
                      &gmsDb[cntIndex].htbl[CL_GMS_CURRENT_VIEW]);

    if (rc != CL_OK)
    {
        return rc;
    }

    /* Cluster joined/left view list. Used for tracking */

    rc = clCntHashtblCreate(
                      viewDbParams.htbleParams.gmsNumOfBuckets, 
                      viewDbParams.htbleParams.gmsHashKeyCompareCallback, 
                      viewDbParams.htbleParams.gmsHashCallback,
                      viewDbParams.htbleParams.gmsHashDeleteCallback,
                      viewDbParams.htbleParams.gmsHashDestroyCallback,
                      CL_CNT_UNIQUE_KEY, 
                      &gmsDb[cntIndex].htbl[CL_GMS_JOIN_LEFT_VIEW]);

    if (rc != CL_OK)
    {
        return rc;
    }

    /* Track hash table create */

    rc = clCntHashtblCreate(
                viewDbParams.trackDbParams->htbleParams.gmsNumOfBuckets, 
                viewDbParams.trackDbParams->htbleParams.
                                                 gmsHashKeyCompareCallback, 
                viewDbParams.trackDbParams->htbleParams.gmsHashCallback,
                viewDbParams.trackDbParams->htbleParams.
                                                     gmsHashDeleteCallback,
                viewDbParams.trackDbParams->htbleParams.
                                                        gmsHashDestroyCallback,
                CL_CNT_UNIQUE_KEY, 
                &gmsDb[cntIndex].htbl[CL_GMS_TRACK]);

    if (rc != CL_OK)
    {
        return rc;
    }

    clGmsMutexCreate(&gmsDb[cntIndex].viewMutex);


    clGmsMutexCreate(&gmsDb[cntIndex].trackMutex);


    gmsDb[cntIndex].view.isActive = CL_TRUE;

    clLog(DBG,GEN,DB,
            "Created View and Track DB for GroupId [%lld]",cntIndex);

    *gmsElement = &gmsDb[cntIndex++];

    return rc;
}
Пример #8
0
ClRcT clRmdObjInit(ClRmdObjHandleT *p)
{
    ClRcT retCode = CL_OK;
    ClRmdObjT *pRmdObject = NULL;
    //unsigned long timeStamp = 0;
    struct timeval tm1;

#ifdef DEBUG
    static ClUint8T rmdAddedTodbgComp = CL_FALSE;

    if (CL_FALSE == rmdAddedTodbgComp)
    {
        retCode = dbgAddComponent(COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR);
        rmdAddedTodbgComp = CL_TRUE;
        if (CL_OK != retCode)
        {
            clLogError("OBG","INI","dbgAddComponent FAILED ");
            CL_FUNC_EXIT();
            return retCode;
        }
    }
#endif
    CL_FUNC_ENTER();

    if (NULL == p)
    {
        RMD_DBG1((" RMD Invalid Object handle passed\n"));
        CL_FUNC_EXIT();
        return ((CL_RMD_RC(CL_ERR_INVALID_PARAMETER)));
    }

    retCode = clOsalInitialize(NULL);

    retCode = clTimerInitialize(NULL);
    pRmdObject = (ClRmdObjT *) clHeapAllocate(sizeof(ClRmdObjT));

    if (NULL == pRmdObject)
    {
        RMD_DBG1((" RMD No Memory\n"));
        CL_FUNC_EXIT();
        return ((CL_RMD_RC(CL_ERR_NO_MEMORY)));
    }

    gettimeofday(&tm1, NULL);
    //timeStamp = tm1.tv_sec * 1000000 + tm1.tv_usec;
    pRmdObject->msgId = 1;
    retCode = clOsalMutexCreate(&pRmdObject->semaForSendHashTable);

    if (CL_OK != CL_GET_ERROR_CODE(retCode))
    {
        RMD_DBG1((" RMD send Mutex creation failed\n"));
        CL_FUNC_EXIT();
        return (retCode);
    }
    retCode = clOsalMutexCreate(&pRmdObject->semaForRecvHashTable);

    if (CL_OK != CL_GET_ERROR_CODE(retCode))
    {
        RMD_DBG1((" RMD  recv Mutex creation failed\n"));

        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable));
        CL_FUNC_EXIT();
        return (retCode);
    }

    retCode =
        clCntHashtblCreate(NUMBER_OF_RECV_BUCKETS, recvKeyCompare,
                           recvHashFunction, recvHashDeleteCallBack,
                           recvHashDeleteCallBack, CL_CNT_UNIQUE_KEY,
                           &pRmdObject->rcvRecContainerHandle);
    if (CL_OK != CL_GET_ERROR_CODE(retCode))
    {
        RMD_DBG1((" RMD  send Hash table creation failed\n"));

        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForRecvHashTable));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable));
        CL_FUNC_EXIT();
        return (retCode);
    }
    retCode =
        clCntHashtblCreate(NUMBER_OF_SEND_BUCKETS, sendKeyCompare,
                           sendHashFunction, sendHashDeleteCallBack,
                           sendHashDestroyCallBack, CL_CNT_UNIQUE_KEY,
                           &pRmdObject->sndRecContainerHandle);
    if (CL_OK != CL_GET_ERROR_CODE(retCode))
    {
        RMD_DBG1((" RMD  recv Hash table creation failed\n"));

        IGNORE_RETURN(clCntDelete(pRmdObject->rcvRecContainerHandle));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForRecvHashTable));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable));
        CL_FUNC_EXIT();
        return (retCode);
    }

    pRmdObject->responseCntxtDbHdl = 0;
    retCode = clHandleDatabaseCreate(NULL, &pRmdObject->responseCntxtDbHdl);
    if (retCode != CL_OK)
    {
        RMD_DBG1((" RMD  Sync Handle Database create failed\n"));
        IGNORE_RETURN(clCntDelete(pRmdObject->sndRecContainerHandle));
        IGNORE_RETURN(clCntDelete(pRmdObject->rcvRecContainerHandle));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForRecvHashTable));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable));

        CL_FUNC_EXIT();
        return retCode;
    }

    pRmdObject->numAtmostOnceEntry = 0;
    pRmdObject->lastAtmostOnceCleanupTime = clOsalStopWatchTimeGet();
    pRmdObject->rmdStats.nRmdCalls = 0;
    pRmdObject->rmdStats.nFailedCalls = 0;
    pRmdObject->rmdStats.nResendRequests = 0;
    pRmdObject->rmdStats.nRmdReplies = 0;
    pRmdObject->rmdStats.nBadReplies = 0;
    pRmdObject->rmdStats.nRmdRequests = 0;
    pRmdObject->rmdStats.nBadRequests = 0;
    pRmdObject->rmdStats.nCallTimeouts = 0;
    pRmdObject->rmdStats.nDupRequests = 0;
    pRmdObject->rmdStats.nAtmostOnceCalls = 0;
    pRmdObject->rmdStats.nResendReplies = 0;
    pRmdObject->rmdStats.nReplySend = 0;
    pRmdObject->rmdStats.nRmdCallOptimized = 0;
    *p = (ClRmdObjHandleT) pRmdObject;
    CL_FUNC_EXIT();
    return (CL_OK);
}