ProviderOperationCounter DefaultProviderManager::_getProvider( const String& moduleFileName, const String& moduleName, const String& providerName) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_getProvider"); ProviderMessageHandler* pr = _lookupProvider(moduleName, providerName); if (!pr->status.isInitialized()) { _initProvider(pr, moduleFileName); } AutoMutex lock(pr->status.getStatusMutex()); if (!pr->status.isInitialized()) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, "provider initialization failed"); } ProviderOperationCounter poc(pr); PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4,"Returning Provider %s", (const char*)providerName.getCString())); PEG_METHOD_EXIT(); return poc; }
Sint16 DefaultProviderManager::_disableProvider( const String& moduleName, const String& providerName) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_disableProvider"); ProviderMessageHandler* pr = _lookupProvider(moduleName, providerName); if (!pr->status.isInitialized()) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL2, "Provider %s is not loaded", (const char*)providerName.getCString())); PEG_METHOD_EXIT(); return 1; } PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4,"Disable Provider %s", (const char*)pr->getName().getCString())); // // Check to see if there are pending requests. If there are pending // requests and the disable timeout has not expired, loop and wait one // second until either there is no pending requests or until timeout // expires. // Uint32 waitTime = PROVIDER_DISABLE_TIMEOUT; while ((pr->status.numCurrentOperations() > 0) && (waitTime > 0)) { Threads::sleep(1000); waitTime = waitTime - 1; } // There are still pending requests, do not disable if (pr->status.numCurrentOperations() > 0) { PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Disable failed since there are pending requests."); PEG_METHOD_EXIT(); return 0; } try { AutoMutex lock(pr->status.getStatusMutex()); if (pr->status.isInitialized()) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Unloading Provider %s", (const char*)pr->getName().getCString())); _unloadProvider(pr); } } catch (...) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL2, "Unload provider failed %s", (const char*)pr->getName().getCString())); PEG_METHOD_EXIT(); return -1; } PEG_METHOD_EXIT(); return 1; }
ProviderName ProviderRegistrar::findProvider(const ProviderName & providerName, Boolean test) { // CIMObjectPath objectName = providerName.getObjectName(); Uint32 flags = providerName.getCapabilitiesMask(); // validate arguments /* if(objectName.getNameSpace().isNull() || objectName.getClassName().isNull()) { throw Exception("Invalid argument."); } */ CIMInstance provider; CIMInstance providerModule; ProviderName temp; Boolean hasNoQuery; switch (flags) { case ProviderType_INSTANCE: if (_prm->lookupInstanceProvider(providerName.getNameSpace(),providerName.getClassName(), provider,providerModule,0)) { if (test) checkBlocked(providerModule); return ProviderName( provider.getProperty(provider.findProperty ("Name")).getValue ().toString (), providerModule.getProperty(providerModule.findProperty ("Location")).getValue().toString(), providerModule.getProperty(providerModule.findProperty ("InterfaceType")).getValue().toString(), ProviderType::INSTANCE); } break; case ProviderType_ASSOCIATION: if (_prm->lookupInstanceProvider(providerName.getNameSpace(),providerName.getClassName(), provider,providerModule,1)) { if (test) checkBlocked(providerModule); return ProviderName( provider.getProperty(provider.findProperty ("Name")).getValue ().toString (), providerModule.getProperty(providerModule.findProperty ("Location")).getValue().toString(), providerModule.getProperty(providerModule.findProperty ("InterfaceType")).getValue().toString(), ProviderType::ASSOCIATION); } break; case ProviderType_QUERY: if (_prm->lookupInstanceProvider(providerName.getNameSpace(),providerName.getClassName(), provider,providerModule,0,&hasNoQuery)) { if (test) checkBlocked(providerModule); return ProviderName( provider.getProperty(provider.findProperty ("Name")).getValue ().toString (), providerModule.getProperty(providerModule.findProperty ("Location")).getValue().toString(), providerModule.getProperty(providerModule.findProperty ("InterfaceType")).getValue().toString(), ProviderType::INSTANCE); } break; case ProviderType_METHOD: if (_prm->lookupMethodProvider(providerName.getNameSpace(),providerName.getClassName(), providerName.getMethodName(),provider,providerModule)) { if (test) checkBlocked(providerModule); return ProviderName( provider.getProperty(provider.findProperty ("Name")).getValue ().toString (), providerModule.getProperty(providerModule.findProperty ("Location")).getValue().toString(), providerModule.getProperty(providerModule.findProperty ("InterfaceType")).getValue().toString(), ProviderType::METHOD); } break; default: CIMObjectPath objectName(String::EMPTY, providerName.getNameSpace(),providerName.getClassName()); temp = _lookupProvider(objectName); } return(temp); }