| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void initializeEntryCache( |
| | | SoftReferenceEntryCacheCfg configuration |
| | | ) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public synchronized void finalizeEntryCache() |
| | | { |
| | | registeredConfiguration.removeSoftReferenceChangeListener (this); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean containsEntry(DN entryDN) |
| | | { |
| | | if (entryDN == null) { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Entry getEntry(DN entryDN) |
| | | { |
| | | SoftReference<CacheEntry> ref = dnMap.get(entryDN); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public long getEntryID(DN entryDN) |
| | | { |
| | | SoftReference<CacheEntry> ref = dnMap.get(entryDN); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public DN getEntryDN(Backend backend, long entryID) |
| | | { |
| | | // Locate specific backend map and return the entry DN by ID. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void putEntry(Entry entry, Backend backend, long entryID) |
| | | { |
| | | // Create the cache entry based on the provided information. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean putEntryIfAbsent(Entry entry, Backend backend, |
| | | long entryID) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void removeEntry(DN entryDN) |
| | | { |
| | | SoftReference<CacheEntry> ref = dnMap.remove(entryDN); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void clear() |
| | | { |
| | | dnMap.clear(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void clearBackend(Backend backend) |
| | | { |
| | | // FIXME -- Would it be better just to dump everything? |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void clearSubtree(DN baseDN) |
| | | { |
| | | // Determine the backend used to hold the specified base DN and clear it. |
| | |
| | | if (backend == null) |
| | | { |
| | | // FIXME -- Should we clear everything just to be safe? |
| | | return; |
| | | } |
| | | else |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void handleLowMemory() |
| | | { |
| | | // This function should automatically be taken care of by the nature of the |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | SoftReferenceEntryCacheCfg configuration, |
| | | List<Message> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | SoftReferenceEntryCacheCfg configuration |
| | | ) |
| | |
| | | * Operate in a loop, receiving notification of soft references that have been |
| | | * freed and removing the corresponding entries from the cache. |
| | | */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | while (!shutdown) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ArrayList<Attribute> getMonitorData() |
| | | { |
| | | ArrayList<Attribute> attrs = new ArrayList<Attribute>(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Long getCacheCount() |
| | | { |
| | | return new Long(dnMap.size()); |
| | |
| | | */ |
| | | private String toVerboseString() |
| | | { |
| | | String verboseString = new String(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | // There're no locks in this cache to keep dnMap and idMap in |
| | |
| | | sb.append(ServerConstants.EOL); |
| | | } |
| | | |
| | | verboseString = sb.toString(); |
| | | String verboseString = sb.toString(); |
| | | |
| | | return (verboseString.length() > 0 ? verboseString : null); |
| | | } |