| | |
| | | */ |
| | | public boolean containsEntry(DN entryDN) |
| | | { |
| | | if (entryDN == null) { |
| | | return false; |
| | | } |
| | | |
| | | // Indicate whether the DN map contains the specified DN. |
| | | return dnMap.containsKey(entryDN); |
| | | } |
| | |
| | | if (ref == null) |
| | | { |
| | | // Indicate cache miss. |
| | | cacheMisses.set(cacheMisses.incrementAndGet()); |
| | | cacheMisses.getAndIncrement(); |
| | | return null; |
| | | } |
| | | else |
| | |
| | | if (cacheEntry == null) |
| | | { |
| | | // Indicate cache miss. |
| | | cacheMisses.set(cacheMisses.incrementAndGet()); |
| | | cacheMisses.getAndIncrement(); |
| | | return null; |
| | | } |
| | | else |
| | | { |
| | | // Indicate cache hit. |
| | | cacheHits.set(cacheHits.incrementAndGet()); |
| | | cacheHits.getAndIncrement(); |
| | | return cacheEntry.getEntry(); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected DN getEntryDN(Backend backend, long entryID) |
| | | public DN getEntryDN(Backend backend, long entryID) |
| | | { |
| | | // Locate specific backend map and return the entry DN by ID. |
| | | ConcurrentHashMap<Long,SoftReference<CacheEntry>> |
| | |
| | | */ |
| | | public void putEntry(Entry entry, Backend backend, long entryID) |
| | | { |
| | | // Check exclude and include filters first. |
| | | if (!filtersAllowCaching(entry)) { |
| | | return; |
| | | } |
| | | |
| | | // Create the cache entry based on the provided information. |
| | | CacheEntry cacheEntry = new CacheEntry(entry, backend, entryID); |
| | | SoftReference<CacheEntry> ref = |
| | |
| | | public boolean putEntryIfAbsent(Entry entry, Backend backend, |
| | | long entryID) |
| | | { |
| | | // Check exclude and include filters first. |
| | | if (!filtersAllowCaching(entry)) { |
| | | return true; |
| | | } |
| | | |
| | | // See if the entry already exists. If so, then return false. |
| | | if (dnMap.containsKey(entry.getDN())) |
| | | { |
| | |
| | | try { |
| | | attrs = EntryCacheCommon.getGenericMonitorData( |
| | | new Long(cacheHits.longValue()), |
| | | new Long(cacheMisses.longValue()), |
| | | // If cache misses is maintained by default cache |
| | | // get it from there and if not point to itself. |
| | | DirectoryServer.getEntryCache().getCacheMisses(), |
| | | null, |
| | | null, |
| | | new Long(dnMap.size()), |
| | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Long getCacheCount() |
| | | { |
| | | return new Long(dnMap.size()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Return a verbose string representation of the current cache maps. |
| | | * This is useful primary for debugging and diagnostic purposes such |
| | | * as in the entry cache unit tests. |