version 1.203, 2008/11/14 00:42:17
|
version 1.204, 2008/11/14 18:48:13
|
|
|
#endif | #endif |
| |
| |
|
//============================================================================== |
|
// |
|
// The class cache caches up PEGASUS_CLASS_CACHE_SIZE fully resolved class |
|
// definitions in memory. To override the default, define |
|
// PEGASUS_CLASS_CACHE_SIZE in your build environment. To suppress the cache |
|
// (and not compile it in at all), set PEGASUS_CLASS_CACHE_SIZE to 0. |
|
// |
|
//============================================================================== |
|
|
|
#if !defined(PEGASUS_CLASS_CACHE_SIZE) |
|
# define PEGASUS_CLASS_CACHE_SIZE 8 |
|
#endif |
|
|
|
#if (PEGASUS_CLASS_CACHE_SIZE != 0) |
|
# define PEGASUS_USE_CLASS_CACHE |
|
#endif |
|
|
|
#define PEGASUS_QUALIFIER_CACHE_SIZE 80 |
|
|
|
|
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
{ | { |
public: | public: |
| |
|
CIMRepositoryRep() |
|
: |
|
#ifdef PEGASUS_USE_CLASS_CACHE |
|
_classCache(PEGASUS_CLASS_CACHE_SIZE), |
|
#endif /* PEGASUS_USE_CLASS_CACHE */ |
|
_qualifierCache(PEGASUS_QUALIFIER_CACHE_SIZE) |
|
{ |
|
} |
|
|
/** | /** |
Checks whether an instance with the specified key values exists in the | Checks whether an instance with the specified key values exists in the |
class hierarchy of the specified class. | class hierarchy of the specified class. |
|
|
RepositoryDeclContext* _context; | RepositoryDeclContext* _context; |
| |
CString _lockFile; | CString _lockFile; |
}; |
|
|
|
// #define TEST_OUTPUT |
|
|
|
//============================================================================== |
|
// |
|
// This is the class cache, which caches up PEGASUS_CLASS_CACHE_SIZE classes |
|
// into memory. To override the default, define PEGASUS_CLASS_CACHE_SIZE in |
|
// your environment. To supress the cache (and not compile it in at all) |
|
// define PEGASUS_CLASS_CACHE_SIZE to 0. |
|
// |
|
//============================================================================== |
|
|
|
#define PEGASUS_QUALIFIER_CACHE_SIZE 80 |
|
|
|
#if !defined(PEGASUS_CLASS_CACHE_SIZE) |
|
# define PEGASUS_CLASS_CACHE_SIZE 8 |
|
#endif |
|
|
|
#if (PEGASUS_CLASS_CACHE_SIZE != 0) |
|
# define PEGASUS_USE_CLASS_CACHE |
|
#endif |
|
| |
#ifdef PEGASUS_USE_CLASS_CACHE | #ifdef PEGASUS_USE_CLASS_CACHE |
static ObjectCache<CIMClass> _classCache(PEGASUS_CLASS_CACHE_SIZE); |
ObjectCache<CIMClass> _classCache; |
#endif /* PEGASUS_USE_CLASS_CACHE */ | #endif /* PEGASUS_USE_CLASS_CACHE */ |
| |
static ObjectCache<CIMQualifierDecl> |
ObjectCache<CIMQualifierDecl> _qualifierCache; |
_qualifierCache(PEGASUS_QUALIFIER_CACHE_SIZE); |
}; |
| |
static String _getCacheKey( | static String _getCacheKey( |
const CIMNamespaceName& nameSpace, | const CIMNamespaceName& nameSpace, |
const CIMName& entryName) | const CIMName& entryName) |
{ | { |
return nameSpace.getString() + ":" + entryName.getString(); |
String key = nameSpace.getString(); |
|
key.append(':'); |
|
key.append(entryName.getString()); |
|
return key; |
} | } |
| |
| |
|
|
| |
String cacheKey = _getCacheKey(nameSpace, className); | String cacheKey = _getCacheKey(nameSpace, className); |
| |
if (!_classCache.get(cacheKey, cimClass)) |
if (!_rep->_classCache.get(cacheKey, cimClass)) |
{ | { |
// Not in cache so load from disk: | // Not in cache so load from disk: |
#endif | #endif |
|
|
{ | { |
// Put in cache: | // Put in cache: |
| |
_classCache.put(cacheKey, cimClass); |
_rep->_classCache.put(cacheKey, cimClass); |
} | } |
} | } |
#endif | #endif |
|
|
| |
#ifdef PEGASUS_USE_CLASS_CACHE | #ifdef PEGASUS_USE_CLASS_CACHE |
| |
_classCache.evict(_getCacheKey(nameSpace, className)); |
_rep->_classCache.evict(_getCacheKey(nameSpace, className)); |
| |
#endif /* PEGASUS_USE_CLASS_CACHE */ | #endif /* PEGASUS_USE_CLASS_CACHE */ |
| |
|
|
// Modifying this class may invalidate subclass definitions in the cache. | // Modifying this class may invalidate subclass definitions in the cache. |
// Since class modification is relatively rare, we just flush the entire | // Since class modification is relatively rare, we just flush the entire |
// cache rather than specifically evicting subclass definitions. | // cache rather than specifically evicting subclass definitions. |
_classCache.clear(); |
_rep->_classCache.clear(); |
| |
#endif /* PEGASUS_USE_CLASS_CACHE */ | #endif /* PEGASUS_USE_CLASS_CACHE */ |
| |
|
|
| |
// Check the cache first: | // Check the cache first: |
| |
if (!_qualifierCache.get(qualifierCacheKey, qualifierDecl)) |
if (!_rep->_qualifierCache.get(qualifierCacheKey, qualifierDecl)) |
{ | { |
// Not in cache so load from disk: | // Not in cache so load from disk: |
| |
|
|
if (!qualifierDecl.isUninitialized()) | if (!qualifierDecl.isUninitialized()) |
{ | { |
// Put in cache | // Put in cache |
_qualifierCache.put(qualifierCacheKey, qualifierDecl); |
_rep->_qualifierCache.put(qualifierCacheKey, qualifierDecl); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return qualifierDecl; | return qualifierDecl; |
|
|
| |
String qualifierCacheKey = | String qualifierCacheKey = |
_getCacheKey(nameSpace, qualifierDecl.getName()); | _getCacheKey(nameSpace, qualifierDecl.getName()); |
_qualifierCache.put(qualifierCacheKey, (CIMQualifierDecl&)qualifierDecl); |
_rep->_qualifierCache.put( |
|
qualifierCacheKey, (CIMQualifierDecl&)qualifierDecl); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
|
|
_rep->_persistentStore->deleteQualifier(nameSpace, qualifierName); | _rep->_persistentStore->deleteQualifier(nameSpace, qualifierName); |
| |
String qualifierCacheKey = _getCacheKey(nameSpace, qualifierName); | String qualifierCacheKey = _getCacheKey(nameSpace, qualifierName); |
_qualifierCache.evict(qualifierCacheKey); |
_rep->_qualifierCache.evict(qualifierCacheKey); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
|
|
{ | { |
#ifdef PEGASUS_USE_CLASS_CACHE | #ifdef PEGASUS_USE_CLASS_CACHE |
cout << "Repository Class Cache Statistics:" << endl; | cout << "Repository Class Cache Statistics:" << endl; |
_classCache.DisplayCacheStatistics(); |
_rep->_classCache.DisplayCacheStatistics(); |
#endif | #endif |
cout << "Repository Qualifier Cache Statistics:" << endl; | cout << "Repository Qualifier Cache Statistics:" << endl; |
_qualifierCache.DisplayCacheStatistics(); |
_rep->_qualifierCache.DisplayCacheStatistics(); |
} | } |
#endif | #endif |
| |