ClRcT clAmsMgmtCCBBatchEntitySetConfig(ClAmsMgmtCCBBatchHandleT batchHandle, ClAmsEntityConfigT *entityConfig, ClUint64T bitmask) { ClAmsMgmtCCBBatchT *batch = (ClAmsMgmtCCBBatchT*)batchHandle; clAmsMgmtCCBEntitySetConfigRequestT req = {0}; ClInt32T op = (ClInt32T)CL_AMS_MGMT_CCB_OPERATION_SET_CONFIG; ClRcT rc = CL_OK; if(!batch || !entityConfig) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!batch->buffer) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); req.bitmask = bitmask; req.entityConfig = entityConfig; rc |= clXdrMarshallClInt32T(&op, batch->buffer, 0); rc |= __marshalClAmsMgmtCCBEntitySetConfig(&req, batch->buffer, batch->version); if(rc != CL_OK) { goto out; } ++batch->items; out: return rc; }
static ClRcT clAmsMgmtOIMoIdGet(ClAmsMgmtHandleT handle, ClAmsEntityT *pEntity, ClCorMOIdT *pMoId) { ClCharT *userData = NULL; ClUint32T dataSize = 0; ClRcT rc = CL_OK; if(!pEntity || !pMoId) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); rc = clAmsMgmtEntityUserDataGetKey(handle, pEntity, &pEntity->name, &userData, &dataSize); if(rc != CL_OK) { clLogError("AMF", "MGMT", "Entity user data get key for [%s] returned [%#x]", pEntity->name.value, rc); return rc; } if(!userData || !dataSize) return CL_AMS_RC(CL_ERR_INVALID_STATE); rc = clCorMoIdUnpack(userData, dataSize, pMoId); clHeapFree(userData); return rc; }
ClRcT clAmsMgmtCCBBatchEntityDelete(ClAmsMgmtCCBBatchHandleT batchHandle, const ClAmsEntityT *entity) { ClAmsMgmtCCBBatchT *batch = (ClAmsMgmtCCBBatchT*)batchHandle; clAmsMgmtCCBEntityDeleteRequestT deleteRequest = {0}; ClInt32T op = (ClInt32T)CL_AMS_MGMT_CCB_OPERATION_DELETE; ClRcT rc = CL_OK; if(!batch || !entity) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!batch->buffer) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); memcpy(&deleteRequest.entity, entity, sizeof(deleteRequest.entity)); CL_AMS_NAME_LENGTH_CHECK(deleteRequest.entity); rc |= clXdrMarshallClInt32T(&op, batch->buffer, 0); rc |= VDECL_VER(clXdrMarshallclAmsMgmtCCBEntityDeleteRequestT, 4, 0, 0)(&deleteRequest, batch->buffer, 0); if(rc != CL_OK) { goto out; } ++batch->items; out: return rc; }
static ClRcT amsMgmtCCBBatchSetSICSIList( CL_IN ClAmsMgmtCCBBatchHandleT batchHandle, CL_IN ClAmsEntityT *siName, CL_IN ClAmsEntityT *csiName, CL_IN ClAmsMgmtCCBOperationsT opId) { ClRcT rc = CL_OK; ClAmsMgmtCCBBatchT *batch = (ClAmsMgmtCCBBatchT*)batchHandle; clAmsMgmtCCBSetSICSIListRequestT req = {0}; ClInt32T op = (ClInt32T)opId; if(!batch || !siName || !csiName) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!batch->buffer) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); memcpy (&req.siName,siName,sizeof(ClAmsEntityT)); memcpy (&req.csiName,csiName,sizeof(ClAmsEntityT)); CL_AMS_NAME_LENGTH_CHECK(req.siName); CL_AMS_NAME_LENGTH_CHECK(req.csiName); rc |= clXdrMarshallClInt32T(&op, batch->buffer, 0); rc |= VDECL_VER(clXdrMarshallclAmsMgmtCCBSetSICSIListRequestT, 4, 0, 0)(&req, batch->buffer, 0); if(rc != CL_OK) goto out; ++batch->items; out: return rc; }
ClRcT clAmsEntityTriggerLoad(ClAmsEntityT *pEntity, ClMetricT *pMetric) { ClRcT rc = CL_OK; ClAmsEntityTriggerT *pEntityTrigger = NULL; #ifdef VXWORKS_BUILD return CL_AMS_RC(CL_ERR_NOT_SUPPORTED); #endif rc = clAmsEntityLocate(pEntity); if(rc != CL_OK) { clLogError("TRIGGER", "LOAD", "Entity [%.*s] not found", pEntity->name.length-1, pEntity->name.value); return rc; } pEntityTrigger = clAmsEntityTriggerCreate(pEntity, pMetric); if(!pEntityTrigger) { clLogError("TRIGGER", "LOAD", "Threshold create failed"); rc = CL_AMS_RC(CL_ERR_UNSPECIFIED); goto out; } out: return rc; }
ClRcT clAmsMgmtOIExtendedIndexGet(ClAmsMgmtOIExtendedClassTypeT type, ClCorInstanceIdT *pIndex) { if(!pIndex || type >= CL_AMS_MGMT_OI_EXTENDED_CLASS_MAX) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!gClAmsMgmtOIInitialized) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); if((ClUint32T)gClAmsMgmtOIExtendedIndexTable[type] + 1 < (ClUint32T)gClAmsMgmtOIExtendedIndexTable[type]) return CL_AMS_RC(CL_ERR_OUT_OF_RANGE); *pIndex = gClAmsMgmtOIExtendedIndexTable[type]++; return CL_OK; }
ClRcT clAmsMgmtOIExtendedIndexPut(ClAmsMgmtOIExtendedClassTypeT type, ClCorInstanceIdT index) { if(type >= CL_AMS_MGMT_OI_EXTENDED_CLASS_MAX) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!gClAmsMgmtOIInitialized) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); /* * No op now but wondering if a bitmap is going to be useful because of the * way the instance id is laid out and mapped to use as an index. */ return CL_OK; }
ClRcT clAmsMgmtOIIndexPut(ClAmsEntityTypeT type, ClCorInstanceIdT index) { if(type > CL_AMS_ENTITY_TYPE_MAX) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!gClAmsMgmtOIInitialized) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); /* * No op now but wondering if a bitmap is going to be useful because of the * way the instance id is laid out and mapped to use as an index. */ return CL_OK; }
ClRcT clAmsMgmtOIIndexGet(ClAmsEntityTypeT type, ClCorInstanceIdT *pIndex) { if(!pIndex || type > CL_AMS_ENTITY_TYPE_MAX) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!gClAmsMgmtOIInitialized) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); if((ClUint32T)gClAmsMgmtOIIndexTable[type] + 1 < (ClUint32T)gClAmsMgmtOIIndexTable[type]) return CL_AMS_RC(CL_ERR_OUT_OF_RANGE); *pIndex = gClAmsMgmtOIIndexTable[type]++; return CL_OK; }
ClRcT clAmsMgmtCCBBatchCommit(CL_IN ClAmsMgmtCCBBatchHandleT batchHandle) { ClRcT rc = CL_OK; ClAmsMgmtCCBBatchT *batch = (ClAmsMgmtCCBBatchT*)batchHandle; ClUint32T saveOffset = 0; if(!batch) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!batch->buffer) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); if(!batch->items) { clLogWarning("CCB", "COMMIT", "Batch commit tried with no items"); return CL_OK; } rc = clBufferWriteOffsetGet(batch->buffer, &saveOffset); if(rc != CL_OK) goto out; rc = clBufferWriteOffsetSet(batch->buffer, batch->itemsOffset, CL_BUFFER_SEEK_SET); if(rc != CL_OK) goto out; /* * Update the item count */ rc = clXdrMarshallClUint32T(&batch->items, batch->buffer, 0); if(rc != CL_OK) goto out; rc = clBufferWriteOffsetSet(batch->buffer, saveOffset, CL_BUFFER_SEEK_SET); if(rc != CL_OK) goto out; rc = cl_ams_ccb_batch_rmd(CL_AMS_MGMT_CCB_BATCH_COMMIT, batch->buffer, CL_VERSION_CODE(5, 1, 0)); if(rc != CL_OK) goto out; /* * Clear the buffer for reuse */ rc = amsMgmtCCBBatchBufferInitialize(batch); out: return rc; }
/* * Change the redundancy model of the SG. on the fly. * If its a forward move, create si/csi/su/comp with the prefix provided. */ ClRcT clAmsMgmtMigrateSGRedundancy(ClAmsSGRedundancyModelT model, const ClCharT *sgName, const ClCharT *prefix, ClUint32T numActiveSUs, ClUint32T numStandbySUs, ClAmsMgmtMigrateListT *migrateList) { ClRcT rc = CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!sgName || !prefix) return rc; if(model >= CL_AMS_SG_REDUNDANCY_MODEL_MAX) { clLogError("AMS", "MIGRATE", "Invalid model [%d] specified.", model); goto out; } if(!gClAmsMgmtSGRedundancyModelMigrationTable[model]) { clLogError("AMS", "MIGRATE", "Migration not supported model [%d]", model); goto out; } return gClAmsMgmtSGRedundancyModelMigrationTable[model](model, sgName, prefix, numActiveSUs, numStandbySUs, migrateList); out: return rc; }
ClRcT clAmsPeSIIsActiveAssignableCustom(CL_IN ClAmsSIT *si) { ClAmsAdminStateT adminState; ClAmsSGT *sg; AMS_CHECK_SI (si); AMS_CHECK_SG (sg = (ClAmsSGT *) si->config.parentSG.ptr); AMS_FUNC_ENTER ( ("SI [%s]\n", si->config.entity.name.value) ); AMS_CALL ( clAmsPeSIComputeAdminState(si, &adminState) ); if ( adminState == CL_AMS_ADMIN_STATE_UNLOCKED ) { if ( si->status.numActiveAssignments < sg->config.numPrefActiveSUsPerSI ) { return clAmsEntityListWalkGetEntity( &si->config.siDependenciesList, (ClAmsEntityCallbackT)clAmsPeSIIsActiveAssignable2); } } return CL_AMS_RC(CL_AMS_ERR_SI_NOT_ASSIGNABLE); }
static ClRcT clAmsEntityLocate(ClAmsEntityT *pEntity) { ClRcT rc = CL_OK; register ClInt32T i; for(i = CL_AMS_ENTITY_TYPE_ENTITY + 1; i < CL_AMS_ENTITY_TYPE_MAX + 1; ++i) { ClAmsEntityConfigT *pEntityConfig = NULL; pEntity->type = (ClAmsEntityTypeT) i; rc = clAmsMgmtEntityGetConfig(gClAmsEntityTriggerMgmtHandle, pEntity, &pEntityConfig); if(rc != CL_OK) { if(pEntityConfig) clHeapFree(pEntityConfig); continue; } memcpy(pEntity, pEntityConfig, sizeof(*pEntity)); clHeapFree(pEntityConfig); return CL_OK; } return CL_AMS_RC(CL_ERR_NOT_EXIST); }
ClRcT clAmsMgmtOIDelete(ClCorInstanceIdT instance, ClAmsEntityT *entity) { ClAmsMgmtOICacheT *entry = NULL; if(!entity || entity->type > CL_AMS_ENTITY_TYPE_MAX) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); clOsalMutexLock(&gClAmsMgmtOICacheMutex); if(!(entry = clAmsMgmtOICacheFind(gClAmsMgmtOICacheTable[entity->type], instance, entity))) { clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); return CL_AMS_RC(CL_ERR_NOT_EXIST); } hashDel(&entry->hash); clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); clHeapFree(entry); return CL_OK; }
/* * Given a moid, return the entity instance associated with it. */ ClRcT clAmsMgmtOIGet(ClCorMOIdT *pMoId, ClAmsEntityT *pEntity) { ClRcT rc = CL_OK; ClAmsMgmtOICacheT *entry = NULL; if(!pMoId || !pEntity || pEntity->type > CL_AMS_ENTITY_TYPE_MAX) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!gClAmsMgmtOIInitialized) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); clOsalMutexLock(&gClAmsMgmtOICacheMutex); entry = clAmsMgmtOICacheFind(gClAmsMgmtOICacheTable[pEntity->type], clCorMoIdToInstanceGet(pMoId), pEntity); if(!entry) { clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); return CL_AMS_RC(CL_ERR_NOT_EXIST); } memcpy(pEntity, &entry->entity, sizeof(*pEntity)); clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); return rc; }
ClRcT clAmsSAPGTrack( CL_IN ClAmsClientHandleT amsHandle, CL_IN ClNameT *csiName, CL_IN ClUint8T trackFlags, CL_IN ClAmsPGNotificationBufferT *notificationBuffer) { return CL_AMS_RC(CL_ERR_NOT_IMPLEMENTED); }
ClRcT clAmsMgmtCCBBatchFinalize(ClAmsMgmtCCBBatchHandleT *batchHandle) { ClAmsMgmtCCBBatchT *batch = NULL; if(!batchHandle || !(batch = (ClAmsMgmtCCBBatchT*)*batchHandle)) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(batch->buffer) clBufferDelete(&batch->buffer); clHeapFree(batch); *batchHandle = (ClAmsMgmtCCBBatchHandleT)0; return CL_OK; }
static ClRcT check_lib_init(void) { ClRcT rc = CL_OK; if (lib_initialized == CL_FALSE) { rc = clAmsLibInitialize(); } return CL_AMS_RC (rc); }
ClRcT clAmsMgmtOIExtendedDelete(ClAmsMgmtOIExtendedClassTypeT type, ClCorInstanceIdT instance) { ClAmsMgmtOIExtendedCacheT *entry = NULL; if(type >= CL_AMS_MGMT_OI_EXTENDED_CLASS_MAX) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); clOsalMutexLock(&gClAmsMgmtOICacheMutex); if(!(entry = clAmsMgmtOIExtendedCacheFind(gClAmsMgmtOIExtendedCacheTable[type], instance))) { clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); return CL_AMS_RC(CL_ERR_NOT_EXIST); } hashDel(&entry->hash); clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); if(entry->pConfig) clHeapFree(entry->pConfig); clHeapFree(entry); return CL_OK; }
ClRcT clAmsMgmtOIExtendedGet(ClCorMOIdT *pMoId, ClAmsMgmtOIExtendedClassTypeT type, ClAmsMgmtOIExtendedEntityConfigT *pConfig, ClUint32T configSize) { ClRcT rc = CL_OK; ClAmsMgmtOIExtendedCacheT *entry = NULL; if(!pMoId || !pConfig || type >= CL_AMS_MGMT_OI_EXTENDED_CLASS_MAX) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); if(!gClAmsMgmtOIInitialized) return CL_AMS_RC(CL_ERR_NOT_INITIALIZED); clOsalMutexLock(&gClAmsMgmtOICacheMutex); entry = clAmsMgmtOIExtendedCacheFind(gClAmsMgmtOIExtendedCacheTable[type], clCorMoIdToInstanceGet(pMoId)); if(!entry || !entry->pConfig || entry->configSize != configSize) { clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); return CL_AMS_RC(CL_ERR_NOT_EXIST); } memcpy(pConfig, entry->pConfig, configSize); clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); return rc; }
/* * Reset to defaults. */ static ClRcT clAmsEntityTriggerReset(ClAmsEntityT *pEntity, ClMetricIdT id) { ClAmsEntityTriggerT *pEntityTrigger = NULL; ClRcT rc = CL_OK; if(!pEntity || pEntity->type > CL_AMS_ENTITY_TYPE_MAX || id >= CL_METRIC_MAX) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); clOsalMutexLock(&gClAmsEntityTriggerList.list.mutex); pEntityTrigger = clAmsEntityTriggerFind(pEntity); if(!pEntityTrigger) { clOsalMutexUnlock(&gClAmsEntityTriggerList.list.mutex); clLogError("TRIGGER", "RESET", "Entity threshold not found for [%.*s], Threshold [%#x]", pEntity->name.length-1, pEntity->name.value, id); return CL_AMS_RC(CL_ERR_NOT_EXIST); } clAmsEntityTriggerLoadDefaults(pEntityTrigger, id); clOsalMutexUnlock(&gClAmsEntityTriggerList.list.mutex); return rc; }
ClRcT clAmsSACSIHAStateGet( CL_IN ClAmsClientHandleT amsHandle, CL_IN const ClNameT *compName, CL_IN const ClNameT *csiName, CL_OUT ClAmsHAStateT *haState) { ClRcT rc; struct ams_instance *ams_instance = NULL; if ( !compName || !csiName || !haState) return CL_ERR_NULL_POINTER; /* * Checkout the client handle */ if ( (rc = clHandleCheckout( handle_database, amsHandle, (void *)&ams_instance)) != CL_OK ) goto error; /* * Send the information to the server to */ if ( ( rc = _clAmsSACSIHAStateGet( (ClNameT *)compName, (ClNameT *)csiName, haState )) != CL_OK ) goto error; if ( (rc = clHandleCheckin( handle_database, amsHandle)) != CL_OK ) goto error; return CL_OK; error: return CL_AMS_RC(rc); }
/****************************************************************************** Static Functions *******************************************************************************/ static ClRcT clAmsLibInitialize(void) { ClRcT rc = CL_OK; ClEoExecutionObjT *eo; if (lib_initialized == CL_FALSE) { if ( (rc = clHandleDatabaseCreate( ams_handle_instance_destructor, &handle_database)) != CL_OK ) goto error_exit; /* * XXX: On the long run, when multiple EOs can exist in same process, * the following function installation may be devorced from the lib * initialization, so that it can be called multiple times. */ if ( ( rc = clEoMyEoObjectGet( &eo)) != CL_OK ) goto error_exit; if ( ( rc = clEoClientInstall( eo, CL_AMS_CLIENT_TABLE_ID, cl_ams_client_callback_list, /* * cdata passsed to each function call */ 0, (int)(sizeof(cl_ams_client_callback_list)/ sizeof(ClEoPayloadWithReplyCallbackT)))) != CL_OK ) goto error_exit; lib_initialized = CL_TRUE; } return CL_OK; error_exit: return CL_AMS_RC (rc); }
ClRcT clAmsEntityTriggerLoadAll(ClMetricT *pMetric) { ClAmsEntityTriggerT *pEntityTrigger = NULL; ClListHeadT *pHead = &gClAmsEntityTriggerList.list.list; register ClListHeadT *pTemp ; #ifdef VXWORKS_BUILD return CL_AMS_RC(CL_ERR_NOT_SUPPORTED); #endif clOsalMutexLock(&gClAmsEntityTriggerList.list.mutex); CL_LIST_FOR_EACH(pTemp, pHead) { pEntityTrigger = CL_LIST_ENTRY(pTemp, ClAmsEntityTriggerT, list); clAmsEntityTriggerUpdate(pEntityTrigger, pMetric); clAmsEntityTriggerCheck(pEntityTrigger, pMetric); }
static ClRcT clAmsMgmtOIConfigAttributeSet(ClAmsMgmtHandleT handle, ClCorTxnSessionIdT *pSession, ClCorMOIdT *pMoId, ClAmsEntityT *pEntity, ClRcT (*pClAmsMgmtOIConfigAttributesGet) (ClAmsEntityConfigT*, ClCorAttributeValueListPtrT )) { ClCorObjectHandleT objHandle = 0; ClRcT rc = CL_OK; ClCorAttributeValueListT attrList = {0}; ClAmsEntityConfigT *pEntityConfig = NULL; if(!handle || !pSession || !pMoId || !pEntity || !pClAmsMgmtOIConfigAttributesGet) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); rc = clAmsMgmtEntityGetConfig(handle, pEntity, &pEntityConfig); if(rc != CL_OK || !pEntityConfig) { clLogError("AMF", "MGMT", "Entity [%s] config get returned [%#x]", pEntity->name.value, rc); return rc; } rc = clCorMoIdToObjectHandleGet(pMoId, &objHandle); if(rc != CL_OK) { goto out_free; } rc = (*pClAmsMgmtOIConfigAttributesGet)(pEntityConfig, &attrList); if(rc != CL_OK) { goto out_free; } rc = clAmsMgmtOIAttributeSet(pEntity, pSession, objHandle, &attrList); out_free: if(pEntityConfig) clHeapFree(pEntityConfig); if(objHandle) clCorObjectHandleFree(&objHandle); if(attrList.pAttributeValue) clHeapFree(attrList.pAttributeValue); return rc; }
ClRcT clAmsEntityTriggerLoadDefault(ClAmsEntityT *pEntity, ClMetricIdT id) { ClRcT rc = CL_OK; #ifdef VXWORKS_BUILD return CL_AMS_RC(CL_ERR_NOT_SUPPORTED); #endif rc = clAmsEntityLocate(pEntity); if(rc != CL_OK) { clLogError("TRIGGER", "RESET", "Entity [%.*s] not found", pEntity->name.length-1, pEntity->name.value); return rc; } return clAmsEntityTriggerReset(pEntity, id); }
static ClRcT clAmsMgmtOIAttributeSet(ClAmsEntityT *pEntity, ClCorTxnSessionIdT *pSession, ClCorObjectHandleT objHandle, ClCorAttributeValueListT *pAttrList) { ClRcT rc = CL_OK; ClUint32T i; if(!pEntity || !objHandle || !pAttrList || !pAttrList->numOfValues || !pAttrList->pAttributeValue) return CL_AMS_RC(CL_ERR_INVALID_PARAMETER); for(i = 0; i < pAttrList->numOfValues; ++i) { ClUint32T attrIndex = pAttrList->pAttributeValue[i].index; if(pAttrList->pAttributeValue[i].index == -100) attrIndex = CL_COR_INVALID_ATTR_IDX; rc = clCorObjectAttributeSet(pSession, objHandle, NULL, pAttrList->pAttributeValue[i].attrId, attrIndex, pAttrList->pAttributeValue[i].bufferPtr, pAttrList->pAttributeValue[i].bufferSize); if(pAttrList->pAttributeValue[i].index == -100) { clHeapFree(pAttrList->pAttributeValue[i].bufferPtr); pAttrList->pAttributeValue[i].bufferPtr = NULL; } if(rc != CL_OK) { clLogError("AMF", "MGMT", "Attribute set for attribute [%d], entity [%s] returned [%#x]", pAttrList->pAttributeValue[i].attrId, pEntity->name.value, rc); while(++i < pAttrList->numOfValues) { if(pAttrList->pAttributeValue[i].index == -100) clHeapFree(pAttrList->pAttributeValue[i].bufferPtr); } goto out; } } out: return rc; }
ClRcT clAmsSACSIQuiescingComplete( CL_IN ClAmsClientHandleT amsHandle, CL_IN ClInvocationT invocation, CL_IN ClRcT error) { ClRcT rc; struct ams_instance *ams_instance = NULL; /* * Checkout the client handle */ if ( (rc = clHandleCheckout( handle_database, amsHandle, (void *)&ams_instance)) != CL_OK ) goto error; /* * Check-In the handle */ if ( (rc = clHandleCheckin( handle_database, amsHandle)) != CL_OK ) goto error; return CL_OK; error: return CL_AMS_RC(rc); }
/* * The trigger to be loaded needn't be in the trigger DB. */ ClRcT clAmsEntityTriggerLoadTrigger(ClAmsEntityT *pEntity, ClMetricIdT id) { ClAmsEntityTriggerT entityTrigger = {{CL_AMS_ENTITY_TYPE_ENTITY}}; ClRcT rc = CL_OK; #ifdef VXWORKS_BUILD return CL_AMS_RC(CL_ERR_NOT_SUPPORTED); #endif rc = clAmsEntityLocate(pEntity); if(rc != CL_OK) { clLogError("TRIGGER", "LOAD", "Entity [%.*s] not found", pEntity->name.length-1, pEntity->name.value); return rc; } memcpy(&entityTrigger.entity, pEntity, sizeof(entityTrigger.entity)); clAmsEntityTriggerLoadDefaults(&entityTrigger, id); rc = clAmsEntityTrigger(&entityTrigger, id, CL_FALSE); return rc; }
ClRcT clAmsSAResponse( CL_IN ClAmsClientHandleT amsHandle, CL_IN ClInvocationT invocation, CL_IN ClRcT error) { ClRcT rc; clAmsClientResponseRequestT req; clAmsClientResponseResponseT *res = NULL; struct ams_instance *ams_instance = NULL; /* * Checkout the client handle */ if ( (rc = clHandleCheckout( handle_database, amsHandle, (void *)&ams_instance)) != CL_OK ) goto error; /* * Copy the client information in the req structure */ req.handle = ams_instance->server_handle; req.invocation = invocation; req.error =error; /* * Send the information to the server to */ if ( (rc = cl_ams_client_response( &req, &res)) != CL_OK ) goto error; /* * Check-In the handle */ if ( (rc = clHandleCheckin( handle_database, amsHandle)) != CL_OK ) goto error; clHeapFree((void*)res); res = NULL; return CL_OK; error: clHeapFree((void*)res); res = NULL; return CL_AMS_RC(rc); }