mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

abobrov
09.48.2007 fbe83410829a01a58ee9ffb68b5f13086fdecee1
opendj-sdk/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
@@ -46,6 +46,7 @@
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.Attribute;
import org.opends.server.types.CacheEntry;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DebugLogLevel;
@@ -209,6 +210,8 @@
    SoftReference<CacheEntry> ref = dnMap.get(entryDN);
    if (ref == null)
    {
      // Indicate cache miss.
      cacheMisses.set(cacheMisses.incrementAndGet());
      return null;
    }
    else
@@ -216,10 +219,14 @@
      CacheEntry cacheEntry = ref.get();
      if (cacheEntry == null)
      {
        // Indicate cache miss.
        cacheMisses.set(cacheMisses.incrementAndGet());
        return null;
      }
      else
      {
        // Indicate cache hit.
        cacheHits.set(cacheHits.incrementAndGet());
        return cacheEntry.getEntry();
      }
    }
@@ -652,6 +659,33 @@
  /**
   * {@inheritDoc}
   */
  public ArrayList<Attribute> getMonitorData()
  {
    ArrayList<Attribute> attrs = new ArrayList<Attribute>();
    try {
      attrs = EntryCacheCommon.getGenericMonitorData(
        new Long(cacheHits.longValue()),
        new Long(cacheMisses.longValue()),
        null,
        null,
        new Long(dnMap.size()),
        null
        );
    } catch (Exception e) {
      if (debugEnabled()) {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
    }
    return attrs;
  }
  /**
   * 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.