<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hey David,<br>
<br>
First of all kudos for taking on such a non-trivial task!<br>
<br>
On 11-01-14 12:22 AM, david marion wrote:
<blockquote cite="mid:COL113-W40326A22D90C6413BF2931D1F30@phx.gbl"
type="cite">
<span style="font-family: Arial; color: navy; font-size: 10pt;"></span><o:p></o:p>
<ol style="margin-top: 0in;" type="1">
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><span
style="font-family: Arial; font-size: 10pt;">Modify
configuration in some way so that the following can be
specified:</span><o:p></o:p></li>
<ol style="margin-top: 0in;" type="a">
<li style="margin: 0in 0in 0pt; color: navy;"
class="MsoNormal"><span style="font-family: Arial;
font-size: 10pt;">The percentage value of used JVM memory
(i.e. 95) at which entries should be evicted to try and
avoid an OOM error.</span><o:p></o:p></li>
<li style="margin: 0in 0in 0pt; color: navy;"
class="MsoNormal"><span style="font-family: Arial;
font-size: 10pt;">The number of items that should be
evicted when memory reaches this threshold</span><o:p></o:p></li>
</ol>
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><span
style="font-family: Arial; font-size: 10pt;">Modify LRU and
LIRS Eviction class so that the accessQueue member can be
accessed by the new Eviction class so that two access queues
don’t have to be maintained.</span><o:p></o:p></li>
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><span
style="font-family: Arial; font-size: 10pt;">Create a new
Eviction class, a subclass of LIRS, where the accessQueue
is used from the Eviction strategy the user specifies and
the for loop in the execute method is exited when the
evicted set equals value from 1.b above.</span><o:p></o:p></li>
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><span
style="font-family: Arial; font-size: 10pt;">Modify
DataContainerFactory.construct() to call
DefaultDataContainer.boundedDataContainer() regardless of
eviction policy. This will always create a
BoundedConcurrentHashMap</span></li>
</ol>
</blockquote>
<br>
I don't think you have to extend LRU and LIRS, as long as you
implement EvictionPolicy you are fullfilling the contract. What
extending LRU and LIRS can do is give you some order in selecting
proper elements for eviction. I think the precise technical term in
research literature is "eviction precision". <br>
<br>
<blockquote cite="mid:COL113-W40326A22D90C6413BF2931D1F30@phx.gbl"
type="cite">
<ol style="margin-top: 0in;" type="1">
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><o:p></o:p><br>
</li>
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><span
style="font-family: Arial; font-size: 10pt;">Create an
instance of the new Eviction class in each segment.</span><o:p></o:p></li>
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><span
style="font-family: Arial; font-size: 10pt;">Modify
BoundedConcurrentHashMap.Segment put and replace methods
such that when new values are going to be put into the
Segment, the memory usage is checked and the execute method
is called on the new Eviction class.</span></li>
</ol>
</blockquote>
<br>
Sounds right!<br>
<br>
<blockquote cite="mid:COL113-W40326A22D90C6413BF2931D1F30@phx.gbl"
type="cite">
<ol style="margin-top: 0in;" type="1">
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><o:p></o:p><br>
</li>
</ol>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span
style="font-family: Arial; color: navy; font-size: 10pt;"> </span><o:p></o:p></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span
style="font-family: Arial; color: navy; font-size: 10pt;">Questions:</span><o:p></o:p></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span
style="font-family: Arial; color: navy; font-size: 10pt;"> </span><o:p></o:p></p>
<ol style="margin-top: 0in;" type="1">
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><span
style="font-family: Arial; font-size: 10pt;">What are the
implications of using a BoundedConcurrentHashMap instead of
a ConcurrentHashMap when maxEntries is set to -1?</span></li>
</ol>
</blockquote>
<br>
I think none except you turn on eviction by using
BoundedConcurrentHashMap.<br>
<br>
<blockquote cite="mid:COL113-W40326A22D90C6413BF2931D1F30@phx.gbl"
type="cite">
<ol style="margin-top: 0in;" type="1">
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><o:p></o:p><br>
</li>
</ol>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span
style="font-family: Arial; color: navy; font-size: 10pt;"> </span><o:p></o:p></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span
style="font-family: Arial; color: navy; font-size: 10pt;">Thoughts</span><o:p></o:p></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span
style="font-family: Arial; color: navy; font-size: 10pt;"> </span><o:p></o:p></p>
<ol style="margin-top: 0in;" type="1">
<li style="margin: 0in 0in 0pt; color: navy;" class="MsoNormal"><span
style="font-family: Arial; font-size: 10pt;">This will not
guarantee that an OOM error does not occur. It will attempt
to guard against an OOM caused by putting new values into
the cache. This will probably be more effective when the
cache is being used in client/server mode, and less
effective when used in embedded mode as to other code
running in the JVM.</span><o:p></o:p></li>
</ol>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span
style="font-family: Arial; color: navy; font-size: 10pt;"> </span><o:p></o:p></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span
style="font-family: Arial; color: navy; font-size: 10pt;"> </span><o:p></o:p></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span
style="font-family: Arial; color: navy; font-size: 10pt;">--
Dave Marion</span><o:p></o:p></p>
<br>
</blockquote>
<br>
Cheers,<br>
Vladimir<br>
</body>
</html>