📄 cimoperationrequestdispatcher.cpp
字号:
moduleList.remove(0, (pos == PEG_NOT_FOUND ? pos : pos + 1)); } }#endif _routing_table = DynamicRoutingTable::get_rw_routing_table(); cimAggregationLocalHost = System::getHostName(); PEG_METHOD_EXIT();}CIMOperationRequestDispatcher::~CIMOperationRequestDispatcher(){ PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMOperationRequestDispatcher::~CIMOperationRequestDispatcher"); PEG_METHOD_EXIT();}void CIMOperationRequestDispatcher::_getProviderName( const OperationContext& context, String& moduleName, String& providerName){ moduleName.clear(); providerName.clear(); if (context.contains(ProviderIdContainer::NAME)) { const ProviderIdContainer pidc = (const ProviderIdContainer) context.get(ProviderIdContainer::NAME); CIMConstInstance module = pidc.getModule(); Uint32 pos = module.findProperty(_PROPERTY_PROVIDERMODULE_NAME); if (pos != PEG_NOT_FOUND) { module.getProperty(pos).getValue().get(moduleName); } CIMConstInstance provider = pidc.getProvider(); pos = provider.findProperty("Name"); if (pos != PEG_NOT_FOUND) { provider.getProperty(pos).getValue().get(providerName); } }}void CIMOperationRequestDispatcher::_logOperation( const CIMRequestMessage* request, const CIMResponseMessage* response){#ifndef PEGASUS_DISABLE_AUDIT_LOGGER PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMOperationRequestDispatcher::_logOperation"); String moduleName; String providerName; if (AuditLogger::isEnabled()) { switch (request->getType()) { case CIM_CREATE_CLASS_REQUEST_MESSAGE: { const CIMCreateClassRequestMessage* req = reinterpret_cast<const CIMCreateClassRequestMessage*>( request); AuditLogger::logUpdateClassOperation( "CreateClass", AuditLogger::EVENT_CREATE, req->userName, req->ipAddress, req->nameSpace, req->className, response->cimException.getCode()); break; } case CIM_MODIFY_CLASS_REQUEST_MESSAGE: { const CIMModifyClassRequestMessage* req = reinterpret_cast<const CIMModifyClassRequestMessage*>( request); AuditLogger::logUpdateClassOperation( "ModifyClass", AuditLogger::EVENT_UPDATE, req->userName, req->ipAddress, req->nameSpace, req->className, response->cimException.getCode()); break; } case CIM_DELETE_CLASS_REQUEST_MESSAGE: { const CIMDeleteClassRequestMessage* req = reinterpret_cast<const CIMDeleteClassRequestMessage*>( request); AuditLogger::logUpdateClassOperation( "DeleteClass", AuditLogger::EVENT_DELETE, req->userName, req->ipAddress, req->nameSpace, req->className, response->cimException.getCode()); break; } case CIM_SET_QUALIFIER_REQUEST_MESSAGE: { const CIMSetQualifierRequestMessage* req = reinterpret_cast<const CIMSetQualifierRequestMessage*>( request); AuditLogger::logUpdateQualifierOperation( "SetQualifier", AuditLogger::EVENT_UPDATE, req->userName, req->ipAddress, req->nameSpace, req->qualifierDeclaration.getName(), response->cimException.getCode()); break; } case CIM_DELETE_QUALIFIER_REQUEST_MESSAGE: { const CIMDeleteQualifierRequestMessage* req = reinterpret_cast<const CIMDeleteQualifierRequestMessage*>( request); AuditLogger::logUpdateQualifierOperation( "DeleteQualifier", AuditLogger::EVENT_DELETE, req->userName, req->ipAddress, req->nameSpace, req->qualifierName, response->cimException.getCode()); break; } case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: { const CIMCreateInstanceRequestMessage* req = reinterpret_cast<const CIMCreateInstanceRequestMessage*>( request); const CIMCreateInstanceResponseMessage* resp = reinterpret_cast<const CIMCreateInstanceResponseMessage*>( response); _getProviderName( req->operationContext, moduleName, providerName); AuditLogger::logUpdateInstanceOperation( "CreateInstance", AuditLogger::EVENT_CREATE, req->userName, req->ipAddress, req->nameSpace, (response->cimException.getCode() == CIM_ERR_SUCCESS) ? resp->instanceName : CIMObjectPath(req->className.getString()), moduleName, providerName, response->cimException.getCode()); break; } case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: { const CIMModifyInstanceRequestMessage* req = reinterpret_cast<const CIMModifyInstanceRequestMessage*>( request); _getProviderName( req->operationContext, moduleName, providerName); AuditLogger::logUpdateInstanceOperation( "ModifyInstance", AuditLogger::EVENT_UPDATE, req->userName, req->ipAddress, req->nameSpace, req->modifiedInstance.getPath(), moduleName, providerName, response->cimException.getCode()); break; } case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: { const CIMDeleteInstanceRequestMessage* req = reinterpret_cast<const CIMDeleteInstanceRequestMessage*>( request); _getProviderName( req->operationContext, moduleName, providerName); AuditLogger::logUpdateInstanceOperation( "DeleteInstance", AuditLogger::EVENT_DELETE, req->userName, req->ipAddress, req->nameSpace, req->instanceName, moduleName, providerName, response->cimException.getCode()); break; } case CIM_SET_PROPERTY_REQUEST_MESSAGE: { const CIMSetPropertyRequestMessage* req = reinterpret_cast<const CIMSetPropertyRequestMessage*>( request); _getProviderName( req->operationContext, moduleName, providerName); AuditLogger::logUpdateInstanceOperation( "SetProperty", AuditLogger::EVENT_UPDATE, req->userName, req->ipAddress, req->nameSpace, req->instanceName, moduleName, providerName, response->cimException.getCode()); break; } case CIM_INVOKE_METHOD_REQUEST_MESSAGE: { const CIMInvokeMethodRequestMessage* req = reinterpret_cast<const CIMInvokeMethodRequestMessage*>( request); _getProviderName( req->operationContext, moduleName, providerName); AuditLogger::logInvokeMethodOperation( req->userName, req->ipAddress, req->nameSpace, req->instanceName, req->methodName, moduleName, providerName, response->cimException.getCode()); break; } default: // Other operations are not logged. break; } } PEG_METHOD_EXIT();#endif}/* send the given response synchronously using the given aggregation object. return whether the sent message was complete or not. The parameters are pointer references because they can be come invalid from external deletes if the message is complete after queueing. They can be zeroed in this function preventing the caller from referencing deleted pointers.*/Boolean CIMOperationRequestDispatcher::_enqueueResponse( OperationAggregate*& poA, CIMResponseMessage*& response){ static const char func[] = "CIMOperationRequestDispatcher::_enqueueResponse"; // Obtain the _enqueueResponseMutex mutex for this chunked request. // This mutex is used to serialize chunked responses from all incoming // provider threads. It is imperative that the sequencing done by the // resequenceResponse() method and the writing of the chunked response // to the connection socket (done as a synchronous enqueue at the end // of this method) are atomic to ensure that the chunk that is marked // as isComplete for the overall response is indeed the last chunk // returned to the client. See PEP 140 for details. // This mutex was moved into the OperationAggregate class as part of // bug 5157 because we only need to serialize on a per-request basis. // This prevents serializing independent requests on separate connections. AutoMutex autoMut(poA->_enqueueResponseMutex); Boolean isComplete = false; try { // get the completion status of the incoming response on this thread. isComplete = response->isComplete(); poA->appendResponse(response); Uint32 type = poA->getRequestType(); // there should never be more than one object in the list for async // queues these functions are called for their jobs other than // aggregating. switch(type) { case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE : handleEnumerateInstanceNamesResponseAggregation(poA); break; case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE : handleEnumerateInstancesResponseAggregation(poA); break; case CIM_ASSOCIATORS_REQUEST_MESSAGE : handleAssociatorsResponseAggregation(poA); break; case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE : handleAssociatorNamesResponseAggregation(poA); break; case CIM_REFERENCES_REQUEST_MESSAGE : handleReferencesResponseAggregation(poA); break; case CIM_REFERENCE_NAMES_REQUEST_MESSAGE : handleReferenceNamesResponseAggregation(poA); break; case CIM_EXEC_QUERY_REQUEST_MESSAGE : handleExecQueryResponseAggregation(poA); break; default: static const char failMsg[] = "Invalid response type to aggregate: "; char typeP[11]; sprintf(typeP,"%u", type); PEG_LOGGER_TRACE((Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, String(func) + String(failMsg) + String(typeP))); PEGASUS_ASSERT(0); break; } // switch // now take the aggregated response. This is now the one we will // work with response = poA->removeResponse(Uint32(0)); // reset the completion flag of the last response added to the list. // This only makes a difference when there was at least two on the list // to begin with before aggregation methods (above) were called. // Typically, there will be more than two on the list when a non-async // destination queue keeps appending the responses until the completion // of all threads/responses has occurred.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -