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

abobrov
02.54.2007 a79aa3ddbd25b8c7c0abc6c8d5a00c7ed27dd81d
opends/src/server/org/opends/server/extensions/EntryCacheCommon.java
@@ -381,7 +381,7 @@
  {
    ArrayList<Attribute> attrs = new ArrayList<Attribute>();
    if ((cacheHits != null) && (cacheMisses != null)) {
    if (cacheHits != null) {
      AttributeType hitsAttrType =
        DirectoryServer.getDefaultAttributeType("entryCacheHits");
      LinkedHashSet<AttributeValue> hitsValues =
@@ -390,29 +390,31 @@
        cacheHits.toString()));
      attrs.add(new Attribute(hitsAttrType, "entryCacheHits",
        hitsValues));
      // Cache misses is required to get cache tries and hit ratio.
      if (cacheMisses != null) {
        AttributeType triesAttrType =
          DirectoryServer.getDefaultAttributeType("entryCacheTries");
        LinkedHashSet<AttributeValue> triesValues =
          new LinkedHashSet<AttributeValue>();
        Long cacheTries = cacheHits + cacheMisses;
        triesValues.add(new AttributeValue(triesAttrType,
          cacheTries.toString()));
        attrs.add(new Attribute(triesAttrType, "entryCacheTries",
          triesValues));
      AttributeType triesAttrType =
        DirectoryServer.getDefaultAttributeType("entryCacheTries");
      LinkedHashSet<AttributeValue> triesValues =
        new LinkedHashSet<AttributeValue>();
      Long cacheTries = cacheHits + cacheMisses;
      triesValues.add(new AttributeValue(triesAttrType,
        cacheTries.toString()));
      attrs.add(new Attribute(triesAttrType, "entryCacheTries",
        triesValues));
      AttributeType hitRatioAttrType =
        DirectoryServer.getDefaultAttributeType("entryCacheHitRatio");
      LinkedHashSet<AttributeValue> hitRatioValues =
        new LinkedHashSet<AttributeValue>();
      Double hitRatioRaw = cacheTries > 0 ?
        cacheHits.doubleValue() / cacheTries.doubleValue() :
        cacheHits.doubleValue() / 1;
      Double hitRatio = hitRatioRaw * 100D;
      hitRatioValues.add(new AttributeValue(hitRatioAttrType,
        Long.toString(hitRatio.longValue())));
      attrs.add(new Attribute(hitRatioAttrType, "entryCacheHitRatio",
        hitRatioValues));
        AttributeType hitRatioAttrType =
          DirectoryServer.getDefaultAttributeType("entryCacheHitRatio");
        LinkedHashSet<AttributeValue> hitRatioValues =
          new LinkedHashSet<AttributeValue>();
        Double hitRatioRaw = cacheTries > 0 ?
          cacheHits.doubleValue() / cacheTries.doubleValue() :
          cacheHits.doubleValue() / 1;
        Double hitRatio = hitRatioRaw * 100D;
        hitRatioValues.add(new AttributeValue(hitRatioAttrType,
          Long.toString(hitRatio.longValue())));
        attrs.add(new Attribute(hitRatioAttrType, "entryCacheHitRatio",
          hitRatioValues));
      }
    }
    if (cacheSize != null) {