| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.SortedMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.EntryCacheCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.BackendInitializationListener; |
| | | import org.opends.server.api.EntryCache; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | /** |
| | | * This class defines the default entry cache which acts as an arbiter for |
| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | |
| | | // The entry cache order array reflects all currently configured and |
| | | // active entry cache implementations in cache level specific order. |
| | | /** |
| | | * The entry cache order array reflects all currently configured and |
| | | * active entry cache implementations in cache level specific order. |
| | | */ |
| | | private static EntryCache<? extends EntryCacheCfg>[] cacheOrder = |
| | | new EntryCache<?>[0]; |
| | | |
| | |
| | | DirectoryServer.registerBackendInitializationListener(this); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeEntryCache(EntryCacheCfg configEntry) |
| | | throws ConfigException, InitializationException |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finalizeEntryCache() |
| | | { |
| | |
| | | cacheOrder = new EntryCache<?>[0]; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean containsEntry(DN entryDN) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry getEntry(Backend backend, long entryID) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry getEntry(DN entryDN) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getEntryID(DN entryDN) |
| | | { |
| | |
| | | return -1; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DN getEntryDN(Backend backend, long entryID) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void putEntry(Entry entry, Backend backend, long entryID) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean putEntryIfAbsent(Entry entry, Backend backend, long entryID) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeEntry(DN entryDN) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void clear() |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void clearBackend(Backend backend) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void clearSubtree(DN baseDN) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleLowMemory() |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | EntryCacheCfg configuration, |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | EntryCacheCfg configuration |
| | | ) |
| | | public ConfigChangeResult applyConfigurationChange(EntryCacheCfg configuration) |
| | | { |
| | | // No implementation required. |
| | | ConfigChangeResult changeResult = new ConfigChangeResult( |
| | | ResultCode.SUCCESS, false, new ArrayList<LocalizableMessage>() |
| | | ); |
| | | |
| | | return changeResult; |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ArrayList<Attribute> getMonitorData() |
| | | { |
| | | ArrayList<Attribute> attrs = new ArrayList<Attribute>(); |
| | | |
| | | // The sum of cache hits of all active entry cache |
| | | // implementations. |
| | | Long entryCacheHits = new Long(0); |
| | | // The sum of cache hits of all active entry cache implementations. |
| | | long entryCacheHits = 0; |
| | | // Common for all active entry cache implementations. |
| | | Long entryCacheMisses = new Long(cacheMisses.longValue()); |
| | | // The sum of cache counts of all active entry cache |
| | | // implementations. |
| | | Long currentEntryCacheCount = new Long(0); |
| | | long entryCacheMisses = cacheMisses.longValue(); |
| | | // The sum of cache counts of all active entry cache implementations. |
| | | long currentEntryCacheCount = 0; |
| | | |
| | | for (EntryCache<?> entryCache : cacheOrder) { |
| | | // Get cache hits and counts from every active cache. |
| | |
| | | return attrs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Long getCacheCount() |
| | | { |
| | | Long cacheCount = new Long(0); |
| | | |
| | | long cacheCount = 0; |
| | | for (EntryCache<?> entryCache : cacheOrder) { |
| | | cacheCount += entryCache.getCacheCount(); |
| | | } |
| | | |
| | | return cacheCount; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toVerboseString() |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | } |
| | | } |
| | | String verboseString = sb.toString(); |
| | | return (verboseString.length() > 0 ? verboseString : null); |
| | | return verboseString.length() > 0 ? verboseString : null; |
| | | } |
| | | |
| | | |
| | |
| | | public void performBackendFinalizationProcessing(Backend backend) |
| | | { |
| | | // Do not clear any backends if the server is shutting down. |
| | | if ( !(DirectoryServer.getInstance().isShuttingDown()) ) { |
| | | if (!DirectoryServer.getInstance().isShuttingDown()) |
| | | { |
| | | clearBackend(backend); |
| | | } |
| | | } |
| | | } |
| | | |