Agandalf
Agandalf

Reputation: 83

Oracle Coherence eviction not working

I am working on implementing Oracle Coherence replicated cache. The implementation is as follows:

<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">

<cache-config>

  <caching-scheme-mapping>
    <cache-mapping>
      <cache-name>EntryList</cache-name>
      <scheme-name>ENTRY_ITEMS</scheme-name>
    </cache-mapping>
  </caching-scheme-mapping>

  <caching-schemes>
    <replicated-scheme>
      <scheme-name>ENTRY_ITEMS</scheme-name>
      <backing-map-scheme>
        <local-scheme>
          <scheme-name>ENTRY_ITEMS</scheme-name>
          <unit-calculator>FIXED</unit-calculator>
          <expiry-delay>60m</expiry-delay> <!-- expire after 60 minutes -->
          <high-units>2000</high-units>
          <eviction-policy>LFU</eviction-policy>
        </local-scheme>
      </backing-map-scheme>
      <autostart>true</autostart>
    </replicated-scheme>
  </caching-schemes>
</cache-config>

tangasol-coherence-override.xml

<coherence xmlns:xsi="http://www.w4.org/2001/XMLSchema-instance"
  xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
  xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-operational-config 
         coherence-operational-config.xsd">

  <cluster-config>
    <member-identity>
      <cluster-name>clusterName</cluster-name>
      <!-- Name of the first member of the cluster -->
      <role-name>RoleName</role-name>
    </member-identity>
    <unicast-listener xml-override=coherence-environment.xml/>
  </cluster-config>

</coherence>

coherence-environment.xml

<unicast-listener xmlns:xsi="http://www.w4.org/2001/XMLSchema-instance"
  xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
  xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-operational-config 
         coherence-operational-config.xsd">

  <well-known-addresses>
    <socket-address id="1">
      <address>member1</address>
      <port>7777</port>
    </socket-address>
  </well-known-addresses>

  <well-known-addresses>
    <socket-address id="2">
      <address>member2</address>
      <port>7777</port>
    </socket-address>
  </well-known-addresses>
</unicast-listener>

This is implemented and tested to be working perfectly.

We were testing the eviction policy of the cache. To ease out testing I did the following:

  1. I keep the size of cache as 4 by setting high-units as 4. Now add 4 entries in the cache. This should fill the cache completely.
  2. Now if I make one more entry number 5 in the cache, I was expecting the lease frequently used entry to be kicked out of the cache to make room for the entry number 5.
  3. The next time I access the cache for the new entry number 5, I should get a cache HIT.
  4. But that's not happening, I always get a Cache MISS.
  5. I ran my java code in debug mode and I see that the code PUT's entry number 5 in the cache but this PUT operation does not reflect on the cache.

Now I am definitely not the first person testing the coherence cache eviction policies. Am I missing anything in the configuration? Am I testing the eviction in a wrong way. Any inputs are welcome.

Thanks.

Upvotes: 1

Views: 767

Answers (2)

Ankur Kumar
Ankur Kumar

Reputation: 104

I have tried your example with 3 as High Units. My observation:

  • Eviction works as soon as I put 4th entry item. So, it works!!
  • You can start Coherence Server (coherence.sh) for command-line monitoring with same override & cache config file. See details, which gets printed when I put following command to see cache:

Map (?): cache EntryList

Cache Configuration: EntryList
  SchemeName: ENTRY_ITEMS
  AutoStart: true
  ServiceName: ReplicatedCache
  ServiceDependencies
    EventDispatcherThreadPriority: 10
    ThreadPriority: 10
    WorkerThreadsMax: 2147483647
    WorkerPriority: 5
    EnsureCacheTimeout: 30000
  BackingMapScheme
    InnerScheme (LocalScheme) 
      SchemeName: ENTRY_ITEMS
      UnitCalculatorBuilder
        Calculator: FIXED
      EvictionPolicyBuilder
        Policy: LFU
      ExpiryDelay: 1h
      HighUnits
        Units: 3
      UnitFactor: 1

Upvotes: 0

Arkadiy Verman
Arkadiy Verman

Reputation: 694

Try to isolate the problem:

  • change<expiry-delay>1</expiry-delay> (1ms)
  • add <low-units>0</low-units> (default value is 75% which is 3 entries).
  • try another policy <eviction-policy>LRU</eviction-policy>

If those won't help, try to add custom eviction policy class to see wheter eviction triggered. see here:

Upvotes: 0

Related Questions