OpenClovis Logo

API Usage Examples
Performance Management Library

Code Examples. More...

Code Examples.

The PM MSOs can be configured to be autocreated in IDE in which case COR server will create it when the node is coming up. Otherwise it can be created later by the user explicitly using COR Apis. Please refer COR section in this API reference guide for the usage examples.

The below code shows how to register the resources (or MOs) with the PM library so that the PM operation will be performed on those MOs.

ClRcT rc = CL_OK;
//Resource names on which PM operation has to be started.
ClCharT* resources[] = {
"\\Chassis:0\\CorFunTestL1:0\\corFunMOCommB1L3:0",
"\\Chassis:0\\CorFunTestL1:0\\corFunMOCommB1L3:2",
"\\Chassis:0\\CorFunTestL1:0\\corFunMOCommB1L3:3",
"\\Chassis:0\\CorFunTestL1:0\\corFunMOCommB1L3:4"
};
ClUint32T count = 4;
ClUint32T i = 0;
ClNameT moIdName = {0};
pMoIdList = (ClCorMOIdListPtrT) clHeapAllocate( sizeof(ClCorMOIdListT) + (count - 1) * sizeof(ClCorMOIdT));
//Populate pMoIdList to be registered with PM.
for (i=0 ; i<count; i++)
{
clNameSet(&moIdName, resources[i]);
//Get the MoId from the name.
rc = clCorMoIdNameToMoIdGet(&moIdName, &pMoIdList->moId[i]);
if (rc != CL_OK)
{
clLogError("APP", "INT", "Failed to get moId from moId name. rc [0x%x]", rc);
clHeapFree(pMoIdList);
return rc;
}
//Set the PM MSO service.
clCorMoIdServiceSet(&pMoIdList->moId[i], CL_COR_SVC_ID_PM_MANAGEMENT);
}
pMoIdList->moIdCnt = count;
//Start the PM operation.
rc = clPMStart(pMoIdList);
if (rc != CL_OK)
{
clLogError("APP", "INT", "Failed to start PM operation on the given Moid list. rc [0x%x]", rc);
clHeapFree(pMoIdList);
return rc;
}

The below code shows the Primary OI implementation for PM Read

ClRcT clCompAppPMObjectRead(ClHandleT txnHandle, ClPMObjectDataPtrT pObjectData)
{
ClUint32T i = 0;
clLogNotice("APP", "READ", "***Invoking read callback function***");
clLogNotice("APP", "READ", "INFO : MoId :");
clCorMoIdShow(pObjectData->pMoId);
clLogNotice("APP", "READ", "Attr Count : [%u]", pObjectData->attrCount);
for (i=0; i<pObjectData->attrCount; i++)
{
clLogNotice("APP", "READ", "--------------------");
clLogNotice("APP", "READ", "Attr Id : [%d]", pObjectData->pAttrData[i].attrId);
clLogNotice("APP", "READ", "Attr Type : [%d]", pObjectData->pAttrData[i].attrType);
clLogNotice("APP", "READ", "Attr DataType : [%d]", pObjectData->pAttrData[i].attrDataType);
clLogNotice("APP", "READ", "Attr Size : [%u]", pObjectData->pAttrData[i].size);
clLogNotice("APP", "READ", "Attr Index : [%d]", pObjectData->pAttrData[i].index);
//This sample code assumes that all attributes read are of ClInt8T type.
clLogNotice("APP", "READ", "Return value [%d]", i);
*(ClInt8T *) pObjectData->pAttrData[i].pPMData = i;
clLogNotice("APP", "READ", "--------------------");
}
return CL_OK;
}

The below code shows how to access the PM reset value. The user is supposed to reset all the PM attributes depending on the PM reset value.

ClRcT clCompAppPMObjectReset(ClHandleT txnHandle, ClPMObjectDataPtrT pObjectData)
{
clLogNotice("APP", "RESET", "***Invoking RESET callback function***");
clLogNotice("APP", "RESET", "--------------------");
clLogNotice("APP", "RESET", "INFO : MoId :");
clCorMoIdShow(pObjectData->pMoId);
clLogNotice("APP", "RESET", "Attr Id : [%d]", pObjectData->pAttrData[0].attrId);
clLogNotice("APP", "RESET", "Attr Type : [%d]", pObjectData->pAttrData[0].attrType);
clLogNotice("APP", "RESET", "Attr DataType : [%d]", pObjectData->pAttrData[0].attrDataType);
clLogNotice("APP", "RESET", "Attr Size : [%u]", pObjectData->pAttrData[0].size);
clLogNotice("APP", "RESET", "Attr Index : [%d]", pObjectData->pAttrData[0].index);
clLogNotice("APP", "RESET", "Reset Value [%d]", *(ClInt8T *) pObjectData->pAttrData[0].pPMData);
clLogNotice("APP", "RESET", "--------------------");
return CL_OK;
}

The below code shows how to stop PM operation on a particular set of MoIds.

//Stop the PM operation on the first two resources in the above list.
pMoIdList->moIdCnt = 2;
rc = clPMStop(pMoIdList);
if (rc != CL_OK)
{
clLogError("APP", "RESET", "Failed to stop PM operation on the moId list. rc [0x%x]", rc);
clHeapFree(pMoIdList);
return rc;
}

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen