(file) Return to CMPIProvider.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / CMPI

Diff for /pegasus/src/Pegasus/ProviderManager2/CMPI/CMPIProvider.cpp between version 1.48 and 1.48.2.6

version 1.48, 2007/09/18 19:22:13 version 1.48.2.6, 2009/06/09 09:19:45
Line 48 
Line 48 
 PEGASUS_USING_STD; PEGASUS_USING_STD;
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
   static const char _MSG_CANNOT_INIT_API_KEY[] =
       "ProviderManager.CMPI.CMPIProvider.CANNOT_INIT_API";
   static const char _MSG_CANNOT_INIT_API[] =
       "Error initializing CMPI MI $0, the following MI"
           " factory function(s) returned an error: $1";
   
   
 // set current operations to 1 to prevent an unload // set current operations to 1 to prevent an unload
 // until the provider has had a chance to initialize // until the provider has had a chance to initialize
 CMPIProvider::CMPIProvider( CMPIProvider::CMPIProvider(
Line 62 
Line 69 
         "CMPIProvider::CMPIProvider()");         "CMPIProvider::CMPIProvider()");
     _current_operations = 1;     _current_operations = 1;
     _currentSubscriptions = 0;     _currentSubscriptions = 0;
     broker.hdl =0;      _broker.hdl =0;
     broker.provider = this;      _broker.provider = this;
     if (mv) miVector=*mv;      if (mv)
       {
           _miVector = *mv;
       }
     unloadStatus = CMPI_RC_DO_NOT_UNLOAD;     unloadStatus = CMPI_RC_DO_NOT_UNLOAD;
     Time::gettimeofday(&_idleTime);     Time::gettimeofday(&_idleTime);
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
Line 86 
Line 96 
     CIMOMHandle *&cimomHandle)     CIMOMHandle *&cimomHandle)
 { {
     _module = module;     _module = module;
     miVector = cmpiProvider;      _miVector = cmpiProvider;
     _cimom_handle = cimomHandle;     _cimom_handle = cimomHandle;
 } }
  
Line 96 
Line 106 
     _cimom_handle = 0;     _cimom_handle = 0;
     _no_unload = 0;     _no_unload = 0;
     _status = UNINITIALIZED;     _status = UNINITIALIZED;
       unloadStatus = CMPI_RC_DO_NOT_UNLOAD;
 } }
  
 CMPIProviderModule *CMPIProvider::getModule() const CMPIProviderModule *CMPIProvider::getModule() const
Line 107 
Line 118 
 { {
     return(_name.subString(1,PEG_NOT_FOUND));     return(_name.subString(1,PEG_NOT_FOUND));
 } }
   
   String CMPIProvider::getNameWithType() const
   {
       return(_name);
   }
   
 void setError( void setError(
     ProviderVector &miVector,     ProviderVector &miVector,
     String &error,     String &error,
Line 162 
Line 179 
     broker.xft=CMPI_BrokerExt_Ftab;     broker.xft=CMPI_BrokerExt_Ftab;
     broker.mft=NULL;    // CMPI memory services not supported     broker.mft=NULL;    // CMPI memory services not supported
  
     broker.clsCache=new ClassCache();      broker.clsCache.reset(new ClassCache());
     broker.name=name;     broker.name=name;
  
     const OperationContext opc;      miVector.instMI = NULL;
     CMPI_ContextOnStack eCtx(opc);      miVector.assocMI = NULL;
     CMPI_ThreadContext thr(&broker,&eCtx);      miVector.methMI = NULL;
     CMPIStatus rcInst = {CMPI_RC_OK, NULL};      miVector.propMI = NULL;
     CMPIStatus rcAssoc = {CMPI_RC_OK, NULL};      miVector.indMI = NULL;
     CMPIStatus rcMeth = {CMPI_RC_OK, NULL};  
     CMPIStatus rcProp = {CMPI_RC_OK, NULL};  
     CMPIStatus rcInd = {CMPI_RC_OK, NULL};  
     String error;  
     String realProviderName(name);  
   
     if (miVector.genericMode)  
     {  
         CString mName=realProviderName.getCString();  
  
         if (miVector.miTypes & CMPI_MIType_Instance)  
         {  
             miVector.instMI =  
                 miVector.createGenInstMI(&broker,&eCtx,mName, &rcInst);  
         }  
         if (miVector.miTypes & CMPI_MIType_Association)  
         {  
             miVector.assocMI =  
                 miVector.createGenAssocMI(&broker,&eCtx,mName, &rcAssoc);  
         }  
         if (miVector.miTypes & CMPI_MIType_Method)  
         {  
             miVector.methMI =  
                 miVector.createGenMethMI(&broker,&eCtx,mName, &rcMeth);  
         }  
         if (miVector.miTypes & CMPI_MIType_Property)  
         {  
             miVector.propMI =  
                 miVector.createGenPropMI(&broker,&eCtx,mName, &rcProp);  
         }  
         if (miVector.miTypes & CMPI_MIType_Indication)  
         {  
             miVector.indMI =  
                 miVector.createGenIndMI(&broker,&eCtx,mName, &rcInd);  
         }  
     }  
     else  
     {  
         if (miVector.miTypes & CMPI_MIType_Instance)  
             miVector.instMI=miVector.createInstMI(&broker,&eCtx, &rcInst);  
         if (miVector.miTypes & CMPI_MIType_Association)  
             miVector.assocMI=miVector.createAssocMI(&broker,&eCtx, &rcAssoc);  
         if (miVector.miTypes & CMPI_MIType_Method)  
             miVector.methMI=miVector.createMethMI(&broker,&eCtx, &rcMeth);  
         if (miVector.miTypes & CMPI_MIType_Property)  
             miVector.propMI=miVector.createPropMI(&broker,&eCtx, &rcProp);  
         if (miVector.miTypes & CMPI_MIType_Indication)  
             miVector.indMI=miVector.createIndMI(&broker,&eCtx, &rcInd);  
     }  
   
     if (miVector.miTypes & CMPI_MIType_Instance)  
     {  
         if (miVector.instMI == NULL || rcInst.rc != CMPI_RC_OK)  
         {  
             setError(miVector, error, realProviderName,  
                 _Generic_Create_InstanceMI, _Create_InstanceMI,  
                 rcInst.msg);  
         }  
     }  
     if (miVector.miTypes & CMPI_MIType_Association)  
     {  
         if (miVector.assocMI == NULL || rcAssoc.rc != CMPI_RC_OK)  
         {  
             setError(miVector, error, realProviderName,  
                 _Generic_Create_AssociationMI, _Create_AssociationMI,  
                 rcAssoc.msg);  
         }  
     }  
     if (miVector.miTypes & CMPI_MIType_Method)  
     {  
         if (miVector.methMI == NULL || rcMeth.rc != CMPI_RC_OK)  
         {  
             setError(miVector, error, realProviderName,  
                 _Generic_Create_MethodMI, _Create_MethodMI,  
                 rcMeth.msg);  
         }  
     }  
     if (miVector.miTypes & CMPI_MIType_Property)  
     {  
         if (miVector.propMI == NULL || rcProp.rc != CMPI_RC_OK)  
         {  
             setError(miVector, error, realProviderName,  
                 _Generic_Create_PropertyMI, _Create_PropertyMI,  
                 rcProp.msg);  
         }  
     }  
     if (miVector.miTypes & CMPI_MIType_Indication)  
     {  
         if (miVector.indMI == NULL || rcInd.rc != CMPI_RC_OK)  
         {  
             setError(miVector, error, realProviderName,  
                 _Generic_Create_IndicationMI, _Create_IndicationMI,  
                 rcInd.msg);  
         }  
     }  
   
     if (error.size() != 0)  
     {  
         throw Exception(MessageLoaderParms(  
             "ProviderManager.CMPI.CMPIProvider.CANNOT_INIT_API",  
             "Error initializing CMPI MI $0, "  
             "the following MI factory function(s) returned an error: $1",  
             realProviderName,  
             error));  
     }  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
Line 287 
Line 200 
     {     {
         String compoundName;         String compoundName;
         if (_location.size() == 0)         if (_location.size() == 0)
             compoundName= providername;  
         else  
             compoundName=_location+":"+providername;  
         try  
         {  
             CMPIProvider::initialize(cimom,miVector,compoundName,broker);  
             if (miVector.miTypes & CMPI_MIType_Method)  
             {             {
                 if (miVector.methMI->ft->miName==NULL)              compoundName = providername;
                 {  
                     unloadStatus = CMPI_RC_OK;  
                 }  
             }  
         }         }
         catch (...)          else
         {         {
             _current_operations = 0;              compoundName = _location + ":" + providername;
             throw;  
         }         }
           CMPIProvider::initialize(cimom,_miVector,compoundName,_broker);
         _status = INITIALIZED;         _status = INITIALIZED;
         _current_operations = 0;         _current_operations = 0;
     }     }
Line 377 
Line 279 
     const OperationContext opc;     const OperationContext opc;
     CMPIStatus rc={CMPI_RC_OK,NULL};     CMPIStatus rc={CMPI_RC_OK,NULL};
     CMPI_ContextOnStack eCtx(opc);     CMPI_ContextOnStack eCtx(opc);
     CMPI_ThreadContext thr(&broker,&eCtx);      CMPI_ThreadContext thr(&_broker,&eCtx);
 /* /*
  @param terminating When true, the terminating argument indicates that the MB  @param terminating When true, the terminating argument indicates that the MB
      is in the process of terminating and that cleanup must be done. When      is in the process of terminating and that cleanup must be done. When
Line 392 
Line 294 
         CMPI_RC_NEVER_UNLOAD Operation successful - never unload.         CMPI_RC_NEVER_UNLOAD Operation successful - never unload.
 */ */
     unloadStatus = CMPI_RC_OK;     unloadStatus = CMPI_RC_OK;
     if (miVector.miTypes & CMPI_MIType_Instance)      if (_miVector.instMI)
     {     {
         rc=miVector.instMI->ft->cleanup(miVector.instMI,&eCtx, terminating);          rc=_miVector.instMI->ft->cleanup(_miVector.instMI,&eCtx, terminating);
         unloadStatus = rc.rc;         unloadStatus = rc.rc;
     }     }
     if (miVector.miTypes & CMPI_MIType_Association)      if (_miVector.assocMI)
     {     {
         rc=miVector.assocMI->ft->cleanup(miVector.assocMI,&eCtx, terminating);          rc=_miVector.assocMI->ft->cleanup(_miVector.assocMI,&eCtx, terminating);
         if (unloadStatus == CMPI_RC_OK)         if (unloadStatus == CMPI_RC_OK)
         {         {
             unloadStatus = rc.rc;             unloadStatus = rc.rc;
         }         }
     }     }
     if (miVector.miTypes & CMPI_MIType_Method)      if (_miVector.methMI)
     {     {
         rc=miVector.methMI->ft->cleanup(miVector.methMI,&eCtx, terminating);          rc=_miVector.methMI->ft->cleanup(_miVector.methMI,&eCtx, terminating);
         if (unloadStatus == CMPI_RC_OK)         if (unloadStatus == CMPI_RC_OK)
         {         {
             unloadStatus = rc.rc;             unloadStatus = rc.rc;
         }         }
     }     }
     if (miVector.miTypes & CMPI_MIType_Property)      if (_miVector.propMI)
     {     {
         rc=miVector.propMI->ft->cleanup(miVector.propMI,&eCtx, terminating);          rc=_miVector.propMI->ft->cleanup(_miVector.propMI,&eCtx, terminating);
         if (unloadStatus == CMPI_RC_OK)         if (unloadStatus == CMPI_RC_OK)
         {         {
             unloadStatus = rc.rc;             unloadStatus = rc.rc;
         }         }
     }     }
     if (miVector.miTypes & CMPI_MIType_Indication)      if (_miVector.indMI)
     {     {
         rc=miVector.indMI->ft->cleanup(miVector.indMI,&eCtx, terminating);          rc=_miVector.indMI->ft->cleanup(_miVector.indMI,&eCtx, terminating);
         if (unloadStatus == CMPI_RC_OK)         if (unloadStatus == CMPI_RC_OK)
         {         {
             unloadStatus = rc.rc;             unloadStatus = rc.rc;
         }         }
     }     }
  
     if (unloadStatus == CMPI_RC_OK)      if (unloadStatus == CMPI_RC_OK || terminating)
     {  
         // Cleanup the class cache  
         {         {
             WriteLock writeLock (broker.rwsemClassCache);  
   
             if (broker.clsCache)  
             {  
                 ClassCache::Iterator i=broker.clsCache->start();  
                 for (; i; i++)  
                 {  
                     delete i.value();  
                 }  
                 delete broker.clsCache;  
                 broker.clsCache=NULL;  
             }  
         }  
   
         // Check the thread list to make sure the thread has been de-allocated         // Check the thread list to make sure the thread has been de-allocated
         if (_threadWatchList.size() != 0)         if (_threadWatchList.size() != 0)
         {         {
Line 510 
Line 396 
         // Wait until all of the threads have been cleaned.         // Wait until all of the threads have been cleaned.
         waitUntilThreadsDone();         waitUntilThreadsDone();
     }     }
       // We have killed all threads running in provider forcibly. Set
       // unloadStatus of provider to OK.
       if (terminating)
       {
           unloadStatus = CMPI_RC_OK;
       }
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
Line 526 
Line 418 
         {         {
  
             _terminate(true);             _terminate(true);
             if (unloadStatus != CMPI_RC_OK)              PEGASUS_ASSERT(unloadStatus == CMPI_RC_OK);
             {  
                 _status=savedStatus;  
                 PEG_METHOD_EXIT();  
                 return;  
             }  
         }         }
         catch (...)         catch (...)
         {         {
Line 617 
Line 504 
         "CMPIProvider::removeThreadFromWatch()");         "CMPIProvider::removeThreadFromWatch()");
     PEGASUS_ASSERT( t != 0 );     PEGASUS_ASSERT( t != 0 );
  
     PEGASUS_ASSERT (_threadWatchList.contains (t));  
     PEGASUS_ASSERT (!_cleanedThreads.contains (t));  
  
     // and remove it from the watched list      // Note: After MI returned true from cleanup() method , there might be some
       // threads running in MI. CMPILocalProviderManager::cleanupThread() called
       // below will take care of joining the running threads in MI.
       {
           AutoMutex mtx(_removeThreadMutex);
           if (_threadWatchList.contains(t))
           {
               // Remove it from the watched list
     _threadWatchList.remove(t);     _threadWatchList.remove(t);
           }
           else
           {
               // This thread already has been removed from watch list.
               PEG_METHOD_EXIT();
               return;
           }
       }
       PEGASUS_ASSERT (!_cleanedThreads.contains (t));
  
     // Add the thread to the CMPIProvider's list.     // Add the thread to the CMPIProvider's list.
     // We use this list to keep track of threads that are     // We use this list to keep track of threads that are
Line 743 
Line 644 
     return _providerInstance;     return _providerInstance;
 } }
  
 PEGASUS_NAMESPACE_END  void CMPIProvider::incCurrentOperations ()
   {
       _current_operations++;
   }
   
   int CMPIProvider::getCurrentOperations ()
   {
       return _current_operations.get();
   }
   
   void CMPIProvider::decCurrentOperations ()
   {
       _current_operations--;
   }
  
   CIMOMHandle *CMPIProvider::getCIMOMHandle()
   {
       return _cimom_handle;
   }
   
   CMPI_Broker *CMPIProvider::getBroker()
   {
       return &_broker;
   }
   
   CMPIInstanceMI *CMPIProvider::getInstMI()
   {
       if (_miVector.instMI == NULL)
       {
           AutoMutex mtx(_statusMutex);
           if (_miVector.instMI == NULL)
           {
               const OperationContext opc;
               CMPI_ContextOnStack eCtx(opc);
               CMPIStatus rc = {CMPI_RC_OK, NULL};
               String providerName = _broker.name;
               CMPIInstanceMI *mi = NULL;
   
               PEGASUS_ASSERT(_miVector.miTypes & CMPI_MIType_Instance);
               if (_miVector.genericMode)
               {
                   mi = _miVector.createGenInstMI(
                       &_broker,
                       &eCtx,
                       (const char *)providerName.getCString(),
                       &rc);
               }
               else
               {
                   mi = _miVector.createInstMI(&_broker, &eCtx, &rc);
               }
   
               if (!mi || rc.rc != CMPI_RC_OK)
               {
                   String error;
                   setError(
                       _miVector,
                       error,
                       getName(),
                       _Generic_Create_InstanceMI,
                       _Create_InstanceMI,
                       rc.msg);
   
                   throw Exception(
                       MessageLoaderParms(
                           _MSG_CANNOT_INIT_API_KEY,
                           _MSG_CANNOT_INIT_API,
                           getName(),
                           error));
               }
               _miVector.instMI = mi;
           }
       }
   
       return _miVector.instMI;
   }
   
   CMPIMethodMI *CMPIProvider::getMethMI()
   {
       if (_miVector.methMI == NULL)
       {
           AutoMutex mtx(_statusMutex);
           if (_miVector.methMI == NULL)
           {
               const OperationContext opc;
               CMPI_ContextOnStack eCtx(opc);
               CMPIStatus rc = {CMPI_RC_OK, NULL};
               String providerName = _broker.name;
               CMPIMethodMI *mi;
               PEGASUS_ASSERT(_miVector.miTypes & CMPI_MIType_Method);
               if (_miVector.genericMode)
               {
                   mi = _miVector.createGenMethMI(
                       &_broker,
                       &eCtx,
                       (const char *)providerName.getCString(),
                       &rc);
               }
               else
               {
                   mi = _miVector.createMethMI(&_broker, &eCtx, &rc);
               }
               if (!mi || rc.rc != CMPI_RC_OK)
               {
                   String error;
                   setError(
                       _miVector,
                       error,
                       getName(),
                       _Generic_Create_MethodMI,
                       _Create_MethodMI,
                       rc.msg);
   
                   throw Exception(
                       MessageLoaderParms(
                           _MSG_CANNOT_INIT_API_KEY,
                           _MSG_CANNOT_INIT_API,
                           getName(),
                           error));
               }
               _miVector.methMI = mi;
           }
       }
   
       return _miVector.methMI;
   }
   
   CMPIAssociationMI *CMPIProvider::getAssocMI()
   {
       if (_miVector.assocMI == NULL)
       {
           AutoMutex mtx(_statusMutex);
           if (_miVector.assocMI == NULL)
           {
               const OperationContext opc;
               CMPI_ContextOnStack eCtx(opc);
               CMPIStatus rc = {CMPI_RC_OK, NULL};
               String providerName = _broker.name;
               CMPIAssociationMI *mi;
               PEGASUS_ASSERT(_miVector.miTypes & CMPI_MIType_Association);
               if (_miVector.genericMode)
               {
                   mi = _miVector.createGenAssocMI(
                       &_broker,
                       &eCtx,
                       (const char *)providerName.getCString(),
                       &rc);
               }
               else
               {
                   mi = _miVector.createAssocMI(&_broker, &eCtx, &rc);
               }
   
               if (!mi || rc.rc != CMPI_RC_OK)
               {
                   String error;
                   setError(
                       _miVector,
                       error,
                       getName(),
                       _Generic_Create_AssociationMI,
                       _Create_AssociationMI,
                       rc.msg);
   
                   throw Exception(
                       MessageLoaderParms(
                           _MSG_CANNOT_INIT_API_KEY,
                           _MSG_CANNOT_INIT_API,
                           getName(),
                           error));
               }
               _miVector.assocMI = mi;
           }
       }
   
       return _miVector.assocMI;
   }
   
   CMPIPropertyMI *CMPIProvider::getPropMI()
   {
       if (_miVector.propMI == NULL)
       {
           AutoMutex mtx(_statusMutex);
           if (_miVector.propMI == NULL)
           {
               const OperationContext opc;
               CMPI_ContextOnStack eCtx(opc);
               CMPIStatus rc = {CMPI_RC_OK, NULL};
               String providerName = _broker.name;
               CMPIPropertyMI *mi;
               PEGASUS_ASSERT(_miVector.miTypes & CMPI_MIType_Property);
   
               if (_miVector.genericMode)
               {
                   mi = _miVector.createGenPropMI(
                       &_broker,
                       &eCtx,
                       (const char *)providerName.getCString(),
                       &rc);
               }
               else
               {
                   mi = _miVector.createPropMI(&_broker, &eCtx, &rc);
               }
   
               if (!mi || rc.rc != CMPI_RC_OK)
               {
                   String error;
                   setError(
                       _miVector,
                       error,
                       getName(),
                       _Generic_Create_PropertyMI,
                       _Create_PropertyMI,
                       rc.msg);
   
                   throw Exception(
                       MessageLoaderParms(
                           _MSG_CANNOT_INIT_API_KEY,
                           _MSG_CANNOT_INIT_API,
                           getName(),
                           error));
               }
               _miVector.propMI = mi;
           }
       }
   
       return _miVector.propMI;
   }
   
   CMPIIndicationMI *CMPIProvider::getIndMI()
   {
       if (_miVector.indMI == NULL)
       {
           AutoMutex mtx(_statusMutex);
           if (_miVector.indMI == NULL)
           {
               const OperationContext opc;
               CMPI_ContextOnStack eCtx(opc);
               CMPIStatus rc = {CMPI_RC_OK, NULL};
               String providerName = _broker.name;
               CMPIIndicationMI *mi;
               PEGASUS_ASSERT(_miVector.miTypes & CMPI_MIType_Indication);
               if (_miVector.genericMode)
               {
                   mi = _miVector.createGenIndMI(
                       &_broker,
                       &eCtx,
                       (const char *)providerName.getCString(),
                       &rc);
               }
               else
               {
                   mi = _miVector.createIndMI(&_broker, &eCtx, &rc);
               }
   
               if (!mi || rc.rc != CMPI_RC_OK)
               {
                   String error;
                   setError(
                       _miVector,
                       error,
                       getName(),
                       _Generic_Create_IndicationMI,
                       _Create_IndicationMI,
                       rc.msg);
   
                   throw Exception(
                       MessageLoaderParms(
                           _MSG_CANNOT_INIT_API_KEY,
                           _MSG_CANNOT_INIT_API,
                           getName(),
                           error));
               }
               _miVector.indMI = mi;
           }
       }
   
       return _miVector.indMI;
   }
   
   CMPIProviderModule *CMPIProvider::getModule()
   {
       return _module;
   }
   
   Uint32 CMPIProvider::getQuantum()
   {
       AutoMutex mutex(_statusMutex);
       return _quantum;
   }
   
   void CMPIProvider::setQuantum(Uint32 quantum)
   {
       AutoMutex mutex(_statusMutex);
       _quantum = quantum;
   }
   
   Mutex &CMPIProvider::getStatusMutex()
   {
       return _statusMutex;
   }
   
   PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.48  
changed lines
  Added in v.1.48.2.6

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2