1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.eviction; |
8 |
| |
9 |
| import org.jboss.cache.Region; |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| public class ElementSizeAlgorithm extends BaseSortedEvictionAlgorithm |
17 |
| { |
18 |
14
| protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
|
19 |
| { |
20 |
14
| return new ElementSizeQueue();
|
21 |
| } |
22 |
| |
23 |
7103
| protected boolean shouldEvictNode(NodeEntry ne)
|
24 |
| { |
25 |
7103
| ElementSizeConfiguration config = (ElementSizeConfiguration) region.getEvictionPolicyConfig();
|
26 |
| |
27 |
7103
| int size = this.getEvictionQueue().getNumberOfNodes();
|
28 |
7103
| if (config.getMaxNodes() != 0 && size > config.getMaxNodes())
|
29 |
| { |
30 |
7087
| return true;
|
31 |
| } |
32 |
| |
33 |
16
| return ne.getNumberOfElements() > config.getMaxElementsPerNode();
|
34 |
| } |
35 |
| |
36 |
| |
37 |
31
| protected void prune() throws EvictionException
|
38 |
| { |
39 |
31
| super.prune();
|
40 |
| |
41 |
| |
42 |
31
| ((ElementSizeQueue) this.evictionQueue).prune();
|
43 |
| } |
44 |
| |
45 |
| } |